1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 20:32:56 +08:00
osu-lazer/osu.Game/Tests/Visual/ScreenTestCase.cs
smoogipoo 91302ea0bc Merge remote-tracking branch 'origin/master' into iscreen
# Conflicts:
#	osu.Game/Screens/Multi/Match/MatchSubScreen.cs
#	osu.Game/Screens/Multi/Multiplayer.cs
#	osu.Game/Screens/Multi/MultiplayerSubScreen.cs
#	osu.Game/Screens/OsuScreen.cs
#	osu.Game/osu.Game.csproj
#	osu.sln
2019-01-29 21:21:36 +09:00

49 lines
1.4 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Screens;
using osu.Game.Screens;
namespace osu.Game.Tests.Visual
{
/// <summary>
/// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions).
/// </summary>
public abstract class ScreenTestCase : OsuTestCase
{
private readonly TestOsuScreen baseScreen;
protected ScreenTestCase()
{
Add(baseScreen = new TestOsuScreen());
}
protected void LoadScreen(OsuScreen screen) => baseScreen.LoadScreen(screen);
public class TestOsuScreen : OsuScreen
{
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);
}
}
}
}