diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2013-08-27 12:06:17 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-05 02:32:57 +0200 |
commit | eb614cf7e73275c6f7b64ae13fb24e41a1dfa88c (patch) | |
tree | ee24e2bb23928306dc1ac469bf191b74a03315d0 /tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp | |
parent | 78f3f35a8b94e067a647a809003ecc60a3b8ad91 (diff) |
Don't assume processEvents(WaitForMoreEvents) will process timers
The WaitForMoreEvents flag only guarantees that we will process _some_
events -- either if they are in the event queue already, or by sleeping
and then waking up to process an event. This event might be a system
event, not the timer firing, so a single call to processEvents() is
not enough to guarantee that the timer has fired. Instead we do a
Q_COMPARE with a timeout, where we continiously process events until
we see that the timer fired.
Change-Id: I5dc04377f04190f3505be22e877af73d11b7547d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index 1c07425fc7..93cf799982 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -148,8 +148,7 @@ void tst_QEventDispatcher::registerTimer() // process events, waiting for the next event... this should only fire the precise timer receivedEventType = -1; timerIdFromEvent = -1; - QVERIFY(eventDispatcher->processEvents(QEventLoop::WaitForMoreEvents)); - QCOMPARE(receivedEventType, int(QEvent::Timer)); + QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2); QCOMPARE(timerIdFromEvent, preciseTimerId); // now unregister it and make sure it's gone eventDispatcher->unregisterTimer(preciseTimerId); @@ -161,8 +160,7 @@ void tst_QEventDispatcher::registerTimer() // do the same again for the coarse timer receivedEventType = -1; timerIdFromEvent = -1; - QVERIFY(eventDispatcher->processEvents(QEventLoop::WaitForMoreEvents)); - QCOMPARE(receivedEventType, int(QEvent::Timer)); + QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2); QCOMPARE(timerIdFromEvent, coarseTimerId); // now unregister it and make sure it's gone eventDispatcher->unregisterTimer(coarseTimerId); |