Files
Ez2Lazer/osu.Game.Tests/Visual/UserInterface/TestSceneHoldToExitGameOverlay.cs
Dean Herbert 3e0abdace8 Apply new inspections from 2026.1EAP1
Nothing really egregious here so not bothering with PR review. One dodgy
bug which has been
[reported](https://youtrack.jetbrains.com/issue/RIDER-135036/Incorrect-recursive-on-all-execution-paths-inspection)
and temporarily ignored.
2026-01-26 17:26:50 +08:00

66 lines
2.1 KiB
C#

// 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 osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual.UserInterface
{
public partial class TestSceneHoldToExitGameOverlay : OsuTestScene
{
protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms
public TestSceneHoldToExitGameOverlay()
{
bool fired = false;
var firedText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "Fired!",
Font = OsuFont.GetFont(size: 50),
Alpha = 0,
};
var overlay = new TestHoldToExitGameOverlay
{
Action = () =>
{
fired = true;
firedText.FadeTo(1).Then().FadeOut(1000);
}
};
Children = new Drawable[]
{
overlay,
firedText
};
AddStep("start confirming", overlay.Begin);
AddStep("abort confirming", overlay.Abort);
AddAssert("ensure not fired internally", () => !overlay.Fired);
AddAssert("ensure aborted", () => !fired);
AddStep("start confirming", overlay.Begin);
AddUntilStep("wait until confirmed", () => fired);
AddAssert("ensure fired internally", () => overlay.Fired);
AddStep("abort after fire", overlay.Abort);
AddAssert("ensure not fired internally", () => !overlay.Fired);
AddStep("start confirming", overlay.Begin);
AddUntilStep("wait until fired again", () => overlay.Fired);
}
private partial class TestHoldToExitGameOverlay : HoldToExitGameOverlay
{
public void Begin() => BeginConfirm();
}
}
}