Fix race condition in the processEvents test

This test verifies processEvents(WaitForMoreEvents)
behavior by first processing all pending events (in
a loop) and then verifying that a following processEvents
call actually waits.

But there is no guarantee that the OS won’t introduce
more events after the first loop has completed. This
does indeed seem to happen on recent versions of macOS.

Change the test to not require that the processEvents
call blocked and de-blacklist.

Task-number: QTBUG-61131
Change-Id: Ic8fa74a6085165442791264f6f137a2fa6083138
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2017-07-19 14:16:26 +02:00
parent 0e9ea94511
commit 4585889467
2 changed files with 4 additions and 7 deletions

View File

@ -216,12 +216,11 @@ void tst_QEventLoop::processEvents()
awakeSpy.clear(); awakeSpy.clear();
QVERIFY(eventLoop.processEvents(QEventLoop::WaitForMoreEvents)); QVERIFY(eventLoop.processEvents(QEventLoop::WaitForMoreEvents));
// Verify that the eventloop has blocked and woken up. Some eventloops
// may block and wake up multiple times.
QVERIFY(aboutToBlockSpy.count() > 0);
QVERIFY(awakeSpy.count() > 0);
// We should get one awake for each aboutToBlock, plus one awake when // We should get one awake for each aboutToBlock, plus one awake when
// processEvents is entered. // processEvents is entered. There is no guarantee that that the
// processEvents call actually blocked, since the OS may introduce
// native events at any time.
QVERIFY(awakeSpy.count() > 0);
QVERIFY(awakeSpy.count() >= aboutToBlockSpy.count()); QVERIFY(awakeSpy.count() >= aboutToBlockSpy.count());
killTimer(timerId); killTimer(timerId);

View File

@ -1,4 +1,2 @@
[processEvents]
osx-10.12
[testQuitLock] [testQuitLock]
osx-10.12 osx-10.12