From 831fa44433059078f0c96d06cf0e69b8686e5d8c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jan 2022 19:35:04 +0900 Subject: [PATCH 1/2] Fix song select tests not waiting for beatmap imports to arrive After the change to realm, notification fires could take a frame or two. We aren't accounting for this. Fixes test failures like https://github.com/ppy/osu/runs/4963255990?check_suite_focus=true --- .../SongSelect/TestScenePlaySongSelect.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 458c6130c7..ca0f2b8012 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -13,6 +13,7 @@ using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Database; using osu.Game.Extensions; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; @@ -73,6 +74,17 @@ public override void SetUpSteps() AddStep("delete all beatmaps", () => manager?.Delete()); } + public override void TearDownSteps() + { + base.TearDownSteps(); + + AddStep("remove song select", () => + { + songSelect?.Expire(); + songSelect = null; + }); + } + [Test] public void TestSingleFilterOnEnter() { @@ -870,9 +882,16 @@ private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDif return set.ChildrenOfType().ToList().FindIndex(i => i == icon); } - private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id)); + private void addRulesetImportStep(int id) + { + Live imported = null; + AddStep($"import test map for ruleset {id}", () => imported = importForRuleset(id)); + // This is specifically for cases where the add is happening post song select load. + // For cases where song select is null, the assertions are provided by the load checks. + AddUntilStep("wait for imported to arrive in carousel", () => songSelect == null || songSelect.Carousel.BeatmapSets.Any(s => s.ID == imported?.ID)); + } - private void importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())); + private Live importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())); private void checkMusicPlaying(bool playing) => AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing); From fae4f8bd8e17f7a5df716b8a19ca731a229c714f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jan 2022 21:59:44 +0900 Subject: [PATCH 2/2] Move nulling of previous `songSelect` to `SetUpSteps` instead --- .../Visual/SongSelect/TestScenePlaySongSelect.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index ca0f2b8012..0c452f857f 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -69,22 +69,13 @@ public override void SetUpSteps() { Ruleset.Value = new OsuRuleset().RulesetInfo; Beatmap.SetDefault(); + + songSelect = null; }); AddStep("delete all beatmaps", () => manager?.Delete()); } - public override void TearDownSteps() - { - base.TearDownSteps(); - - AddStep("remove song select", () => - { - songSelect?.Expire(); - songSelect = null; - }); - } - [Test] public void TestSingleFilterOnEnter() {