diff --git a/osu.Game/Tests/Visual/ScreenTestCase.cs b/osu.Game/Tests/Visual/ScreenTestCase.cs index dd3587ebd0..e635a9837d 100644 --- a/osu.Game/Tests/Visual/ScreenTestCase.cs +++ b/osu.Game/Tests/Visual/ScreenTestCase.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Screens; @@ -11,38 +12,21 @@ namespace osu.Game.Tests.Visual /// public abstract class ScreenTestCase : OsuTestCase { - private readonly TestOsuScreen baseScreen; + private readonly ScreenStack stack; protected ScreenTestCase() { - Add(baseScreen = new TestOsuScreen()); + Add(stack = new ScreenStack + { + RelativeSizeAxes = Axes.Both, + }); } - protected void LoadScreen(OsuScreen screen) => baseScreen.LoadScreen(screen); - - public class TestOsuScreen : OsuScreen + protected void LoadScreen(OsuScreen screen) { - private OsuScreen nextScreen; - - public void LoadScreen(OsuScreen screen) => Schedule(() => - { - nextScreen = screen; - - if (this.IsCurrentScreen()) - { - this.Push(screen); - nextScreen = null; - } - else - this.MakeCurrent(); - }); - - public override void OnResuming(IScreen last) - { - base.OnResuming(last); - if (nextScreen != null) - LoadScreen(nextScreen); - } + if (stack.CurrentScreen != null) + stack.Exit(); + stack.Push(screen); } } }