1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 22:22:55 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneHoldToConfirmOverlay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.1 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.
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Menu;
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneHoldToConfirmOverlay : OsuTestScene
{
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
public TestSceneHoldToConfirmOverlay()
{
bool fired = false;
2018-05-14 18:08:00 +08:00
var firedText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2018-05-14 18:08:00 +08:00
Text = "Fired!",
Font = OsuFont.GetFont(size: 50),
Alpha = 0,
};
var overlay = new TestHoldToConfirmOverlay
{
Action = () =>
{
fired = true;
2018-05-14 18:08:00 +08:00
firedText.FadeTo(1).Then().FadeOut(1000);
}
};
Children = new Drawable[]
{
overlay,
2018-05-14 18:08:00 +08:00
firedText
};
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);
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);
}
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
{
public void Begin() => BeginConfirm();
}
}
}