1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Add test coverage of resuming after pause not skipping forward in time

This commit is contained in:
Dean Herbert 2022-08-29 19:02:01 +09:00
parent eb3601b7ff
commit ad5ef52922

View File

@ -90,6 +90,9 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("player not playing", () => !Player.LocalUserPlaying.Value);
resumeAndConfirm();
AddAssert("Resumed without seeking forward", () => Player.LastResumeTime, () => Is.LessThanOrEqualTo(Player.LastPauseTime));
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
}
@ -378,7 +381,16 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
private void confirmClockRunning(bool isRunning) =>
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.IsRunning == isRunning);
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () =>
{
bool completed = Player.GameplayClockContainer.IsRunning == isRunning;
if (completed)
{
}
return completed;
});
protected override bool AllowFail => true;
@ -386,6 +398,9 @@ namespace osu.Game.Tests.Visual.Gameplay
protected class PausePlayer : TestPlayer
{
public double LastPauseTime { get; private set; }
public double LastResumeTime { get; private set; }
public bool FailOverlayVisible => FailOverlay.State.Value == Visibility.Visible;
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
@ -399,6 +414,23 @@ namespace osu.Game.Tests.Visual.Gameplay
base.OnEntering(e);
GameplayClockContainer.Stop();
}
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;
}
}
}
}
}