tests/auto/other: Avoid unconditional qWait()s

There is no need to qWait() before a QTRY_VERIFY. qWait() will also
intermittently handle events while waiting, so calling it in a loop isn't
necessary.

Change-Id: Ica7fbf18c03e673213dd9b72f31f71937cdcb145
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Kari Oikarinen 2018-04-03 10:21:24 +03:00
parent a1b1dd3b84
commit fd87c8da82
2 changed files with 3 additions and 14 deletions

View File

@ -196,7 +196,6 @@ void tst_QFocusEvent::checkReason_BackTab()
// Now test the backtab key // Now test the backtab key
QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab ); QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab );
QTest::qWait(200);
QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved); QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved);
QVERIFY(childFocusWidgetTwo->focusInEventRecieved); QVERIFY(childFocusWidgetTwo->focusInEventRecieved);
@ -217,7 +216,6 @@ void tst_QFocusEvent::checkReason_Popup()
QMenu* popupMenu = new QMenu( testFocusWidget ); QMenu* popupMenu = new QMenu( testFocusWidget );
popupMenu->addMenu( "Test" ); popupMenu->addMenu( "Test" );
popupMenu->popup( QPoint(0,0) ); popupMenu->popup( QPoint(0,0) );
QTest::qWait(50);
QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
@ -308,7 +306,7 @@ void tst_QFocusEvent::checkReason_focusWidget()
window1.show(); window1.show();
edit1.setFocus(); edit1.setFocus();
QTest::qWait(100); QTRY_VERIFY(edit1.hasFocus());
edit2.setFocus(); edit2.setFocus();
QVERIFY(frame1.focusWidget() != 0); QVERIFY(frame1.focusWidget() != 0);
@ -344,7 +342,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
QVERIFY( !childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->hasFocus() );
d->hide(); d->hide();
QTest::qWait(100);
if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive) if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)
|| !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) { || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) {

View File

@ -420,11 +420,7 @@ void tst_QObjectRace::disconnectRace()
threads[i]->start(); threads[i]->start();
} }
QTime timeLimiter; QTest::qWait(TimeLimit);
timeLimiter.start();
while (timeLimiter.elapsed() < TimeLimit)
QTest::qWait(10);
for (int i = 0; i < ThreadCount; ++i) { for (int i = 0; i < ThreadCount; ++i) {
threads[i]->requestInterruption(); threads[i]->requestInterruption();
@ -450,11 +446,7 @@ void tst_QObjectRace::disconnectRace()
threads[i]->start(); threads[i]->start();
} }
QTime timeLimiter; QTest::qWait(TimeLimit);
timeLimiter.start();
while (timeLimiter.elapsed() < TimeLimit)
QTest::qWait(10);
senderThread->requestInterruption(); senderThread->requestInterruption();
QVERIFY(senderThread->wait(300)); QVERIFY(senderThread->wait(300));