Add failing test coverage of user pausing or quick exiting during cooldown

This commit is contained in:
Dean Herbert 2021-02-15 14:36:14 +09:00
parent 2b69c7b325
commit 25f5120fdf

View File

@ -90,19 +90,47 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
[Test] [Test]
public void TestPauseDuringCooldownTooSoon() public void TestExternalPauseDuringCooldownTooSoon()
{ {
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10))); AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
pauseAndConfirm(); pauseAndConfirm();
resume(); resume();
pause(); pauseExternally();
confirmResumed(); confirmResumed();
AddAssert("not exited", () => Player.IsCurrentScreen()); AddAssert("not exited", () => Player.IsCurrentScreen());
} }
[Test]
public void TestUserPauseDuringCooldownTooSoon()
{
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
pauseAndConfirm();
resume();
AddStep("pause via exit key", () => Player.ExitViaPause());
confirmResumed();
AddAssert("not exited", () => Player.IsCurrentScreen());
}
[Test]
public void TestQuickExitDuringCooldownTooSoon()
{
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
pauseAndConfirm();
resume();
AddStep("pause via exit key", () => Player.ExitViaQuickExit());
confirmResumed();
AddAssert("exited", () => !Player.IsCurrentScreen());
}
[Test] [Test]
public void TestExitSoonAfterResumeSucceeds() public void TestExitSoonAfterResumeSucceeds()
{ {
@ -125,7 +153,7 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(false); confirmClockRunning(false);
pause(); pauseExternally();
confirmPausedWithNoOverlay(); confirmPausedWithNoOverlay();
AddAssert("fail overlay still shown", () => Player.FailOverlayVisible); AddAssert("fail overlay still shown", () => Player.FailOverlayVisible);
@ -237,7 +265,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void pauseAndConfirm() private void pauseAndConfirm()
{ {
pause(); pauseExternally();
confirmPaused(); confirmPaused();
} }
@ -286,7 +314,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
private void restart() => AddStep("restart", () => Player.Restart()); private void restart() => AddStep("restart", () => Player.Restart());
private void pause() => AddStep("pause", () => Player.Pause()); private void pauseExternally() => AddStep("pause", () => Player.Pause());
private void resume() => AddStep("resume", () => Player.Resume()); private void resume() => AddStep("resume", () => Player.Resume());
private void confirmPauseOverlayShown(bool isShown) => private void confirmPauseOverlayShown(bool isShown) =>
@ -305,6 +333,10 @@ namespace osu.Game.Tests.Visual.Gameplay
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible; public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
public void ExitViaPause() => PerformExit(true);
public void ExitViaQuickExit() => PerformExit(false);
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);