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-05-10 08:30:24 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-02-12 04:04:46 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2018-05-10 08:30:24 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
2023-06-25 12:26:08 +00:00
|
|
|
|
public partial class TestSceneHoldToExitGameOverlay : OsuTestScene
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
2019-08-16 04:46:08 +00:00
|
|
|
|
protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms
|
|
|
|
|
|
2023-06-25 12:26:08 +00:00
|
|
|
|
public TestSceneHoldToExitGameOverlay()
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
|
|
|
|
bool fired = false;
|
|
|
|
|
|
2018-05-14 10:08:00 +00:00
|
|
|
|
var firedText = new OsuSpriteText
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-05-14 10:08:00 +00:00
|
|
|
|
Text = "Fired!",
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 50),
|
2018-05-10 08:30:24 +00:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-23 05:46:38 +00:00
|
|
|
|
var overlay = new TestHoldToExitGameOverlay
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
fired = true;
|
2018-05-14 10:08:00 +00:00
|
|
|
|
firedText.FadeTo(1).Then().FadeOut(1000);
|
2018-05-10 08:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
overlay,
|
2018-05-14 10:08:00 +00:00
|
|
|
|
firedText
|
2018-05-10 08:30:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AddStep("start confirming", () => overlay.Begin());
|
|
|
|
|
AddStep("abort confirming", () => overlay.Abort());
|
|
|
|
|
|
2019-09-19 13:35:14 +00:00
|
|
|
|
AddAssert("ensure not fired internally", () => !overlay.Fired);
|
2018-05-10 08:30:24 +00:00
|
|
|
|
AddAssert("ensure aborted", () => !fired);
|
|
|
|
|
|
|
|
|
|
AddStep("start confirming", () => overlay.Begin());
|
|
|
|
|
|
2019-03-19 08:24:26 +00:00
|
|
|
|
AddUntilStep("wait until confirmed", () => fired);
|
2019-09-19 13:35:14 +00:00
|
|
|
|
AddAssert("ensure fired internally", () => overlay.Fired);
|
|
|
|
|
|
|
|
|
|
AddStep("abort after fire", () => overlay.Abort());
|
|
|
|
|
AddAssert("ensure not fired internally", () => !overlay.Fired);
|
|
|
|
|
AddStep("start confirming", () => overlay.Begin());
|
|
|
|
|
AddUntilStep("wait until fired again", () => overlay.Fired);
|
2018-05-10 08:30:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 05:46:38 +00:00
|
|
|
|
private partial class TestHoldToExitGameOverlay : HoldToExitGameOverlay
|
2018-05-10 08:30:24 +00:00
|
|
|
|
{
|
|
|
|
|
public void Begin() => BeginConfirm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|