1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 17:27:39 +08:00
osu-lazer/osu.Game/Tests/Visual/ScreenTestScene.cs

57 lines
1.7 KiB
C#
Raw Normal View History

// 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
2021-06-22 23:48:41 +08:00
using osu.Framework.Allocation;
2019-01-31 10:00:44 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
2021-06-22 23:48:41 +08:00
using osu.Game.Overlays;
2018-04-13 17:19:50 +08:00
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 ScreenTestScene : OsuManualInputManagerTestScene
2018-04-13 17:19:50 +08:00
{
protected readonly OsuScreenStack Stack;
2019-01-31 13:55:48 +08:00
private readonly Container content;
protected override Container<Drawable> Content => content;
2021-06-22 23:48:41 +08:00
[Cached]
protected DialogOverlay DialogOverlay { get; private set; }
protected ScreenTestScene()
2018-04-13 17:19:50 +08:00
{
base.Content.AddRange(new Drawable[]
{
Stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both },
2021-06-22 23:48:41 +08:00
content = new Container { RelativeSizeAxes = Axes.Both },
DialogOverlay = new DialogOverlay()
});
2019-01-31 10:00:44 +08:00
}
2018-04-13 17:19:50 +08:00
protected void LoadScreen(OsuScreen screen) => Stack.Push(screen);
[SetUpSteps]
public virtual void SetUpSteps() => addExitAllScreensStep();
2020-01-31 21:09:39 +08:00
[TearDownSteps]
public virtual void TearDownSteps() => addExitAllScreensStep();
private void addExitAllScreensStep()
2019-01-31 10:00:44 +08:00
{
AddUntilStep("exit all screens", () =>
{
if (Stack.CurrentScreen == null) return true;
Stack.Exit();
return false;
});
2018-04-13 17:19:50 +08:00
}
}
}