mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Add TestCaseHoldToQuit
This commit is contained in:
parent
630980255e
commit
b3cf381c5d
56
osu.Game.Tests/Visual/TestCaseHoldToQuit.cs
Normal file
56
osu.Game.Tests/Visual/TestCaseHoldToQuit.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
[Description("'Hold to Quit' UI element")]
|
||||||
|
public class TestCaseHoldToQuit : OsuTestCase
|
||||||
|
{
|
||||||
|
private bool exitAction;
|
||||||
|
|
||||||
|
public TestCaseHoldToQuit()
|
||||||
|
{
|
||||||
|
HoldToQuit holdToQuit;
|
||||||
|
Add(holdToQuit = new HoldToQuit
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
});
|
||||||
|
holdToQuit.Button.ExitAction = () => exitAction = true;
|
||||||
|
|
||||||
|
var text = holdToQuit.Children.OfType<SpriteText>().Single();
|
||||||
|
|
||||||
|
AddStep("Text fade in", () =>
|
||||||
|
{
|
||||||
|
exitAction = false;
|
||||||
|
holdToQuit.Button.TriggerOnMouseDown();
|
||||||
|
holdToQuit.Button.TriggerOnMouseUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
|
||||||
|
|
||||||
|
AddStep("Text fade out", () =>
|
||||||
|
{
|
||||||
|
exitAction = false;
|
||||||
|
holdToQuit.Button.TriggerOnMouseDown();
|
||||||
|
holdToQuit.Button.TriggerOnMouseUp();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
|
||||||
|
|
||||||
|
AddStep("Trigger exit action", () =>
|
||||||
|
{
|
||||||
|
exitAction = false;
|
||||||
|
holdToQuit.Button.TriggerOnMouseDown();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep(() => exitAction, $"{nameof(holdToQuit.Button.ExitAction)} was triggered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user