From 75f7d43d9d7b84bd38ed28e1e438d715c2295f92 Mon Sep 17 00:00:00 2001 From: Endrik Tombak Date: Mon, 2 Apr 2018 11:56:35 +0300 Subject: [PATCH] Testcases for CarouselRoot --- .../Visual/TestCaseBeatmapCarousel.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index c68e548f44..4ae897bc1a 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -42,6 +42,7 @@ namespace osu.Game.Tests.Visual private readonly Stack selectedSets = new Stack(); + private readonly HashSet eagerSelectedIDs = new HashSet(); private BeatmapInfo currentSelection; @@ -80,6 +81,7 @@ namespace osu.Game.Tests.Visual testEmptyTraversal(); testHiding(); testSelectingFilteredRuleset(); + testCarouselRootIsRandom(); } private void ensureRandomFetchSuccess() => @@ -151,6 +153,17 @@ namespace osu.Game.Tests.Visual 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); + } + ); + } + /// /// Test keyboard traversal /// @@ -403,6 +416,23 @@ namespace osu.Game.Tests.Visual AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle)); } + private void testCarouselRootIsRandom() + { + List beatmapSets = new List(); + + 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) { return new BeatmapSetInfo