diff options
author | Liang Qi <liang.qi@qt.io> | 2018-05-24 16:27:08 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-05-24 16:29:14 +0200 |
commit | f82e5085169876e0ec7c1b744d021b068c281cfe (patch) | |
tree | a870e1f68ce62818a0793c4c78a67971e841e676 /tests/auto | |
parent | f74d4fb1dacc682e2e6f4a44e4240f642a2c3b70 (diff) | |
parent | ee47999333dde1d38b73d04e142e05f06f8c56ed (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
mkspecs/features/qt_common.prf
src/corelib/tools/qstring.cpp
src/plugins/platforms/windows/qwindowsmousehandler.cpp
src/widgets/widgets/qmainwindowlayout_p.h
Change-Id: I5df613008f6336f69b257d08e49a133d033a9d65
Diffstat (limited to 'tests/auto')
13 files changed, 87 insertions, 86 deletions
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 7d6a7973dc..63187c9668 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -2,6 +2,8 @@ CONFIG += testcase CONFIG -= debug_and_release_target QT = core-private testlib network SOURCES = ../tst_qprocess.cpp +INCLUDEPATH += ../../../../../shared +HEADERS += ../../../../../shared/emulationdetector.h TARGET = ../tst_qprocess diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 6b4d292fe3..e19653abf0 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -27,6 +27,7 @@ ** ****************************************************************************/ +#include <emulationdetector.h> #include <QtTest/QtTest> #include <QtCore/QProcess> @@ -1165,6 +1166,8 @@ void tst_QProcess::processInAThread() void tst_QProcess::processesInMultipleThreads() { + if (EmulationDetector::isRunningArmOnX86()) + QSKIP("Flakily hangs in QEMU. QTBUG-67760"); for (int i = 0; i < 10; ++i) { // run from 1 to 10 threads, but run at least some tests // with more threads than the ideal diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/40.json b/tests/auto/corelib/serialization/json/invalidBinaryData/40.bjson Binary files differindex 277096f8cb..277096f8cb 100644 --- a/tests/auto/corelib/serialization/json/invalidBinaryData/40.json +++ b/tests/auto/corelib/serialization/json/invalidBinaryData/40.bjson diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson b/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson Binary files differnew file mode 100644 index 0000000000..0b5940ab95 --- /dev/null +++ b/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 203d9d8683..ade9c5e754 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -93,6 +93,7 @@ private slots: void lambdaCustomDeleter(); #endif void creating(); + void creatingCvQualified(); void creatingVariadic(); void creatingQObject(); void mixTrackingPointerCode(); @@ -1771,6 +1772,13 @@ void tst_QSharedPointer::creating() safetyCheck(); } +void tst_QSharedPointer::creatingCvQualified() +{ + auto cptr = QSharedPointer<const Data>::create(); + auto vptr = QSharedPointer<volatile Data>::create(); + auto cvptr = QSharedPointer<const volatile Data>::create(); +} + void tst_QSharedPointer::creatingVariadic() { int i = 42; diff --git a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp index 8e063733e9..7a3def410a 100644 --- a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp +++ b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp @@ -469,6 +469,9 @@ void tst_QNetworkRequest::rawHeaderParsing_data() << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << true << "Set-Cookie" << "a=b; path=/\nc=d"; + QTest::newRow("Content-Disposition") << QNetworkRequest::ContentDispositionHeader + << QVariant("attachment; filename=\"test.txt\"") << true + << "Content-Disposition" << "attachment; filename=\"test.txt\""; } void tst_QNetworkRequest::rawHeaderParsing() diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 23c8460133..c64310a715 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -2070,8 +2070,6 @@ void tst_QSqlQuery::prepare_bind_exec() const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db)); - if (dbType == QSqlDriver::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) - QSKIP("Can't transliterate extended unicode to ascii"); if (dbType == QSqlDriver::DB2) QSKIP("Needs someone with more Unicode knowledge than I have to fix"); @@ -2347,6 +2345,16 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE(q.value(0).toInt(), 107); QCOMPARE(q.value(1).toString(), QString("name")); QCOMPARE(q.value(2).toString(), QString("107")); + + // Test just duplicated placeholders + QVERIFY(q.prepare("insert into " + qtest_prepare + " (id, name, name2) values (110, :name, :name)")); + q.bindValue(":name", "name"); + QVERIFY_SQL(q, exec()); + QVERIFY(q.exec("select * from " + qtest_prepare + " where id > 109 order by id")); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 110); + QCOMPARE(q.value(1).toString(), QString("name")); + QCOMPARE(q.value(2).toString(), QString("name")); } // end of SQLite scope } diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index e39110bb50..eee227fc2f 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 @@ -1330,7 +1327,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 @@ -1341,8 +1337,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 @@ -1350,7 +1345,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); @@ -1358,8 +1352,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 ade5866abb..8f9a8c11a7 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() diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index c0f33b9c79..2e5d24cd26 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -167,6 +167,12 @@ void tst_QCommandLinkButton::onReleased() void tst_QCommandLinkButton::setAutoRepeat() { + // Give the last tests time to finish - i.e., wait for the window close and + // deactivate to avoid a race condition here. We can't add this to the end + // of the defaultAndAutoDefault test, since any failure in that test will + // return out of that function. + QTest::qWait(1000); + // If this changes, this test must be completely revised. QVERIFY( !testWidget->isCheckable() ); @@ -421,8 +427,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault() QVERIFY(dialog.isVisible()); QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide())); - QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); - QApplication::sendEvent(&dialog, &event); + QTest::keyClick(&dialog, Qt::Key_Return); QVERIFY(!dialog.isVisible()); } @@ -462,8 +467,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault() QVERIFY(dialog.isVisible()); QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide())); - QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); - QApplication::sendEvent(&dialog, &event); + QTest::keyClick(&dialog, Qt::Key_Return); QVERIFY(!dialog.isVisible()); } @@ -478,8 +482,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault() // No default button is set, and button2 is the first autoDefault button // that is next in the tab order QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide())); - QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); - QApplication::sendEvent(&dialog, &event); + QTest::keyClick(&dialog, Qt::Key_Return); QVERIFY(!dialog.isVisible()); // Reparenting diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 36fd0eb54a..ee9446f00b 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -814,6 +814,7 @@ void tst_QDoubleSpinBox::setReadOnly() QDoubleSpinBox spin(0); spin.setValue(0.2); spin.show(); + QVERIFY(QTest::qWaitForWindowActive(&spin)); QCOMPARE(spin.value(), 0.2); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1.2); @@ -836,7 +837,7 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); - QApplication::setActiveWindow(testFocusWidget); + testFocusWidget->activateWindow(); QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); box->setFocus(); QTRY_VERIFY(box->hasFocus()); @@ -844,7 +845,6 @@ void tst_QDoubleSpinBox::editingFinished() QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); - box->setFocus(); QTest::keyClick(box, Qt::Key_Up); QTest::keyClick(box, Qt::Key_Up); |