From af78a3e99d9126d6bd47219b4fe6a1b6625376d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Dec 2021 17:09:08 +0900 Subject: [PATCH 1/3] Fix weird loop logic --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index be390742ea..01692ebc80 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -883,7 +883,7 @@ namespace osu.Game.Tests.Visual.SongSelect { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); - for (int i = 0; i < 100; i += 10) + for (int i = 0; i < 10; i++) manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets)).Wait(); }); } From 5c8e317a6e7b647b40e1f92a9d0d6eb17dbafda5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Dec 2021 17:11:15 +0900 Subject: [PATCH 2/3] Chooser earlier items in song select tests to avoid potentially not having enough --- .../Visual/SongSelect/TestScenePlaySongSelect.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 01692ebc80..dcc34d2eaa 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -488,8 +488,9 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("select beatmap externally", () => { target = manager.GetAllUsableBeatmapSets() - .Where(b => b.Beatmaps.Any(bi => bi.RulesetID == targetRuleset)) - .ElementAt(5).Beatmaps.First(bi => bi.RulesetID == targetRuleset); + .First(b => b.Beatmaps.Any(bi => bi.RulesetID == targetRuleset)) + .Beatmaps + .First(bi => bi.RulesetID == targetRuleset); Beatmap.Value = manager.GetWorkingBeatmap(target); }); @@ -534,8 +535,10 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("select beatmap externally", () => { - target = manager.GetAllUsableBeatmapSets().Where(b => b.Beatmaps.Any(bi => bi.RulesetID == 1)) - .ElementAt(5).Beatmaps.First(); + target = manager + .GetAllUsableBeatmapSets() + .First(b => b.Beatmaps.Any(bi => bi.RulesetID == 1)) + .Beatmaps.First(); Beatmap.Value = manager.GetWorkingBeatmap(target); }); From f492cf84d9d83d8ea9a39e5c1c511471d5bd7f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 20 Dec 2021 11:24:40 +0100 Subject: [PATCH 3/3] Ensure presence of at least 1 difficulty for each ruleset --- .../SongSelect/TestScenePlaySongSelect.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index dcc34d2eaa..912d3f838c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -466,7 +466,9 @@ namespace osu.Game.Tests.Visual.SongSelect public void TestExternalBeatmapChangeWhileFiltered(bool differentRuleset) { createSongSelect(); - addManyTestMaps(); + // ensure there is at least 1 difficulty for each of the rulesets + // (catch is excluded inside of addManyTestMaps). + addManyTestMaps(3); changeRuleset(0); @@ -519,7 +521,9 @@ namespace osu.Game.Tests.Visual.SongSelect public void TestExternalBeatmapChangeWhileFilteredThenRefilter() { createSongSelect(); - addManyTestMaps(); + // ensure there is at least 1 difficulty for each of the rulesets + // (catch is excluded inside of addManyTestMaps). + addManyTestMaps(3); changeRuleset(0); @@ -880,14 +884,21 @@ namespace osu.Game.Tests.Visual.SongSelect AddUntilStep("wait for carousel loaded", () => songSelect.Carousel.IsAlive); } - private void addManyTestMaps() + /// + /// Imports test beatmap sets to show in the carousel. + /// + /// + /// The exact count of difficulties to create for each beatmap set. + /// A value causes the count of difficulties to be selected randomly. + /// + private void addManyTestMaps(int? difficultyCountPerSet = null) { AddStep("import test maps", () => { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); for (int i = 0; i < 10; i++) - manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets)).Wait(); + manager.Import(TestResources.CreateTestBeatmapSetInfo(difficultyCountPerSet, usableRulesets)).Wait(); }); }