osu/osu.Game.Tests/Visual/UserInterface/TestSceneHoldToConfirmOverlay.cs

69 lines
1.9 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 System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Menu;
2019-03-24 16:02:36 +00:00
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneHoldToConfirmOverlay : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ExitConfirmOverlay),
typeof(HoldToConfirmContainer),
};
public TestSceneHoldToConfirmOverlay()
{
bool fired = false;
2018-05-14 10:08:00 +00:00
var firedText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2018-05-14 10:08:00 +00:00
Text = "Fired!",
Font = OsuFont.GetFont(size: 50),
Alpha = 0,
};
var overlay = new TestHoldToConfirmOverlay
{
Action = () =>
{
fired = true;
2018-05-14 10:08:00 +00:00
firedText.FadeTo(1).Then().FadeOut(1000);
}
};
Children = new Drawable[]
{
overlay,
2018-05-14 10:08:00 +00:00
firedText
};
AddStep("start confirming", () => overlay.Begin());
AddStep("abort confirming", () => overlay.Abort());
AddAssert("ensure aborted", () => !fired);
AddStep("start confirming", () => overlay.Begin());
2019-03-19 08:24:26 +00:00
AddUntilStep("wait until confirmed", () => fired);
}
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
{
protected override bool AllowMultipleFires => true;
public void Begin() => BeginConfirm();
public void Abort() => AbortConfirm();
}
}
}