Use shorter sleep times in wxStopWatch unit test.

Make wxStopWatchTestCase::Misc() run in 2.5 seconds instead of 7. This not
only makes the test run faster but allows us to test wxMilliSleep() and
precision of wxStopWatch for time periods in fractional seconds.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-11-27 19:50:05 +00:00
parent e76e89aabe
commit c439998525

View File

@@ -62,7 +62,7 @@ void StopWatchTestCase::Misc()
sw.Pause(); // pause it immediately sw.Pause(); // pause it immediately
wxSleep(2); wxSleep(1);
t = sw.Time(); t = sw.Time();
// check that the stop watch doesn't advance while paused // check that the stop watch doesn't advance while paused
@@ -72,27 +72,31 @@ void StopWatchTestCase::Misc()
t >= 0 && t < tolerance t >= 0 && t < tolerance
); );
static const int sleepTime = 500;
sw.Resume(); sw.Resume();
wxSleep(3); wxMilliSleep(sleepTime);
t = sw.Time(); t = sw.Time();
// check that it did advance now by ~3s // check that it did advance now by ~1.5s
WX_ASSERT_MESSAGE WX_ASSERT_MESSAGE
( (
("Actual time value is %ld", t), ("Actual time value is %ld", t),
t > 3000 - tolerance && t < 3000 + tolerance t > sleepTime - tolerance && t < sleepTime + tolerance
); );
sw.Pause(); sw.Pause();
// check that this sleep won't be taken into account below
wxMilliSleep(sleepTime);
sw.Resume(); sw.Resume();
wxSleep(2); wxMilliSleep(sleepTime);
t = sw.Time(); t = sw.Time();
// and it should advance again // and it should advance again
WX_ASSERT_MESSAGE WX_ASSERT_MESSAGE
( (
("Actual time value is %ld", t), ("Actual time value is %ld", t),
t > 5000 - tolerance && t < 5000 + tolerance t > 2*sleepTime - tolerance && t < 2*sleepTime + tolerance
); );
} }