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