mirror of
https://github.com/osukey/osukey.git
synced 2025-07-22 10:50:03 +09:00
Add tests for initial load states of PlaySongSelect
This commit is contained in:
@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
|
private WorkingBeatmap defaultBeatmap;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -47,10 +48,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
|
||||||
|
|
||||||
|
private class TestSongSelect : PlaySongSelect
|
||||||
|
{
|
||||||
|
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
||||||
|
public new BeatmapCarousel Carousel => base.Carousel;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapManager baseManager)
|
private void load(BeatmapManager baseManager)
|
||||||
{
|
{
|
||||||
PlaySongSelect songSelect;
|
TestSongSelect songSelect = null;
|
||||||
|
|
||||||
if (manager == null)
|
if (manager == null)
|
||||||
{
|
{
|
||||||
@ -64,14 +71,43 @@ namespace osu.Game.Tests.Visual
|
|||||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||||
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
||||||
{
|
{
|
||||||
DefaultBeatmap = baseManager.GetWorkingBeatmap(null)
|
DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
|
||||||
});
|
});
|
||||||
|
|
||||||
for (int i = 0; i < 100; i += 10)
|
|
||||||
manager.Import(createTestBeatmapSet(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Add(songSelect = new PlaySongSelect());
|
void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
|
||||||
|
{
|
||||||
|
if (deleteMaps) manager.DeleteAll();
|
||||||
|
|
||||||
|
if (songSelect != null)
|
||||||
|
{
|
||||||
|
Remove(songSelect);
|
||||||
|
songSelect.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Add(songSelect = new TestSongSelect());
|
||||||
|
});
|
||||||
|
|
||||||
|
loadNewSongSelect(true);
|
||||||
|
|
||||||
|
AddWaitStep(1);
|
||||||
|
|
||||||
|
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
||||||
|
|
||||||
|
AddStep("import test maps", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 100; i += 10)
|
||||||
|
manager.Import(createTestBeatmapSet(i));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddWaitStep(1);
|
||||||
|
AddStep("select random", () => songSelect.Carousel.SelectNextRandom());
|
||||||
|
|
||||||
|
AddWaitStep(1);
|
||||||
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||||
|
|
||||||
|
loadNewSongSelect();
|
||||||
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
||||||
|
|
||||||
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
|
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
|
||||||
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
||||||
|
@ -142,7 +142,6 @@ namespace osu.Game.Screens.Select
|
|||||||
if (newSet == null)
|
if (newSet == null)
|
||||||
{
|
{
|
||||||
itemsCache.Invalidate();
|
itemsCache.Invalidate();
|
||||||
SelectNext();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected Container LeftContent;
|
protected Container LeftContent;
|
||||||
|
|
||||||
private readonly BeatmapCarousel carousel;
|
protected readonly BeatmapCarousel Carousel;
|
||||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||||
private DialogOverlay dialogOverlay;
|
private DialogOverlay dialogOverlay;
|
||||||
private BeatmapManager beatmaps;
|
private BeatmapManager beatmaps;
|
||||||
@ -103,7 +103,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Right = left_area_padding * 2,
|
Right = left_area_padding * 2,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carousel = new BeatmapCarousel
|
Carousel = new BeatmapCarousel
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Size = new Vector2(carousel_width, 1),
|
Size = new Vector2(carousel_width, 1),
|
||||||
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = filter_height,
|
Height = filter_height,
|
||||||
FilterChanged = c => carousel.Filter(c),
|
FilterChanged = c => Carousel.Filter(c),
|
||||||
Exit = Exit,
|
Exit = Exit,
|
||||||
},
|
},
|
||||||
beatmapInfoWedge = new BeatmapInfoWedge
|
beatmapInfoWedge = new BeatmapInfoWedge
|
||||||
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Right = left_area_padding,
|
Right = left_area_padding,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new ResetScrollContainer(() => carousel.ScrollToSelected())
|
new ResetScrollContainer(() => Carousel.ScrollToSelected())
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 250,
|
Width = 250,
|
||||||
@ -190,15 +190,15 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
initialAddSetsTask = new CancellationTokenSource();
|
initialAddSetsTask = new CancellationTokenSource();
|
||||||
|
|
||||||
carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
|
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
|
||||||
|
|
||||||
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
|
Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled;
|
||||||
Beatmap.TriggerChange();
|
Beatmap.TriggerChange();
|
||||||
|
|
||||||
Beatmap.ValueChanged += b =>
|
Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
if (IsCurrentScreen)
|
if (IsCurrentScreen)
|
||||||
carousel.SelectBeatmap(b?.BeatmapInfo);
|
Carousel.SelectBeatmap(b?.BeatmapInfo);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,9 +212,9 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
// if we have a pending filter operation, we want to run it now.
|
// if we have a pending filter operation, we want to run it now.
|
||||||
// it could change selection (ie. if the ruleset has been changed).
|
// it could change selection (ie. if the ruleset has been changed).
|
||||||
carousel.FlushPendingFilterOperations();
|
Carousel.FlushPendingFilterOperations();
|
||||||
|
|
||||||
carousel.SelectBeatmap(beatmap);
|
Carousel.SelectBeatmap(beatmap);
|
||||||
|
|
||||||
if (selectionChangedDebounce?.Completed == false)
|
if (selectionChangedDebounce?.Completed == false)
|
||||||
{
|
{
|
||||||
@ -282,9 +282,9 @@ namespace osu.Game.Screens.Select
|
|||||||
private void triggerRandom()
|
private void triggerRandom()
|
||||||
{
|
{
|
||||||
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
||||||
carousel.SelectPreviousRandom();
|
Carousel.SelectPreviousRandom();
|
||||||
else
|
else
|
||||||
carousel.SelectNextRandom();
|
Carousel.SelectNextRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
protected override void OnEntering(Screen last)
|
||||||
@ -416,17 +416,17 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s);
|
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
|
||||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
|
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
|
||||||
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||||
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||||
|
|
||||||
private void carouselBeatmapsLoaded()
|
private void carouselBeatmapsLoaded()
|
||||||
{
|
{
|
||||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||||
else
|
else
|
||||||
carousel.SelectNextRandom();
|
Carousel.SelectNextRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(BeatmapSetInfo beatmap)
|
private void delete(BeatmapSetInfo beatmap)
|
||||||
|
Reference in New Issue
Block a user