1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 05:22:54 +08:00

Refactor pause test to actually use quick exit action keybinding

This commit is contained in:
Joseph Madamba 2023-01-10 15:43:50 -08:00
parent 51dbe2c3a3
commit 404d34f592

View File

@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.Gameplay
pauseAndConfirm(); pauseAndConfirm();
resume(); resume();
AddStep("pause via exit key", () => Player.ExitViaQuickExit()); exitViaQuickExitAction();
confirmResumed(); confirmResumed();
AddAssert("exited", () => !Player.IsCurrentScreen()); AddAssert("exited", () => !Player.IsCurrentScreen());
@ -252,7 +252,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestQuickExitFromFailedGameplay() public void TestQuickExitFromFailedGameplay()
{ {
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed); AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddStep("quick exit", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyExitOverlay>().First().Action?.Invoke()); exitViaQuickExitAction();
confirmExited(); confirmExited();
} }
@ -268,7 +268,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestQuickExitFromGameplay() public void TestQuickExitFromGameplay()
{ {
AddStep("quick exit", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyExitOverlay>().First().Action?.Invoke()); exitViaQuickExitAction();
confirmExited(); confirmExited();
} }
@ -382,6 +382,15 @@ namespace osu.Game.Tests.Visual.Gameplay
private void restart() => AddStep("restart", () => Player.Restart()); private void restart() => AddStep("restart", () => Player.Restart());
private void pauseViaBackAction() => AddStep("press escape", () => InputManager.Key(Key.Escape)); private void pauseViaBackAction() => AddStep("press escape", () => InputManager.Key(Key.Escape));
private void exitViaQuickExitAction() => AddStep("press ctrl-tilde", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Tilde);
InputManager.ReleaseKey(Key.Tilde);
InputManager.ReleaseKey(Key.ControlLeft);
});
private void resume() => AddStep("resume", () => Player.Resume()); private void resume() => AddStep("resume", () => Player.Resume());
private void confirmPauseOverlayShown(bool isShown) => private void confirmPauseOverlayShown(bool isShown) =>
@ -412,8 +421,6 @@ namespace osu.Game.Tests.Visual.Gameplay
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible; public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
public void ExitViaQuickExit() => PerformExit(false);
public override void OnEntering(ScreenTransitionEvent e) public override void OnEntering(ScreenTransitionEvent e)
{ {
base.OnEntering(e); base.OnEntering(e);