diff options
Diffstat (limited to 'tests')
27 files changed, 388 insertions, 137 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 25bc8a5e45..3a607983f9 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -127,7 +127,7 @@ if (QT_WITH_ANGLE OR (NOT WIN32 AND NOT APPLE AND NOT NO_EGL)) endif() expect_pass(test_opengl_lib) -if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) +if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS) expect_pass(test_interface) endif() diff --git a/tests/auto/corelib/io/qfile/BLACKLIST b/tests/auto/corelib/io/qfile/BLACKLIST index 7aac313b12..e3bc093c83 100644 --- a/tests/auto/corelib/io/qfile/BLACKLIST +++ b/tests/auto/corelib/io/qfile/BLACKLIST @@ -3,3 +3,7 @@ msvc-2015 [readLineStdin_lineByLine] msvc-2015 +[openStandardStreamsFileDescriptors] +osx +[openStandardStreamsBufferedStreams] +osx diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 8a7ca8429f..3425c14cd4 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -464,6 +464,15 @@ void tst_qstandardpaths::testCustomRuntimeDirectory() #endif #ifdef Q_XDG_PLATFORM + struct EnvVarRestorer + { + EnvVarRestorer() : origRuntimeDir(qgetenv("XDG_RUNTIME_DIR")) {} + ~EnvVarRestorer() { qputenv("XDG_RUNTIME_DIR", origRuntimeDir.constData()); } + const QByteArray origRuntimeDir; + }; + EnvVarRestorer restorer; + + // When $XDG_RUNTIME_DIR points to a directory with wrong ownership, QStandardPaths should warn qputenv("XDG_RUNTIME_DIR", QFile::encodeName("/tmp")); // It's very unlikely that /tmp is 0600 or that we can chmod it // The call below outputs @@ -474,6 +483,20 @@ void tst_qstandardpaths::testCustomRuntimeDirectory() qPrintable(QString::fromLatin1("QStandardPaths: wrong ownership on runtime directory /tmp, 0 instead of %1").arg(uid))); const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); QVERIFY2(runtimeDir.isEmpty(), qPrintable(runtimeDir)); + + // When $XDG_RUNTIME_DIR points to a non-existing directory, QStandardPaths should warn (QTBUG-48771) + qputenv("XDG_RUNTIME_DIR", "does_not_exist"); + QTest::ignoreMessage(QtWarningMsg, "QStandardPaths: XDG_RUNTIME_DIR points to non-existing path 'does_not_exist', please create it with 0700 permissions."); + const QString nonExistingRuntimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); + QVERIFY2(nonExistingRuntimeDir.isEmpty(), qPrintable(nonExistingRuntimeDir)); + + // When $XDG_RUNTIME_DIR points to a file, QStandardPaths should warn + const QString file = QFINDTESTDATA("tst_qstandardpaths.cpp"); + QVERIFY(!file.isEmpty()); + qputenv("XDG_RUNTIME_DIR", QFile::encodeName(file)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(QString::fromLatin1("QStandardPaths: XDG_RUNTIME_DIR points to '%1' which is not a directory").arg(file))); + const QString noRuntimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); + QVERIFY2(noRuntimeDir.isEmpty(), qPrintable(file)); #endif } diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 58a3db9615..621e215d60 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -229,6 +229,13 @@ void tst_QTemporaryDir::autoRemove() void tst_QTemporaryDir::nonWritableCurrentDir() { #ifdef Q_OS_UNIX + +# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + const char nonWritableDir[] = "/data"; +# else + const char nonWritableDir[] = "/home"; +# endif + if (::geteuid() == 0) QSKIP("not valid running this test as root"); @@ -240,13 +247,13 @@ void tst_QTemporaryDir::nonWritableCurrentDir() } QString dir; }; - ChdirOnReturn cor(QDir::currentPath()); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) - QDir::setCurrent("/data"); -#else - QDir::setCurrent("/home"); -#endif + const QFileInfo nonWritableDirFi = QFileInfo(QLatin1String(nonWritableDir)); + QVERIFY(nonWritableDirFi.isDir()); + QVERIFY(!nonWritableDirFi.isWritable()); + + ChdirOnReturn cor(QDir::currentPath()); + QVERIFY(QDir::setCurrent(nonWritableDirFi.absoluteFilePath())); // QTemporaryDir("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryDir dir("tempXXXXXX"); diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 97dfac3062..07257297e0 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -79,6 +79,8 @@ private slots: void toLocalFile(); void fromLocalFile_data(); void fromLocalFile(); + void fromLocalFileNormalize_data(); + void fromLocalFileNormalize(); void macTypes(); void relative(); void compat_legacy(); @@ -1242,16 +1244,6 @@ void tst_QUrl::fromLocalFile_data() << QString::fromLatin1("/"); QTest::newRow("data7") << QString::fromLatin1("/Mambo <#5>.mp3") << QString::fromLatin1("file:///Mambo <%235>.mp3") << QString::fromLatin1("/Mambo <#5>.mp3"); - QTest::newRow("data8") << QString::fromLatin1("/a%.txt") << QString::fromLatin1("file:///a%25.txt") - << QString::fromLatin1("/a%.txt"); - QTest::newRow("data9") << QString::fromLatin1("/a%25.txt") << QString::fromLatin1("file:///a%2525.txt") - << QString::fromLatin1("/a%25.txt"); - QTest::newRow("data10") << QString::fromLatin1("/%80.txt") << QString::fromLatin1("file:///%2580.txt") - << QString::fromLatin1("/%80.txt"); - QTest::newRow("data11") << QString::fromLatin1("./a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); - QTest::newRow("data12") << QString::fromLatin1("././a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); - QTest::newRow("data13") << QString::fromLatin1("b/../a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); - QTest::newRow("data14") << QString::fromLatin1("/b/../a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); } void tst_QUrl::fromLocalFile() @@ -1266,6 +1258,41 @@ void tst_QUrl::fromLocalFile() QCOMPARE(url.path(), thePath); } +void tst_QUrl::fromLocalFileNormalize_data() +{ + QTest::addColumn<QString>("theFile"); // should support the fromLocalFile/toLocalFile roundtrip (so no //host or windows path) + QTest::addColumn<QString>("theUrl"); + QTest::addColumn<QString>("urlWithNormalizedPath"); + + QTest::newRow("data0") << QString::fromLatin1("/a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("file:///a.txt"); + QTest::newRow("data1") << QString::fromLatin1("a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("file:a.txt"); + QTest::newRow("data8") << QString::fromLatin1("/a%.txt") << QString::fromLatin1("file:///a%25.txt") + << QString::fromLatin1("file:///a%25.txt"); + QTest::newRow("data9") << QString::fromLatin1("/a%25.txt") << QString::fromLatin1("file:///a%2525.txt") + << QString::fromLatin1("file:///a%2525.txt"); + QTest::newRow("data10") << QString::fromLatin1("/%80.txt") << QString::fromLatin1("file:///%2580.txt") + << QString::fromLatin1("file:///%2580.txt"); + QTest::newRow("data11") << QString::fromLatin1("./a.txt") << QString::fromLatin1("file:./a.txt") << QString::fromLatin1("file:a.txt"); + QTest::newRow("data12") << QString::fromLatin1("././a.txt") << QString::fromLatin1("file:././a.txt") << QString::fromLatin1("file:a.txt"); + QTest::newRow("data13") << QString::fromLatin1("b/../a.txt") << QString::fromLatin1("file:b/../a.txt") << QString::fromLatin1("file:a.txt"); + QTest::newRow("data14") << QString::fromLatin1("/b/../a.txt") << QString::fromLatin1("file:///b/../a.txt") << QString::fromLatin1("file:///a.txt"); + QTest::newRow("data15") << QString::fromLatin1("/b/.") << QString::fromLatin1("file:///b/.") << QString::fromLatin1("file:///b"); +} + +void tst_QUrl::fromLocalFileNormalize() +{ + QFETCH(QString, theFile); + QFETCH(QString, theUrl); + QFETCH(QString, urlWithNormalizedPath); + + QUrl url = QUrl::fromLocalFile(theFile); + + QCOMPARE(url.toString(QUrl::DecodeReserved), theUrl); + QCOMPARE(url.toLocalFile(), theFile); // roundtrip + QCOMPARE(url.path(), theFile); // works as well as long as we don't test windows paths + QCOMPARE(url.toString(QUrl::NormalizePathSegments), urlWithNormalizedPath); +} + void tst_QUrl::macTypes() { #ifndef Q_OS_MAC @@ -2961,6 +2988,9 @@ void tst_QUrl::fromUserInputWithCwd_data() while (it.hasNext()) { it.next(); QUrl url = QUrl::fromLocalFile(it.filePath()); + if (it.fileName() == QLatin1String(".")) { + url = QUrl::fromLocalFile(QDir::currentPath()); // fromUserInput cleans the path + } QTest::newRow(("file-" + QByteArray::number(c++)).constData()) << it.fileName() << QDir::currentPath() << url << url; } @@ -3023,6 +3053,8 @@ void tst_QUrl::fileName_data() << QString() << "tmp.txt" << "tmp.txt"; QTest::newRow("encoded") << "print:/specials/Print%20To%20File%20(PDF%252FAcrobat)" << "/specials/" << "Print To File (PDF%252FAcrobat)" << "Print To File (PDF%2FAcrobat)"; + QTest::newRow("endsWithDot") << "file:///temp/." + << "/temp/" << "." << "."; } void tst_QUrl::fileName() @@ -3515,7 +3547,7 @@ void tst_QUrl::setComponents_data() << PrettyDecoded << "/path" << "trash:/path"; QTest::newRow("path-withdotdot") << QUrl("file:///tmp") << int(Path) << "//tmp/..///root/." << Tolerant << true - << PrettyDecoded << "/root" << "file:///root"; + << PrettyDecoded << "/tmp/..///root/." << "file:///tmp/..///root/."; // the other fields can be present and be empty // that is, their delimiters would be present, but there would be nothing to one side diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 165464e7b9..8b2cee5e2f 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1116,6 +1116,12 @@ void tst_QtJson::fromVariant() QCOMPARE(QJsonValue::fromVariant(QVariant(stringList)), QJsonValue(jsonArray_string)); QCOMPARE(QJsonValue::fromVariant(QVariant(variantList)), QJsonValue(jsonArray_variant)); QCOMPARE(QJsonValue::fromVariant(QVariant(variantMap)), QJsonValue(jsonObject)); + + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonValue(true))).isBool()); + QVERIFY(QJsonValue::fromVariant(QVariant(jsonArray_string)).isArray()); + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonDocument(jsonArray_string))).isArray()); + QVERIFY(QJsonValue::fromVariant(QVariant(jsonObject)).isObject()); + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonDocument(jsonObject))).isObject()); } void tst_QtJson::fromVariantMap() diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 0171c4ac5a..1b4dc020f2 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -35,6 +35,11 @@ #include "qstandardpaths.h" +#ifdef Q_OS_UNIX +#include <sys/types.h> +#include <sys/stat.h> +#endif + #include <QtCore/QElapsedTimer> #include <QtCore/QFile> #include <QtCore/QFileInfo> @@ -646,6 +651,28 @@ void tst_QMimeDatabase::knownSuffix() QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.tar.bz2")), QString::fromLatin1("tar.bz2")); } +void tst_QMimeDatabase::symlinkToFifo() // QTBUG-48529 +{ +#ifdef Q_OS_UNIX + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + const QString dir = tempDir.path(); + const QString fifo = dir + "/fifo"; + QCOMPARE(mkfifo(QFile::encodeName(fifo), 0006), 0); + + QMimeDatabase db; + QCOMPARE(db.mimeTypeForFile(fifo).name(), QString::fromLatin1("inode/fifo")); + + // Now make a symlink to the fifo + const QString link = dir + "/link"; + QVERIFY(QFile::link(fifo, link)); + QCOMPARE(db.mimeTypeForFile(link).name(), QString::fromLatin1("inode/fifo")); + +#else + QSKIP("This test requires pipes and symlinks"); +#endif +} + void tst_QMimeDatabase::findByFileName_data() { QTest::addColumn<QString>("filePath"); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h index 2827bd2dc4..4b703f15d7 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h @@ -70,6 +70,7 @@ private slots: void suffixes_data(); void suffixes(); void knownSuffix(); + void symlinkToFifo(); void fromThreads(); // shared-mime-info test suite diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index 507f7e3992..b588e1fe82 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -93,29 +93,20 @@ void tst_QTimeLine::range() QCOMPARE(timeLine.endFrame(), 16); // Verify that you can change the range in the timeLine - timeLine.setFrameRange(10, 20); + timeLine.setFrameRange(1000, 2000); QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); - timeLine.start(); -#ifdef Q_OS_WINCE - QTest::qWait(1000); -#else - QTest::qWait(100); -#endif - QCOMPARE(timeLine.state(), QTimeLine::Running); + timeLine.start(); // make sure that the logic works for a running timeline + QTRY_COMPARE(timeLine.state(), QTimeLine::Running); + timeLine.setCurrentTime(timeLine.duration()/2); int oldValue = timeLine.currentFrame(); - timeLine.setFrameRange(0, 5); + timeLine.setFrameRange(0, 500); QVERIFY(timeLine.currentFrame() < oldValue); - timeLine.setEndFrame(100); - timeLine.setStartFrame(50); + timeLine.setEndFrame(10000); + timeLine.setStartFrame(5000); QVERIFY(timeLine.currentFrame() > oldValue); - timeLine.setFrameRange(0, 5); -#ifdef Q_OS_WINCE - QTest::qWait(500); -#else - QTest::qWait(50); -#endif - QVERIFY(spy.count() > 1); + timeLine.setFrameRange(0, 500); + QTRY_VERIFY(spy.count() > 1); QVERIFY(timeLine.currentFrame() < oldValue); } @@ -123,19 +114,17 @@ void tst_QTimeLine::currentTime() { QTimeLine timeLine(2000); timeLine.setUpdateInterval((timeLine.duration()/2) / 33); - QSignalSpy spy(&timeLine, &QTimeLine::valueChanged); - QVERIFY(spy.isValid()); timeLine.setFrameRange(10, 20); QCOMPARE(timeLine.currentTime(), 0); timeLine.start(); - QTest::qWait(timeLine.duration()/2); - QCOMPARE(timeLine.state(), QTimeLine::Running); - QVERIFY(timeLine.currentTime() > timeLine.duration()/2 - timeLine.duration()/10); - QVERIFY(timeLine.currentTime() < timeLine.duration()/2 + timeLine.duration()/10); - QTest::qWait(timeLine.duration()/4 + timeLine.duration()); - QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + QTRY_COMPARE(timeLine.state(), QTimeLine::Running); + QTRY_VERIFY(timeLine.currentTime() > timeLine.duration()/2 - timeLine.duration()/4); + QVERIFY(timeLine.currentTime() < timeLine.duration()/2 + timeLine.duration()/4); + QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); QCOMPARE(timeLine.currentTime(), timeLine.duration()); + QSignalSpy spy(&timeLine, &QTimeLine::valueChanged); + QVERIFY(spy.isValid()); spy.clear(); timeLine.setCurrentTime(timeLine.duration()/2); timeLine.setCurrentTime(timeLine.duration()/2); @@ -144,24 +133,22 @@ void tst_QTimeLine::currentTime() QCOMPARE(timeLine.currentTime(), timeLine.duration()/2); timeLine.resume(); // Let it update on its own - QTest::qWait(timeLine.duration()/4); QCOMPARE(timeLine.state(), QTimeLine::Running); - QVERIFY(timeLine.currentTime() > timeLine.duration()/2); + QTRY_VERIFY(timeLine.currentTime() > timeLine.duration()/2); QVERIFY(timeLine.currentTime() < timeLine.duration()); - QTest::qWait(timeLine.duration()/4 + timeLine.duration()); - QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY(timeLine.currentTime() == timeLine.duration()); + QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); + QCOMPARE(timeLine.currentTime(), timeLine.duration()); // Reverse should decrease the currentTime timeLine.setCurrentTime(timeLine.duration()/2); timeLine.start(); // Let it update on its own - QTest::qWait(timeLine.duration()/4); - QCOMPARE(timeLine.state(), QTimeLine::Running); int currentTime = timeLine.currentTime(); + QTRY_VERIFY(timeLine.currentTime() > currentTime); + QCOMPARE(timeLine.state(), QTimeLine::Running); + currentTime = timeLine.currentTime(); timeLine.setDirection(QTimeLine::Backward); - QTest::qWait(timeLine.duration()/4); - QVERIFY(timeLine.currentTime() < currentTime); + QTRY_VERIFY(timeLine.currentTime() < currentTime); timeLine.stop(); } @@ -174,11 +161,9 @@ void tst_QTimeLine::duration() QCOMPARE(timeLine.duration(), 1000); timeLine.start(); - QTest::qWait(999); - QCOMPARE(timeLine.state(), QTimeLine::Running); - QVERIFY(timeLine.currentTime() > 900); - QTest::qWait(100); - QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + QTRY_COMPARE(timeLine.state(), QTimeLine::Running); + QTRY_VERIFY(timeLine.currentTime() > 0); + QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); QCOMPARE(timeLine.currentTime(), 1000); // The duration shouldn't change QCOMPARE(timeLine.duration(), 1000); @@ -187,7 +172,7 @@ void tst_QTimeLine::duration() void tst_QTimeLine::frameRate() { QTimeLine timeLine; - timeLine.setFrameRange(10, 20); + timeLine.setFrameRange(100, 2000); QCOMPARE(timeLine.updateInterval(), 1000 / 25); timeLine.setUpdateInterval(1000 / 60); QCOMPARE(timeLine.updateInterval(), 1000 / 60); @@ -213,31 +198,27 @@ void tst_QTimeLine::frameRate() void tst_QTimeLine::value() { - QTimeLine timeLine(2000); - QVERIFY(timeLine.currentValue() == 0.0); + QTimeLine timeLine(5000); + QCOMPARE(timeLine.currentValue(), 0.0); // Default speed QSignalSpy spy(&timeLine, &QTimeLine::valueChanged); QVERIFY(spy.isValid()); timeLine.start(); - QTest::qWait(timeLine.duration()/3); - QVERIFY(timeLine.currentValue() > 0); - QTest::qWait(timeLine.duration()); - QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - qreal currentValue = timeLine.currentValue(); - QVERIFY(currentValue == 1); + QTRY_VERIFY(timeLine.currentValue() > 0); + QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); + QCOMPARE(timeLine.currentValue(), 1.0); QVERIFY(spy.count() > 0); // Reverse should decrease the value timeLine.setCurrentTime(100); timeLine.start(); // Let it update on its own - QTest::qWait(500); QCOMPARE(timeLine.state(), QTimeLine::Running); + QTRY_VERIFY(timeLine.currentValue()); qreal value = timeLine.currentValue(); timeLine.setDirection(QTimeLine::Backward); - QTest::qWait(1000); - QVERIFY(timeLine.currentValue() < value); + QTRY_VERIFY(timeLine.currentValue() < value); timeLine.stop(); } @@ -251,22 +232,19 @@ void tst_QTimeLine::currentFrame() QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); timeLine.start(); - QTest::qWait(timeLine.duration()/3); - QVERIFY(timeLine.currentFrame() > 10); - QTest::qWait(timeLine.duration()); - QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + QTRY_VERIFY(timeLine.currentFrame() > 10); + QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); QCOMPARE(timeLine.currentFrame(), 20); // Reverse should decrease the value timeLine.setCurrentTime(timeLine.duration()/2); timeLine.start(); // Let it update on its own - QTest::qWait(timeLine.duration()/4); QCOMPARE(timeLine.state(), QTimeLine::Running); + QTRY_VERIFY(timeLine.currentTime() > timeLine.duration()/2); // wait for continuation int value = timeLine.currentFrame(); timeLine.setDirection(QTimeLine::Backward); - QTest::qWait(timeLine.duration()/2); - QVERIFY(timeLine.currentFrame() < value); + QTRY_VERIFY(timeLine.currentFrame() < value); timeLine.stop(); } @@ -505,9 +483,8 @@ void tst_QTimeLine::finished() QSignalSpy spy(&timeLine, &QTimeLine::finished); QVERIFY(spy.isValid()); timeLine.start(); - QTest::qWait(timeLine.duration()*2); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QCOMPARE(spy.count(), 1); spy.clear(); timeLine.start(); @@ -606,16 +583,15 @@ void tst_QTimeLine::resume() { QCOMPARE(timeLine.currentTime(), 0); timeLine.start(); - QTest::qWait(250); + QTRY_VERIFY(timeLine.currentTime() > 0); timeLine.stop(); int oldCurrentTime = timeLine.currentTime(); QVERIFY(oldCurrentTime > 0); QVERIFY(oldCurrentTime < 1000); timeLine.resume(); - QTest::qWait(250); + QTRY_VERIFY(timeLine.currentTime() > oldCurrentTime); timeLine.stop(); int currentTime = timeLine.currentTime(); - QVERIFY(currentTime > oldCurrentTime); QVERIFY(currentTime < 1000); } timeLine.setDirection(QTimeLine::Backward); @@ -623,13 +599,13 @@ void tst_QTimeLine::resume() timeLine.setCurrentTime(1000); QCOMPARE(timeLine.currentTime(), 1000); timeLine.start(); - QTest::qWait(250); + QTRY_VERIFY(timeLine.currentTime() < 1000); timeLine.stop(); int oldCurrentTime = timeLine.currentTime(); QVERIFY(oldCurrentTime < 1000); QVERIFY(oldCurrentTime > 0); timeLine.resume(); - QTest::qWait(250); + QTRY_VERIFY(timeLine.currentTime() < oldCurrentTime); timeLine.stop(); int currentTime = timeLine.currentTime(); QVERIFY(currentTime < oldCurrentTime); @@ -643,8 +619,7 @@ void tst_QTimeLine::restart() timeLine.setFrameRange(0,9); timeLine.start(); - QTest::qWait(timeLine.duration()*2); - QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QTRY_COMPARE(timeLine.currentFrame(), timeLine.endFrame()); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); // A restart with the same duration @@ -652,8 +627,7 @@ void tst_QTimeLine::restart() QCOMPARE(timeLine.state(), QTimeLine::Running); QCOMPARE(timeLine.currentFrame(), timeLine.startFrame()); QCOMPARE(timeLine.currentTime(), 0); - QTest::qWait(250); - QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QTRY_COMPARE(timeLine.currentFrame(), timeLine.endFrame()); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); // Set a smaller duration and restart @@ -662,8 +636,7 @@ void tst_QTimeLine::restart() QCOMPARE(timeLine.state(), QTimeLine::Running); QCOMPARE(timeLine.currentFrame(), timeLine.startFrame()); QCOMPARE(timeLine.currentTime(), 0); - QTest::qWait(250); - QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QTRY_COMPARE(timeLine.currentFrame(), timeLine.endFrame()); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); // Set a longer duration and restart diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index bd1fef5193..67cbc4bfef 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -1,10 +1,16 @@ TEMPLATE=subdirs + +# Run this test first SUBDIRS=\ + qdbusconnection_delayed + +SUBDIRS+=\ qdbusabstractadaptor \ qdbusabstractinterface \ qdbusconnection \ qdbusconnection_no_app \ qdbusconnection_no_bus \ + qdbusconnection_no_libdbus \ qdbuscontext \ qdbusinterface \ qdbuslocalcalls \ diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 7cd8c875ec..aa17d71d60 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -71,6 +71,7 @@ void tst_QDBusConnection::noConnection() QVERIFY(con.callWithCallback(msg, &spy, SLOT(asyncReply)) == 0); QDBusMessage reply = con.call(msg); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); QDBusReply<void> voidreply(reply); @@ -152,6 +153,7 @@ void tst_QDBusConnection::send() QDBusMessage reply = con.call(msg); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.arguments().count(), 1); QCOMPARE(reply.arguments().at(0).typeName(), "QStringList"); QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); @@ -171,6 +173,7 @@ void tst_QDBusConnection::sendWithGui() QDBusMessage reply = con.call(msg, QDBus::BlockWithGui); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.arguments().count(), 1); QCOMPARE(reply.arguments().at(0).typeName(), "QStringList"); QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); @@ -840,6 +843,7 @@ void tst_QDBusConnection::callSelf() QString(), "test3"); msg << 44; reply = connection.call(msg); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.arguments().value(0).toInt(), 45); } @@ -907,6 +911,7 @@ void tst_QDBusConnection::callSelfByAnotherName() QString(), "test0"); QDBusMessage reply = con.call(msg, QDBus::Block, 1000); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); } @@ -922,6 +927,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject() QDBusMessage msg = QDBusMessage::createMethodCall(con.baseService(), "/p1", "local.BaseObject", "anotherMethod"); QDBusMessage reply = con.call(msg, QDBus::Block); + QCOMPARE(msg.serial(), reply.replySerial()); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); QCOMPARE(reply.arguments().count(), 0); } @@ -1202,6 +1208,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), path, QString(), "hello"); QDBusMessage reply = con.call(message, QDBus::Block, 5000); + QCOMPARE(message.serial(), reply.replySerial()); QCOMPARE(obj.callCount, 1); QCOMPARE(obj.lastMessage.service(), con.baseService()); QCOMPARE(obj.lastMessage.interface(), QString()); diff --git a/tests/auto/dbus/qdbusconnection_delayed/qdbusconnection_delayed.pro b/tests/auto/dbus/qdbusconnection_delayed/qdbusconnection_delayed.pro new file mode 100644 index 0000000000..71a75c644d --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_delayed/qdbusconnection_delayed.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +TARGET = tst_qdbusconnection_delayed +QT = core dbus testlib +SOURCES += tst_qdbusconnection_delayed.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/dbus/qdbusconnection_delayed/tst_qdbusconnection_delayed.cpp b/tests/auto/dbus/qdbusconnection_delayed/tst_qdbusconnection_delayed.cpp new file mode 100644 index 0000000000..c4f3063169 --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_delayed/tst_qdbusconnection_delayed.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Intel Corporation. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtDBus> +#include <QtTest> + +#ifdef Q_OS_WIN +# include <process.h> +# define getpid _getpid +#else +# include <sys/types.h> +# include <unistd.h> +#endif + +class tst_QDBusConnection_Delayed : public QObject +{ + Q_OBJECT +private slots: + void delayedMessages(); +}; + +class Foo : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.qtproject.tst_qdbusconnection_delayed.Foo") +public slots: + int bar() { return 42; } +}; + +static bool executedOnce = false; + +void tst_QDBusConnection_Delayed::delayedMessages() +{ + if (executedOnce) + QSKIP("This test can only be executed once"); + executedOnce = true; + + int argc = 1; + char *argv[] = { const_cast<char *>("tst_qdbusconnection_delayed"), 0 }; + QCoreApplication app(argc, argv); + + QDBusConnection session = QDBusConnection::sessionBus(); + QVERIFY(session.isConnected()); + QVERIFY(!session.baseService().isEmpty()); + + QDBusConnection other = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "other"); + QVERIFY(other.isConnected()); + QVERIFY(!other.baseService().isEmpty()); + + // make a method call: those should work even if delivery is disabled + QVERIFY(session.interface()->isServiceRegistered(other.baseService())); + + // acquire a name in the main session bus connection: the effect is immediate + QString name = "org.qtproject.tst_qdbusconnection_delayed-" + + QString::number(getpid()); + QVERIFY(session.registerService(name)); + QVERIFY(other.interface()->isServiceRegistered(name)); + + // make an asynchronous call to a yet-unregistered object + QDBusPendingCallWatcher pending(other.asyncCall(QDBusMessage::createMethodCall(name, "/foo", QString(), "bar"))); + + // sleep the main thread without running the event loop; + // the call must not be delivered + QTest::qSleep(1000); + QVERIFY(!pending.isFinished()); + + // now register the object + Foo foo; + session.registerObject("/foo", &foo, QDBusConnection::ExportAllSlots); + + connect(&pending, &QDBusPendingCallWatcher::finished, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(pending.isFinished()); + QVERIFY2(!pending.isError(), pending.error().name().toLatin1()); + QVERIFY(!pending.reply().arguments().isEmpty()); + QCOMPARE(pending.reply().arguments().at(0), QVariant(42)); +} + +QTEST_APPLESS_MAIN(tst_QDBusConnection_Delayed) + +#include "tst_qdbusconnection_delayed.moc" diff --git a/tests/auto/dbus/qdbusconnection_no_bus/qdbusconnection_no_bus.pro b/tests/auto/dbus/qdbusconnection_no_bus/qdbusconnection_no_bus.pro index 97d3c0ebf4..1998cc6df7 100644 --- a/tests/auto/dbus/qdbusconnection_no_bus/qdbusconnection_no_bus.pro +++ b/tests/auto/dbus/qdbusconnection_no_bus/qdbusconnection_no_bus.pro @@ -1,4 +1,4 @@ -CONFIG += testcase +CONFIG += testcase parallel_test TARGET = tst_qdbusconnection_no_bus QT = core dbus testlib SOURCES += tst_qdbusconnection_no_bus.cpp diff --git a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp index 21f8f11f80..5a74096059 100644 --- a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp +++ b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp @@ -52,7 +52,9 @@ public: tst_QDBusConnectionNoBus() { qputenv("DBUS_SESSION_BUS_ADDRESS", "unix:abstract=/tmp/does_not_exist"); +#ifdef SIMULATE_LOAD_FAIL qputenv("QT_SIMULATE_DBUS_LIBFAIL", "1"); +#endif } private slots: @@ -67,7 +69,7 @@ void tst_QDBusConnectionNoBus::connectToBus() QDBusConnection con = QDBusConnection::sessionBus(); - QVERIFY(true); // if we didn't crash here, the test passed :) + QVERIFY(!con.isConnected()); // if we didn't crash here, the test passed :) } QTEST_APPLESS_MAIN(tst_QDBusConnectionNoBus) diff --git a/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro b/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro new file mode 100644 index 0000000000..cb0eab1a18 --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +TARGET = tst_qdbusconnection_no_libdbus +QT = core dbus testlib +DEFINES += SIMULATE_LOAD_FAIL +SOURCES += ../qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp diff --git a/tests/auto/dbus/qdbusmetaobject/qdbusmetaobject.pro b/tests/auto/dbus/qdbusmetaobject/qdbusmetaobject.pro index 12f801613d..1302263e2d 100644 --- a/tests/auto/dbus/qdbusmetaobject/qdbusmetaobject.pro +++ b/tests/auto/dbus/qdbusmetaobject/qdbusmetaobject.pro @@ -1,4 +1,4 @@ -CONFIG += testcase +CONFIG += testcase parallel_test TARGET = tst_qdbusmetaobject QT = core dbus-private testlib SOURCES += tst_qdbusmetaobject.cpp diff --git a/tests/auto/dbus/qdbusmetatype/qdbusmetatype.pro b/tests/auto/dbus/qdbusmetatype/qdbusmetatype.pro index 38d7370667..ee6f7c305d 100644 --- a/tests/auto/dbus/qdbusmetatype/qdbusmetatype.pro +++ b/tests/auto/dbus/qdbusmetatype/qdbusmetatype.pro @@ -1,4 +1,4 @@ -CONFIG += testcase +CONFIG += testcase parallel_test TARGET = tst_qdbusmetatype QT = core dbus testlib SOURCES += tst_qdbusmetatype.cpp diff --git a/tests/auto/dbus/qdbustype/qdbustype.pro b/tests/auto/dbus/qdbustype/qdbustype.pro index 1b3e0f8008..17ae349675 100644 --- a/tests/auto/dbus/qdbustype/qdbustype.pro +++ b/tests/auto/dbus/qdbustype/qdbustype.pro @@ -1,4 +1,4 @@ -CONFIG += testcase +CONFIG += testcase parallel_test TARGET = tst_qdbustype QT = core-private dbus-private testlib SOURCES += tst_qdbustype.cpp diff --git a/tests/auto/dbus/qdbusxmlparser/qdbusxmlparser.pro b/tests/auto/dbus/qdbusxmlparser/qdbusxmlparser.pro index 3e47b00814..d695cc998f 100644 --- a/tests/auto/dbus/qdbusxmlparser/qdbusxmlparser.pro +++ b/tests/auto/dbus/qdbusxmlparser/qdbusxmlparser.pro @@ -1,4 +1,4 @@ -CONFIG += testcase +CONFIG += testcase parallel_test TARGET = tst_qdbusxmlparser QT = core-private dbus-private xml testlib SOURCES += tst_qdbusxmlparser.cpp diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index c9b795d098..12858c97ee 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -14,3 +14,5 @@ wince { # needed for getaddrinfo with official MinGW mingw:DEFINES += _WIN32_WINNT=0x0501 + +winrt: WINRT_MANIFEST.capabilities += internetClientServer diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index fa65c29b00..1918c8d151 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -49,6 +49,24 @@ #include <qdebug.h> +static bool waitForWindowExposed(QWindow *window) +{ + if (!window) + return false; +#ifdef Q_OS_OSX + QTest::qWait(100); + return window->isExposed(); +#endif + return QTest::qWaitForWindowExposed(window); +} + +static bool waitForWindowExposed(QWidget *widget) +{ + if (!widget) + return false; + return waitForWindowExposed(widget->windowHandle()); +} + static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) { return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); @@ -364,7 +382,7 @@ void tst_Gestures::customGesture() GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QVERIFY(waitForWindowExposed(&widget)); CustomEvent event; event.hotSpot = widget.mapToGlobal(QPoint(5,5)); @@ -833,7 +851,7 @@ void tst_Gestures::graphicsItemGesture() item->setPos(100, 100); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -895,7 +913,7 @@ void tst_Gestures::graphicsView() item->setPos(100, 100); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -971,7 +989,7 @@ void tst_Gestures::graphicsItemTreeGesture() item1_child2->setParentItem(item1); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1028,7 +1046,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() item2_child1->setPos(10, 10); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); @@ -1087,7 +1105,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() item2_child1->setPos(0, 0); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1385,7 +1403,7 @@ void tst_Gestures::testMapToScene() item0->setPos(14, 16); view.show(); // need to show to give it a global coordinate - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); QPoint origin = view.mapToGlobal(QPoint()); @@ -1511,7 +1529,7 @@ void tst_Gestures::autoCancelGestures() parent.grabGesture(CustomGesture::GestureType); child->grabGesture(secondGesture); parent.show(); - QVERIFY(QTest::qWaitForWindowExposed(&parent)); + QVERIFY(waitForWindowExposed(&parent)); /* An event is sent to both the child and the parent, when the child gets it a gesture is triggered @@ -1570,7 +1588,7 @@ void tst_Gestures::autoCancelGestures2() child->grabGesture(secondGesture); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1616,7 +1634,7 @@ void tst_Gestures::graphicsViewParentPropagation() item1_c1_c1->setPos(0, 0); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); @@ -1686,7 +1704,7 @@ void tst_Gestures::panelPropagation() item1_child1_child1->setZValue(10); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1797,7 +1815,7 @@ void tst_Gestures::panelStacksBehindParent() panel->setZValue(5); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1881,7 +1899,7 @@ void tst_Gestures::deleteGestureTargetItem() items.insert(item2->objectName(), item2); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); if (propagateUpdateGesture) @@ -1926,7 +1944,7 @@ void tst_Gestures::viewportCoordinates() scene.addItem(item1); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1963,7 +1981,7 @@ void tst_Gestures::partialGesturePropagation() scene.addItem(item4); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->ignoredUpdatedGestures << CustomGesture::GestureType; @@ -2051,7 +2069,7 @@ void tst_Gestures::testQGestureRecognizerCleanup() //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); w->show(); - QVERIFY(QTest::qWaitForWindowExposed(w)); + QVERIFY(waitForWindowExposed(w)); delete w; } @@ -2172,7 +2190,7 @@ void tst_Gestures::testReuseCanceledGestures() gv->viewport()->grabGesture(tapGestureTypeId); mw.show(); - QVERIFY(QTest::qWaitForWindowExposed(&mw)); + QVERIFY(waitForWindowExposed(&mw)); QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center()))); targetPos = gv->viewport()->mapFromParent(targetPos); @@ -2238,7 +2256,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView() scene.addItem(item2); view.show(); - QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(waitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -2303,7 +2321,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() NoConsumeWidgetBug13501 w; w.grabGesture(Qt::TapGesture); w.show(); - QVERIFY(QTest::qWaitForWindowExposed(&w)); + QVERIFY(waitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); QTouchDevice *device = new QTouchDevice; device->setType(QTouchDevice::TouchScreen); diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index fdbb6e13d4..7942a84615 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -121,7 +121,7 @@ void tst_toolsupport::offsets_data() } #ifdef Q_OS_LINUX - if (sizeof(void *) == 8) { + { QTestData &data = QTest::newRow("QFilePrivate::fileName") << pmm_to_offsetof(&QFilePrivate::fileName); data << 168 << 248; diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index bed4c792a1..beafef5ad2 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2205,9 +2205,10 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "" << true; + // FIXME: This also tests that 'exe' is accepted, but does not test whether it actually works. QTest::newRow("write_file(): append") << "VAR = 'one more line'\n" - "write_file(" + wpath + ", VAR, append): OK = 1\n" + "write_file(" + wpath + ", VAR, append exe): OK = 1\n" "OUT = $$cat(" + wpath + ", lines)" << "OK = 1\nOUT = 'other content' 'one more line'" << "" @@ -2227,7 +2228,13 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) QTest::newRow("write_file(): bad number of arguments") << "write_file(1, 2, 3, 4): OK = 1" << "OK = UNDEF" - << "##:1: write_file(name, [content var, [append]]) requires one to three arguments." + << "##:1: write_file(name, [content var, [append] [exe]]) requires one to three arguments." + << true; + + QTest::newRow("write_file(): invalid flag") + << "write_file(file, VAR, fail): OK = 1" + << "OK = UNDEF" + << "##:1: write_file(): invalid flag fail." << true; // FIXME: This doesn't test whether it actually works. diff --git a/tests/auto/tools/qmakelib/tst_qmakelib.h b/tests/auto/tools/qmakelib/tst_qmakelib.h index c4716ca65e..b043d31e21 100644 --- a/tests/auto/tools/qmakelib/tst_qmakelib.h +++ b/tests/auto/tools/qmakelib/tst_qmakelib.h @@ -90,8 +90,8 @@ public: virtual void message(int type, const QString &msg, const QString &fileName, int lineNo) { print(fileName, lineNo, type, msg); } - virtual void fileMessage(const QString &msg) - { doPrint(msg); } + virtual void fileMessage(int type, const QString &msg) + { Q_UNUSED(type) doPrint(msg); } virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {} virtual void doneWithEval(ProFile *) {} diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index 781adeedad..9f03e9b3a0 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -36,7 +36,22 @@ #include <QAction> // Temporarily disabling IRIX due to build issuues with GCC -#if !defined(__sgi) || defined(__sgi) && !defined(__GNUC__) +#if defined(__sgi) && defined(__GNUC__) + +class tst_QUndoGroup : public QObject +{ + Q_OBJECT +public: + tst_QUndoGroup() {} + +private slots: + void setActive() { QSKIP( "Not tested on irix-g++"); } + void addRemoveStack() { QSKIP( "Not tested on irix-g++"); } + void deleteStack() { QSKIP( "Not tested on irix-g++"); } + void checkSignals() { QSKIP( "Not tested on irix-g++"); } + void addStackAndDie() { QSKIP( "Not tested on irix-g++"); } +}; +#else /****************************************************************************** ** Commands @@ -645,22 +660,7 @@ void tst_QUndoGroup::commandTextFormat() qApp->removeTranslator(&translator); #endif } - -#else -class tst_QUndoGroup : public QObject -{ - Q_OBJECT -public: - tst_QUndoGroup() {} - -private slots: - void setActive() { QSKIP( "Not tested on irix-g++"); } - void addRemoveStack() { QSKIP( "Not tested on irix-g++"); } - void deleteStack() { QSKIP( "Not tested on irix-g++"); } - void checkSignals() { QSKIP( "Not tested on irix-g++"); } - void addStackAndDie() { QSKIP( "Not tested on irix-g++"); } -}; -#endif +#endif // !(SGI && GCC) QTEST_MAIN(tst_QUndoGroup) diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index a77bae22e9..c0faefb918 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -38,6 +38,9 @@ # include <QtGui/QScreen> # include <QtGui/QWindow> # include <qpa/qplatformwindow.h> +# if QT_VERSION >= 0x050600 +# include <private/qhighdpiscaling_p.h> +# endif #endif #include <QtCore/QMetaObject> #include <QtCore/QRect> @@ -131,9 +134,19 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option str << "[top] "; if (w->isExposed()) str << "[exposed] "; + if (w->surfaceClass() == QWindow::Offscreen) + str << "[offscreen] "; + str << "surface=" << w->surfaceType() << ' '; if (const Qt::WindowState state = w->windowState()) str << "windowState=" << state << ' '; formatRect(str, w->geometry()); + if (w->isTopLevel()) { + str << " \"" << w->screen()->name() << "\" "; +#if QT_VERSION >= 0x050600 + if (QHighDpiScaling::isActive()) + str << "factor=" << QHighDpiScaling::factor(w) << ' '; +#endif + } if (!(options & DontPrintWindowFlags)) { str << ' '; formatWindowFlags(str, w->flags()); |