mirror of
https://github.com/ppy/osu
synced 2025-03-23 19:36:56 +00:00
Testcases for CarouselRoot
This commit is contained in:
parent
69e2d4fd22
commit
75f7d43d9d
@ -42,6 +42,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
|
|
||||||
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
||||||
|
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
|
||||||
|
|
||||||
private BeatmapInfo currentSelection;
|
private BeatmapInfo currentSelection;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
testEmptyTraversal();
|
testEmptyTraversal();
|
||||||
testHiding();
|
testHiding();
|
||||||
testSelectingFilteredRuleset();
|
testSelectingFilteredRuleset();
|
||||||
|
testCarouselRootIsRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureRandomFetchSuccess() =>
|
private void ensureRandomFetchSuccess() =>
|
||||||
@ -151,6 +153,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddAssert("Selection is visible", selectedBeatmapVisible);
|
AddAssert("Selection is visible", selectedBeatmapVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkNonmatchingFilter()
|
||||||
|
{
|
||||||
|
AddStep("Toggel non-matching filter", () =>
|
||||||
|
{
|
||||||
|
carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false);
|
||||||
|
carousel.Filter(new FilterCriteria(), false);
|
||||||
|
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test keyboard traversal
|
/// Test keyboard traversal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -403,6 +416,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void testCarouselRootIsRandom()
|
||||||
|
{
|
||||||
|
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>();
|
||||||
|
|
||||||
|
for (int i = 1; i <= 50; i++)
|
||||||
|
beatmapSets.Add(createTestBeatmapSet(i));
|
||||||
|
|
||||||
|
AddStep("Load 50 Beatmaps", () => { carousel.BeatmapSets = beatmapSets; });
|
||||||
|
advanceSelection(direction: 1, diff: false);
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
checkNonmatchingFilter();
|
||||||
|
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||||
|
}
|
||||||
|
|
||||||
private BeatmapSetInfo createTestBeatmapSet(int id)
|
private BeatmapSetInfo createTestBeatmapSet(int id)
|
||||||
{
|
{
|
||||||
return new BeatmapSetInfo
|
return new BeatmapSetInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user