summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp13
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp79
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp31
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp3
4 files changed, 50 insertions, 76 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 90f8457b7f..c3bdf3701f 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -494,9 +494,6 @@ void tst_QFiledialog::completer()
QAbstractItemModel *cModel = completer->completionModel();
QVERIFY(cModel);
- //wait a bit
- QTest::qWait(500);
-
// path C:\depot\qt\examples\dialogs\standarddialogs
// files
// [debug] [release] [tmp] dialog dialog main makefile makefile.debug makefile.release standarddialgos
@@ -509,7 +506,7 @@ void tst_QFiledialog::completer()
// \ -> \_viminfo
// c:\depot -> 'nothing'
// c:\depot\ -> C:\depot\devtools, C:\depot\dteske
- QCOMPARE(model->index(fd.directory().path()), model->index(startPath));
+ QTRY_COMPARE(model->index(fd.directory().path()), model->index(startPath));
if (input.isEmpty()) {
// Try to find a suitable directory under root that does not
@@ -1331,7 +1328,6 @@ void tst_QFiledialog::clearLineEdit()
// saving a file the text shouldn't be cleared
fd.setDirectory(QDir::home());
- QTest::qWait(1000);
#ifdef QT_KEYPAD_NAVIGATION
list->setEditFocus(true);
#endif
@@ -1342,8 +1338,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
- QTest::qWait(2000);
- QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
+ QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(!lineEdit->text().isEmpty());
// selecting a dir the text should be cleared so one can just hit ok
@@ -1351,7 +1346,6 @@ void tst_QFiledialog::clearLineEdit()
fd.setFileMode(QFileDialog::Directory);
fd.setDirectory(QDir::home());
- QTest::qWait(1000);
QTest::keyClick(list, Qt::Key_Down);
#ifndef Q_OS_MAC
QTest::keyClick(list, Qt::Key_Return);
@@ -1359,8 +1353,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
- QTest::qWait(2000);
- QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
+ QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(lineEdit->text().isEmpty());
//remove the dir
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index eafd4d7cea..fca1f17a4d 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -184,8 +184,7 @@ void tst_QFileDialog2::listRoot()
fd.show();
QCOMPARE(qt_test_isFetchedRoot(),false);
fd.setDirectory("");
- QTest::qWait(500);
- QCOMPARE(qt_test_isFetchedRoot(),true);
+ QTRY_COMPARE(qt_test_isFetchedRoot(),true);
}
#endif
@@ -231,9 +230,7 @@ void tst_QFileDialog2::deleteDirAndFiles()
delete t;
FriendlyQFileDialog fd;
fd.d_func()->removeDirectory(tempPath);
- QFileInfo info(tempPath);
- QTest::qWait(2000);
- QVERIFY(!info.exists());
+ QTRY_VERIFY(!QFileInfo::exists(tempPath));
}
#endif
@@ -551,22 +548,22 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog()
QFileDialog fd(0, "", QDir::currentPath(), 0);
fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit");
- QTest::qWait(200);
+ QVERIFY(edit);
QTest::keyClick(edit, Qt::Key_T);
QTest::keyClick(edit, Qt::Key_S);
- QTest::qWait(200);
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
dialog->setFileMode(QFileDialog::ExistingFile);
dialog->show();
+ QVERIFY(QTest::qWaitForWindowActive(dialog));
QListView *list = dialog->findChild<QListView*>("listView");
- QTest::qWait(200);
+ QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
dialog->close();
fd.close();
@@ -603,21 +600,18 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior()
fd.setViewMode(QFileDialog::List);
fd.setDirectory(current.absolutePath());
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
- QTest::qWait(200);
+ QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Backspace);
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QCOMPARE(fd.isVisible(), true);
- QTest::qWait(200);
file.close();
file2.close();
file.remove();
@@ -734,11 +728,11 @@ void tst_QFileDialog2::task233037_selectingDirectory()
list->setEditFocus(true);
#endif
QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(100);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
QVERIFY(button);
- QCOMPARE(button->isEnabled(), true);
+ QVERIFY(button->isEnabled());
current.rmdir("test");
}
@@ -766,10 +760,10 @@ void tst_QFileDialog2::task235069_hideOnEscape()
fd.setDirectory(current.absolutePath());
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QWidget *child = fd.findChild<QWidget *>(childName);
QVERIFY(child);
child->setFocus();
- QTest::qWait(200);
QTest::keyClick(child, Qt::Key_Escape);
QCOMPARE(fd.isVisible(), false);
QCOMPARE(spyFinished.count(), 1); // QTBUG-7690
@@ -788,14 +782,13 @@ void tst_QFileDialog2::task236402_dontWatchDeletedDir()
fd.setDirectory(current.absolutePath());
fd.setAcceptMode( QFileDialog::AcceptSave);
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
+ QVERIFY(list);
list->setFocus();
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Backspace);
QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(200);
fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
QTest::qWait(1000);
}
@@ -810,16 +803,16 @@ void tst_QFileDialog2::task203703_returnProperSeparator()
fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::Directory);
fd.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
+ QVERIFY(list);
list->setFocus();
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(1000);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
+ QVERIFY(button);
QTest::keyClick(button, Qt::Key_Return);
- QTest::qWait(500);
QString result = fd.selectedFiles().first();
QVERIFY(result.at(result.count() - 1) != '/');
QVERIFY(!result.contains('\\'));
@@ -846,47 +839,52 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
fd.setDirectory(current.absolutePath());
fd.setViewMode(QFileDialog::Detail);
fd.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QTreeView *tree = fd.findChild<QTreeView*>("treeView");
+ QVERIFY(tree);
tree->header()->setSortIndicator(3,Qt::DescendingOrder);
- QTest::qWait(200);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
+ QVERIFY(button);
QTest::mouseClick(button, Qt::LeftButton);
- QTest::qWait(500);
QFileDialog fd2;
fd2.setFileMode(QFileDialog::Directory);
fd2.restoreState(fd.saveState());
current.cd("aaaaaaaaaaaaaaaaaa");
fd2.setDirectory(current.absolutePath());
fd2.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd2));
QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView");
+ QVERIFY(tree2);
tree2->setFocus();
QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
QDialogButtonBox *buttonBox2 = fd2.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox2);
QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
+ QVERIFY(button2);
fd2.selectFile("g");
QTest::mouseClick(button2, Qt::LeftButton);
- QTest::qWait(500);
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g"));
QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
fd3.restoreState(fd.saveState());
fd3.setFileMode(QFileDialog::Directory);
fd3.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd3));
QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView");
+ QVERIFY(tree3);
tree3->setFocus();
QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox3);
QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
+ QVERIFY(button3);
QTest::mouseClick(button3, Qt::LeftButton);
- QTest::qWait(500);
QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
current.cd("aaaaaaaaaaaaaaaaaa");
@@ -908,9 +906,8 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
{
QFileDialog d;
d.setNameFilter("*.cpp *.h");
-
d.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&d));
QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
QComboBox *filterCombo = 0;
@@ -961,9 +958,10 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries()
urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
fd.setSidebarUrls(urls);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
+ QVERIFY(sidebar);
sidebar->setFocus();
sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
@@ -1014,16 +1012,17 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
urls << QUrl::fromLocalFile("NotFound");
fd.setSidebarUrls(urls);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
+ QVERIFY(sidebar);
sidebar->setFocus();
//We enter in the first bookmark
sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
+ QVERIFY(model);
//There is no file
QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
//Icon is not enabled QUrlModel::EnabledRole
@@ -1034,7 +1033,6 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
//We enter in the second bookmark which is invalid
sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
//We fallback to root because the entry in the bookmark is invalid
QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
@@ -1086,7 +1084,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
fd.selectFile("new_file.txt");
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
@@ -1130,7 +1128,7 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
fd.setOption(QFileDialog::HideNameFilterDetails, true);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
//Extensions are hidden
QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo");
@@ -1141,7 +1139,6 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
//We should have the full names
fd.setOption(QFileDialog::HideNameFilterDetails, false);
- QTest::qWait(250);
filters->setCurrentIndex(0);
QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
filters->setCurrentIndex(1);
@@ -1155,14 +1152,12 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0);
- QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0);
- QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 40a7d56432..d8a680881a 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -176,15 +176,12 @@ void tst_QFileSystemModel::indexPath()
#if !defined(Q_OS_WIN)
int depth = QDir::currentPath().count('/');
model->setRootPath(QDir::currentPath());
- QTest::qWait(WAITTIME);
QString backPath;
for (int i = 0; i <= depth * 2 + 1; ++i) {
backPath += "../";
QModelIndex idx = model->index(backPath);
QVERIFY(i != depth - 1 ? idx.isValid() : !idx.isValid());
}
- QTest::qWait(WAITTIME * 3);
- qApp->processEvents();
#endif
}
@@ -296,9 +293,7 @@ void tst_QFileSystemModel::iconProvider()
QVERIFY(!documentPaths.isEmpty());
const QString documentPath = documentPaths.front();
myModel->setRootPath(documentPath);
- //Let's wait to populate the model
- QTest::qWait(250);
- //We change the provider, icons must me updated
+ //We change the provider, icons must be updated
CustomFileIconProvider *custom = new CustomFileIconProvider();
myModel->setIconProvider(custom);
@@ -421,7 +416,6 @@ void tst_QFileSystemModel::rowsInserted()
for (int i = 0; i < count; ++i)
files.append(QLatin1Char('c') + QString::number(i));
QVERIFY(createFiles(tmp, files, 5));
- TRY_WAIT(model->rowCount(root) == oldCount + count);
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
for (int i = 0; i < spy0.count(); ++i) {
@@ -467,7 +461,6 @@ void tst_QFileSystemModel::rowsRemoved()
QFETCH(int, count);
QFETCH(int, ascending);
model->sort(0, (Qt::SortOrder)ascending);
- QTest::qWait(WAITTIME);
QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
@@ -477,8 +470,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + '/' + model->index(i, 0, root).data().toString()));
}
for (int i = 0 ; i < 10; ++i) {
- QTest::qWait(WAITTIME);
- qApp->processEvents();
if (count != 0) {
if (i == 10 || spy0.count() != 0) {
QVERIFY(spy0.count() >= 1);
@@ -504,7 +495,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::exists(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".c")));
- QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0);
if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0);
@@ -517,10 +507,8 @@ void tst_QFileSystemModel::dataChanged_data()
void tst_QFileSystemModel::dataChanged()
{
- // This can't be tested right now sense we don't watch files, only directories
- return;
+ QSKIP("This can't be tested right now since we don't watch files, only directories.");
- /*
QString tmp = flatDirTestPath;
rowCount();
QModelIndex root = model->index(model->rootPath());
@@ -538,7 +526,6 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
- */
}
void tst_QFileSystemModel::filters_data()
@@ -796,7 +783,7 @@ void tst_QFileSystemModel::sort()
tree->setModel(myModel);
tree->show();
tree->resize(800, 800);
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(tree));
tree->header()->setSortIndicator(1,Qt::DescendingOrder);
tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
QStringList dirsToOpen;
@@ -807,16 +794,15 @@ void tst_QFileSystemModel::sort()
for (int i = dirsToOpen.size() -1 ; i > 0 ; --i) {
QString path = dirsToOpen[i];
- QTest::qWait(500);
tree->expand(myModel->index(path, 0));
}
tree->expand(myModel->index(dirPath, 0));
- QTest::qWait(500);
QModelIndex parent = myModel->index(dirPath, 0);
QList<QString> expectedOrder;
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) {
+ QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
// File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list
@@ -858,8 +844,8 @@ void tst_QFileSystemModel::mkdir()
QModelIndex idx = model->mkdir(tmpDir, "NewFoldermkdirtest4");
QVERIFY(idx.isValid());
int oldRow = idx.row();
- QTest::qWait(WAITTIME);
idx = model->index(newFolderPath);
+ QVERIFY(idx.isValid());
QVERIFY(model->remove(idx));
QVERIFY(!bestatic.exists());
QVERIFY(0 != idx.row());
@@ -981,7 +967,6 @@ void tst_QFileSystemModel::drives()
foreach(const QFileInfo& driveRoot, drives)
if (driveRoot.exists())
driveCount++;
- QTest::qWait(5000);
QTRY_COMPARE(model.rowCount(), driveCount);
}
@@ -989,7 +974,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
{
QDir dir(flatDirTestPath);
- for (int i = 0; i < 3; ++i) {
+ const int itemCount = 3;
+ for (int i = 0; i < itemCount; ++i) {
QLatin1Char c('a' + i);
dir.mkdir(c + QLatin1String("-dir"));
QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
@@ -998,7 +984,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
}
QModelIndex root = model->setRootPath(flatDirTestPath);
- QTest::qWait(1000); // allow model to be notified by the file system watcher
+ // Wait for model to be notified by the file system watcher
+ QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
// ensure that no file occurs before a directory
for (int i = 0; i < model->rowCount(root); ++i) {
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 00d640e55e..2ada4fedb6 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -197,8 +197,7 @@ void tst_QProgressDialog::task198202()
dlg.setLabel(0);
QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar");
dlg.setBar(0);
- QTest::qWait(20);
- QCOMPARE(dlg.sizeHint().height(), futureHeight);
+ QTRY_COMPARE(dlg.sizeHint().height(), futureHeight);
}
void tst_QProgressDialog::QTBUG_31046()