Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase tolerance in decoupling framed clock tests #6011

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions osu.Framework.Tests/Clocks/DecouplingFramedClockTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;

Expand Down
Loading