Replace hard-coded qWait() by QTRY_COMPARE/VERIFY in widget tests.

Task-number: QTBUG-38890
Change-Id: I9a729430fcd30b782c100bb76d5e287a3b4c1238
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
Friedemann Kleint 2014-05-23 12:14:02 +02:00 committed by The Qt Project
parent 5d48eb8bbc
commit 787c0d76a2
2 changed files with 7 additions and 15 deletions

View File

@ -1726,9 +1726,8 @@ void tst_QMainWindow::addToolbarAfterShow()
QToolBar toolBar;
mainWindow.addToolBar(&toolBar);
QTest::qWait(100);
QVERIFY(!toolBar.isHidden());
QTRY_VERIFY(!toolBar.isHidden());
}
void tst_QMainWindow::centralWidgetSize()
@ -1743,8 +1742,7 @@ void tst_QMainWindow::centralWidgetSize()
mainWindow.setCentralWidget(&widget);
mainWindow.show();
QTest::qWait(100);
QCOMPARE(widget.size(), widget.sizeHint());
QTRY_COMPARE(widget.size(), widget.sizeHint());
}
void tst_QMainWindow::dockWidgetSize()
@ -1789,19 +1787,15 @@ void tst_QMainWindow::QTBUG2774_stylechange()
{
QTest::qWait(1000);
mw.setStyleSheet("QMainWindow::separator { width: 50px; height:50px; }");
QTest::qWait(5000);
QApplication::processEvents();
QVERIFY(central->width() < centralOriginalWidth);
QTRY_VERIFY(central->width() < centralOriginalWidth);
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 49)));
}
{
mw.setStyleSheet("QMainWindow::separator { width: 0px; height: 0px; }");
QApplication::processEvents();
QVERIFY(central->width() > centralOriginalWidth);
QTRY_VERIFY(central->width() > centralOriginalWidth);
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 1)));
}

View File

@ -127,9 +127,7 @@ void tst_QStatusBar::tempMessage()
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1000);
QVERIFY(testWidget->currentMessage().isNull());
QTRY_VERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
testWidget->showMessage("Ready again", 500);
@ -294,10 +292,10 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(3000);
QTest::qWait(1500);
// Message disappears after 2 seconds
QVERIFY(testWidget->currentMessage().isNull());
QTRY_VERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
// Set display message for 2 seconds first