From 7ceced70122d51ffc030074d1f3738645367be59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Oct 2023 14:47:04 +0900 Subject: [PATCH] Scope `TestPauseWithLargeOffset` to focus on what matters See https://github.com/ppy/osu/actions/runs/6693917410/job/18186111009 This test is to make sure we don't seek before the original pause time, so I've exposed that value precisely to avoid CI woes. --- osu.Game.Tests/Visual/Gameplay/TestScenePause.cs | 16 ++++++++++------ .../Screens/Play/MasterGameplayClockContainer.cs | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 29c9381ee4..ec3b3e0822 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestPauseWithLargeOffset() { - double lastTime; + double lastStopTime; bool alwaysGoingForward = true; AddStep("force large offset", () => @@ -84,20 +84,24 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("add time forward check hook", () => { - lastTime = double.MinValue; + lastStopTime = double.MinValue; alwaysGoingForward = true; Player.OnUpdate += _ => { - double currentTime = Player.GameplayClockContainer.CurrentTime; - bool goingForward = currentTime >= lastTime - 500; + var masterClock = (MasterGameplayClockContainer)Player.GameplayClockContainer; + + double currentTime = masterClock.CurrentTime; + + bool goingForward = currentTime >= (masterClock.LastStopTime ?? lastStopTime); alwaysGoingForward &= goingForward; if (!goingForward) - Logger.Log($"Backwards time occurred ({lastTime:N1} -> {currentTime:N1})"); + Logger.Log($"Went too far backwards (last stop: {lastStopTime:N1} current: {currentTime:N1})"); - lastTime = currentTime; + if (masterClock.LastStopTime != null) + lastStopTime = masterClock.LastStopTime.Value; }; }); diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 1c860e9d4b..54ed7ba626 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play /// /// In the future I want to change this. /// - private double? actualStopTime; + internal double? LastStopTime; [Resolved] private MusicController musicController { get; set; } = null!; @@ -100,7 +100,7 @@ namespace osu.Game.Screens.Play protected override void StopGameplayClock() { - actualStopTime = GameplayClock.CurrentTime; + LastStopTime = GameplayClock.CurrentTime; if (IsLoaded) { @@ -127,17 +127,17 @@ namespace osu.Game.Screens.Play public override void Seek(double time) { // Safety in case the clock is seeked while stopped. - actualStopTime = null; + LastStopTime = null; base.Seek(time); } protected override void PrepareStart() { - if (actualStopTime != null) + if (LastStopTime != null) { - Seek(actualStopTime.Value); - actualStopTime = null; + Seek(LastStopTime.Value); + LastStopTime = null; } else base.PrepareStart();