2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (this.IsCurrentScreen())
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
this.Push(screen);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
nextScreen = null;
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-01-23 19:52:00 +08:00
|
|
|
|
this.MakeCurrent();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnResuming(IScreen last)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
if (nextScreen != null)
|
|
|
|
|
LoadScreen(nextScreen);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|