1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 22:02:56 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCaseQuitButton.cs

52 lines
1.6 KiB
C#
Raw Normal View History

2018-04-29 00:24:49 +08:00
// 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;
2018-05-04 05:01:00 +08:00
using osu.Framework.Graphics.Containers;
2018-04-29 00:24:49 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Screens.Play.HUD;
namespace osu.Game.Tests.Visual
{
[Description("'Hold to Quit' UI element")]
2018-05-04 05:01:00 +08:00
public class TestCaseQuitButton : OsuTestCase
2018-04-29 00:24:49 +08:00
{
2018-05-04 05:01:00 +08:00
private readonly QuitButton quitButton;
private Drawable innerButton => quitButton.Children.Single(child => child is CircularContainer);
2018-04-29 00:24:49 +08:00
private bool exitAction;
2018-05-04 05:01:00 +08:00
public TestCaseQuitButton()
2018-04-29 00:24:49 +08:00
{
2018-05-04 05:01:00 +08:00
Add(quitButton = new QuitButton
2018-04-29 00:24:49 +08:00
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
});
2018-05-04 05:01:00 +08:00
quitButton.ExitAction = () => exitAction = true;
2018-04-29 00:24:49 +08:00
2018-05-04 05:01:00 +08:00
var text = quitButton.Children.OfType<SpriteText>().Single();
2018-04-29 00:24:49 +08:00
2018-05-01 08:56:01 +08:00
AddStep("Trigger text fade in/out", () =>
2018-04-29 00:24:49 +08:00
{
exitAction = false;
2018-05-04 05:01:00 +08:00
innerButton.TriggerOnMouseDown();
innerButton.TriggerOnMouseUp();
2018-04-29 00:24:49 +08:00
});
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
AddStep("Trigger exit action", () =>
{
exitAction = false;
2018-05-04 05:01:00 +08:00
innerButton.TriggerOnMouseDown();
2018-04-29 00:24:49 +08:00
});
2018-05-04 05:01:00 +08:00
AddUntilStep(() => exitAction, $"{nameof(quitButton.ExitAction)} was triggered");
2018-04-29 00:24:49 +08:00
}
}
}