From e67d73be7dd1ffa6eb7fd8089c801206c889536a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 11 Jun 2024 12:00:02 +0200 Subject: [PATCH] Add test coverage --- .../Editor/TestSceneManiaEditorSaving.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaEditorSaving.cs diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaEditorSaving.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaEditorSaving.cs new file mode 100644 index 0000000000..9765648f44 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaEditorSaving.cs @@ -0,0 +1,45 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays; +using osu.Game.Screens.Edit; +using osu.Game.Screens.Edit.Setup; +using osu.Game.Tests.Visual; +using osuTK.Input; + +namespace osu.Game.Rulesets.Mania.Tests.Editor +{ + public partial class TestSceneManiaEditorSaving : EditorSavingTestScene + { + protected override Ruleset CreateRuleset() => new ManiaRuleset(); + + [Test] + public void TestKeyCountChange() + { + LabelledSliderBar keyCount = null!; + + AddStep("go to setup screen", () => InputManager.Key(Key.F4)); + AddUntilStep("retrieve key count slider", () => keyCount = Editor.ChildrenOfType().Single().ChildrenOfType>().First(), () => Is.Not.Null); + AddAssert("key count is 5", () => keyCount.Current.Value, () => Is.EqualTo(5)); + AddStep("change key count to 8", () => + { + keyCount.Current.Value = 8; + }); + AddUntilStep("dialog visible", () => Game.ChildrenOfType().SingleOrDefault()?.CurrentDialog, Is.InstanceOf); + AddStep("refuse", () => InputManager.Key(Key.Number2)); + AddAssert("key count is 5", () => keyCount.Current.Value, () => Is.EqualTo(5)); + + AddStep("change key count to 8 again", () => + { + keyCount.Current.Value = 8; + }); + AddUntilStep("dialog visible", () => Game.ChildrenOfType().Single().CurrentDialog, Is.InstanceOf); + AddStep("acquiesce", () => InputManager.Key(Key.Number1)); + AddUntilStep("beatmap became 8K", () => Game.Beatmap.Value.BeatmapInfo.Difficulty.CircleSize, () => Is.EqualTo(8)); + } + } +}