1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Add TestCaseHoldToQuit

This commit is contained in:
TocoToucan 2018-04-28 19:24:49 +03:00
parent 630980255e
commit b3cf381c5d

View 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");
}
}
}