From b7ae431252d0cf5b537b312f9b613f4115c77d69 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 30 Mar 2022 01:08:22 +0300 Subject: [PATCH] Add test coverage --- .../SongSelect/TestScenePlaySongSelect.cs | 62 ++++++++++++++++++- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index c0c1e6b7a4..d27f16a624 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -68,7 +68,9 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("reset defaults", () => { Ruleset.Value = new OsuRuleset().RulesetInfo; + Beatmap.SetDefault(); + SelectedMods.SetDefault(); songSelect = null; }); @@ -563,7 +565,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestAutoplayViaCtrlEnter() + public void TestAutoplayShortcut() { addRulesetImportStep(0); @@ -580,11 +582,65 @@ namespace osu.Game.Tests.Visual.SongSelect AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); - AddAssert("autoplay enabled", () => songSelect.Mods.Value.FirstOrDefault() is ModAutoplay); + AddAssert("autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); - AddAssert("mod disabled", () => songSelect.Mods.Value.Count == 0); + AddAssert("no mods selected", () => songSelect.Mods.Value.Count == 0); + } + + [Test] + public void TestAutoplayShortcutKeepsAutoplayIfSelectedAlready() + { + addRulesetImportStep(0); + + createSongSelect(); + + AddUntilStep("wait for selection", () => !Beatmap.IsDefault); + + changeMods(new OsuModAutoplay()); + + AddStep("press ctrl+enter", () => + { + InputManager.PressKey(Key.ControlLeft); + InputManager.Key(Key.Enter); + InputManager.ReleaseKey(Key.ControlLeft); + }); + + AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); + + AddAssert("autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); + + AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); + + AddAssert("autoplay still selected", () => songSelect.Mods.Value.Single() is ModAutoplay); + } + + [Test] + public void TestAutoplayShortcutReturnsInitialModsOnExit() + { + addRulesetImportStep(0); + + createSongSelect(); + + AddUntilStep("wait for selection", () => !Beatmap.IsDefault); + + changeMods(new OsuModRelax()); + + AddStep("press ctrl+enter", () => + { + InputManager.PressKey(Key.ControlLeft); + InputManager.Key(Key.Enter); + InputManager.ReleaseKey(Key.ControlLeft); + }); + + AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); + + AddAssert("only autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); + + AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); + + AddAssert("relax returned", () => songSelect.Mods.Value.Single() is ModRelax); } [Test]