mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Add tests for initial load states of PlaySongSelect
This commit is contained in:
parent
8e644e878a
commit
cf316b3c51
@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
|
||||
private RulesetStore rulesets;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
private WorkingBeatmap defaultBeatmap;
|
||||
|
||||
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);
|
||||
|
||||
private class TestSongSelect : PlaySongSelect
|
||||
{
|
||||
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager baseManager)
|
||||
{
|
||||
PlaySongSelect songSelect;
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
if (manager == null)
|
||||
{
|
||||
@ -64,14 +71,43 @@ namespace osu.Game.Tests.Visual
|
||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||
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 Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
||||
|
@ -142,7 +142,6 @@ namespace osu.Game.Screens.Select
|
||||
if (newSet == null)
|
||||
{
|
||||
itemsCache.Invalidate();
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
protected Container LeftContent;
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
protected readonly BeatmapCarousel Carousel;
|
||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||
private DialogOverlay dialogOverlay;
|
||||
private BeatmapManager beatmaps;
|
||||
@ -103,7 +103,7 @@ namespace osu.Game.Screens.Select
|
||||
Right = left_area_padding * 2,
|
||||
}
|
||||
},
|
||||
carousel = new BeatmapCarousel
|
||||
Carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = filter_height,
|
||||
FilterChanged = c => carousel.Filter(c),
|
||||
FilterChanged = c => Carousel.Filter(c),
|
||||
Exit = Exit,
|
||||
},
|
||||
beatmapInfoWedge = new BeatmapInfoWedge
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Select
|
||||
Right = left_area_padding,
|
||||
},
|
||||
},
|
||||
new ResetScrollContainer(() => carousel.ScrollToSelected())
|
||||
new ResetScrollContainer(() => Carousel.ScrollToSelected())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 250,
|
||||
@ -190,15 +190,15 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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.ValueChanged += b =>
|
||||
{
|
||||
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.
|
||||
// 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)
|
||||
{
|
||||
@ -282,9 +282,9 @@ namespace osu.Game.Screens.Select
|
||||
private void triggerRandom()
|
||||
{
|
||||
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
||||
carousel.SelectPreviousRandom();
|
||||
Carousel.SelectPreviousRandom();
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
Carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
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 onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
|
||||
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 onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(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 onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
Carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
private void delete(BeatmapSetInfo beatmap)
|
||||
|
Loading…
Reference in New Issue
Block a user