2019-03-17 23:46:15 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-03-26 12:18:33 +08:00
|
|
|
using System.Linq;
|
2019-03-18 18:44:21 +08:00
|
|
|
using NUnit.Framework;
|
2023-01-11 07:43:06 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-09-17 13:40:29 +08:00
|
|
|
using osu.Framework.Bindables;
|
2019-03-26 12:18:33 +08:00
|
|
|
using osu.Framework.Graphics;
|
2019-03-18 10:48:11 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-03-18 13:57:06 +08:00
|
|
|
using osu.Framework.Screens;
|
2019-05-10 17:10:07 +08:00
|
|
|
using osu.Framework.Testing;
|
2021-09-17 13:40:29 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-03-26 12:18:33 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2019-03-17 23:46:15 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Screens.Play;
|
2020-07-17 18:17:48 +08:00
|
|
|
using osu.Game.Skinning;
|
2019-03-26 12:18:33 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Input;
|
2019-03-17 23:46:15 +08:00
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2019-03-17 23:46:15 +08:00
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestScenePause : OsuPlayerTestScene
|
2019-03-17 23:46:15 +08:00
|
|
|
{
|
2019-03-18 18:44:21 +08:00
|
|
|
protected new PausePlayer Player => (PausePlayer)base.Player;
|
|
|
|
|
2019-03-26 12:18:33 +08:00
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
public TestScenePause()
|
2019-03-17 23:46:15 +08:00
|
|
|
{
|
2022-07-26 13:11:52 +08:00
|
|
|
base.Content.Add(content = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both });
|
2019-03-17 23:46:15 +08:00
|
|
|
}
|
|
|
|
|
2023-01-11 07:43:06 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0);
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:10:07 +08:00
|
|
|
[SetUpSteps]
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
2020-01-31 12:54:26 +08:00
|
|
|
|
2019-05-10 17:10:07 +08:00
|
|
|
AddStep("resume player", () => Player.GameplayClockContainer.Start());
|
|
|
|
confirmClockRunning(true);
|
|
|
|
}
|
|
|
|
|
2023-01-11 07:51:22 +08:00
|
|
|
[Test]
|
|
|
|
public void TestTogglePauseViaBackAction()
|
|
|
|
{
|
|
|
|
pauseViaBackAction();
|
|
|
|
pauseViaBackAction();
|
|
|
|
confirmPausedWithNoOverlay();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestTogglePauseViaPauseGameplayAction()
|
|
|
|
{
|
|
|
|
pauseViaPauseGameplayAction();
|
|
|
|
pauseViaPauseGameplayAction();
|
|
|
|
confirmPausedWithNoOverlay();
|
|
|
|
}
|
|
|
|
|
2021-09-17 13:40:29 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPauseWithLargeOffset()
|
|
|
|
{
|
|
|
|
double lastTime;
|
|
|
|
bool alwaysGoingForward = true;
|
|
|
|
|
|
|
|
AddStep("force large offset", () =>
|
|
|
|
{
|
|
|
|
var offset = (BindableDouble)LocalConfig.GetBindable<double>(OsuSetting.AudioOffset);
|
|
|
|
|
|
|
|
// use a large negative offset to avoid triggering a fail from forwards seeking.
|
|
|
|
offset.MinValue = -5000;
|
|
|
|
offset.Value = -5000;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("add time forward check hook", () =>
|
|
|
|
{
|
|
|
|
lastTime = double.MinValue;
|
|
|
|
alwaysGoingForward = true;
|
|
|
|
|
|
|
|
Player.OnUpdate += _ =>
|
|
|
|
{
|
|
|
|
double currentTime = Player.GameplayClockContainer.CurrentTime;
|
2022-08-30 00:21:53 +08:00
|
|
|
alwaysGoingForward &= currentTime >= lastTime - 500;
|
2021-09-17 13:40:29 +08:00
|
|
|
lastTime = currentTime;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
|
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
|
|
|
|
resumeAndConfirm();
|
|
|
|
|
2022-08-30 00:21:53 +08:00
|
|
|
AddAssert("time didn't go too far backwards", () => alwaysGoingForward);
|
2021-09-17 13:40:29 +08:00
|
|
|
|
2021-09-17 15:28:47 +08:00
|
|
|
AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0));
|
2021-09-17 13:40:29 +08:00
|
|
|
}
|
|
|
|
|
2019-03-18 18:44:21 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPauseResume()
|
2019-03-17 23:46:15 +08:00
|
|
|
{
|
2019-03-26 12:18:33 +08:00
|
|
|
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
|
|
|
|
pauseAndConfirm();
|
2022-04-26 11:02:38 +08:00
|
|
|
AddAssert("player not playing", () => !Player.LocalUserPlaying.Value);
|
|
|
|
|
2019-03-26 12:18:33 +08:00
|
|
|
resumeAndConfirm();
|
2022-08-29 18:02:01 +08:00
|
|
|
|
|
|
|
AddAssert("Resumed without seeking forward", () => Player.LastResumeTime, () => Is.LessThanOrEqualTo(Player.LastPauseTime));
|
|
|
|
|
2022-04-26 11:02:38 +08:00
|
|
|
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
|
2019-03-26 12:18:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestResumeWithResumeOverlay()
|
|
|
|
{
|
|
|
|
AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
|
2019-12-19 19:03:14 +08:00
|
|
|
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
2019-03-26 12:18:33 +08:00
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
resume();
|
|
|
|
|
2021-02-15 13:23:59 +08:00
|
|
|
confirmPausedWithNoOverlay();
|
2020-11-05 22:41:56 +08:00
|
|
|
AddStep("click to resume", () => InputManager.Click(MouseButton.Left));
|
2019-03-26 12:18:33 +08:00
|
|
|
|
|
|
|
confirmClockRunning(true);
|
|
|
|
}
|
|
|
|
|
2019-10-27 03:29:52 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPauseWithResumeOverlay()
|
|
|
|
{
|
|
|
|
AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
|
2019-12-19 19:03:14 +08:00
|
|
|
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
2019-10-27 03:29:52 +08:00
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
resume();
|
2021-02-15 14:57:34 +08:00
|
|
|
|
2021-02-15 13:23:59 +08:00
|
|
|
confirmPausedWithNoOverlay();
|
2019-10-27 03:29:52 +08:00
|
|
|
pauseAndConfirm();
|
|
|
|
|
|
|
|
AddUntilStep("resume overlay is not active", () => Player.DrawableRuleset.ResumeOverlay.State.Value == Visibility.Hidden);
|
|
|
|
confirmPaused();
|
2021-02-15 14:57:34 +08:00
|
|
|
confirmNotExited();
|
2019-10-27 03:29:52 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 12:18:33 +08:00
|
|
|
[Test]
|
|
|
|
public void TestResumeWithResumeOverlaySkipped()
|
|
|
|
{
|
|
|
|
AddStep("move cursor to button", () =>
|
|
|
|
InputManager.MoveMouseTo(Player.HUDOverlay.HoldToQuit.Children.OfType<HoldToConfirmContainer>().First().ScreenSpaceDrawQuad.Centre));
|
2019-12-19 19:03:14 +08:00
|
|
|
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
2019-03-26 12:18:33 +08:00
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
pauseAndConfirm();
|
|
|
|
resumeAndConfirm();
|
2019-03-18 18:44:21 +08:00
|
|
|
}
|
2019-03-18 10:48:11 +08:00
|
|
|
|
2021-02-20 13:19:44 +08:00
|
|
|
[Test]
|
|
|
|
public void TestUserPauseWhenPauseNotAllowed()
|
|
|
|
{
|
|
|
|
AddStep("disable pause support", () => Player.Configuration.AllowPause = false);
|
|
|
|
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2021-02-20 13:19:44 +08:00
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
2021-02-15 13:36:14 +08:00
|
|
|
[Test]
|
|
|
|
public void TestUserPauseDuringCooldownTooSoon()
|
|
|
|
{
|
|
|
|
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
|
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
|
|
|
|
resume();
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2021-02-15 13:36:14 +08:00
|
|
|
|
|
|
|
confirmResumed();
|
2021-02-15 14:57:34 +08:00
|
|
|
confirmNotExited();
|
2021-02-15 13:36:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestQuickExitDuringCooldownTooSoon()
|
|
|
|
{
|
|
|
|
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
|
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
|
|
|
|
resume();
|
2023-01-11 07:43:50 +08:00
|
|
|
exitViaQuickExitAction();
|
2021-02-15 13:36:14 +08:00
|
|
|
|
|
|
|
confirmResumed();
|
|
|
|
AddAssert("exited", () => !Player.IsCurrentScreen());
|
|
|
|
}
|
|
|
|
|
2019-03-21 15:11:44 +08:00
|
|
|
[Test]
|
2021-02-09 16:29:27 +08:00
|
|
|
public void TestExitSoonAfterResumeSucceeds()
|
2019-03-21 15:11:44 +08:00
|
|
|
{
|
2019-11-28 14:58:26 +08:00
|
|
|
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
2019-03-21 15:33:34 +08:00
|
|
|
|
2019-11-28 14:58:26 +08:00
|
|
|
pauseAndConfirm();
|
2019-03-21 15:33:34 +08:00
|
|
|
resume();
|
|
|
|
|
2021-02-09 16:29:27 +08:00
|
|
|
AddStep("exit quick", () => Player.Exit());
|
2019-03-21 15:33:34 +08:00
|
|
|
|
2021-02-15 13:23:59 +08:00
|
|
|
confirmResumed();
|
2021-02-09 16:29:27 +08:00
|
|
|
AddAssert("exited", () => !Player.IsCurrentScreen());
|
2019-03-21 15:11:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-18 18:44:21 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPauseAfterFail()
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2019-06-04 15:13:16 +08:00
|
|
|
AddUntilStep("fail overlay shown", () => Player.FailOverlayVisible);
|
2019-03-18 10:48:11 +08:00
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
confirmClockRunning(false);
|
|
|
|
|
2021-02-19 16:15:38 +08:00
|
|
|
AddStep("pause via forced pause", () => Player.Pause());
|
2019-03-21 15:33:34 +08:00
|
|
|
|
2021-02-15 13:23:59 +08:00
|
|
|
confirmPausedWithNoOverlay();
|
2019-03-18 18:44:21 +08:00
|
|
|
AddAssert("fail overlay still shown", () => Player.FailOverlayVisible);
|
2019-03-21 15:11:44 +08:00
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
exitAndConfirm();
|
2019-03-21 15:11:44 +08:00
|
|
|
}
|
|
|
|
|
2019-10-04 11:25:23 +08:00
|
|
|
[Test]
|
2021-02-19 16:15:38 +08:00
|
|
|
public void TestExitFromFailedGameplayAfterFailAnimation()
|
2019-10-04 11:25:23 +08:00
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2021-02-19 16:15:38 +08:00
|
|
|
AddUntilStep("wait for fail overlay shown", () => Player.FailOverlayVisible);
|
|
|
|
|
|
|
|
confirmClockRunning(false);
|
|
|
|
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2021-02-19 16:15:38 +08:00
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestExitFromFailedGameplayDuringFailAnimation()
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2021-02-19 16:15:38 +08:00
|
|
|
|
|
|
|
// will finish the fail animation and show the fail/pause screen.
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2021-02-19 16:15:38 +08:00
|
|
|
AddAssert("fail overlay shown", () => Player.FailOverlayVisible);
|
2019-10-04 11:25:23 +08:00
|
|
|
|
2021-02-19 16:15:38 +08:00
|
|
|
// will actually exit.
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2019-10-04 11:25:23 +08:00
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
2019-10-04 12:23:01 +08:00
|
|
|
[Test]
|
|
|
|
public void TestQuickRetryFromFailedGameplay()
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2020-09-29 13:18:54 +08:00
|
|
|
AddStep("quick retry", () => Player.GameplayClockContainer.ChildrenOfType<HotkeyRetryOverlay>().First().Action?.Invoke());
|
2019-10-04 12:23:01 +08:00
|
|
|
|
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestQuickExitFromFailedGameplay()
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2023-01-11 07:43:50 +08:00
|
|
|
exitViaQuickExitAction();
|
2019-10-04 12:23:01 +08:00
|
|
|
|
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
2019-03-21 15:11:44 +08:00
|
|
|
[Test]
|
|
|
|
public void TestExitFromGameplay()
|
|
|
|
{
|
2020-06-23 16:38:30 +08:00
|
|
|
// an externally triggered exit should immediately exit, skipping all pause logic.
|
2019-11-28 14:58:26 +08:00
|
|
|
AddStep("exit", () => Player.Exit());
|
2019-10-03 03:07:07 +08:00
|
|
|
confirmExited();
|
2019-03-18 18:44:21 +08:00
|
|
|
}
|
2019-03-18 13:57:06 +08:00
|
|
|
|
2019-10-04 12:23:01 +08:00
|
|
|
[Test]
|
|
|
|
public void TestQuickExitFromGameplay()
|
|
|
|
{
|
2023-01-11 07:43:50 +08:00
|
|
|
exitViaQuickExitAction();
|
2019-10-04 12:23:01 +08:00
|
|
|
|
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
2019-06-25 22:48:42 +08:00
|
|
|
[Test]
|
|
|
|
public void TestExitViaHoldToExit()
|
|
|
|
{
|
|
|
|
AddStep("exit", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(Player.HUDOverlay.HoldToQuit.First(c => c is HoldToConfirmContainer));
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
confirmPaused();
|
|
|
|
|
|
|
|
AddStep("release", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
|
|
|
|
exitAndConfirm();
|
|
|
|
}
|
|
|
|
|
2019-03-18 18:44:21 +08:00
|
|
|
[Test]
|
|
|
|
public void TestExitFromPause()
|
|
|
|
{
|
2019-03-21 15:33:34 +08:00
|
|
|
pauseAndConfirm();
|
|
|
|
exitAndConfirm();
|
|
|
|
}
|
2019-03-18 13:57:06 +08:00
|
|
|
|
2019-09-13 14:41:53 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRestartAfterResume()
|
|
|
|
{
|
2019-11-28 14:58:26 +08:00
|
|
|
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
|
|
|
|
2019-09-13 14:41:53 +08:00
|
|
|
pauseAndConfirm();
|
|
|
|
resumeAndConfirm();
|
|
|
|
restart();
|
|
|
|
confirmExited();
|
|
|
|
}
|
|
|
|
|
2020-07-17 18:17:48 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPauseSoundLoop()
|
|
|
|
{
|
|
|
|
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
|
|
|
|
|
|
|
SkinnableSound getLoop() => Player.ChildrenOfType<PauseOverlay>().FirstOrDefault()?.ChildrenOfType<SkinnableSound>().FirstOrDefault();
|
|
|
|
|
|
|
|
pauseAndConfirm();
|
|
|
|
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
|
|
|
|
|
|
|
resumeAndConfirm();
|
|
|
|
AddUntilStep("loop is stopped", () => !getLoop().IsPlaying);
|
|
|
|
|
|
|
|
AddUntilStep("pause again", () =>
|
|
|
|
{
|
|
|
|
Player.Pause();
|
2022-08-15 16:06:24 +08:00
|
|
|
return !Player.GameplayClockContainer.IsRunning;
|
2020-07-17 18:17:48 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
|
|
|
|
|
|
|
resumeAndConfirm();
|
|
|
|
AddUntilStep("loop is stopped", () => !getLoop().IsPlaying);
|
|
|
|
}
|
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
private void pauseAndConfirm()
|
|
|
|
{
|
2023-01-11 07:43:06 +08:00
|
|
|
pauseViaBackAction();
|
2019-03-21 15:33:34 +08:00
|
|
|
confirmPaused();
|
2019-03-21 15:11:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
private void resumeAndConfirm()
|
|
|
|
{
|
|
|
|
resume();
|
|
|
|
confirmResumed();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void exitAndConfirm()
|
2019-03-21 15:11:44 +08:00
|
|
|
{
|
2021-02-15 14:57:34 +08:00
|
|
|
confirmNotExited();
|
2019-03-18 18:44:21 +08:00
|
|
|
AddStep("exit", () => Player.Exit());
|
2019-03-21 15:33:34 +08:00
|
|
|
confirmExited();
|
2019-11-06 09:32:09 +08:00
|
|
|
confirmNoTrackAdjustments();
|
2019-03-21 15:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void confirmPaused()
|
|
|
|
{
|
|
|
|
confirmClockRunning(false);
|
2021-02-15 14:57:34 +08:00
|
|
|
confirmNotExited();
|
2022-01-26 00:45:11 +08:00
|
|
|
AddAssert("player not failed", () => !Player.GameplayState.HasFailed);
|
2019-03-21 15:33:34 +08:00
|
|
|
AddAssert("pause overlay shown", () => Player.PauseOverlayVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void confirmResumed()
|
|
|
|
{
|
|
|
|
confirmClockRunning(true);
|
|
|
|
confirmPauseOverlayShown(false);
|
|
|
|
}
|
|
|
|
|
2021-02-15 13:23:59 +08:00
|
|
|
private void confirmPausedWithNoOverlay()
|
|
|
|
{
|
|
|
|
confirmClockRunning(false);
|
|
|
|
confirmPauseOverlayShown(false);
|
|
|
|
}
|
|
|
|
|
2021-02-15 14:57:34 +08:00
|
|
|
private void confirmExited() => AddUntilStep("player exited", () => !Player.IsCurrentScreen());
|
|
|
|
private void confirmNotExited() => AddAssert("player not exited", () => Player.IsCurrentScreen());
|
2019-03-17 23:46:15 +08:00
|
|
|
|
2019-11-06 09:32:09 +08:00
|
|
|
private void confirmNoTrackAdjustments()
|
|
|
|
{
|
2022-09-06 19:06:30 +08:00
|
|
|
AddUntilStep("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value, () => Is.EqualTo(1));
|
2019-11-06 09:32:09 +08:00
|
|
|
}
|
|
|
|
|
2019-09-13 14:41:53 +08:00
|
|
|
private void restart() => AddStep("restart", () => Player.Restart());
|
2023-01-11 07:43:06 +08:00
|
|
|
private void pauseViaBackAction() => AddStep("press escape", () => InputManager.Key(Key.Escape));
|
2023-01-11 07:51:22 +08:00
|
|
|
private void pauseViaPauseGameplayAction() => AddStep("press middle mouse", () => InputManager.Click(MouseButton.Middle));
|
2023-01-11 07:43:50 +08:00
|
|
|
|
|
|
|
private void exitViaQuickExitAction() => AddStep("press ctrl-tilde", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.ControlLeft);
|
|
|
|
InputManager.PressKey(Key.Tilde);
|
|
|
|
InputManager.ReleaseKey(Key.Tilde);
|
|
|
|
InputManager.ReleaseKey(Key.ControlLeft);
|
|
|
|
});
|
|
|
|
|
2019-03-21 15:33:34 +08:00
|
|
|
private void resume() => AddStep("resume", () => Player.Resume());
|
|
|
|
|
|
|
|
private void confirmPauseOverlayShown(bool isShown) =>
|
|
|
|
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
|
|
|
|
|
|
|
|
private void confirmClockRunning(bool isRunning) =>
|
2022-08-29 18:02:01 +08:00
|
|
|
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () =>
|
|
|
|
{
|
|
|
|
bool completed = Player.GameplayClockContainer.IsRunning == isRunning;
|
|
|
|
|
|
|
|
if (completed)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return completed;
|
|
|
|
});
|
2019-03-21 15:33:34 +08:00
|
|
|
|
2019-03-18 18:44:21 +08:00
|
|
|
protected override bool AllowFail => true;
|
|
|
|
|
2020-03-05 10:25:07 +08:00
|
|
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new PausePlayer();
|
2019-03-18 18:44:21 +08:00
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
protected partial class PausePlayer : TestPlayer
|
2019-03-17 23:46:15 +08:00
|
|
|
{
|
2022-08-29 18:02:01 +08:00
|
|
|
public double LastPauseTime { get; private set; }
|
|
|
|
public double LastResumeTime { get; private set; }
|
|
|
|
|
2019-06-11 13:28:52 +08:00
|
|
|
public bool FailOverlayVisible => FailOverlay.State.Value == Visibility.Visible;
|
2019-03-18 10:48:11 +08:00
|
|
|
|
2019-06-11 13:28:52 +08:00
|
|
|
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
|
2019-03-26 12:18:33 +08:00
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnEntering(ScreenTransitionEvent e)
|
2019-05-10 17:10:07 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnEntering(e);
|
2019-05-10 17:10:07 +08:00
|
|
|
GameplayClockContainer.Stop();
|
|
|
|
}
|
2022-08-29 18:02:01 +08:00
|
|
|
|
|
|
|
private bool? isRunning;
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
{
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
if (GameplayClockContainer.IsRunning != isRunning)
|
|
|
|
{
|
|
|
|
isRunning = GameplayClockContainer.IsRunning;
|
|
|
|
|
|
|
|
if (isRunning.Value)
|
|
|
|
LastResumeTime = GameplayClockContainer.CurrentTime;
|
|
|
|
else
|
|
|
|
LastPauseTime = GameplayClockContainer.CurrentTime;
|
|
|
|
}
|
|
|
|
}
|
2019-03-17 23:46:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|