2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2021-06-22 15:48:41 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-01-24 07:40:16 +00:00
|
|
|
|
using osu.Framework.Development;
|
2019-01-31 02:00:44 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-29 05:34:58 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-10-05 09:53:20 +00:00
|
|
|
|
using osu.Framework.Logging;
|
2020-01-31 04:54:26 +00:00
|
|
|
|
using osu.Framework.Testing;
|
2021-06-22 15:48:41 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2018-04-13 09:19:50 +00: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>
|
2020-03-23 01:01:33 +00:00
|
|
|
|
public abstract class ScreenTestScene : OsuManualInputManagerTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-12-09 17:30:23 +00:00
|
|
|
|
protected readonly OsuScreenStack Stack;
|
2019-01-31 05:55:48 +00:00
|
|
|
|
|
2019-03-29 05:34:58 +00:00
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2021-06-22 15:48:41 +00:00
|
|
|
|
[Cached]
|
|
|
|
|
protected DialogOverlay DialogOverlay { get; private set; }
|
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
|
protected ScreenTestScene()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-03-29 05:34:58 +00:00
|
|
|
|
base.Content.AddRange(new Drawable[]
|
|
|
|
|
{
|
2021-12-20 09:24:14 +00:00
|
|
|
|
Stack = new OsuScreenStack
|
|
|
|
|
{
|
|
|
|
|
Name = nameof(ScreenTestScene),
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
2021-06-22 15:48:41 +00:00
|
|
|
|
content = new Container { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
DialogOverlay = new DialogOverlay()
|
2019-03-29 05:34:58 +00:00
|
|
|
|
});
|
2021-10-05 09:53:20 +00:00
|
|
|
|
|
|
|
|
|
Stack.ScreenPushed += (lastScreen, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed → {newScreen}");
|
|
|
|
|
Stack.ScreenExited += (lastScreen, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed ← {newScreen}");
|
2019-01-31 02:00:44 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-01-31 04:54:26 +00:00
|
|
|
|
protected void LoadScreen(OsuScreen screen) => Stack.Push(screen);
|
|
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public virtual void SetUpSteps() => addExitAllScreensStep();
|
|
|
|
|
|
2020-01-31 13:09:39 +00:00
|
|
|
|
[TearDownSteps]
|
2022-01-24 07:40:16 +00:00
|
|
|
|
public virtual void TearDownSteps()
|
|
|
|
|
{
|
|
|
|
|
if (DebugUtils.IsNUnitRunning)
|
|
|
|
|
addExitAllScreensStep();
|
|
|
|
|
}
|
2020-01-31 04:54:26 +00:00
|
|
|
|
|
|
|
|
|
private void addExitAllScreensStep()
|
2019-01-31 02:00:44 +00:00
|
|
|
|
{
|
2020-01-31 04:54:26 +00:00
|
|
|
|
AddUntilStep("exit all screens", () =>
|
|
|
|
|
{
|
|
|
|
|
if (Stack.CurrentScreen == null) return true;
|
|
|
|
|
|
2019-12-09 17:30:23 +00:00
|
|
|
|
Stack.Exit();
|
2020-01-31 04:54:26 +00:00
|
|
|
|
return false;
|
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|