Remove usage of deprecated qWaitForWindowShown in dialog tests.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Fri, 20 Jul 2012 14:18:29 +0000 (16:18 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 23 Jul 2012 22:08:28 +0000 (00:08 +0200)
Change-Id: Id3ebe202d65ee682e8e2e3ae107808e9abb6cc15
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp

index c23ccc8..99963ce 100644 (file)
@@ -524,23 +524,23 @@ void tst_QDialog::reject()
 {
     TestRejectDialog dialog;
     dialog.show();
-    QTest::qWaitForWindowShown(&dialog);
-    QTRY_VERIFY(dialog.isVisible());
+    QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+    QVERIFY(dialog.isVisible());
     dialog.reject();
     QTRY_VERIFY(!dialog.isVisible());
     QCOMPARE(dialog.called, 1);
 
     dialog.show();
-    QTest::qWaitForWindowShown(&dialog);
-    QTRY_VERIFY(dialog.isVisible());
+    QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+    QVERIFY(dialog.isVisible());
     QVERIFY(dialog.close());
     QTRY_VERIFY(!dialog.isVisible());
     QCOMPARE(dialog.called, 2);
 
     dialog.cancelReject = true;
     dialog.show();
-    QTest::qWaitForWindowShown(&dialog);
-    QTRY_VERIFY(dialog.isVisible());
+    QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+    QVERIFY(dialog.isVisible());
     dialog.reject();
     QTRY_VERIFY(dialog.isVisible());
     QCOMPARE(dialog.called, 3);
index 98ea8f4..b50e32c 100644 (file)
@@ -286,7 +286,7 @@ void tst_QFiledialog::filesSelectedSignal()
     QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &)));
 
     fd.show();
-    QTest::qWait(500);
+    QVERIFY(QTest::qWaitForWindowExposed(&fd));
     QListView *listView = qFindChild<QListView*>(&fd, "listView");
     QVERIFY(listView);
 
@@ -938,7 +938,7 @@ void tst_QFiledialog::selectFiles()
     QString temporary = QDir::tempPath() + QLatin1String("/blah");
     dialog->selectFile(temporary);
     dialog->show();
-    QTest::qWait(500);
+    QVERIFY(QTest::qWaitForWindowExposed(dialog));
     QLineEdit *lineEdit = qFindChild<QLineEdit*>(dialog, "fileNameEdit");
     QVERIFY(lineEdit);
     QCOMPARE(lineEdit->text(),QLatin1String("blah"));
@@ -1012,9 +1012,9 @@ void tst_QFiledialog::focus()
     fd.setDirectory(QDir::currentPath());
     fd.show();
     QApplication::setActiveWindow(&fd);
-    QTest::qWaitForWindowShown(&fd);
-    QTRY_COMPARE(fd.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+    QVERIFY(QTest::qWaitForWindowActive(&fd));
+    QCOMPARE(fd.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
     qApp->processEvents();
 
     // make sure the tests work with focus follows mouse
index 1bf9409..3506057 100644 (file)
@@ -1104,14 +1104,14 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
 
     fd.show();
     QApplication::setActiveWindow(&fd);
-    QTest::qWaitForWindowShown(&fd);
-    QTRY_COMPARE(fd.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+    QVERIFY(QTest::qWaitForWindowActive(&fd));
+    QCOMPARE(fd.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
 
-    QTest::qWait(250);
     QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+    QVERIFY(lineEdit);
 
-    QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
+    QTRY_COMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
     QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
 }
 
@@ -1147,9 +1147,9 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly()
     fd.show();
 
     QApplication::setActiveWindow(&fd);
-    QTest::qWaitForWindowShown(&fd);
-    QTRY_COMPARE(fd.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+    QVERIFY(QTest::qWaitForWindowActive(&fd));
+    QCOMPARE(fd.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
 
     QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
     QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2);
@@ -1195,9 +1195,9 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails()
     fd.show();
 
     QApplication::setActiveWindow(&fd);
-    QTest::qWaitForWindowShown(&fd);
-    QTRY_COMPARE(fd.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+    QVERIFY(QTest::qWaitForWindowActive(&fd));
+    QCOMPARE(fd.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
 
     QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
     //We compare the current combobox text with the stripped version
@@ -1211,9 +1211,9 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails()
     fd2.show();
 
     QApplication::setActiveWindow(&fd2);
-    QTest::qWaitForWindowShown(&fd2);
-    QTRY_COMPARE(fd2.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2));
+    QVERIFY(QTest::qWaitForWindowActive(&fd2));
+    QCOMPARE(fd2.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2));
 
     QComboBox *filters2 = qFindChild<QComboBox*>(&fd2, "fileTypeCombo");
     //We compare the current combobox text with the non stripped version
@@ -1228,9 +1228,9 @@ void tst_QFileDialog2::dontShowCompleterOnRoot()
     fd.show();
 
     QApplication::setActiveWindow(&fd);
-    QTest::qWaitForWindowShown(&fd);
-    QTRY_COMPARE(fd.isVisible(), true);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+    QVERIFY(QTest::qWaitForWindowActive(&fd));
+    QCOMPARE(fd.isVisible(), true);
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
 
     fd.setDirectory("");
     QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
index 8da5973..63e8373 100644 (file)
@@ -140,7 +140,7 @@ void tst_QProgressDialog::task198202()
     //should not crash
     QProgressDialog dlg(QLatin1String("test"),QLatin1String("test"),1,10);
     dlg.show();
-    QTest::qWait(20);
+    QVERIFY(QTest::qWaitForWindowExposed(&dlg));
     int futureHeight = dlg.sizeHint().height() - qFindChild<QLabel*>(&dlg)->sizeHint().height();
     dlg.setLabel(0);
     QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar");
index 362c269..a51717f 100644 (file)
@@ -2537,7 +2537,7 @@ void tst_QWizard::task161658_alignments()
     int idx = wizard.addPage(&page);
     wizard.setStartId(idx);
     wizard.show();
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&wizard));
 
     foreach (QLabel *subtitleLabel, qFindChildren<QLabel *>(&wizard)) {
         if (subtitleLabel->text().startsWith("SUBTITLE#")) {
@@ -2569,7 +2569,8 @@ void tst_QWizard::task177022_setFixedSize()
     QCOMPARE(wiz.maximumHeight(), height);
 
     wiz.show();
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&wiz));
+
     QCOMPARE(wiz.size(), QSize(width, height));
     QCOMPARE(wiz.minimumWidth(), width);
     QCOMPARE(wiz.minimumHeight(), height);
@@ -2601,7 +2602,8 @@ void tst_QWizard::task248107_backButton()
     wizard.addPage(&page4);
 
     wizard.show();
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&wizard));
+
     QCOMPARE(wizard.currentPage(), &page1);
 
     QTest::mouseClick(wizard.button(QWizard::NextButton), Qt::LeftButton);