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 System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
public class TestCaseHoldToConfirmOverlay : OsuTestCase
|
|
|
|
|
{
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ExitConfirmOverlay) };
|
|
|
|
|
|
|
|
|
|
public TestCaseHoldToConfirmOverlay()
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var overlay = new TestHoldToConfirmOverlay
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
AddAssert("ensure aborted", () => !fired);
|
|
|
|
|
|
|
|
|
|
AddStep("start confirming", () => overlay.Begin());
|
|
|
|
|
|
2019-03-19 16:24:26 +08:00
|
|
|
|
AddUntilStep("wait until confirmed", () => fired);
|
2018-05-10 16:30:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
|
|
|
|
{
|
|
|
|
|
protected override bool AllowMultipleFires => true;
|
|
|
|
|
|
|
|
|
|
public void Begin() => BeginConfirm();
|
|
|
|
|
public void Abort() => AbortConfirm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|