diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs index f52a764708..1d572772eb 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -68,6 +68,37 @@ namespace osu.Game.Tests.Visual.Editing }); } + [Test] + public void TestGameplayTestWhenTrackRunning() + { + AddStep("start track", () => EditorClock.Start()); + AddAssert("sample playback enabled", () => !Editor.SamplePlaybackDisabled.Value); + + AddStep("click test gameplay button", () => + { + var button = Editor.ChildrenOfType().Single(); + + InputManager.MoveMouseTo(button); + InputManager.Click(MouseButton.Left); + }); + + EditorPlayer editorPlayer = null; + AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); + AddAssert("editor track stopped", () => !EditorClock.IsRunning); + AddAssert("sample playback disabled", () => Editor.SamplePlaybackDisabled.Value); + + AddStep("exit player", () => editorPlayer.Exit()); + AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); + AddUntilStep("background has correct params", () => + { + var background = this.ChildrenOfType().Single(); + return background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0; + }); + + AddStep("start track", () => EditorClock.Start()); + AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value); + } + [Test] public void TestCancelGameplayTestWithUnsavedChanges() { diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index d97838e86d..ab24391bb4 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -545,9 +545,9 @@ namespace osu.Game.Screens.Edit public override void OnSuspending(IScreen next) { - refetchBeatmap(); - base.OnSuspending(next); + clock.Stop(); + refetchBeatmap(); } private void refetchBeatmap()