X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b0ec002323e2a8b17fe2a9eb13db97d7ca8c1471..cd15bcaf50ead53ccf9d50965312f0dc754affb4:/tests/events/stopwatch.cpp diff --git a/tests/events/stopwatch.cpp b/tests/events/stopwatch.cpp index f50da74306..a3827877b6 100644 --- a/tests/events/stopwatch.cpp +++ b/tests/events/stopwatch.cpp @@ -26,6 +26,14 @@ #include "wx/stopwatch.h" #include "wx/utils.h" +namespace +{ + +const long tolerance = 50; // in ms +const int sleepTime = 500; + +} // anonymous namespace + // -------------------------------------------------------------------------- // test class // -------------------------------------------------------------------------- @@ -39,10 +47,12 @@ private: CPPUNIT_TEST_SUITE( StopWatchTestCase ); CPPUNIT_TEST( Misc ); CPPUNIT_TEST( BackwardsClockBug ); + CPPUNIT_TEST( RestartBug ); CPPUNIT_TEST_SUITE_END(); void Misc(); void BackwardsClockBug(); + void RestartBug(); DECLARE_NO_COPY_CLASS(StopWatchTestCase) }; @@ -55,8 +65,6 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StopWatchTestCase, "StopWatchTestCase" ); void StopWatchTestCase::Misc() { - static const long tolerance = 10; // in ms - wxStopWatch sw; long t; wxLongLong usec; @@ -81,7 +89,6 @@ void StopWatchTestCase::Misc() t >= 0 && t < tolerance ); - static const int sleepTime = 500; sw.Resume(); wxMilliSleep(sleepTime); t = sw.Time(); @@ -124,3 +131,22 @@ void StopWatchTestCase::BackwardsClockBug() } } } + +void StopWatchTestCase::RestartBug() +{ + wxStopWatch sw; + sw.Pause(); + + // Calling Start() should resume the stopwatch if it was paused. + static const int offset = 5000; + sw.Start(offset); + wxMilliSleep(sleepTime); + + long t = sw.Time(); + WX_ASSERT_MESSAGE + ( + ("Actual time value is %ld", t), + t > offset + sleepTime - tolerance && + t < offset + sleepTime + tolerance + ); +}