mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:28:00 +08:00
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.
This commit is contained in:
parent
d379e553da
commit
7ceced7012
@ -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;
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play
|
||||
///
|
||||
/// In the future I want to change this.
|
||||
/// </summary>
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user