diff --git a/osu.Framework.Tests/Clocks/DecouplingFramedClockTest.cs b/osu.Framework.Tests/Clocks/DecouplingFramedClockTest.cs index 5eb2113776..8147244762 100644 --- a/osu.Framework.Tests/Clocks/DecouplingFramedClockTest.cs +++ b/osu.Framework.Tests/Clocks/DecouplingFramedClockTest.cs @@ -355,7 +355,7 @@ public void TestBackwardPlaybackOverZeroBoundary() while (source.IsRunning) { decouplingClock.ProcessFrame(); - Assert.That(decouplingClock.CurrentTime, Is.EqualTo(source.CurrentTime).Within(5)); + Assert.That(decouplingClock.CurrentTime, Is.EqualTo(source.CurrentTime).Within(30)); } Assert.That(source.IsRunning, Is.False); @@ -395,7 +395,7 @@ public void TestForwardPlaybackOverZeroBoundary() decouplingClock.ProcessFrame(); } - Assert.That(source.CurrentTime, Is.EqualTo(decouplingClock.CurrentTime).Within(5)); + Assert.That(source.CurrentTime, Is.EqualTo(decouplingClock.CurrentTime).Within(30)); Assert.That(source.IsRunning, Is.True); } @@ -416,11 +416,27 @@ public void TestForwardPlaybackOverLengthBoundary() decouplingClock.ProcessFrame(); double time = decouplingClock.CurrentTime; + const double tolerance = 30; - while (decouplingClock.CurrentTime < 10000) + // The decoupling clock generally lags behind the source clock, + // so we don't want the threshold here to go up to the full tolerance, + // to avoid situations like so: + // + // x: decouplingClock + // o: sourceClock + // + // ------x-----------o------> + // 9980ms 10000ms + // + // The source clock has reached its playback limit and cannot seek further, so it will stop. + // The decoupling clock hasn't caught up to the source clock yet, but it is close enough to pass the tolerance check. + // + // Subtracting the tolerance ensures that both the decoupling and source clocks stay in the same 30ms band, but neither stops yet. + // We will assert that the source should eventually stop further down anyway. + while (decouplingClock.CurrentTime < 10000 - tolerance) { Assert.That(source.IsRunning, Is.True); - Assert.That(source.CurrentTime, Is.EqualTo(decouplingClock.CurrentTime).Within(5)); + Assert.That(source.CurrentTime, Is.EqualTo(decouplingClock.CurrentTime).Within(30)); Assert.That(decouplingClock.CurrentTime, Is.GreaterThanOrEqualTo(time)); time = decouplingClock.CurrentTime;