From eb614cf7e73275c6f7b64ae13fb24e41a1dfa88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 27 Aug 2013 12:06:17 +0200 Subject: [PATCH] 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 --- .../kernel/qeventdispatcher/tst_qeventdispatcher.cpp | 6 ++---- 1 file 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 1c07425fc78..93cf7999821 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);