From 6000ffed2a7eb000efb4ea045055d620be2dcbbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 2 May 2024 14:15:46 +0200 Subject: [PATCH] Add extended test coverage for intended behaviour --- .../Editor/TestSceneOsuEditorGrids.cs | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuEditorGrids.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuEditorGrids.cs index b720eb148b..5798869210 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuEditorGrids.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuEditorGrids.cs @@ -53,10 +53,17 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor AddUntilStep("distance snap grid visible", () => this.ChildrenOfType().Any()); AddStep("release alt", () => InputManager.ReleaseKey(Key.AltLeft)); AddUntilStep("distance snap grid hidden", () => !this.ChildrenOfType().Any()); + + AddStep("enable distance snap grid", () => InputManager.Key(Key.T)); + AddUntilStep("distance snap grid visible", () => this.ChildrenOfType().Any()); + AddStep("hold alt", () => InputManager.PressKey(Key.AltLeft)); + AddUntilStep("distance snap grid hidden", () => !this.ChildrenOfType().Any()); + AddStep("release alt", () => InputManager.ReleaseKey(Key.AltLeft)); + AddUntilStep("distance snap grid visible", () => this.ChildrenOfType().Any()); } [Test] - public void TestDistanceSnapAdjustDoesNotHideTheGrid() + public void TestDistanceSnapAdjustDoesNotHideTheGridIfStartingEnabled() { double distanceSnap = double.PositiveInfinity; @@ -79,6 +86,34 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor AddUntilStep("distance snap grid still visible", () => this.ChildrenOfType().Any()); } + [Test] + public void TestDistanceSnapAdjustShowsGridMomentarilyIfStartingDisabled() + { + double distanceSnap = double.PositiveInfinity; + + AddStep("select second object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects.ElementAt(1))); + AddUntilStep("distance snap grid hidden", () => !this.ChildrenOfType().Any()); + AddStep("store distance snap", () => distanceSnap = this.ChildrenOfType().First().DistanceSpacingMultiplier.Value); + + AddStep("start increasing distance", () => + { + InputManager.PressKey(Key.AltLeft); + InputManager.PressKey(Key.ControlLeft); + }); + + AddUntilStep("distance snap grid visible", () => this.ChildrenOfType().Any()); + + AddStep("finish increasing distance", () => + { + InputManager.ScrollVerticalBy(1); + InputManager.ReleaseKey(Key.ControlLeft); + InputManager.ReleaseKey(Key.AltLeft); + }); + + AddUntilStep("distance snap increased", () => this.ChildrenOfType().First().DistanceSpacingMultiplier.Value, () => Is.GreaterThan(distanceSnap)); + AddUntilStep("distance snap hidden in the end", () => !this.ChildrenOfType().Any()); + } + [Test] public void TestGridSnapMomentaryToggle() {