diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-12-09 17:10:21 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-12-09 17:11:20 +0100 |
commit | 4714f86c54eb358ec431fb94d6b135b4cad2a7c7 (patch) | |
tree | ead864148546b91c076f0852136680b816c7831a /tests | |
parent | d5d073f87434fbe0f80269e9948b644f5ced1faf (diff) | |
parent | b986131c6d1243725134285dfc94581f80c00746 (diff) |
Merge remote-tracking branch 'gerrit/master' into containers
Change-Id: I01f94564c17d68872839be5396c24b661e53d571
Diffstat (limited to 'tests')
62 files changed, 919 insertions, 533 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 8e87e761db..1fc1ba381c 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -21,7 +21,6 @@ cross_compile: SUBDIRS -= tools # disable 'make check' on Mac OS X for the following subdirs for the time being mac { - gui.CONFIG += no_check_target network.CONFIG += no_check_target widgets.CONFIG += no_check_target } diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 90cd1aedb9..300f30e133 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -199,7 +199,8 @@ private slots: void mapOpenMode_data(); void mapOpenMode(); - void openStandardStreams(); + void openStandardStreamsFileDescriptors(); + void openStandardStreamsBufferedStreams(); void resize_data(); void resize(); @@ -228,9 +229,6 @@ private: NumberOfFileTypes }; - void openStandardStreamsFileDescriptors(); - void openStandardStreamsBufferedStreams(); - bool openFd(QFile &file, QIODevice::OpenMode mode, QFile::FileHandleFlags handleFlags) { int fdMode = QT_OPEN_LARGEFILE | QT_OPEN_BINARY; @@ -2971,29 +2969,35 @@ void tst_QFile::openStandardStreamsFileDescriptors() //it does not have functions to simply open them like below . QSKIP("Opening standard streams on Windows CE via descriptor not implemented"); #endif - // Using file descriptors + /* in/out/err.isSequential() are only true when run in a console (CI); + * it is false when they are redirected from/to files. + * Prevent failures in case someone runs tests with stdout/stderr redirected. */ + { QFile in; in.open(STDIN_FILENO, QIODevice::ReadOnly); + if (!in.isSequential()) + QSKIP("Standard input redirected."); QCOMPARE( in.pos(), (qint64)0 ); QCOMPARE( in.size(), (qint64)0 ); - QVERIFY( in.isSequential() ); } { QFile out; - out.open(STDOUT_FILENO, QIODevice::WriteOnly); + QVERIFY(out.open(STDOUT_FILENO, QIODevice::WriteOnly)); + if (!out.isSequential()) + QSKIP("Standard output redirected."); QCOMPARE( out.pos(), (qint64)0 ); QCOMPARE( out.size(), (qint64)0 ); - QVERIFY( out.isSequential() ); } { QFile err; err.open(STDERR_FILENO, QIODevice::WriteOnly); + if (!err.isSequential()) + QSKIP("Standard error redirected."); QCOMPARE( err.pos(), (qint64)0 ); QCOMPARE( err.size(), (qint64)0 ); - QVERIFY( err.isSequential() ); } } @@ -3028,12 +3032,6 @@ void tst_QFile::openStandardStreamsBufferedStreams() } } -void tst_QFile::openStandardStreams() -{ - openStandardStreamsFileDescriptors(); - openStandardStreamsBufferedStreams(); -} - void tst_QFile::writeNothing() { for (int i = 0; i < NumberOfFileTypes; ++i) { diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 39ce734c56..a8dba5eb8b 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -4,12 +4,5 @@ embedded: QT += gui SOURCES = ../tst_qprocess.cpp TARGET = ../tst_qprocess -win32 { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qprocess - } else { - TARGET = ../../release/tst_qprocess - } -} TESTDATA += ../testBatFiles/* diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro index f53e5790ea..0146a6a985 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro @@ -3,7 +3,7 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -TARGET = one space +TARGET = "one space" # This app is testdata for tst_qprocess target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro index a4ee0cfd83..f881c2a824 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro @@ -3,7 +3,7 @@ CONFIG -= qt app_bundle CONFIG += console DESTDIR = ./ -TARGET = two space s +TARGET = "two space s" # This app is testdata for tst_qprocess target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index f5754c07aa..9d0121307c 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1421,6 +1421,15 @@ void tst_QProcess::spaceArgsTest_data() << QString::fromLatin1(" \"\"\"\"\"\"\" \"\" \"\"\"\"\"\"\" "); } +static QByteArray startFailMessage(const QString &program, const QProcess &process) +{ + QByteArray result = "Process '"; + result += program.toLocal8Bit(); + result += "' failed to start: "; + result += process.errorString().toLocal8Bit(); + return result; +} + //----------------------------------------------------------------------------- void tst_QProcess::spaceArgsTest() { @@ -1438,13 +1447,17 @@ void tst_QProcess::spaceArgsTest() QString program = programs.at(i); process->start(program, args); -#if !defined(Q_OS_WINCE) - QVERIFY(process->waitForStarted(5000)); - QVERIFY(process->waitForFinished(5000)); +#if defined(Q_OS_WINCE) + const int timeOutMS = 10000; #else - QVERIFY(process->waitForStarted(10000)); - QVERIFY(process->waitForFinished(10000)); + const int timeOutMS = 5000; #endif + QByteArray errorMessage; + bool started = process->waitForStarted(timeOutMS); + if (!started) + errorMessage = startFailMessage(program, *process); + QVERIFY2(started, errorMessage.constData()); + QVERIFY(process->waitForFinished(timeOutMS)); #if !defined(Q_OS_WINCE) QStringList actual = QString::fromLatin1(process->readAll()).split("|"); @@ -1463,9 +1476,13 @@ void tst_QProcess::spaceArgsTest() if (!stringArgs.isEmpty()) program += QString::fromLatin1(" ") + stringArgs; + errorMessage.clear(); process->start(program); + started = process->waitForStarted(5000); + if (!started) + errorMessage = startFailMessage(program, *process); - QVERIFY(process->waitForStarted(5000)); + QVERIFY2(started, errorMessage.constData()); QVERIFY(process->waitForFinished(5000)); #if !defined(Q_OS_WINCE) diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 434b15b125..60c7174f3a 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -55,12 +55,7 @@ class tst_QTemporaryDir : public QObject { Q_OBJECT public: - tst_QTemporaryDir(); - virtual ~tst_QTemporaryDir(); public slots: - void init(); - void cleanup(); - void initTestCase(); void cleanupTestCase(); @@ -75,7 +70,6 @@ private slots: void openOnRootDrives(); void stressTest(); void rename(); - void autoRemoveAfterFailedRename(); void QTBUG_4796_data(); void QTBUG_4796(); @@ -115,23 +109,6 @@ void tst_QTemporaryDir::getSetCheck() QCOMPARE(true, obj1.autoRemove()); } -tst_QTemporaryDir::tst_QTemporaryDir() -{ -} - -tst_QTemporaryDir::~tst_QTemporaryDir() -{ - -} - -void tst_QTemporaryDir::init() -{ -} - -void tst_QTemporaryDir::cleanup() -{ -} - void tst_QTemporaryDir::fileTemplate_data() { QTest::addColumn<QString>("constructorTemplate"); @@ -142,10 +119,12 @@ void tst_QTemporaryDir::fileTemplate_data() QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "qt_XXXXXXxxx"; QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "qt_XXXXXXxXx"; QTest::newRow("constructor with no suffix") << "qt_XXXXXX" << "qt_"; - QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_XXXX"; + QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_"; + // When more than 6 X are present at the end, linux and windows will only replace the last 6, + // while Mac OS will actually replace all of them so we can only expect "qt_" (and check isValid). QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_"; - QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_XXXX"; - QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_XXXXX"; + QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_"; + QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_"; } void tst_QTemporaryDir::fileTemplate() @@ -175,7 +154,7 @@ void tst_QTemporaryDir::fileName() dir.setAutoRemove(true); QString fileName = dir.path(); QVERIFY2(fileName.contains("/tst_qtemporarydir-"), qPrintable(fileName)); - QVERIFY(QFile::exists(fileName)); + QVERIFY(QDir(fileName).exists()); // Get path to the temp dir, without the file name. QString absoluteFilePath = QFileInfo(fileName).absolutePath(); #if defined(Q_OS_WIN) @@ -198,9 +177,9 @@ void tst_QTemporaryDir::autoRemove() #ifdef Q_OS_WIN // Windows seems unreliable here: sometimes it says the directory still exists, // immediately after we deleted it. - QTRY_VERIFY(!QFile::exists(dirName)); + QTRY_VERIFY(!QDir(dirName).exists()); #else - QVERIFY(!QFile::exists(dirName)); + QVERIFY(!QDir(dirName).exists()); #endif // Test if disabling auto remove works. @@ -210,9 +189,9 @@ void tst_QTemporaryDir::autoRemove() QVERIFY(dir.isValid()); dirName = dir.path(); } - QVERIFY(QFile::exists(dirName)); + QVERIFY(QDir(dirName).exists()); QVERIFY(QDir().rmdir(dirName)); - QVERIFY(!QFile::exists(dirName)); + QVERIFY(!QDir(dirName).exists()); // Do not explicitly call setAutoRemove (tests if it really is the default as documented) { @@ -221,9 +200,9 @@ void tst_QTemporaryDir::autoRemove() dirName = dir.path(); } #ifdef Q_OS_WIN - QTRY_VERIFY(!QFile::exists(dirName)); + QTRY_VERIFY(!QDir(dirName).exists()); #else - QVERIFY(!QFile::exists(dirName)); + QVERIFY(!QDir(dirName).exists()); #endif // Test autoremove with files and subdirs in the temp dir @@ -240,25 +219,32 @@ void tst_QTemporaryDir::autoRemove() QCOMPARE(file.write("Hello"), 5LL); } #ifdef Q_OS_WIN - QTRY_VERIFY(!QFile::exists(dirName)); + QTRY_VERIFY(!QDir(dirName).exists()); #else - QVERIFY(!QFile::exists(dirName)); + QVERIFY(!QDir(dirName).exists()); #endif } void tst_QTemporaryDir::nonWritableCurrentDir() { #ifdef Q_OS_UNIX - QString cwd = QDir::currentPath(); - QDir::setCurrent("/"); + struct ChdirOnReturn + { + ChdirOnReturn(const QString& d) : dir(d) {} + ~ChdirOnReturn() { + QDir::setCurrent(dir); + } + QString dir; + }; + ChdirOnReturn cor(QDir::currentPath()); + + QDir::setCurrent("/home"); // QTemporaryDir("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... - QString fileName; QTemporaryDir dir("tempXXXXXX"); dir.setAutoRemove(true); QVERIFY(!dir.isValid()); - fileName = dir.path(); - QDir::setCurrent(cwd); + QVERIFY(dir.path().isEmpty()); #endif } @@ -267,13 +253,13 @@ void tst_QTemporaryDir::openOnRootDrives() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif - // If it's possible to create a dir in the root directory, it + // If it's possible to create a file in the root directory, it // must be possible to create a temp dir there too. foreach (const QFileInfo &driveInfo, QDir::drives()) { - QFile testFile(driveInfo.filePath() + "XXXXXX.txt"); + QFile testFile(driveInfo.filePath() + "XXXXXX"); if (testFile.open(QIODevice::ReadWrite)) { testFile.remove(); - QTemporaryDir dir(driveInfo.filePath() + "XXXXXX.txt"); + QTemporaryDir dir(driveInfo.filePath() + "XXXXXX"); dir.setAutoRemove(true); QVERIFY(dir.isValid()); } @@ -328,41 +314,6 @@ void tst_QTemporaryDir::rename() QVERIFY(!dir.exists()); } -void tst_QTemporaryDir::autoRemoveAfterFailedRename() -{ - struct CleanOnReturn - { - ~CleanOnReturn() - { - if (!tempName.isEmpty()) - QVERIFY(QDir(tempName).removeRecursively()); - } - - void reset() - { - tempName.clear(); - } - - QString tempName; - }; - - CleanOnReturn cleaner; - - { - QTemporaryDir dir; - QVERIFY(dir.isValid()); - cleaner.tempName = dir.path(); - - QVERIFY(QFile::exists(cleaner.tempName)); - QVERIFY(!QFileInfo("i-do-not-exist").isDir()); - QVERIFY(!QDir().rename(cleaner.tempName, "i-do-not-exist/dir.txt")); - QVERIFY(QFile::exists(cleaner.tempName)); - } - - QVERIFY(!QFile::exists(cleaner.tempName)); - cleaner.reset(); -} - void tst_QTemporaryDir::QTBUG_4796_data() { QTest::addColumn<QString>("prefix"); @@ -380,7 +331,7 @@ void tst_QTemporaryDir::QTBUG_4796_data() QTest::newRow("<unicode>XXXXXX") << unicode << QString() << true; } -void tst_QTemporaryDir::QTBUG_4796() +void tst_QTemporaryDir::QTBUG_4796() // unicode support { QVERIFY(QDir("test-XXXXXX").exists()); @@ -443,9 +394,9 @@ void tst_QTemporaryDir::QTBUG_4796() QString fileName5 = currentDir.relativeFilePath(dir5.path()); QString fileName6 = currentDir.relativeFilePath(dir6.path()); - QVERIFY(fileName1.startsWith(fileTemplate1)); - QVERIFY(fileName2.startsWith(fileTemplate2)); - QVERIFY(fileName5.startsWith("test-XXXXXX/" + fileTemplate1)); + QVERIFY(fileName1.startsWith(prefix)); + QVERIFY(fileName2.startsWith(prefix)); + QVERIFY(fileName5.startsWith("test-XXXXXX/" + prefix)); QVERIFY(fileName6.startsWith("test-XXXXXX/" + prefix)); if (!prefix.isEmpty()) { @@ -459,7 +410,7 @@ void tst_QTemporaryDir::QTBUG_4796() QTest::qWait(20); #endif foreach (const QString &tempName, cleaner.tempNames) - QVERIFY2(!QFile::exists(tempName), qPrintable(tempName)); + QVERIFY2(!QDir(tempName).exists(), qPrintable(tempName)); cleaner.reset(); } diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 46c0e19c9e..a1e9d98461 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -256,16 +256,23 @@ void tst_QTemporaryFile::autoRemove() void tst_QTemporaryFile::nonWritableCurrentDir() { #ifdef Q_OS_UNIX - QString cwd = QDir::currentPath(); - QDir::setCurrent("/"); + struct ChdirOnReturn + { + ChdirOnReturn(const QString& d) : dir(d) {} + ~ChdirOnReturn() { + QDir::setCurrent(dir); + } + QString dir; + }; + ChdirOnReturn cor(QDir::currentPath()); + + QDir::setCurrent("/home"); // QTemporaryFile("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... - QString fileName; QTemporaryFile file("tempXXXXXX"); file.setAutoRemove(true); QVERIFY(!file.open()); - fileName = file.fileName(); - QDir::setCurrent(cwd); + QVERIFY(file.fileName().isEmpty()); #endif } diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index 1cb6b7f3f9..e94b6d3fb9 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -43,6 +43,7 @@ #include "externaltests.h" #include <QtCore/QTemporaryFile> +#include <QtCore/QTemporaryDir> #include <QtCore/QProcess> #include <QtCore/QByteArray> #include <QtCore/QString> @@ -75,42 +76,6 @@ static QString makespec() return QString::fromLatin1(p + 1); } -static bool removeRecursive(const QString &pathname) -{ - QFileInfo fi(pathname); - if (!fi.exists()) - return true; - - if (fi.isFile()) - return QFile::remove(pathname); - - if (!fi.isDir()) { - // not a file or directory. How do I remove it? - return false; - } - - // not empty -- we must empty it first - QDirIterator di(pathname, QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot); - while (di.hasNext()) { - di.next(); - if (!di.fileInfo().exists() && !di.fileInfo().isSymLink()) - continue; - bool ok; - if (di.fileInfo().isFile() || di.fileInfo().isSymLink()) - ok = QFile::remove(di.filePath()); - else - ok = removeRecursive(di.filePath()); - if (!ok) { - return false; - } - } - - QDir dir(pathname); - QString dirname = dir.dirName(); - dir.cdUp(); - return dir.rmdir(dirname); -} - QT_BEGIN_NAMESPACE namespace QTest { class QExternalProcess: public QProcess @@ -140,7 +105,7 @@ namespace QTest { QExternalTestPrivate() : qtModules(QExternalTest::QtCore | QExternalTest::QtGui | QExternalTest::QtTest), appType(QExternalTest::AutoApplication), - exitCode(-1) + temporaryDir(0), exitCode(-1) { } ~QExternalTestPrivate() @@ -156,7 +121,8 @@ namespace QTest { QExternalTest::QtModules qtModules; QExternalTest::ApplicationType appType; - QString temporaryDir; + QString temporaryDirPath; + QTemporaryDir *temporaryDir; QByteArray sourceCode; QByteArray std_out; QByteArray std_err; @@ -330,9 +296,8 @@ namespace QTest { // actual execution code void QExternalTestPrivate::clear() { - if (!temporaryDir.isEmpty()) - removeTemporaryDirectory(); - + delete temporaryDir; + temporaryDir = 0; sourceCode.clear(); std_out.clear(); std_err.clear(); @@ -340,14 +305,6 @@ namespace QTest { failedStage = QExternalTest::FileStage; } - void QExternalTestPrivate::removeTemporaryDirectory() - { - if (temporaryDir.isEmpty()) - qWarning() << "Temporary directory is expected to be non-empty"; - removeRecursive(temporaryDir); - temporaryDir.clear(); - } - bool QExternalTestPrivate::prepareSourceCode(const QByteArray &body) { sourceCode.clear(); @@ -448,7 +405,7 @@ namespace QTest { " return 0;\n" "}\n"; - QFile sourceFile(temporaryDir + QLatin1String("/project.cpp")); + QFile sourceFile(temporaryDirPath + QLatin1String("/project.cpp")); if (!sourceFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { std_err = sourceFile.errorString().toLocal8Bit(); return false; @@ -457,7 +414,7 @@ namespace QTest { sourceFile.write(sourceCode); sourceFile.close(); - sourceFile.setFileName(temporaryDir + QLatin1String("/user_code.cpp")); + sourceFile.setFileName(temporaryDirPath + QLatin1String("/user_code.cpp")); if (!sourceFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { std_err = sourceFile.errorString().toLocal8Bit(); return false; @@ -469,27 +426,24 @@ namespace QTest { bool QExternalTestPrivate::createTemporaryDirectory() { - QDir temp = QDir::temp(); - QString subdir = QString::fromLatin1("qexternaltest-%1-%2-%3") - .arg(QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"))) - .arg(quintptr(this), 0, 16) - .arg(qrand()); - if (!temp.mkdir(subdir)) - return false; - - if (!temp.cd(subdir)) + delete temporaryDir; + temporaryDir = new QTemporaryDir; + if (temporaryDir->isValid()) { + temporaryDirPath = temporaryDir->path(); + return true; + } else { + delete temporaryDir; + temporaryDir = 0; return false; - - temporaryDir = temp.absolutePath(); - return true; + } } bool QExternalTestPrivate::createProjectFile() { - if (temporaryDir.isEmpty()) + if (temporaryDirPath.isEmpty()) qWarning() << "Temporary directory is expected to be non-empty"; - QFile projectFile(temporaryDir + QLatin1String("/project.pro")); + QFile projectFile(temporaryDirPath + QLatin1String("/project.pro")); if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { std_err = projectFile.errorString().toLocal8Bit(); return false; @@ -597,7 +551,7 @@ namespace QTest { bool QExternalTestPrivate::runQmake() { - if (temporaryDir.isEmpty()) + if (temporaryDirPath.isEmpty()) qWarning() << "Temporary directory is expected to be non-empty"; if (!createProjectFile()) @@ -610,7 +564,7 @@ namespace QTest { << QLatin1String("-spec") << makespec() << QLatin1String("project.pro"); - qmake.setWorkingDirectory(temporaryDir); + qmake.setWorkingDirectory(temporaryDirPath); qmake.start(QLatin1String("qmake"), args); std_out += "### --- stdout from qmake --- ###\n"; @@ -633,11 +587,11 @@ namespace QTest { bool QExternalTestPrivate::runMake(Target target) { - if (temporaryDir.isEmpty()) + if (temporaryDirPath.isEmpty()) qWarning() << "Temporary directory is expected to be non-empty"; QExternalProcess make; - make.setWorkingDirectory(temporaryDir); + make.setWorkingDirectory(temporaryDirPath); QStringList environment = QProcess::systemEnvironment(); environment += QLatin1String("LC_ALL=C"); diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index e62ee0f051..7eb1bd2dee 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -1663,7 +1663,13 @@ void tst_QSharedPointer::invalidConstructs_data() // use of forward-declared class QTest::newRow("forward-declaration") +#ifdef Q_CC_CLANG + // Deleting a forward declaration is undefined, which results in a linker error with clang + << &QTest::QExternalTest::tryLinkFail +#else + // Other compilers accept the code, but do not call the destructor at run-time << &QTest::QExternalTest::tryRun +#endif << "forwardDeclaredDestructorRunCount = 0;\n" "{ QSharedPointer<ForwardDeclared> ptr = QSharedPointer<ForwardDeclared>(forwardPointer()); }\n" "exit(forwardDeclaredDestructorRunCount);"; diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index f386624092..c15d1e6976 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -57,7 +57,7 @@ #include <QSet> -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include <windows.h> #endif @@ -117,7 +117,7 @@ private slots: void convertFromImageNoDetach(); void convertFromImageDetach(); -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) void toWinHBITMAP_data(); void toWinHBITMAP(); void fromWinHBITMAP_data(); @@ -167,32 +167,28 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32); QImage actualImage = actual.toImage().convertToFormat(QImage::Format_RGB32); - if (expectedImage.size() != actualImage.size()) + if (expectedImage.size() != actualImage.size()) { + qWarning("Image size comparison failed: expected: %dx%d, got %dx%d", + expectedImage.size().width(), expectedImage.size().height(), + actualImage.size().width(), actualImage.size().height()); return false; + } - int size = actual.width() * actual.height(); - - int threshold = 2; - if (QPixmap::defaultDepth() == 16) - threshold = 10; + const int size = actual.width() * actual.height(); + const int threshold = QPixmap::defaultDepth() == 16 ? 10 : 2; QRgb *a = (QRgb *)actualImage.bits(); QRgb *e = (QRgb *)expectedImage.bits(); for (int i = 0; i < size; ++i) { - QColor ca(a[i]); - QColor ce(e[i]); - - bool result = true; - - if (qAbs(ca.red() - ce.red()) > threshold) - result = false; - if (qAbs(ca.green() - ce.green()) > threshold) - result = false; - if (qAbs(ca.blue() - ce.blue()) > threshold) - result = false; - - if (!result) + const QColor ca(a[i]); + const QColor ce(e[i]); + if (qAbs(ca.red() - ce.red()) > threshold + || qAbs(ca.green() - ce.green()) > threshold + || qAbs(ca.blue() - ce.blue()) > threshold) { + qWarning("Color mismatch at pixel #%d: Expected: %d,%d,%d, got %d,%d,%d", + i, ce.red(), ce.green(), ce.blue(), ca.red(), ca.green(), ca.blue()); return false; + } } return true; @@ -855,7 +851,15 @@ void tst_QPixmap::convertFromImageDetach() QVERIFY(copy.isDetached()); } -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) + +Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap); +Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0); +Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); +Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p); +Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h); +Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); + void tst_QPixmap::toWinHBITMAP_data() { QTest::addColumn<int>("red"); @@ -876,7 +880,7 @@ void tst_QPixmap::toWinHBITMAP() QPixmap pm(100, 100); pm.fill(QColor(red, green, blue)); - HBITMAP bitmap = pm.toWinHBITMAP(); + HBITMAP bitmap = qt_pixmapToWinHBITMAP(pm); QVERIFY(bitmap != 0); @@ -931,7 +935,7 @@ void tst_QPixmap::fromWinHBITMAP() #ifdef Q_OS_WINCE //the device context has to be deleted before QPixmap::fromWinHBITMAP() DeleteDC(bitmap_dc); #endif - QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap); + QPixmap pixmap = qt_pixmapFromWinHBITMAP(bitmap); QCOMPARE(pixmap.width(), 100); QCOMPARE(pixmap.height(), 100); @@ -949,30 +953,39 @@ void tst_QPixmap::fromWinHBITMAP() ReleaseDC(0, display_dc); } -static void compareImages(const QImage &image1, const QImage &image2) +static bool compareImages(const QImage &actualImage, const QImage &expectedImage) { - QCOMPARE(image1.width(), image2.width()); - QCOMPARE(image1.height(), image2.height()); - QCOMPARE(image1.format(), image2.format()); + if (actualImage.width() != expectedImage.width() + || actualImage.height() != expectedImage.height()) { + qWarning("Image size comparison failed: expected: %dx%d, got %dx%d", + expectedImage.size().width(), expectedImage.size().height(), + actualImage.size().width(), actualImage.size().height()); + return false; + } + if (actualImage.format() != expectedImage.format()) { + qWarning("Image format comparison failed: expected: %d, got %d", + expectedImage.format(), actualImage.format()); + return false; + } static const int fuzz = 1; - for (int y = 0; y < image1.height(); y++) - { - for (int x = 0; x < image2.width(); x++) - { - QRgb p1 = image1.pixel(x, y); - QRgb p2 = image2.pixel(x, y); - - bool pixelMatches = - qAbs(qRed(p1) - qRed(p2)) <= fuzz - && qAbs(qGreen(p1) - qGreen(p2)) <= fuzz - && qAbs(qBlue(p1) - qBlue(p2)) <= fuzz - && qAbs(qAlpha(p1) - qAlpha(p2)) <= fuzz; - - QVERIFY(pixelMatches); + for (int y = 0; y < actualImage.height(); ++y) { + for (int x = 0; x < expectedImage.width(); ++x) { + const QRgb p1 = actualImage.pixel(x, y); + const QRgb p2 = expectedImage.pixel(x, y); + + if (qAbs(qRed(p1) - qRed(p2)) > fuzz + || qAbs(qGreen(p1) - qGreen(p2)) > fuzz + || qAbs(qBlue(p1) - qBlue(p2)) > fuzz + || qAbs(qAlpha(p1) - qAlpha(p2)) > fuzz) { + qWarning("Color mismatch at pixel %d,%d: Expected: 0x%x. got 0x%x", + x, y, p2, p1); + return false; + } } } + return true; } void tst_QPixmap::toWinHICON_data() @@ -995,9 +1008,7 @@ void tst_QPixmap::toWinHICON_data() void tst_QPixmap::toWinHICON() { -#ifdef Q_OS_WINCE - QSKIP("Test shall be enabled for Windows CE shortly."); -#endif + enum { Alpha = 2 }; QFETCH(int, width); QFETCH(int, height); @@ -1008,28 +1019,27 @@ void tst_QPixmap::toWinHICON() HDC display_dc = GetDC(0); HDC bitmap_dc = CreateCompatibleDC(display_dc); - HBITMAP bitmap = empty.toWinHBITMAP(QPixmap::Alpha); + HBITMAP bitmap = qt_pixmapToWinHBITMAP(empty, Alpha); SelectObject(bitmap_dc, bitmap); QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); imageFromFile = imageFromFile.convertToFormat(QImage::Format_ARGB32_Premultiplied); - HICON icon = QPixmap::fromImage(imageFromFile).toWinHICON(); + HICON icon = qt_pixmapToWinHICON(QPixmap::fromImage(imageFromFile)); DrawIconEx(bitmap_dc, 0, 0, icon, width, height, 0, 0, DI_NORMAL); DestroyIcon(icon); DeleteDC(bitmap_dc); - QImage imageFromHICON = QPixmap::fromWinHBITMAP(bitmap, QPixmap::Alpha).toImage(); + QImage imageFromHICON = qt_pixmapFromWinHBITMAP(bitmap, Alpha).toImage(); ReleaseDC(0, display_dc); // fuzzy comparison must be used, as the pixel values change slightly during conversion // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere - // QVERIFY(imageFromHICON == imageFromFile); - compareImages(imageFromHICON, imageFromFile); + QVERIFY(compareImages(imageFromHICON, imageFromFile)); } void tst_QPixmap::fromWinHICON_data() @@ -1039,16 +1049,12 @@ void tst_QPixmap::fromWinHICON_data() void tst_QPixmap::fromWinHICON() { -#ifdef Q_OS_WINCE - QSKIP("Test shall be enabled for Windows CE shortly."); - -#else QFETCH(int, width); QFETCH(int, height); QFETCH(QString, image); HICON icon = (HICON)LoadImage(0, (wchar_t*)(image + QLatin1String(".ico")).utf16(), IMAGE_ICON, width, height, LR_LOADFROMFILE); - QImage imageFromHICON = QPixmap::fromWinHICON(icon).toImage(); + QImage imageFromHICON = qt_pixmapFromWinHICON(icon).toImage(); DestroyIcon(icon); QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); @@ -1057,12 +1063,10 @@ void tst_QPixmap::fromWinHICON() // fuzzy comparison must be used, as the pixel values change slightly during conversion // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere - // QVERIFY(imageFromHICON == imageFromFile); - compareImages(imageFromHICON, imageFromFile); -#endif + QVERIFY(compareImages(imageFromHICON, imageFromFile)); } -#endif // Q_WS_WIN +#endif // Q_OS_WIN void tst_QPixmap::onlyNullPixmapsOutsideGuiThread() { diff --git a/tests/auto/gui/kernel/qclipboard/test/test.pro b/tests/auto/gui/kernel/qclipboard/test/test.pro index 5d28e8e060..1c92fa4107 100644 --- a/tests/auto/gui/kernel/qclipboard/test/test.pro +++ b/tests/auto/gui/kernel/qclipboard/test/test.pro @@ -19,3 +19,5 @@ wince* { DEPLOYMENT += copier paster rsc reg_resource } + +mac: CONFIG += insignificant_test # QTBUG-23057 diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro index 1e0baafd09..c6eb02919e 100644 --- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro +++ b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro @@ -7,3 +7,5 @@ QT += core-private gui-private SOURCES += tst_qkeysequence.cpp RESOURCES += qkeysequence.qrc + +mac: CONFIG += insignificant_test # QTBUG-23058 diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 4583e79561..07afe4a89c 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -51,6 +51,7 @@ public: bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; ulong timestamp; + QTouchDevice *deviceFromEvent; tst_QTouchEventWidget() : QWidget() @@ -78,6 +79,7 @@ public: seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); event->setAccepted(acceptTouchBegin); if (deleteInTouchBegin) delete this; @@ -88,6 +90,7 @@ public: seenTouchUpdate = seenTouchBegin && !seenTouchEnd; touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); event->setAccepted(acceptTouchUpdate); if (deleteInTouchUpdate) delete this; @@ -98,6 +101,7 @@ public: seenTouchEnd = seenTouchBegin && !seenTouchEnd; touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); event->setAccepted(acceptTouchEnd); if (deleteInTouchEnd) delete this; @@ -190,7 +194,7 @@ class tst_QTouchEvent : public QObject { Q_OBJECT public: - tst_QTouchEvent() { } + tst_QTouchEvent(); ~tst_QTouchEvent() { } private slots: @@ -205,8 +209,21 @@ private slots: void deleteInRawEventTranslation(); void crashInQGraphicsSceneAfterNotHandlingTouchBegin(); void touchBeginWithGraphicsWidget(); + +private: + QTouchDevice *touchScreenDevice; + QTouchDevice *touchPadDevice; }; +tst_QTouchEvent::tst_QTouchEvent() +{ + touchScreenDevice = new QTouchDevice; + touchPadDevice = new QTouchDevice; + touchPadDevice->setType(QTouchDevice::TouchPad); + QWindowSystemInterface::registerTouchDevice(touchScreenDevice); + QWindowSystemInterface::registerTouchDevice(touchPadDevice); +} + void tst_QTouchEvent::touchDisabledByDefault() { // QWidget @@ -219,7 +236,7 @@ void tst_QTouchEvent::touchDisabledByDefault() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(QTouchEvent::TouchPoint(0)); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); @@ -248,7 +265,7 @@ void tst_QTouchEvent::touchDisabledByDefault() touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -272,7 +289,7 @@ void tst_QTouchEvent::touchEventAcceptedByDefault() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(QTouchEvent::TouchPoint(0)); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); @@ -310,7 +327,7 @@ void tst_QTouchEvent::touchEventAcceptedByDefault() touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -338,7 +355,7 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(QTouchEvent::TouchPoint(0)); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); @@ -390,7 +407,7 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -426,7 +443,7 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -454,7 +471,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(QTouchEvent::TouchPoint(0)); QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); @@ -466,7 +483,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() // send the touch update to the child, but ignore it, it doesn't propagate QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointMoved, touchPoints); @@ -478,7 +495,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() // send the touch end, same thing should happen as with touch update QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointReleased, touchPoints); @@ -513,7 +530,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -526,7 +543,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() // send the touch update to the child, but ignore it, it doesn't propagate touchPoint.setState(Qt::TouchPointMoved); QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointMoved, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -540,7 +557,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() // send the touch end, same thing should happen as with touch update touchPoint.setState(Qt::TouchPointReleased); QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointReleased, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -576,9 +593,12 @@ void tst_QTouchEvent::basicRawEventTranslation() rawTouchPoint.setState(Qt::TouchPointPressed); rawTouchPoint.setScreenPos(screenPos); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); + QList<QPointF> rawPosList; + rawPosList << QPointF(12, 34) << QPointF(56, 78); + rawTouchPoint.setRawScreenPositions(rawPosList); const ulong timestamp = 1234; qt_translateRawTouchEvent(&touchWidget, - QTouchEvent::TouchScreen, + touchScreenDevice, QList<QTouchEvent::TouchPoint>() << rawTouchPoint, timestamp); QVERIFY(touchWidget.seenTouchBegin); @@ -605,13 +625,15 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchBeginPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); + QCOMPARE(touchBeginPoint.velocity(), QVector2D()); + QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList); // moving the point should translate to TouchUpdate rawTouchPoint.setState(Qt::TouchPointMoved); rawTouchPoint.setScreenPos(screenPos + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); qt_translateRawTouchEvent(&touchWidget, - QTouchEvent::TouchScreen, + touchScreenDevice, QList<QTouchEvent::TouchPoint>() << rawTouchPoint, 0); QVERIFY(touchWidget.seenTouchBegin); @@ -643,7 +665,7 @@ void tst_QTouchEvent::basicRawEventTranslation() rawTouchPoint.setScreenPos(screenPos + delta + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); qt_translateRawTouchEvent(&touchWidget, - QTouchEvent::TouchScreen, + touchScreenDevice, QList<QTouchEvent::TouchPoint>() << rawTouchPoint, 0); QVERIFY(touchWidget.seenTouchBegin); @@ -709,7 +731,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -770,7 +792,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -831,7 +853,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -924,7 +946,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchPadDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -985,7 +1007,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchPadDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -1046,7 +1068,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchPadDevice, rawTouchPoints, 0); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); @@ -1123,17 +1145,17 @@ void tst_QTouchEvent::deleteInEventHandler() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(QTouchEvent::TouchPoint(0)); QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointStationary, touchPoints); QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointReleased, touchPoints); @@ -1200,19 +1222,19 @@ void tst_QTouchEvent::deleteInEventHandler() QList<QTouchEvent::TouchPoint> touchPoints; touchPoints.append(touchPoint); QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); touchPoints[0].setState(Qt::TouchPointMoved); QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointMoved, touchPoints); touchPoints[0].setState(Qt::TouchPointReleased); QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + touchScreenDevice, Qt::NoModifier, Qt::TouchPointReleased, touchPoints); @@ -1304,20 +1326,20 @@ void tst_QTouchEvent::deleteInRawEventTranslation() rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); // generate begin events on all widgets, the left widget should die - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); QVERIFY(pl.isNull() && !pc.isNull() && !pr.isNull()); // generate update events on all widget, the center widget should die rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[2].setState(Qt::TouchPointMoved); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); // generate end events on all widget, the right widget should die rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[2].setState(Qt::TouchPointReleased); - qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints, 0); + qt_translateRawTouchEvent(&touchWidget, touchScreenDevice, rawTouchPoints, 0); } void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() @@ -1343,11 +1365,11 @@ void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() QPoint centerPos = view.mapFromScene(rect->boundingRect().center()); // Touch the button - QTest::touchEvent(view.viewport()).press(0, centerPos, static_cast<QWindow *>(0)); - QTest::touchEvent(view.viewport()).release(0, centerPos, static_cast<QWindow *>(0)); + QTest::touchEvent(view.viewport(), touchScreenDevice).press(0, centerPos, static_cast<QWindow *>(0)); + QTest::touchEvent(view.viewport(), touchScreenDevice).release(0, centerPos, static_cast<QWindow *>(0)); // Touch outside of the button - QTest::touchEvent(view.viewport()).press(0, view.mapFromScene(QPoint(10, 10)), static_cast<QWindow *>(0)); - QTest::touchEvent(view.viewport()).release(0, view.mapFromScene(QPoint(10, 10)), static_cast<QWindow *>(0)); + QTest::touchEvent(view.viewport(), touchScreenDevice).press(0, view.mapFromScene(QPoint(10, 10)), static_cast<QWindow *>(0)); + QTest::touchEvent(view.viewport(), touchScreenDevice).release(0, view.mapFromScene(QPoint(10, 10)), static_cast<QWindow *>(0)); } void tst_QTouchEvent::touchBeginWithGraphicsWidget() @@ -1368,12 +1390,12 @@ void tst_QTouchEvent::touchBeginWithGraphicsWidget() QTest::qWaitForWindowShown(&view); view.fitInView(scene.sceneRect()); - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()); - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .stationary(0) .press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()) .release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); @@ -1385,12 +1407,12 @@ void tst_QTouchEvent::touchBeginWithGraphicsWidget() root->reset(); glassWidget->setWindowFlags(Qt::Window); // make the glassWidget a panel - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()); - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .stationary(0) .press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); - QTest::touchEvent(static_cast<QWindow *>(0)) + QTest::touchEvent(static_cast<QWindow *>(0), touchScreenDevice) .release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()) .release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 9fb49e8ceb..0115d96c56 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -5,3 +5,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp +mac: CONFIG += insignificant_test # QTBUG-23059 diff --git a/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro b/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro index f397f48bb8..b0e69dca2e 100644 --- a/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro +++ b/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro @@ -5,3 +5,5 @@ SOURCES += tst_qprinterinfo.cpp QT += printsupport network testlib DEFINES += QT_USE_USING_NAMESPACE + +mac: CONFIG += insignificant_test # QTBUG-23060 diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index 0cc574a5bc..f3c020dde2 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -7,3 +7,5 @@ TARGET = tst_qopengl QT += gui gui-private core-private testlib SOURCES += tst_qopengl.cpp + +mac: CONFIG += insignificant_test # QTBUG-23061 diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 08442cc0ad..c853aaa100 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -10,3 +10,4 @@ wince* { DEPLOYMENT += additionalFiles } +mac: CONFIG += insignificant_test # QTBUG-23062 diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro index fff006ca8c..a0955af710 100644 --- a/tests/auto/gui/text/qstatictext/qstatictext.pro +++ b/tests/auto/gui/text/qstatictext/qstatictext.pro @@ -3,3 +3,5 @@ TARGET = tst_qstatictext QT += widgets widgets-private testlib QT += core core-private gui gui-private SOURCES += tst_qstatictext.cpp + +mac: CONFIG += insignificant_test # QTBUG-23063 diff --git a/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro b/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro index 6dcb1b44a0..516fa67f11 100644 --- a/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro +++ b/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro @@ -6,3 +6,5 @@ QT += core-private gui-private testlib HEADERS += SOURCES += tst_qtextscriptengine.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src + +mac: CONFIG += insignificant_test # QTBUG-23064 diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index 5055ab61a3..c24fe7553d 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -31,3 +31,7 @@ win32:SUBDIRS -= qtextpiecetable qstatictext \ qtextlayout \ qtextpiecetable \ + +mac { + qtextlayout.CONFIG = no_check_target # QTBUG-23050 +} diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro b/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro index c7a4308b17..2eb00593e0 100644 --- a/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro +++ b/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro @@ -1,6 +1,6 @@ HEADERS += Test.h SOURCES += main.cpp Test.cpp -QT += network +QT = core network testlib CONFIG -= app_bundle CONFIG += console diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 13c39471b3..6c6697bfdc 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -1,7 +1,6 @@ CONFIG += testcase -QT += widgets testlib -QT += core-private network-private +QT = core-private network-private testlib SOURCES += ../tst_qtcpsocket.cpp win32: { wince*: { @@ -10,8 +9,6 @@ wince*: { LIBS += -lws2_32 } } -QT += network -vxworks:QT -= gui TARGET = tst_qtcpsocket @@ -24,5 +21,3 @@ win32 { } else { DESTDIR = ../ } - -CONFIG+=insignificant_test # unstable, QTBUG-21043 diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 98ce112a9e..218e372e4d 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -63,10 +63,6 @@ #include <QHostAddress> #include <QHostInfo> #include <QMap> -#ifndef Q_OS_VXWORKS -#include <QMessageBox> -#include <QPushButton> -#endif #include <QPointer> #include <QProcess> #include <QStringList> @@ -175,7 +171,7 @@ private slots: void socketsInThreads(); void waitForReadyReadInASlot(); void remoteCloseError(); - void openMessageBoxInErrorSlot(); + void nestedEventLoopInErrorSlot(); #ifndef Q_OS_WIN void connectToLocalHostNoService(); #endif @@ -217,7 +213,7 @@ protected slots: void downloadBigFileSlot(); void recursiveReadyReadSlot(); void waitForReadyReadInASlotSlot(); - void messageBoxSlot(); + void enterLoopSlot(); void hostLookupSlot(); void abortiveClose_abortSlot(); void remoteCloseErrorSlot(); @@ -583,6 +579,7 @@ void tst_QTcpSocket::setSocketDescriptor() QVERIFY(socket->setSocketDescriptor(sock, QTcpSocket::UnconnectedState)); QCOMPARE(socket->socketDescriptor(), (int)sock); + qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test. socket->connectToHost(QtNetworkSettings::serverName(), 143); QCOMPARE(socket->state(), QTcpSocket::HostLookupState); QCOMPARE(socket->socketDescriptor(), (int)sock); @@ -1271,6 +1268,7 @@ void tst_QTcpSocket::disconnectWhileLookingUp() } else { socket->disconnectFromHost(); QVERIFY(socket->openMode() == QIODevice::ReadWrite); + QVERIFY(socket->waitForDisconnected(5000)); } // let anything queued happen @@ -1827,35 +1825,29 @@ void tst_QTcpSocket::remoteCloseErrorSlot() static_cast<QTcpSocket *>(sender())->close(); } -void tst_QTcpSocket::messageBoxSlot() +void tst_QTcpSocket::enterLoopSlot() { -#if !defined(Q_OS_VXWORKS) // no gui QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender()); socket->deleteLater(); - QMessageBox box; - QTimer::singleShot(100, &box, SLOT(close())); - // This should not delete the socket - box.exec(); + // enter nested event loop + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); // Fire a non-0 singleshot to leave time for the delete QTimer::singleShot(250, this, SLOT(exitLoopSlot())); -#endif } //---------------------------------------------------------------------------------- -void tst_QTcpSocket::openMessageBoxInErrorSlot() +void tst_QTcpSocket::nestedEventLoopInErrorSlot() { -#if defined(Q_OS_VXWORKS) // no gui - QSKIP("no default gui available on VxWorks"); -#else QTcpSocket *socket = newSocket(); QPointer<QTcpSocket> p(socket); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(messageBoxSlot())); + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(enterLoopSlot())); socket->connectToHost("hostnotfoundhostnotfound.troll.no", 9999); // Host not found, fyi enterLoop(30); QVERIFY(!p); -#endif } //---------------------------------------------------------------------------------- @@ -1979,16 +1971,9 @@ public slots: //---------------------------------------------------------------------------------- void tst_QTcpSocket::waitForConnectedInHostLookupSlot2() { -#if defined(Q_OS_WIN) || defined(Q_OS_VXWORKS) - QSKIP("waitForConnectedInHostLookupSlot2 is not run on Windows and VxWorks"); -#else - Foo foo; - QPushButton top("Go", 0); - top.show(); - connect(&top, SIGNAL(clicked()), &foo, SLOT(doIt())); - QTimer::singleShot(100, &top, SLOT(animateClick())); + QTimer::singleShot(100, &foo, SLOT(doIt())); QTimer::singleShot(5000, &foo, SLOT(exitLoop())); enterLoop(30); @@ -1997,7 +1982,6 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot2() QVERIFY(foo.attemptedToConnect); QCOMPARE(foo.count, 1); -#endif } //---------------------------------------------------------------------------------- diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 378aff924d..a83611e2b5 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -195,6 +195,7 @@ private slots: void setEmptyDefaultConfiguration(); void versionAccessors(); void sslOptions(); + void encryptWithoutConnecting(); static void exitLoop() { @@ -2122,6 +2123,18 @@ void tst_QSslSocket::sslOptions() #endif } +void tst_QSslSocket::encryptWithoutConnecting() +{ + if (!QSslSocket::supportsSsl()) + return; + + QTest::ignoreMessage(QtWarningMsg, + "QSslSocket::startClientEncryption: cannot start handshake when not connected"); + + QSslSocket sock; + sock.startClientEncryption(); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 098f84b399..1a71f9170a 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -2335,7 +2335,10 @@ void tst_Gestures::bug_13501_gesture_not_accepted() w.show(); QTest::qWaitForWindowShown(&w); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); - QTest::touchEvent(&w).press(0, QPoint(10, 10), &w); + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); } QTEST_MAIN(tst_Gestures) diff --git a/tests/auto/other/languagechange/languagechange.pro b/tests/auto/other/languagechange/languagechange.pro index 541a2f05fd..efbc524556 100644 --- a/tests/auto/other/languagechange/languagechange.pro +++ b/tests/auto/other/languagechange/languagechange.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_languagechange QT += widgets core-private testlib SOURCES += tst_languagechange.cpp - -CONFIG += insignificant_test # QTBUG-21402 diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index 97a2683a75..3b77b13275 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -44,6 +44,7 @@ #include <qapplication.h> #include <QtCore/QSet> +#include <QtCore/QFile> #include <QtCore/QTranslator> #include <private/qthread_p.h> #include <QtWidgets/QInputDialog> @@ -88,14 +89,15 @@ class TransformTranslator : public QTranslator public: TransformTranslator() : QTranslator() {} TransformTranslator(QObject *parent) : QTranslator(parent) {} - virtual QString translate(const char *context, const char *sourceText, const char *comment = 0) const + QString translate(const char *context, const char *sourceText, + const char *disambiguation = 0, int = -1) const { QByteArray total(context); total.append("::"); total.append(sourceText); - if (comment) { + if (disambiguation) { total.append("::"); - total.append(comment); + total.append(disambiguation); } m_translations.insert(total); QString res; @@ -201,9 +203,10 @@ void tst_languageChange::retranslatability() QFETCH( TranslationSet, expected); // This will always be queried for when a language changes - expected.insert("QApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right " - "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " - "get proper widget layout."); + expected.insert("QCoreApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right " + "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " + "get proper widget layout."); + TransformTranslator translator; QTimer::singleShot(500, &translator, SLOT(install())); switch (dialogType) { @@ -212,25 +215,30 @@ void tst_languageChange::retranslatability() break; case ColorDialog: -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC QSKIP("The native color dialog is used on Mac OS"); #else (void)QColorDialog::getColor(); #endif break; case FileDialog: { -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC QSKIP("The native file dialog is used on Mac OS"); #endif QFileDialog dlg; dlg.setOption(QFileDialog::DontUseNativeDialog); - QString tmpParentDir = QDir::tempPath() + "/languagechangetestdir"; - QString tmpDir = tmpParentDir + "/finaldir"; - QString fooName = tmpParentDir + "/foo"; + QString tmpParentDir = QDir::tempPath(); + if (!tmpParentDir.endsWith(QLatin1Char('/'))) + tmpParentDir += QLatin1Char('/'); + tmpParentDir += QStringLiteral("languagechangetestdir"); + const QString tmpDir = tmpParentDir + QStringLiteral("/finaldir"); + const QString fooName = tmpParentDir + QStringLiteral("/foo"); QDir dir; QCOMPARE(dir.mkpath(tmpDir), true); - QCOMPARE(QFile::copy(QApplication::applicationFilePath(), fooName), true); - + QFile fooFile(fooName); + QVERIFY(fooFile.open(QIODevice::WriteOnly|QIODevice::Text)); + fooFile.write("test"); + fooFile.close(); dlg.setDirectory(tmpParentDir); #ifdef Q_OS_WINCE dlg.setDirectory("\\Windows"); diff --git a/tests/auto/other/modeltest/tst_modeltest.cpp b/tests/auto/other/modeltest/tst_modeltest.cpp index 434537a81f..e5c227d167 100644 --- a/tests/auto/other/modeltest/tst_modeltest.cpp +++ b/tests/auto/other/modeltest/tst_modeltest.cpp @@ -207,8 +207,8 @@ public: , storePersistentFailureCount(0) , checkPersistentFailureCount(0) { - connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent())); - connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent())); + connect(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(storePersistent())); + connect(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(checkPersistent())); } public slots: @@ -235,7 +235,7 @@ public slots: void storePersistent() { - // This method is called from layoutAboutToBeChanged. Persistent indexes should be valid + // This method is called from rowsAboutToBeMoved. Persistent indexes should be valid foreach(const QModelIndex &idx, m_persistentProxyIndexes) if (!idx.isValid()) { qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 625ed3b82a..2a838c0e3d 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -141,7 +141,7 @@ static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *c { if (!parentInterface || !childWidget) return -1; - QAccessibleInterface *childInterface = QAccessibleInterface::queryAccessibleInterface(childWidget); + QAccessibleInterface *childInterface = QAccessible::queryAccessibleInterface(childWidget); if (!childInterface) return -1; int index = parentInterface->indexOfChild(childInterface); @@ -344,9 +344,9 @@ class QtTestAccessibleWidgetIface: public QAccessibleWidget { public: QtTestAccessibleWidgetIface(QtTestAccessibleWidget *w): QAccessibleWidget(w) {} - QString text(Text t) const + QString text(QAccessible::Text t) const { - if (t == Help) + if (t == QAccessible::Help) return QString::fromLatin1("Help yourself"); return QAccessibleWidget::text(t); } @@ -1877,8 +1877,8 @@ void tst_QAccessibility::mdiSubWindowTest() QCOMPARE(interface->state(), state); const QRect originalGeometry = testWindow->geometry(); testWindow->showMaximized(); - state &= ~QAccessible::Sizeable; - state &= ~QAccessible::Movable; + state &= (uint)~QAccessible::Sizeable; + state &= (uint)~QAccessible::Movable; QCOMPARE(interface->state(), state); testWindow->showNormal(); testWindow->move(-10, 0); @@ -2526,7 +2526,7 @@ void tst_QAccessibility::listTest() QVERIFY(cellInterface); QCOMPARE(cellInterface->rowIndex(), 3); QCOMPARE(cellInterface->columnIndex(), 0); - QVERIFY(!cellInterface->isExpandable()); + QVERIFY(!(cell4->state() & QAccessible::Expandable)); delete cell4; delete cell1; @@ -2620,7 +2620,7 @@ void tst_QAccessibility::treeTest() QCOMPARE(cell2->role(), QAccessible::TreeItem); QCOMPARE(cell2->tableCellInterface()->rowIndex(), 1); QCOMPARE(cell2->tableCellInterface()->columnIndex(), 0); - QVERIFY(cell2->tableCellInterface()->isExpandable()); + QVERIFY(cell2->state() & QAccessible::Expandable); QCOMPARE(iface->indexOfChild(cell2), 5); QVERIFY(!(cell2->state() & QAccessible::Expanded)); QCOMPARE(table2->columnDescription(1), QString("Work")); @@ -2644,7 +2644,7 @@ void tst_QAccessibility::treeTest() QCOMPARE(cell2->role(), QAccessible::TreeItem); QCOMPARE(cell2->tableCellInterface()->rowIndex(), 4); QCOMPARE(cell2->tableCellInterface()->columnIndex(), 0); - QVERIFY(!cell2->tableCellInterface()->isExpandable()); + QVERIFY(!(cell2->state() & QAccessible::Expandable)); QCOMPARE(iface->indexOfChild(cell2), 11); QCOMPARE(table2->columnDescription(0), QString("Artist")); diff --git a/tests/auto/testlib/selftests/.gitignore b/tests/auto/testlib/selftests/.gitignore index 56ba17abd7..98a3f49081 100644 --- a/tests/auto/testlib/selftests/.gitignore +++ b/tests/auto/testlib/selftests/.gitignore @@ -13,7 +13,6 @@ fetchbogus/tst_fetchbogus globaldata/tst_globaldata maxwarnings/tst_maxwarnings multiexec/tst_multiexec -qexecstringlist/tst_qexecstringlist singleskip/tst_singleskip skip/tst_skip skipglobal/tst_skipglobal diff --git a/tests/auto/testlib/selftests/qexecstringlist/qexecstringlist.pro b/tests/auto/testlib/selftests/qexecstringlist/qexecstringlist.pro deleted file mode 100644 index de8a7da37e..0000000000 --- a/tests/auto/testlib/selftests/qexecstringlist/qexecstringlist.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += tst_qexecstringlist.cpp -QT = core testlib - -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - - -TARGET = qexecstringlist diff --git a/tests/auto/testlib/selftests/selftests.pro b/tests/auto/testlib/selftests/selftests.pro index 68239754aa..b4c4255dfc 100644 --- a/tests/auto/testlib/selftests/selftests.pro +++ b/tests/auto/testlib/selftests/selftests.pro @@ -3,7 +3,7 @@ TEMPLATE = subdirs SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skip \ strcmp expectfail sleep fetchbogus crashes multiexec failinit failinitdata \ skipinit skipinitdata datetime singleskip assert differentexec \ - exceptionthrow qexecstringlist datatable commandlinedata\ + exceptionthrow datatable commandlinedata \ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ benchliboptions xunit badxml longstring float printdatatags \ printdatatagswithglobaltags findtestdata diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index fb303af2b5..5090fa7378 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -95,7 +95,6 @@ <file>expected_multiexec.xunitxml</file> <file>expected_printdatatags.txt</file> <file>expected_printdatatagswithglobaltags.txt</file> - <file>expected_qexecstringlist.txt</file> <file>expected_singleskip.lightxml</file> <file>expected_singleskip.txt</file> <file>expected_singleskip.xml</file> diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index b98a02aa4e..f7a485b857 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -327,7 +327,6 @@ void tst_Selftests::runSubTest_data() << "multiexec" << "printdatatags" << "printdatatagswithglobaltags" - << "qexecstringlist" << "singleskip" << "skip" << "skipinit" @@ -392,9 +391,6 @@ void tst_Selftests::runSubTest_data() if (subtest == "multiexec") { continue; } - if (subtest == "qexecstringlist") { - continue; - } if (subtest == "benchliboptions") { continue; } @@ -430,11 +426,20 @@ void tst_Selftests::runSubTest_data() } } +static inline QProcessEnvironment processEnvironment() +{ + QProcessEnvironment result; + const QString path = QStringLiteral("PATH"); + result.insert(path, QProcessEnvironment::systemEnvironment().value(path)); + return result; +} + void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments) { QProcess proc; - proc.setEnvironment(QStringList("")); - proc.start(subdir + "/" + subdir, arguments); + static const QProcessEnvironment environment = processEnvironment(); + proc.setProcessEnvironment(environment); + proc.start(subdir + QLatin1Char('/') + subdir, arguments); QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); QList<QByteArray> actualOutputs; @@ -473,6 +478,15 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge QString logger = loggers[n]; QList<QByteArray> res = splitLines(actualOutputs[n]); QList<QByteArray> exp = expectedResult(subdir, logger); +#ifdef Q_CC_MSVC + // MSVC formats double numbers differently + if (n == 0 && subdir == QStringLiteral("float")) { + for (int i = 0; i < exp.size(); ++i) { + exp[i].replace("e-07", "e-007"); + exp[i].replace("e+07", "e+007"); + } + } +#endif // For the "crashes" test, there are multiple versions of the // expected output. Load the one with the same line count as diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 8a2fdc97f3..8474293a54 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -10791,7 +10791,10 @@ void tst_QGraphicsItem::touchEventPropagation() touchPoints << tp; sendMousePress(&scene, tp.scenePos()); - QTouchEvent touchBegin(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + QTouchEvent touchBegin(QEvent::TouchBegin, device, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); qApp->sendEvent(&scene, &touchBegin); QCOMPARE(touchEventReceiver->touchBeginEventCount, expectedCount); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index cc3fd85da6..bf547cc7d9 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -60,16 +60,6 @@ Q_DECLARE_METATYPE(IntList) typedef QList<bool> BoolList; Q_DECLARE_METATYPE(BoolList) -// Will try to wait for the condition while allowing event processing -// for a maximum of 2 seconds. -#define WAIT_FOR_CONDITION(expr, expected) \ - do { \ - const int step = 100; \ - for (int i = 0; i < 2000 && expr != expected; i+=step) { \ - QTest::qWait(step); \ - } \ - } while(0) - class protected_QHeaderView : public QHeaderView { Q_OBJECT @@ -1447,23 +1437,12 @@ void tst_QHeaderView::focusPolicy() QApplication::setActiveWindow(&widget); QTest::qWaitForWindowShown(&widget); widget.activateWindow(); - QTest::qWait(100); - - qApp->processEvents(); - - WAIT_FOR_CONDITION(widget.hasFocus(), true); - - QVERIFY(widget.hasFocus()); + QTRY_VERIFY(widget.hasFocus()); QVERIFY(!widget.header()->hasFocus()); widget.setFocusPolicy(Qt::NoFocus); widget.clearFocus(); - - qApp->processEvents(); - qApp->processEvents(); - - WAIT_FOR_CONDITION(widget.hasFocus(), false); - QVERIFY(!widget.hasFocus()); + QTRY_VERIFY(!widget.hasFocus()); QVERIFY(!widget.header()->hasFocus()); QTest::keyPress(&widget, Qt::Key_Tab); diff --git a/tests/auto/widgets/itemviews/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/widgets/itemviews/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index fb5fe579a6..cc8299e28f 100644 --- a/tests/auto/widgets/itemviews/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/widgets/itemviews/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -148,6 +148,7 @@ private slots: void filteredColumns(); void testParentLayoutChanged(); + void moveSourceRows(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -3232,6 +3233,16 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() proxy.setDynamicSortFilter(true); proxy.setSourceModel(&model); + proxy.setObjectName("proxy"); + + // When Proxy1 emits layoutChanged(QList<QPersistentModelIndex>) this + // one will too, with mapped indexes. + QSortFilterProxyModel proxy2; + proxy2.sort(0, Qt::AscendingOrder); + proxy2.setDynamicSortFilter(true); + + proxy2.setSourceModel(&proxy); + proxy2.setObjectName("proxy2"); qRegisterMetaType<QList<QPersistentModelIndex> >(); @@ -3244,6 +3255,9 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); + QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QStandardItem *item = model.invisibleRootItem()->child(1)->child(1); // Ensure mapped: @@ -3256,6 +3270,8 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QCOMPARE(layoutChangedSpy.size(), 1); QCOMPARE(parentsAboutToBeChangedSpy.size(), 1); QCOMPARE(parentsChangedSpy.size(), 1); + QCOMPARE(proxy2ParentsAboutToBeChangedSpy.size(), 1); + QCOMPARE(proxy2ParentsChangedSpy.size(), 1); QVariantList beforeSignal = parentsAboutToBeChangedSpy.first(); QVariantList afterSignal = parentsChangedSpy.first(); @@ -3274,6 +3290,173 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QVERIFY(beforeParents.first() == proxy.mapFromSource(model.indexFromItem(model.invisibleRootItem()->child(1)))); + QList<QPersistentModelIndex> proxy2BeforeList = proxy2ParentsAboutToBeChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); + QList<QPersistentModelIndex> proxy2AfterList = proxy2ParentsChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); + + QCOMPARE(proxy2BeforeList.size(), beforeParents.size()); + QCOMPARE(proxy2AfterList.size(), afterParents.size()); + foreach (const QPersistentModelIndex &idx, proxy2BeforeList) + QVERIFY(beforeParents.contains(proxy2.mapToSource(idx))); + foreach (const QPersistentModelIndex &idx, proxy2AfterList) + QVERIFY(afterParents.contains(proxy2.mapToSource(idx))); + +} + +class SignalArgumentChecker : public QObject +{ + Q_OBJECT +public: + SignalArgumentChecker(QAbstractItemModel *model, QAbstractProxyModel *proxy, QObject *parent = 0) + : QObject(parent), m_model(model), m_proxy(proxy) + { + connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); + connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + connect(proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)), SLOT(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); + connect(proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)), SLOT(layoutChanged(QList<QPersistentModelIndex>))); + } + +private slots: + void rowsAboutToBeMoved(const QModelIndex &source, int, int, const QModelIndex &destination, int) + { + m_p1PersistentBefore = source; + m_p2PersistentBefore = destination; + m_p2FirstProxyChild = m_proxy->index(0, 0, m_proxy->mapFromSource(destination)); + } + + void rowsMoved(const QModelIndex &source, int, int, const QModelIndex &destination, int) + { + m_p1PersistentAfter = source; + m_p2PersistentAfter = destination; + } + + void layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents) + { + QVERIFY(m_p1PersistentBefore.isValid()); + QVERIFY(m_p2PersistentBefore.isValid()); + QCOMPARE(parents.size(), 2); + QVERIFY(parents.first() != parents.at(1)); + QVERIFY(parents.contains(m_proxy->mapFromSource(m_p1PersistentBefore))); + QVERIFY(parents.contains(m_proxy->mapFromSource(m_p2PersistentBefore))); + } + + void layoutChanged(const QList<QPersistentModelIndex> &parents) + { + QVERIFY(m_p1PersistentAfter.isValid()); + QVERIFY(m_p2PersistentAfter.isValid()); + QCOMPARE(parents.size(), 2); + QVERIFY(parents.first() != parents.at(1)); + QVERIFY(parents.contains(m_proxy->mapFromSource(m_p1PersistentAfter))); + QVERIFY(parents.contains(m_proxy->mapFromSource(m_p2PersistentAfter))); + + // In the source model, the rows were moved to row 1 in the parent. + // m_p2FirstProxyChild was created with row 0 in the proxy. + // The moved rows in the proxy do not appear at row 1 because of sorting. + // Sorting causes them to appear at row 0 instead, pushing what used to + // be row 0 in the proxy down by two rows. + QCOMPARE(m_p2FirstProxyChild.row(), 2); + } + +private: + QAbstractItemModel *m_model; + QAbstractProxyModel *m_proxy; + QPersistentModelIndex m_p1PersistentBefore; + QPersistentModelIndex m_p2PersistentBefore; + QPersistentModelIndex m_p1PersistentAfter; + QPersistentModelIndex m_p2PersistentAfter; + + QPersistentModelIndex m_p2FirstProxyChild; +}; + +void tst_QSortFilterProxyModel::moveSourceRows() +{ + qRegisterMetaType<QList<QPersistentModelIndex> >(); + + DynamicTreeModel model; + + { + ModelInsertCommand insertCommand(&model); + insertCommand.setStartRow(0); + insertCommand.setEndRow(9); + insertCommand.doCommand(); + } + { + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(QList<int>() << 2); + insertCommand.setStartRow(0); + insertCommand.setEndRow(9); + insertCommand.doCommand(); + } + { + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(QList<int>() << 5); + insertCommand.setStartRow(0); + insertCommand.setEndRow(9); + insertCommand.doCommand(); + } + + QSortFilterProxyModel proxy; + proxy.setDynamicSortFilter(true); + proxy.sort(0, Qt::AscendingOrder); + + // We need to check the arguments at emission time + SignalArgumentChecker checker(&model, &proxy); + + proxy.setSourceModel(&model); + + QSortFilterProxyModel filterProxy; + filterProxy.setDynamicSortFilter(true); + filterProxy.sort(0, Qt::AscendingOrder); + filterProxy.setSourceModel(&proxy); + filterProxy.setFilterRegExp("6"); // One of the parents + + QSortFilterProxyModel filterBothProxy; + filterBothProxy.setDynamicSortFilter(true); + filterBothProxy.sort(0, Qt::AscendingOrder); + filterBothProxy.setSourceModel(&proxy); + filterBothProxy.setFilterRegExp("5"); // The parents are 6 and 3. This filters both out. + + QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy proxyBeforeMoveSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy proxyAfterMoveSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy proxyBeforeParentLayoutSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); + QSignalSpy proxyAfterParentLayoutSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); + QSignalSpy filterAfterParentLayoutSpy(&filterProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); + QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + + { + ModelMoveCommand moveCommand(&model, 0); + moveCommand.setAncestorRowNumbers(QList<int>() << 2); + moveCommand.setDestAncestors(QList<int>() << 5); + moveCommand.setStartRow(3); + moveCommand.setEndRow(4); + moveCommand.setDestRow(1); + moveCommand.doCommand(); + } + + // Proxy notifies layout change + QCOMPARE(modelBeforeSpy.size(), 1); + QCOMPARE(proxyBeforeParentLayoutSpy.size(), 1); + QCOMPARE(modelAfterSpy.size(), 1); + QCOMPARE(proxyAfterParentLayoutSpy.size(), 1); + + // But it doesn't notify a move. + QCOMPARE(proxyBeforeMoveSpy.size(), 0); + QCOMPARE(proxyAfterMoveSpy.size(), 0); + + QCOMPARE(filterBeforeParentLayoutSpy.size(), 1); + QCOMPARE(filterAfterParentLayoutSpy.size(), 1); + + QList<QPersistentModelIndex> filterBeforeParents = filterBeforeParentLayoutSpy.first().first().value<QList<QPersistentModelIndex> >(); + QList<QPersistentModelIndex> filterAfterParents = filterAfterParentLayoutSpy.first().first().value<QList<QPersistentModelIndex> >(); + + QCOMPARE(filterBeforeParents.size(), 1); + QCOMPARE(filterAfterParents.size(), 1); + + QCOMPARE(filterBothBeforeParentLayoutSpy.size(), 0); + QCOMPARE(filterBothAfterParentLayoutSpy.size(), 0); } QTEST_MAIN(tst_QSortFilterProxyModel) diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 84aa8c7180..383fcf8b3f 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -46,16 +46,6 @@ #include <QtTest/QtTest> #include "private/qapplication_p.h" -// Will try to wait for the condition while allowing event processing -// for a maximum of 2 seconds. -#define WAIT_FOR_CONDITION(expr, expected) \ - do { \ - const int step = 100; \ - for (int i = 0; i < 2000 && expr != expected; i+=step) { \ - QTest::qWait(step); \ - } \ - } while(0) - #ifdef QT_BUILD_INTERNAL #define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) \ QVERIFY(static_cast<QTableViewPrivate*>(QObjectPrivate::get(TEST_VIEW_))->spans.checkConsistency()) @@ -3358,16 +3348,9 @@ void tst_QTableView::tabFocus() window.setFocus(); QTest::qWait(100); window.activateWindow(); - QTest::qWait(100); - - qApp->processEvents(); - - WAIT_FOR_CONDITION(window.hasFocus(), true); - - qApp->processEvents(); // window - QVERIFY(window.hasFocus()); + QTRY_VERIFY(window.hasFocus()); QVERIFY(!view->hasFocus()); QVERIFY(!edit->hasFocus()); diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index f6d0902533..d1f2304378 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -9,7 +9,6 @@ SUBDIRS=\ qgridlayout \ qinputcontext \ qlayout \ - qsound \ qstackedlayout \ qtooltip \ qwidget \ diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 8cf85dd8ea..81cdffe4e5 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1933,27 +1933,31 @@ void tst_QApplication::touchEventPropagation() release.setState(Qt::TouchPointReleased); releasedTouchPoints << release; + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + { // touch event behavior on a window TouchEventPropagationTestWidget window; window.setObjectName("1. window"); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(!window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); window.reset(); window.setAttribute(Qt::WA_AcceptTouchEvents); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); window.reset(); window.acceptTouchEvent = true; - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); } @@ -1965,8 +1969,8 @@ void tst_QApplication::touchEventPropagation() TouchEventPropagationTestWidget widget(&window); widget.setObjectName("2. widget"); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); @@ -1975,8 +1979,8 @@ void tst_QApplication::touchEventPropagation() window.reset(); widget.reset(); widget.setAttribute(Qt::WA_AcceptTouchEvents); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); @@ -1985,8 +1989,8 @@ void tst_QApplication::touchEventPropagation() window.reset(); widget.reset(); widget.acceptMouseEvent = true; - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); @@ -1995,8 +1999,8 @@ void tst_QApplication::touchEventPropagation() window.reset(); widget.reset(); widget.acceptTouchEvent = true; - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); @@ -2006,8 +2010,8 @@ void tst_QApplication::touchEventPropagation() widget.reset(); widget.setAttribute(Qt::WA_AcceptTouchEvents, false); window.setAttribute(Qt::WA_AcceptTouchEvents); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); @@ -2016,8 +2020,8 @@ void tst_QApplication::touchEventPropagation() window.reset(); widget.reset(); window.acceptTouchEvent = true; - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); @@ -2027,8 +2031,8 @@ void tst_QApplication::touchEventPropagation() widget.reset(); widget.acceptMouseEvent = true; // doesn't matter, touch events are propagated first window.acceptTouchEvent = true; - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints, 0); - qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, pressedTouchPoints, 0); + qt_translateRawTouchEvent(&window, device, releasedTouchPoints, 0); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); diff --git a/tests/auto/widgets/kernel/qsound/.gitignore b/tests/auto/widgets/kernel/qsound/.gitignore deleted file mode 100644 index c9d313c2cf..0000000000 --- a/tests/auto/widgets/kernel/qsound/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qsound diff --git a/tests/auto/widgets/kernel/qsound/4.wav b/tests/auto/widgets/kernel/qsound/4.wav Binary files differdeleted file mode 100644 index e31b060908..0000000000 --- a/tests/auto/widgets/kernel/qsound/4.wav +++ /dev/null diff --git a/tests/auto/widgets/kernel/qsound/qsound.pro b/tests/auto/widgets/kernel/qsound/qsound.pro deleted file mode 100644 index 8317283d54..0000000000 --- a/tests/auto/widgets/kernel/qsound/qsound.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qsound -SOURCES += tst_qsound.cpp -QT += testlib widgets - -wince* { - deploy.files += 4.wav - DEPLOYMENT += deploy - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index c8c8136f44..a7912aedc1 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -162,8 +162,11 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setPos(touchStart); touchPoint.setScenePos(touchStart); touchPoint.setScreenPos(touchStart); + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); QTouchEvent touchEvent1(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -177,7 +180,7 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setScenePos(touchUpdate); touchPoint.setScreenPos(touchUpdate); QTouchEvent touchEvent2(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointMoved, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -202,7 +205,7 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setScenePos(touchEnd); touchPoint.setScreenPos(touchEnd); QTouchEvent touchEvent5(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointReleased, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -233,8 +236,11 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setPos(touchStart); touchPoint.setScenePos(touchStart); touchPoint.setScreenPos(touchStart); + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); QTouchEvent touchEvent1(QEvent::TouchBegin, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -246,7 +252,7 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setScenePos(touchUpdate); touchPoint.setScreenPos(touchUpdate); QTouchEvent touchEvent2(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointMoved, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -259,7 +265,7 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setScenePos(touchEnd); touchPoint.setScreenPos(touchEnd); QTouchEvent touchEvent5(QEvent::TouchEnd, - QTouchEvent::TouchScreen, + device, Qt::NoModifier, Qt::TouchPointReleased, (QList<QTouchEvent::TouchPoint>() << touchPoint)); diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt index b6d5f318fd..1f2bd3e80a 100644 --- a/tests/manual/cmake/CMakeLists.txt +++ b/tests/manual/cmake/CMakeLists.txt @@ -29,3 +29,5 @@ endmacro() # expect_pass(pass1) expect_pass(pass2) expect_pass(pass3) +expect_fail(fail4) +expect_fail(fail5) diff --git a/tests/manual/cmake/fail4/CMakeLists.txt b/tests/manual/cmake/fail4/CMakeLists.txt new file mode 100644 index 0000000000..dcd4b8bd65 --- /dev/null +++ b/tests/manual/cmake/fail4/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass4) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +qt5_wrap_cpp(moc_files myobject.h) + +# Test options. The -binary option generates a binary to dlopen instead of +# a source file to compile. The compiler will consider it garbage when used +# in the add_executable call. +qt5_add_resources(rcc_files "pass4.qrc" OPTIONS -binary) + +add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) +target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/testlib/selftests/qexecstringlist/tst_qexecstringlist.cpp b/tests/manual/cmake/fail4/myobject.cpp index aacfab76f1..251239cde0 100644 --- a/tests/auto/testlib/selftests/qexecstringlist/tst_qexecstringlist.cpp +++ b/tests/manual/cmake/fail4/myobject.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -39,58 +39,16 @@ ** ****************************************************************************/ +#include "myobject.h" -#include <QtCore> -#include <QtTest/QtTest> - -class tst_QExecStringList: public QObject -{ - Q_OBJECT - -private slots: - void testA() const; - void testB() const; - void testB_data() const; - void testC() const; -}; - -void tst_QExecStringList::testA() const -{ -} - -void tst_QExecStringList::testB() const -{ - QFETCH(bool, dummy); - Q_UNUSED(dummy); -} - -void tst_QExecStringList::testB_data() const -{ - QTest::addColumn<bool>("dummy"); - - QTest::newRow("Data1") << false; - QTest::newRow("Data2") << false; - QTest::newRow("Data3") << false; -} - -void tst_QExecStringList::testC() const +MyObject::MyObject(QObject *parent) + : QObject(parent) { + emit someSignal(); } -int main(int argc,char *argv[]) +int main(int argc, char **argv) { - QCoreApplication app(argc, argv); - - tst_QExecStringList test; - - QTest::qExec(&test, app.arguments()); - QTest::qExec(&test, QStringList("appName")); - QTest::qExec(&test, QStringList("appName") << "testA"); - QTest::qExec(&test, QStringList("appName") << "testB"); - QTest::qExec(&test, QStringList("appName") << "testB:Data2"); - QTest::qExec(&test, QStringList("appName") << "testC"); - + MyObject myObject; return 0; } - -#include "tst_qexecstringlist.moc" diff --git a/tests/manual/cmake/fail4/myobject.h b/tests/manual/cmake/fail4/myobject.h new file mode 100644 index 0000000000..e2e908d32c --- /dev/null +++ b/tests/manual/cmake/fail4/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/manual/cmake/fail4/pass4.qrc b/tests/manual/cmake/fail4/pass4.qrc new file mode 100644 index 0000000000..00a17f541f --- /dev/null +++ b/tests/manual/cmake/fail4/pass4.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>resource_file.txt</file> +</qresource> +</RCC> + diff --git a/tests/manual/cmake/fail4/resource_file.txt b/tests/manual/cmake/fail4/resource_file.txt new file mode 100644 index 0000000000..2c604a4f18 --- /dev/null +++ b/tests/manual/cmake/fail4/resource_file.txt @@ -0,0 +1 @@ +Ken sent me. diff --git a/tests/manual/cmake/fail5/CMakeLists.txt b/tests/manual/cmake/fail5/CMakeLists.txt new file mode 100644 index 0000000000..f82a62b626 --- /dev/null +++ b/tests/manual/cmake/fail5/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass5) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +# Test options. The -i option removes the include "myobject.h" from the moc file +# causing a compile failure. -> Options work +qt5_wrap_cpp(moc_files myobject.h OPTIONS -i) + +add_executable(myobject myobject.cpp ${moc_files}) +target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/fail5/myobject.cpp b/tests/manual/cmake/fail5/myobject.cpp new file mode 100644 index 0000000000..251239cde0 --- /dev/null +++ b/tests/manual/cmake/fail5/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/manual/cmake/fail5/myobject.h b/tests/manual/cmake/fail5/myobject.h new file mode 100644 index 0000000000..e2e908d32c --- /dev/null +++ b/tests/manual/cmake/fail5/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt b/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt new file mode 100644 index 0000000000..cc1a1bc588 --- /dev/null +++ b/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 2.8) + +project("pass(needsquoting)6") + +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Widgets REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +qt5_wrap_cpp(moc_files mywidget.h) +qt5_wrap_ui(ui_files mywidget.ui) + +add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp b/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp new file mode 100644 index 0000000000..75804f9b3c --- /dev/null +++ b/tests/manual/cmake/pass(needsquoting)6/mywidget.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mywidget.h" +#include "ui_mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyWidget myWidget; + return 0; +} diff --git a/tests/auto/widgets/kernel/qsound/tst_qsound.cpp b/tests/manual/cmake/pass(needsquoting)6/mywidget.h index 5f1e5fb47c..0f59d3835e 100644 --- a/tests/auto/widgets/kernel/qsound/tst_qsound.cpp +++ b/tests/manual/cmake/pass(needsquoting)6/mywidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -39,45 +39,27 @@ ** ****************************************************************************/ +#ifndef MYWIDGET_H +#define MYWIDGET_H -#include <QtTest/QtTest> -#include <QtWidgets> +#include <QWidget> -class tst_QSound : public QObject +namespace Ui { - Q_OBJECT +class MyWidget; +} +class MyWidget : public QWidget +{ + Q_OBJECT public: - tst_QSound( QObject* parent=0) : QObject(parent) {} + MyWidget(QWidget *parent = 0); -private slots: - void checkFinished(); +signals: + void someSignal(); - // Manual tests - void staticPlay(); +private: + Ui::MyWidget *ui; }; -void tst_QSound::checkFinished() -{ - QSKIP("QSound is not implemented on Lighthouse"); - QSound sound(SRCDIR"4.wav"); - sound.setLoops(3); - sound.play(); - QTest::qWait(5000); - -#if defined(Q_WS_QWS) - QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort); #endif - QVERIFY(sound.isFinished() ); -} - -void tst_QSound::staticPlay() -{ - QSKIP("Test disabled -- only for manual purposes"); - // Check that you hear sound with static play also. - QSound::play(SRCDIR"4.wav"); - QTest::qWait(2000); -} - -QTEST_MAIN(tst_QSound); -#include "tst_qsound.moc" diff --git a/tests/manual/cmake/pass(needsquoting)6/mywidget.ui b/tests/manual/cmake/pass(needsquoting)6/mywidget.ui new file mode 100644 index 0000000000..ac42ac4dc2 --- /dev/null +++ b/tests/manual/cmake/pass(needsquoting)6/mywidget.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/cmake/pass2/CMakeLists.txt b/tests/manual/cmake/pass2/CMakeLists.txt index 153b038c02..ac1bb15846 100644 --- a/tests/manual/cmake/pass2/CMakeLists.txt +++ b/tests/manual/cmake/pass2/CMakeLists.txt @@ -9,5 +9,7 @@ include_directories(${Qt5Core_INCLUDE_DIRS}) qt5_wrap_cpp(moc_files myobject.h) -add_executable(myobject myobject.cpp ${moc_files}) +qt5_add_resources(rcc_files "pass2.qrc") + +add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/manual/cmake/pass2/myobject.cpp b/tests/manual/cmake/pass2/myobject.cpp index 251239cde0..0f3d8b5b50 100644 --- a/tests/manual/cmake/pass2/myobject.cpp +++ b/tests/manual/cmake/pass2/myobject.cpp @@ -50,5 +50,7 @@ MyObject::MyObject(QObject *parent) int main(int argc, char **argv) { MyObject myObject; + // Compile error if the resource file was not created. + Q_INIT_RESOURCE(pass2); return 0; } diff --git a/tests/manual/cmake/pass2/pass2.qrc b/tests/manual/cmake/pass2/pass2.qrc new file mode 100644 index 0000000000..00a17f541f --- /dev/null +++ b/tests/manual/cmake/pass2/pass2.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>resource_file.txt</file> +</qresource> +</RCC> + diff --git a/tests/manual/cmake/pass2/resource_file.txt b/tests/manual/cmake/pass2/resource_file.txt new file mode 100644 index 0000000000..2c604a4f18 --- /dev/null +++ b/tests/manual/cmake/pass2/resource_file.txt @@ -0,0 +1 @@ +Ken sent me. |