diff options
author | Liang Qi <liang.qi@qt.io> | 2017-03-20 08:44:28 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-03-20 09:00:44 +0100 |
commit | ae2695535a2f1abbd4c6596a22dd33319b9388dd (patch) | |
tree | 91df41df365a13ea71b1361d909535e5b7a7360a /tests/auto | |
parent | 8066ae49433ed7604e710eef7b15d15de171608e (diff) | |
parent | c1a2f97a3b3a8c058b1760b57e5c83bf7815b84a (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/corelib/io/qfilesystemengine_win.cpp
src/gui/text/qdistancefield.cpp
src/plugins/platforms/xcb/qxcbconnection.h
Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
Diffstat (limited to 'tests/auto')
68 files changed, 658 insertions, 326 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index cadd97fb3a..d3c4d470f5 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -23,6 +23,7 @@ uikit: SUBDIRS = corelib gui wince: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools cmake installed_cmake +else:!qtConfig(process): SUBDIRS -= tools !qtHaveModule(opengl): SUBDIRS -= opengl !qtHaveModule(gui): SUBDIRS -= gui !qtHaveModule(widgets): SUBDIRS -= widgets diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index bdd862e316..0f2e9b5d68 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -33,7 +33,9 @@ #include <qtextcodec.h> #include <qfile.h> #include <time.h> -#include <qprocess.h> +#if QT_CONFIG(process) +# include <qprocess.h> +#endif #include <QThreadPool> class tst_QTextCodec : public QObject @@ -2085,7 +2087,7 @@ void tst_QTextCodec::codecForUtfText() #if defined(Q_OS_UNIX) void tst_QTextCodec::toLocal8Bit() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess process; diff --git a/tests/auto/corelib/codecs/utf8/utf8data.cpp b/tests/auto/corelib/codecs/utf8/utf8data.cpp index 603ebbbcef..2267dc8514 100644 --- a/tests/auto/corelib/codecs/utf8/utf8data.cpp +++ b/tests/auto/corelib/codecs/utf8/utf8data.cpp @@ -85,10 +85,10 @@ void loadInvalidUtf8Rows() // overlong 6: xxxx:xxz0 xz00:0000 xz00:0000 xz00:0000 xz00:0001 xz00:0001 QTest::newRow("overlong-1-6") << QByteArray("\xFC\x80\x80\x80\x81\x81"); - // NBSP: U+00A0: 10 00 0000 + // U+0080: 10 00 0000 // proper encoding: xxz0:0010 xz00:0000 // overlong 3: xxxz:0000 xz00:0010 xz00:0000 - QTest::newRow("overlong-2-3") << QByteArray("\xC0\x82\x80"); + QTest::newRow("overlong-2-3") << QByteArray("\xE0\x82\x80"); // overlong 4: xxxx:z000 xz00:0000 xz00:0010 xz00:0000 QTest::newRow("overlong-2-4") << QByteArray("\xF0\x80\x82\x80"); // overlong 5: xxxx:xz00 xz00:0000 xz00:0000 xz00:0010 xz00:0000 diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index c2d7338042..bb8bb6cc21 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -29,7 +29,9 @@ #include <qdebug.h> #include <qglobal.h> -#include <QtCore/QProcess> +#if QT_CONFIG(process) +# include <QtCore/QProcess> +#endif #include <QtTest/QTest> class tst_qmessagehandler : public QObject @@ -102,7 +104,7 @@ void tst_qmessagehandler::initTestCase() QVERIFY2(!m_appDir.isEmpty(), qPrintable( QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath()))); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) m_baseEnvironment = QProcess::systemEnvironment(); for (int i = 0; i < m_baseEnvironment.count(); ++i) { if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) { @@ -110,7 +112,7 @@ void tst_qmessagehandler::initTestCase() break; } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_qmessagehandler::cleanup() @@ -813,7 +815,7 @@ void tst_qmessagehandler::qMessagePattern_data() void tst_qmessagehandler::qMessagePattern() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, pattern); @@ -855,7 +857,7 @@ void tst_qmessagehandler::qMessagePattern() void tst_qmessagehandler::setMessagePattern() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else @@ -892,7 +894,7 @@ void tst_qmessagehandler::setMessagePattern() output.replace("\r\n", "\n"); #endif QCOMPARE(QString::fromLatin1(output), QString::fromLatin1(expected)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } Q_DECLARE_METATYPE(QtMsgType) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index b64de488ed..762cb539e0 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -855,7 +855,7 @@ void tst_QDir::entryList() void tst_QDir::entryListTimedSort() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString touchBinary = "/bin/touch"; if (!QFile::exists(touchBinary)) QSKIP("/bin/touch not found"); @@ -889,7 +889,7 @@ void tst_QDir::entryListTimedSort() QCOMPARE(actual.last(), aFileInfo.fileName()); #else QSKIP("This test requires QProcess support."); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QDir::entryListSimple_data() diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 57e197aa83..a23ebc8d72 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -50,7 +50,9 @@ QT_END_NAMESPACE #if !defined(QT_NO_NETWORK) #include <QHostInfo> #endif -#include <QProcess> +#if QT_CONFIG(process) +# include <QProcess> +#endif #ifdef Q_OS_WIN # include <qt_windows.h> #else @@ -884,7 +886,7 @@ void tst_QFile::readAllBuffer() QFile::remove(fileName); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class StdinReaderProcessGuard { // Ensure the stdin reader process is stopped on destruction. Q_DISABLE_COPY(StdinReaderProcessGuard) @@ -908,11 +910,11 @@ public: private: QProcess *m_process; }; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_QFile::readAllStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QByteArray lotsOfData(1024, '@'); // 10 megs @@ -935,7 +937,7 @@ void tst_QFile::readAllStdin() void tst_QFile::readLineStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QByteArray lotsOfData(1024, '@'); // 10 megs @@ -976,7 +978,7 @@ void tst_QFile::readLineStdin() void tst_QFile::readLineStdin_lineByLine() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else for (int i = 0; i < 2; ++i) { @@ -1139,6 +1141,7 @@ void tst_QFile::invalidFile_data() #else #if !defined(Q_OS_WINRT) QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); + QTest::newRow( "date" ) << QString( "testLog-03:20.803Z.txt" ); #endif QTest::newRow( "colon3" ) << QString( ":failinvalid" ); QTest::newRow( "forwardslash" ) << QString( "fail/invalid" ); @@ -1684,7 +1687,7 @@ void tst_QFile::isSequential() void tst_QFile::encodeName() { - QCOMPARE(QFile::encodeName(QString::null), QByteArray()); + QCOMPARE(QFile::encodeName(QString()), QByteArray()); } void tst_QFile::truncate() diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 7bdebd1593..87b579bb2b 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -31,7 +31,6 @@ #include <qfile.h> #include <qdir.h> #include <qcoreapplication.h> -#include <qlibrary.h> #include <qtemporaryfile.h> #include <qtemporarydir.h> #include <qdir.h> diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index b21701f341..a13ff0358a 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -72,7 +72,7 @@ void tst_QLockFile::initTestCase() { #if defined(Q_OS_ANDROID) QSKIP("This test requires deploying and running external console applications"); -#elif defined(QT_NO_PROCESS) +#elif !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); @@ -80,7 +80,7 @@ void tst_QLockFile::initTestCase() QString testdata_dir = QFileInfo(QFINDTESTDATA("qlockfiletesthelper")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); m_helperApp = "qlockfiletesthelper/qlockfile_test_helper"; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::lockUnlock() @@ -114,7 +114,7 @@ void tst_QLockFile::lockUnlock() void tst_QLockFile::lockOutOtherProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else // Lock @@ -138,7 +138,7 @@ void tst_QLockFile::lockOutOtherProcess() QCOMPARE(ret, int(QLockFile::NoError)); // Lock doesn't survive process though (on clean exit) QVERIFY(!QFile::exists(fileName)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static QLockFile::LockError tryLockFromThread(const QString &fileName) @@ -254,7 +254,7 @@ void tst_QLockFile::staleLockFromCrashedProcess_data() void tst_QLockFile::staleLockFromCrashedProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(int, staleLockTime); @@ -274,12 +274,12 @@ void tst_QLockFile::staleLockFromCrashedProcess() QVERIFY(secondLock.tryLock()); #endif QCOMPARE(int(secondLock.error()), int(QLockFile::NoError)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleLockFromCrashedProcessReusedPid() { -#if defined(QT_NO_PROCESS) +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #elif defined(Q_OS_WINRT) || defined(QT_PLATFORM_UIKIT) QSKIP("We cannot retrieve information about other processes on this platform."); @@ -298,12 +298,12 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid() secondLock.setStaleLockTime(0); QVERIFY(secondLock.tryLock()); QCOMPARE(int(secondLock.error()), int(QLockFile::NoError)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleShortLockFromBusyProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else const QString fileName = dir.path() + "/staleLockFromBusyProcess"; @@ -331,12 +331,12 @@ void tst_QLockFile::staleShortLockFromBusyProcess() proc.waitForFinished(); QVERIFY(secondLock.tryLock()); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleLongLockFromBusyProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else const QString fileName = dir.path() + "/staleLockFromBusyProcess"; @@ -358,7 +358,7 @@ void tst_QLockFile::staleLongLockFromBusyProcess() QVERIFY(!secondLock.removeStaleLockFile()); proc.waitForFinished(); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static QString tryStaleLockFromThread(const QString &fileName) @@ -388,7 +388,7 @@ static QString tryStaleLockFromThread(const QString &fileName) void tst_QLockFile::staleLockRace() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else // Multiple threads notice a stale lock at the same time @@ -406,7 +406,7 @@ void tst_QLockFile::staleLockRace() synchronizer.waitForFinished(); foreach (const QFuture<QString> &future, synchronizer.futures()) QVERIFY2(future.result().isEmpty(), qPrintable(future.result())); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::noPermissions() diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp index d76156219e..b7367ff8c6 100644 --- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp @@ -38,7 +38,6 @@ int main(int argc, char **argv) if (argc < 3) return 13; -#ifndef QT_NO_PROCESS QProcess process; QProcess::ProcessChannelMode mode = (QProcess::ProcessChannelMode)atoi(argv[1]); @@ -69,6 +68,5 @@ int main(int argc, char **argv) if ((mode == QProcess::ForwardedErrorChannel || mode == QProcess::ForwardedChannels) && !process.readAllStandardError().isEmpty()) return 6; -#endif return 0; } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 03c28f4d0b..0783a65d8b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -53,7 +53,6 @@ public slots: void cleanupTestCase(); void init(); -#ifndef QT_NO_PROCESS private slots: void getSetCheck(); void constructing(); @@ -159,26 +158,18 @@ protected slots: private: qint64 bytesAvailable; QTemporaryDir m_temporaryDir; -#endif //QT_NO_PROCESS }; void tst_QProcess::initTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); // chdir to our testdata path and execute helper apps relative to that. QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); -#endif } void tst_QProcess::cleanupTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#endif } void tst_QProcess::init() @@ -186,8 +177,6 @@ void tst_QProcess::init() bytesAvailable = 0; } -#ifndef QT_NO_PROCESS - // Testing get/set functions void tst_QProcess::getSetCheck() { @@ -2406,7 +2395,5 @@ void tst_QProcess::processEventsInAReadyReadSlot() QVERIFY(process.waitForFinished()); } -#endif //QT_NO_PROCESS - QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 7f29e2a7d7..0e423a56ca 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -40,8 +40,9 @@ #include <QTemporaryDir> #include <QTextStream> #include <QTextCodec> -#include <QProcess> - +#if QT_CONFIG(process) +# include <QProcess> +#endif #include "../../../network-settings.h" @@ -1493,7 +1494,7 @@ void tst_QTextStream::pos3LargeFile() // ------------------------------------------------------------------------------ void tst_QTextStream::readStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; @@ -1520,7 +1521,7 @@ void tst_QTextStream::readStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readAllFromStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; @@ -1541,7 +1542,7 @@ void tst_QTextStream::readAllFromStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readLineFromStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index a7c608ec2e..31e76c4407 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -928,7 +928,7 @@ void tst_QCoreApplication::threadedEventDelivery() QCOMPARE(receiver.recordedEvents.contains(QEvent::User + 1), eventsReceived); } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void tst_QCoreApplication::addRemoveLibPaths() { QStringList paths = QCoreApplication::libraryPaths(); diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index 342bd272a3..b6c20a915f 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -59,7 +59,7 @@ private slots: void applicationEventFilters_auxThread(); void threadedEventDelivery_data(); void threadedEventDelivery(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void addRemoveLibPaths(); #endif }; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f44c40c27f..db6bdf0809 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -41,8 +41,9 @@ #include <QThread> #include <QMutex> #include <QWaitCondition> -#include <QProcess> - +#if QT_CONFIG(process) +# include <QProcess> +#endif #include "qobject.h" #ifdef QT_BUILD_INTERNAL #include <private/qobject_p.h> @@ -281,7 +282,7 @@ static void playWithObjects() void tst_QObject::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString testDataDir = QFileInfo(QFINDTESTDATA("signalbug")).absolutePath(); QVERIFY2(QDir::setCurrent(testDataDir), qPrintable("Could not chdir to " + testDataDir)); #endif @@ -3006,7 +3007,7 @@ void tst_QObject::dynamicProperties() void tst_QObject::recursiveSignalEmission() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess proc; @@ -5306,6 +5307,15 @@ void tst_QObject::connectNoDefaultConstructorArg() QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection)); } +struct MoveOnly +{ + int value; + explicit MoveOnly(int v = 1) : value(v) {} + MoveOnly(MoveOnly &&o) : value(o.value) { o.value = -1; } + MoveOnly &operator=(MoveOnly &&o) { value = o.value; o.value = -1; return *this; } + Q_DISABLE_COPY(MoveOnly); +}; + class ReturnValue : public QObject { friend class tst_QObject; Q_OBJECT @@ -5315,6 +5325,7 @@ signals: int returnInt(int); void returnVoid(int); CustomType returnCustomType(int); + MoveOnly returnMoveOnly(int); QObject *returnPointer(); public slots: @@ -5327,6 +5338,7 @@ public slots: QString returnHello() { return QStringLiteral("hello"); } QObject *returnThisSlot1() { return this; } ReturnValue *returnThisSlot2() { return this; } + MoveOnly returnMoveOnlySlot(int i) { return MoveOnly(i); } public: struct VariantFunctor { QVariant operator()(int i) { return i; } @@ -5343,6 +5355,9 @@ public: struct VoidFunctor { void operator()(int) {} }; + struct MoveOnlyFunctor { + MoveOnly operator()(int i) { return MoveOnly(i); } + }; }; QString someFunctionReturningString(int i) { @@ -5380,6 +5395,7 @@ void tst_QObject::returnValue() emit r.returnVoid(45); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } { // connected to a slot returning the same type CheckInstanceCount checker; @@ -5394,6 +5410,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(&receiver)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } if (!isBlockingQueued) { // connected to simple functions or functor CheckInstanceCount checker; @@ -5412,6 +5430,10 @@ void tst_QObject::returnValue() ReturnValue::IntFunctor intFunctor; QVERIFY(connect(&r, &ReturnValue::returnInt, intFunctor)); QCOMPARE(emit r.returnInt(45), int(45)); + + ReturnValue::MoveOnlyFunctor moveOnlyFunctor; + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, moveOnlyFunctor)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } { // connected to a slot with different type CheckInstanceCount checker; @@ -5450,6 +5472,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnVoidSlot, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnVoidSlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5465,6 +5489,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, Qt::QueuedConnection)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); QCoreApplication::processEvents(); @@ -5548,6 +5574,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int(45)); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, 45); } { // connected to a slot returning void CheckInstanceCount checker; @@ -5560,6 +5588,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnVoidSlot()), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnVoidSlot()), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5573,6 +5603,9 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), Qt::QueuedConnection)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); + QCoreApplication::processEvents(); //Queued conneciton with different return type should be safe @@ -5679,6 +5712,27 @@ public slots: virtual void slot2() { ++virtual_base_count; } }; +struct NormalBase +{ + QByteArray lastCalled; + virtual ~NormalBase() {} + virtual void virtualBaseSlot() { lastCalled = "virtualBaseSlot"; } + void normalBaseSlot() { lastCalled = "normalBaseSlot"; } +}; + +class ObjectWithMultiInheritance : public VirtualSlotsObject, public NormalBase +{ + Q_OBJECT +}; + +// Normally, the class that inherit QObject always must go first, because of the way qobject_cast +// work, and moc checks for that. But if we don't use Q_OBJECT, this should work +class ObjectWithMultiInheritance2 : public NormalBase, public VirtualSlotsObject +{ + // no QObject as QObject always must go first + // Q_OBJECT +}; + // VMI = Virtual or Multiple Inheritance // (in this case, both) void tst_QObject::connectSlotsVMIClass() @@ -5761,6 +5815,93 @@ void tst_QObject::connectSlotsVMIClass() QCOMPARE(obj.virtual_base_count, 1); QCOMPARE(obj.regular_call_count, 0); } + + // test connecting a slot that is virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::virtualBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("virtualBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot that is not virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the first non-QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the second QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::slot1; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + } } #ifndef QT_BUILD_INTERNAL diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index 26caff4301..8833321b4f 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -28,7 +28,9 @@ #include <QDebug> #include <QFile> -#include <QProcess> +#if QT_CONFIG(process) +# include <QProcess> +#endif #include <QSharedMemory> #include <QTest> #include <QThread> @@ -133,7 +135,7 @@ tst_QSharedMemory::~tst_QSharedMemory() void tst_QSharedMemory::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary"); #endif } @@ -455,7 +457,7 @@ void tst_QSharedMemory::emptyMemory() #if !defined(Q_OS_WIN) void tst_QSharedMemory::readOnly() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else rememberKey("readonly_segfault"); @@ -736,7 +738,7 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer() void tst_QSharedMemory::simpleProcessProducerConsumer_data() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QTest::addColumn<int>("processes"); int tries = 5; for (int i = 0; i < tries; ++i) { @@ -751,7 +753,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer_data() */ void tst_QSharedMemory::simpleProcessProducerConsumer() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QFETCH(int, processes); diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp index 641ea5fc9d..6ff1e14976 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -172,7 +172,7 @@ void tst_QSystemSemaphore::release() void tst_QSystemSemaphore::basicProcesses() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 0, QSystemSemaphore::Create); @@ -208,7 +208,7 @@ void tst_QSystemSemaphore::processes_data() void tst_QSystemSemaphore::processes() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); @@ -237,7 +237,7 @@ void tst_QSystemSemaphore::processes() #if !defined(Q_OS_WIN) && !defined(QT_POSIX_IPC) void tst_QSystemSemaphore::undo() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); @@ -262,7 +262,7 @@ void tst_QSystemSemaphore::undo() void tst_QSystemSemaphore::initialValue() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp index 1ca730d0c7..529c8942b3 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp @@ -36,7 +36,7 @@ void tst_QMimeDatabase::initTestCaseInternal() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else const QString mimeDirName = m_globalXdgDir + QStringLiteral("/mime"); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 2edb94d542..02ba987ccd 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -858,7 +858,7 @@ void tst_QMimeDatabase::fromThreads() QVERIFY(tp.waitForDone(60000)); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) enum { UpdateMimeDatabaseTimeout = 120 * 1000 // 2min @@ -901,7 +901,7 @@ static bool waitAndRunUpdateMimeDatabase(const QString &path) } return runUpdateMimeDatabase(path); } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) static void checkHasMimeType(const QString &mimeType) { @@ -936,7 +936,7 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QSKIP("This test requires XDG_DATA_DIRS"); #endif -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else qmime_secondsBetweenChecks = 0; @@ -989,12 +989,12 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QMimeDatabase::installNewLocalMimeType() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else qmime_secondsBetweenChecks = 0; @@ -1057,7 +1057,7 @@ void tst_QMimeDatabase::installNewLocalMimeType() QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); -#endif +#endif // QT_CONFIG(process) } QTEST_GUILESS_MAIN(tst_QMimeDatabase) diff --git a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp index fe6b1ca299..34dc103672 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp +++ b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp @@ -29,11 +29,12 @@ #include <QtTest/qtest.h> #include <QtCore/qdir.h> #include <QtCore/qfileinfo.h> +#include <QtCore/qplugin.h> #include <private/qfactoryloader_p.h> #include "plugin1/plugininterface1.h" #include "plugin2/plugininterface2.h" -#ifdef QT_NO_LIBRARY +#if !QT_CONFIG(library) Q_IMPORT_PLUGIN(Plugin1) Q_IMPORT_PLUGIN(Plugin2) #endif @@ -54,7 +55,7 @@ void tst_QFactoryLoader::initTestCase() { const QString binFolder = QFINDTESTDATA(binFolderC); QVERIFY2(!binFolder.isEmpty(), "Unable to locate 'bin' folder"); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QCoreApplication::setLibraryPaths(QStringList(QFileInfo(binFolder).absolutePath())); #endif } diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index e2c137e25f..cb45336d4c 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -91,7 +91,7 @@ void tst_QUuid::initTestCase() //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; uuidB = QUuid(0x1ab6e93a, 0xb1cb, 0x4a87, 0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) // chdir to the directory containing our testdata, then refer to it with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); @@ -338,7 +338,7 @@ void tst_QUuid::threadUniqueness() void tst_QUuid::processUniqueness() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess process; diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index 5f67ffedd1..37b052bf1d 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -43,6 +43,11 @@ # undef interface #endif +struct ResultStoreInt : QtPrivate::ResultStoreBase +{ + ~ResultStoreInt() { clear<int>(); } +}; + class tst_QFuture: public QObject { Q_OBJECT @@ -78,7 +83,7 @@ void tst_QFuture::resultStore() int int2 = 2; { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; QCOMPARE(store.begin(), store.end()); QCOMPARE(store.resultAt(0), store.end()); QCOMPARE(store.resultAt(1), store.end()); @@ -86,9 +91,9 @@ void tst_QFuture::resultStore() { - QtPrivate::ResultStoreBase store; - store.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since - store.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. + ResultStoreInt store; + store.addResult(-1, &int0); + store.addResult(1, &int1); QtPrivate::ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QVERIFY(it == store.begin()); @@ -108,9 +113,9 @@ void tst_QFuture::resultStore() QVector<int> vec1 = QVector<int>() << 4 << 5; { - QtPrivate::ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); + ResultStoreInt store; + store.addResults(-1, &vec0, 2); + store.addResults(-1, &vec1, 2); QtPrivate::ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QCOMPARE(it, store.begin()); @@ -131,9 +136,9 @@ void tst_QFuture::resultStore() QCOMPARE(it, store.end()); } { - QtPrivate::ResultStoreBase store; + ResultStoreInt store; store.addResult(-1, &int0); - store.addResults(-1, &vec1, 2, 2); + store.addResults(-1, &vec1, 2); store.addResult(-1, &int1); QtPrivate::ResultIteratorBase it = store.begin(); @@ -162,7 +167,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.resultAt(4), store.end()); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(-1, &int1); @@ -186,36 +191,36 @@ void tst_QFuture::resultStore() ++it; QVERIFY(it == store.end()); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), vec0[0]); + QCOMPARE(store.resultAt(2).value<int>(), vec0[1]); + QCOMPARE(store.resultAt(3).value<int>(), int1); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(200, &int1); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), vec0[0]); + QCOMPARE(store.resultAt(2).value<int>(), vec0[1]); + QCOMPARE(store.resultAt(200).value<int>(), int1); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(1, &int1); store.addResult(0, &int0); store.addResult(-1, &int2); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), int1); + QCOMPARE(store.resultAt(2).value<int>(), int2); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; QCOMPARE(store.contains(0), false); QCOMPARE(store.contains(1), false); QCOMPARE(store.contains(INT_MAX), false); @@ -223,7 +228,7 @@ void tst_QFuture::resultStore() { // Test filter mode, where "gaps" in the result array aren't allowed. - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -257,7 +262,7 @@ void tst_QFuture::resultStore() { // test canceled results - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -294,7 +299,7 @@ void tst_QFuture::resultStore() { // test addResult return value - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -340,7 +345,7 @@ void tst_QFuture::resultStore() { // test resultCount in non-filtered mode. It should always be possible // to iterate through the results 0 to resultCount. - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(0, &int0); QCOMPARE(store.count(), 1); @@ -354,7 +359,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(2, &int0); QCOMPARE(store.count(), 0); @@ -366,7 +371,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -378,7 +383,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -386,7 +391,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.count(), 4); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -398,7 +403,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -411,22 +416,22 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults<int>(0, 3); QCOMPARE(store.count(), 2); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults<int>(0, 3); QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 store.addResult(5, &int0); @@ -434,7 +439,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.addResult(1, &int0); store.addResult(3, &int0); store.addResults(6, &vec0); @@ -449,7 +454,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(1, &int0); store.addResult(3, &int0); @@ -465,7 +470,7 @@ void tst_QFuture::resultStore() store.addCanceledResult(0); store.addCanceledResult(2); - store.addCanceledResults(4, 2); + store.addCanceledResults<int>(4, 2); QCOMPARE(store.contains(0), true); QCOMPARE(store.contains(1), true); @@ -477,7 +482,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.contains(7), false); } { - QtPrivate::ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addCanceledResult(0); QCOMPARE(store.contains(0), false); diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index e6c3a0cfd7..0962001741 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -36,11 +36,6 @@ #include <qthread.h> #include <qwaitcondition.h> -#ifdef Q_OS_WIN -#include <private/qsystemlibrary_p.h> -#include <cmath> -#endif - class tst_QMutex : public QObject { Q_OBJECT @@ -54,7 +49,6 @@ public: Q_ENUM(TimeUnit); private slots: - void initTestCase(); void convertToMilliseconds_data(); void convertToMilliseconds(); void tryLock_non_recursive(); @@ -70,8 +64,6 @@ private slots: void tryLockNegative_data(); void tryLockNegative(); void moreStress(); -private: - void initializeSystemTimersResolution(); }; static const int iterations = 100; @@ -81,57 +73,24 @@ QMutex normalMutex, recursiveMutex(QMutex::Recursive); QSemaphore testsTurn; QSemaphore threadsTurn; -enum { waitTime = 100 }; -uint systemTimersResolution = 1; - -#if QT_HAS_INCLUDE(<chrono>) -static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime); -#endif - /* Depending on the OS, tryWaits may return early than expected because of the resolution of the underlying timer is too coarse. E.g.: on Windows WaitForSingleObjectEx does *not* use high resolution multimedia timers, and it's actually very coarse, about 16msec by default. - - Try to find out the timer resolution in here, so that the tryLock tests can - actually take into account early wakes. */ -void tst_QMutex::initializeSystemTimersResolution() -{ +enum { #ifdef Q_OS_WIN - // according to MSDN, Windows can default up to this - systemTimersResolution = 16; - - // private API. There's no way on Windows to otherwise know the - // actual resolution of the application's timers (you can only set it) - // cf. https://stackoverflow.com/questions/7685762/windows-7-timing-functions-how-to-use-getsystemtimeadjustment-correctly/11743614#11743614 - typedef NTSTATUS (NTAPI *NtQueryTimerResolutionType)(OUT PULONG MinimumResolution, - OUT PULONG MaximumResolution, - OUT PULONG ActualResolution); - - const NtQueryTimerResolutionType NtQueryTimerResolutionPtr = - reinterpret_cast<NtQueryTimerResolutionType>(QSystemLibrary::resolve(QStringLiteral("ntdll"), "NtQueryTimerResolution")); - - if (!NtQueryTimerResolutionPtr) - return; - - ULONG minimumResolution; - ULONG maximumResolution; - ULONG actualResolution; - - if (!NtQueryTimerResolutionPtr(&minimumResolution, &maximumResolution, &actualResolution)) { - // the result is in 100ns units => adjust to msec - const double actualResolutionMsec = actualResolution / 10000.0; - systemTimersResolution = static_cast<int>(std::ceil(actualResolutionMsec)); - } -#endif // Q_OS_WIN -} + systemTimersResolution = 16, +#else + systemTimersResolution = 1, +#endif + waitTime = 100 +}; -void tst_QMutex::initTestCase() -{ - initializeSystemTimersResolution(); -} +#if QT_HAS_INCLUDE(<chrono>) +static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime); +#endif void tst_QMutex::convertToMilliseconds_data() { diff --git a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp index 3626b8db33..fba617e34d 100644 --- a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp +++ b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp @@ -32,6 +32,11 @@ using namespace QtPrivate; +struct ResultStoreInt : ResultStoreBase +{ + ~ResultStoreInt() { clear<int>(); } +}; + class tst_QtConcurrentResultStore : public QObject { Q_OBJECT @@ -67,20 +72,20 @@ void tst_QtConcurrentResultStore::init() void tst_QtConcurrentResultStore::construction() { - ResultStore<int> store; + ResultStoreBase store; QCOMPARE(store.count(), 0); } void tst_QtConcurrentResultStore::iterators() { { - ResultStore<int> store; + ResultStoreBase store; QCOMPARE(store.begin(), store.end()); QCOMPARE(store.resultAt(0), store.end()); QCOMPARE(store.resultAt(1), store.end()); } { - ResultStoreBase storebase; + ResultStoreInt storebase; storebase.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since storebase.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. ResultIteratorBase it = storebase.begin(); @@ -103,7 +108,7 @@ void tst_QtConcurrentResultStore::addResult() { { // test addResult return value - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); QCOMPARE(store.addResult(0, &int0), 0); @@ -149,10 +154,9 @@ void tst_QtConcurrentResultStore::addResult() void tst_QtConcurrentResultStore::addResults() { - - ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); + ResultStoreInt store; + store.addResults(-1, &vec0); + store.addResults(-1, &vec1); ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QCOMPARE(it, store.begin()); @@ -175,7 +179,7 @@ void tst_QtConcurrentResultStore::addResults() void tst_QtConcurrentResultStore::resultIndex() { - ResultStore<int> store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(-1, &int1); @@ -199,41 +203,41 @@ void tst_QtConcurrentResultStore::resultIndex() ++it; QVERIFY(it == store.end()); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), vec0[0]); + QCOMPARE(store.resultAt(2).value<int>(), vec0[1]); + QCOMPARE(store.resultAt(3).value<int>(), int1); } void tst_QtConcurrentResultStore::resultAt() { { - ResultStore<int> store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(200, &int1); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), vec0[0]); + QCOMPARE(store.resultAt(2).value<int>(), vec0[1]); + QCOMPARE(store.resultAt(200).value<int>(), int1); } { - ResultStore<int> store; + ResultStoreInt store; store.addResult(1, &int1); store.addResult(0, &int0); store.addResult(-1, &int2); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); + QCOMPARE(store.resultAt(0).value<int>(), int0); + QCOMPARE(store.resultAt(1).value<int>(), int1); + QCOMPARE(store.resultAt(2).value<int>(), int2); } } void tst_QtConcurrentResultStore::contains() { { - ResultStore<int> store; + ResultStoreInt store; QCOMPARE(store.contains(0), false); QCOMPARE(store.contains(1), false); QCOMPARE(store.contains(INT_MAX), false); @@ -245,7 +249,7 @@ void tst_QtConcurrentResultStore::contains() QVERIFY(store.contains(int2)); } { - ResultStore<int> store; + ResultStoreInt store; store.addResult(1, &int0); store.addResult(3, &int0); store.addResults(6, &vec0); @@ -260,7 +264,7 @@ void tst_QtConcurrentResultStore::contains() } { - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(1, &int0); store.addResult(3, &int0); @@ -276,7 +280,7 @@ void tst_QtConcurrentResultStore::contains() store.addCanceledResult(0); store.addCanceledResult(2); - store.addCanceledResults(4, 2); + store.addCanceledResults<int>(4, 2); QCOMPARE(store.contains(0), true); QCOMPARE(store.contains(1), true); @@ -288,7 +292,7 @@ void tst_QtConcurrentResultStore::contains() QCOMPARE(store.contains(7), false); } { - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addCanceledResult(0); QCOMPARE(store.contains(0), false); @@ -302,7 +306,7 @@ void tst_QtConcurrentResultStore::contains() void tst_QtConcurrentResultStore::filterMode() { // Test filter mode, where "gaps" in the result array aren't allowed. - ResultStore<int> store; + ResultStoreInt store; QCOMPARE(store.filterMode(), false); store.setFilterMode(true); QVERIFY(store.filterMode()); @@ -339,7 +343,7 @@ void tst_QtConcurrentResultStore::filterMode() void tst_QtConcurrentResultStore::addCanceledResult() { // test canceled results - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -379,7 +383,7 @@ void tst_QtConcurrentResultStore::count() { // test resultCount in non-filtered mode. It should always be possible // to iterate through the results 0 to resultCount. - ResultStore<int> store; + ResultStoreInt store; store.addResult(0, &int0); QCOMPARE(store.count(), 1); @@ -393,7 +397,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore<int> store; + ResultStoreInt store; store.addResult(2, &int0); QCOMPARE(store.count(), 0); @@ -405,7 +409,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore<int> store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -417,7 +421,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore<int> store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -425,7 +429,7 @@ void tst_QtConcurrentResultStore::count() QCOMPARE(store.count(), 4); } { - ResultStore<int> store; + ResultStoreInt store; store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -437,7 +441,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -450,22 +454,22 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults<int>(0, 3); QCOMPARE(store.count(), 2); } { - ResultStore<int> store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults<int>(0, 3); QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 store.addResult(5, &int0); diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST index 22e30d0fd6..06ae815f29 100644 --- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -1,2 +1,4 @@ [tryAcquireWithTimeout:0.2s] windows +[tryAcquireWithTimeout:2s] +windows diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index 49a3b3e4db..403e28b07b 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -76,7 +76,7 @@ int Pointer::count = 0; void tst_QThreadStorage::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString crashOnExitDir = QFINDTESTDATA("crashonexit"); QVERIFY2(!crashOnExitDir.isEmpty(), qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'") @@ -300,7 +300,7 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) { const int timeout = 60000; @@ -325,7 +325,7 @@ static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) void tst_QThreadStorage::crashOnExit() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QString errorMessage; diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index a54ad3d9c9..10398f1a99 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -509,7 +509,7 @@ void tst_QCommandLineParser::testCpp11StyleInitialization() void tst_QCommandLineParser::testVersionOption() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else #if defined(Q_OS_ANDROID) @@ -526,7 +526,7 @@ void tst_QCommandLineParser::testVersionOption() output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif QCOMPARE(output, QString("qcommandlineparser_test_helper 1.0\n")); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static const char expectedOptionsHelp[] = @@ -575,7 +575,7 @@ void tst_QCommandLineParser::testHelpOption_data() void tst_QCommandLineParser::testHelpOption() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else #if defined(Q_OS_ANDROID) @@ -618,12 +618,12 @@ void tst_QCommandLineParser::testHelpOption() expectedResizeHelp.replace("testhelper/", "testhelper\\"); #endif QCOMPARE(output, QString(expectedResizeHelp)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QCommandLineParser::testQuoteEscaping() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #elif defined(Q_OS_ANDROID) QSKIP("Deploying executable applications to file system on Android not supported."); @@ -644,7 +644,7 @@ void tst_QCommandLineParser::testQuoteEscaping() QVERIFY2(output.contains("KEY1=\"VALUE1\""), qPrintable(output)); QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output)); QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } QTEST_APPLESS_MAIN(tst_QCommandLineParser) diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 5eec44dffd..28ad2d193c 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -119,6 +119,8 @@ private slots: void fromStringDateFormat(); void fromStringStringFormat_data(); void fromStringStringFormat(); + void fromStringStringFormatLocale_data(); + void fromStringStringFormatLocale(); #ifdef Q_OS_WIN void fromString_LOCALE_ILDATE(); #endif @@ -665,6 +667,29 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt.time(), utc.time()); QCOMPARE(dt.timeSpec(), Qt::UTC); + { + QDateTime dt1 = QDateTime::fromMSecsSinceEpoch(msecs, Qt::UTC); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + { + QDateTime dt1(utc.date(), utc.time(), Qt::UTC); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + { + // used to fail to clear the ShortData bit, causing corruption + QDateTime dt1 = dt.addDays(0); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + if (zoneIsCET) { QCOMPARE(dt.toLocalTime(), cet); @@ -2377,6 +2402,54 @@ void tst_QDateTime::fromStringStringFormat() QCOMPARE(dt, expected); } +void tst_QDateTime::fromStringStringFormatLocale_data() +{ + QTest::addColumn<QString>("string"); + QTest::addColumn<QString>("format"); + QTest::addColumn<QLocale>("locale"); + QTest::addColumn<QDateTime>("expected"); + + QLocale c = QLocale::c(); + QDateTime dt(QDate(2017, 02, 25), QTime(17, 21, 25)); + + // The formats correspond to the locale formats, with the timezone removed. + // We hardcode them in case an update to the locale DB changes them. + + QTest::newRow("C:long") << "Saturday, 25 February 2017 17:21:25" << "dddd, d MMMM yyyy HH:mm:ss" << c << dt; + QTest::newRow("C:short") << "25 Feb 2017 17:21:25" << "d MMM yyyy HH:mm:ss" << c << dt; + QTest::newRow("C:narrow") << "25 Feb 2017 17:21:25" << "d MMM yyyy HH:mm:ss" << c << dt; + + QLocale fr(QLocale::French); + QTest::newRow("fr:long") << "Samedi 25 février 2017 17:21:25" << "dddd d MMMM yyyy HH:mm:ss" << fr << dt; + QTest::newRow("fr:short") << "25/02/2017 17:21" << "dd/MM/yyyy HH:mm" << fr << dt.addSecs(-25); + + // In Turkish, the word for Friday ("Cuma") is a prefix for the word for + // Saturday ("Cumartesi") + QLocale tr(QLocale::Turkish); + QTest::newRow("tr:long") << "25 Åžubat 2017 Cumartesi 17:21:25" << "d MMMM yyyy dddd HH:mm:ss" << tr << dt; + QTest::newRow("tr:long2") << "24 Åžubat 2017 Cuma 17:21:25" << "d MMMM yyyy dddd HH:mm:ss" << tr << dt.addDays(-1); + QTest::newRow("tr:mashed") << "25 Åžubat2017 Cumartesi17:21:25" << "d MMMMyyyy ddddHH:mm:ss" << tr << dt; + QTest::newRow("tr:mashed2") << "24 Åžubat2017 Cuma17:21:25" << "d MMMMyyyy ddddHH:mm:ss" << tr << dt.addDays(-1); + QTest::newRow("tr:short") << "25.02.2017 17:21" << "d.MM.yyyy HH:mm" << tr << dt.addSecs(-25); +} + +void tst_QDateTime::fromStringStringFormatLocale() +{ + QFETCH(QString, string); + QFETCH(QString, format); + QFETCH(QLocale, locale); + QFETCH(QDateTime, expected); + + QDateTime parsed = locale.toDateTime(string, format); + QCOMPARE(parsed, expected); + + parsed = locale.toDateTime(string.toLower(), format); + QCOMPARE(parsed, expected); + + parsed = locale.toDateTime(string.toUpper(), format); + QCOMPARE(parsed, expected); +} + #ifdef Q_OS_WIN // Windows only void tst_QDateTime::fromString_LOCALE_ILDATE() diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 6f20e3db91..5d13d9e454 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -35,7 +35,9 @@ #include <QScopedArrayPointer> #include <qtextcodec.h> #include <qdatetime.h> -#include <qprocess.h> +#if QT_CONFIG(process) +# include <qprocess.h> +#endif #include <float.h> #include <locale.h> @@ -78,6 +80,7 @@ private slots: void ctor(); void emptyCtor(); void legacyNames(); + void consistentC(); void unixLocaleName(); void matchingLocales(); void stringToDouble_data(); @@ -152,7 +155,7 @@ tst_QLocale::tst_QLocale() void tst_QLocale::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp"); QVERIFY2(!syslocaleapp_dir.isEmpty(), qPrintable(QStringLiteral("Cannot find 'syslocaleapp' starting from ") @@ -165,7 +168,7 @@ void tst_QLocale::initTestCase() QVERIFY2(fi.exists() && fi.isExecutable(), qPrintable(QDir::toNativeSeparators(m_sysapp) + QStringLiteral(" does not exist or is not executable."))); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLocale::cleanupTestCase() @@ -420,7 +423,7 @@ void tst_QLocale::ctor() #undef TEST_CTOR } -#if !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) static inline bool runSysApp(const QString &binary, const QStringList &env, QString *output, @@ -472,7 +475,7 @@ static inline bool runSysAppTest(const QString &binary, void tst_QLocale::emptyCtor() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #define TEST_CTOR(req_lc, exp_str) \ @@ -577,6 +580,15 @@ void tst_QLocale::legacyNames() #undef TEST_CTOR } +void tst_QLocale::consistentC() +{ + const QLocale c(QLocale::C); + QCOMPARE(c, QLocale::c()); + QCOMPARE(c, QLocale(QLocale::C, QLocale::AnyScript, QLocale::AnyCountry)); + QVERIFY(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, + QLocale::AnyCountry).contains(c)); +} + void tst_QLocale::matchingLocales() { const QLocale c(QLocale::C); diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index 7bebe5e9e0..e8f56fc1d3 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -31,7 +31,9 @@ #include <QtCore/QTemporaryFile> #include <QtCore/QTemporaryDir> -#include <QtCore/QProcess> +#if QT_CONFIG(process) +# include <QtCore/QProcess> +#endif #include <QtCore/QByteArray> #include <QtCore/QString> #include <QtCore/QFileInfo> @@ -66,7 +68,7 @@ static QString makespec() QT_BEGIN_NAMESPACE namespace QTest { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class QExternalProcess: public QProcess { protected: @@ -87,7 +89,7 @@ namespace QTest { } #endif }; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) class QExternalTestPrivate { @@ -554,7 +556,7 @@ namespace QTest { bool QExternalTestPrivate::runQmake() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) if (temporaryDirPath.isEmpty()) qWarning() << "Temporary directory is expected to be non-empty"; @@ -597,14 +599,14 @@ namespace QTest { } return ok && exitCode == 0; -#else // QT_NO_PROCESS +#else // QT_CONFIG(process) return false; -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } bool QExternalTestPrivate::runMake(Target target) { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) return false; #else if (temporaryDirPath.isEmpty()) @@ -663,7 +665,7 @@ namespace QTest { std_err += make.readAllStandardError(); return ok; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } bool QExternalTestPrivate::commonSetup(const QByteArray &body) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index dfa8cceccc..3f118d04ce 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -3818,7 +3818,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith(QLatin1Char('x')) ); QVERIFY( !a.startsWith(QChar()) ); - a = QString::null; + a = QString(); QVERIFY( !a.startsWith("") ); QVERIFY( a.startsWith(QString::null) ); QVERIFY( !a.startsWith("ABC") ); @@ -3928,7 +3928,7 @@ void tst_QString::endsWith() QVERIFY( a.endsWith(QLatin1String(0)) ); QVERIFY( !a.endsWith(QLatin1String("ABC")) ); - a = QString::null; + a = QString(); QVERIFY( !a.endsWith("") ); QVERIFY( a.endsWith(QString::null) ); QVERIFY( !a.endsWith("ABC") ); diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 4c9916cc52..5467d438a3 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -751,7 +751,9 @@ void tst_QTextBoundaryFinder::isAtSoftHyphen() doTestData(testString, expectedSoftHyphenPositions, QTextBoundaryFinder::Line, QTextBoundaryFinder::SoftHyphen); } +#if QT_CONFIG(library) #include <qlibrary.h> +#endif #define LIBTHAI_MAJOR 0 typedef int (*th_brk_def) (const unsigned char*, int*, size_t); @@ -759,7 +761,7 @@ static th_brk_def th_brk = 0; static bool init_libthai() { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(library) static bool triedResolve = false; if (!triedResolve) { th_brk = (th_brk_def) QLibrary::resolve("thai", (int)LIBTHAI_MAJOR, "th_brk"); diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index c37a15089a..2e34e82388 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -134,7 +134,7 @@ void tst_QVersionNumber::singleInstanceData() namespace UglyOperator { // ugh, but the alternative (operator <<) is even worse... -static inline QVector<int> operator+(QVector<int> v, int i) { v.push_back(i); return qMove(v); } +static inline QVector<int> operator+(QVector<int> v, int i) { v.push_back(i); return v; } } void tst_QVersionNumber::comparisonData() diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index 1769583fca..2c58d7e235 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -29,3 +29,8 @@ SUBDIRS+=\ !qtConfig(private_tests): SUBDIRS -= \ qdbusmarshall \ +!qtConfig(process): SUBDIRS -= \ + qdbusabstractadaptor \ + qdbusabstractinterface \ + qdbusinterface \ + qdbusmarshall diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 95daa256b5..d521c18cef 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1410,7 +1410,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() void tst_QDBusConnection::pendingCallWhenDisconnected() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("Test requires QProcess"); #else if (!QCoreApplication::instance()) diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index c5117228d3..6b4ddeaba5 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -1084,7 +1084,7 @@ static bool canSendUnixFd(DBusConnection *connection) # if DBUS_VERSION-0 >= 0x010400 can_send_type = dbus_connection_can_send_type; # endif -#elif !defined(QT_NO_LIBRARY) +#elif QT_CONFIG(library) // run-time check if the next functions are available can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp index d9a4a6c43f..f475e87a2b 100644 --- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp @@ -90,7 +90,7 @@ static void addFixedTypes() // the library recognizes this as valid type first. // The following function was added for Unix FD support, so if it is // present, so is support for Unix FDs. -# ifndef QT_NO_LIBRARY +# if QT_CONFIG(library) bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type"); # else bool supportsUnixFds = false; diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 01f3eabb17..ecf8c033b5 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -699,7 +699,7 @@ void tst_QIcon::fromThemeCache() QIcon::setThemeSearchPaths(QStringList()); QSKIP("gtk-update-icon-cache not run (binary not found)"); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess process; process.start(gtkUpdateIconCache, QStringList() << QStringLiteral("-f") << QStringLiteral("-t") << (dir.path() + QLatin1String("/testcache"))); @@ -709,7 +709,7 @@ void tst_QIcon::fromThemeCache() QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) QVERIFY(QFileInfo(cacheName).lastModified() >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified()); QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes QVERIFY(!QIcon::fromTheme("button-open").isNull()); diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp index 8dcf104035..8a2a35f86c 100644 --- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -56,6 +56,7 @@ private slots: void pixmapKey(); void noLeak(); void strictCacheLimit(); + void noCrashOnLargeInsert(); }; static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key) @@ -525,5 +526,15 @@ void tst_QPixmapCache::strictCacheLimit() QVERIFY(QPixmapCache::totalUsed() <= limit); } +void tst_QPixmapCache::noCrashOnLargeInsert() +{ + QPixmapCache::clear(); + QPixmapCache::setCacheLimit(100); + QPixmap pixmap(500, 500); + pixmap.fill(Qt::transparent); + QPixmapCache::insert("test", pixmap); + QVERIFY(true); // no crash +} + QTEST_MAIN(tst_QPixmapCache) #include "tst_qpixmapcache.moc" diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index b1ec94403a..87fd5c0dc6 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -73,7 +73,7 @@ void tst_QClipboard::cleanupTestCase() void tst_QClipboard::init() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath(); QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); #endif @@ -218,7 +218,7 @@ void tst_QClipboard::testSignals() #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) static bool runHelper(const QString &program, const QStringList &arguments, QByteArray *errorMessage) { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess process; process.setReadChannelMode(QProcess::ForwardedChannels); process.start(program, arguments); @@ -254,19 +254,19 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt return false; } return true; -#else // QT_NO_PROCESS +#else // QT_CONFIG(process) Q_UNUSED(program) Q_UNUSED(arguments) Q_UNUSED(errorMessage) return false; -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } // Test that pasted text remains on the clipboard after a Qt application exits. // This test does not make sense on X11 and embedded, copied data disappears from the clipboard when the application exits void tst_QClipboard::copy_exit_paste() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) // ### It's still possible to test copy/paste - just keep the apps running if (!PlatformClipboard::isAvailable()) QSKIP("Native clipboard not working in this setup"); @@ -282,12 +282,12 @@ void tst_QClipboard::copy_exit_paste() QStringList() << QStringLiteral("--text") << stringArgument, &errorMessage), errorMessage.constData()); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QClipboard::copyImage() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) if (!PlatformClipboard::isAvailable()) QSKIP("Native clipboard not working in this setup"); QImage image(100, 100, QImage::Format_ARGB32); @@ -303,7 +303,7 @@ void tst_QClipboard::copyImage() QVERIFY2(runHelper(QStringLiteral("paster/paster"), QStringList(QStringLiteral("--image")), &errorMessage), errorMessage.constData()); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } #endif // Q_OS_WIN || Q_OS_MAC || Q_OS_QNX diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 2603206ab0..1f826c01cf 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -486,7 +486,7 @@ void tst_QFont::styleName() QString getPlatformGenericFont(const char* genericName) { -#if defined(Q_OS_UNIX) && !defined(QT_NO_FONTCONFIG) +#if defined(Q_OS_UNIX) && !defined(QT_NO_FONTCONFIG) && QT_CONFIG(process) QProcess p; p.start(QLatin1String("fc-match"), (QStringList() << "-f%{family}" << genericName)); if (!p.waitForStarted()) diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index a13fa86405..a1c8399a26 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -124,7 +124,7 @@ protected slots: private: QFtp *newFtp(); void addCommand( QFtp::Command, int ); - bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString::null ); + bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate ); void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 4dcce8509c..fbd8f5a780 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -4297,14 +4297,14 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket() // Currently no stdin/out supported for Windows CE. void tst_QNetworkReply::ioPutToFileFromProcess_data() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) putToFile_data(); #endif } void tst_QNetworkReply::ioPutToFileFromProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else @@ -4342,7 +4342,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QByteArray contents = file.readAll(); QCOMPARE(contents, data); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QNetworkReply::ioPutToFtpFromFile_data() diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp index 138a0859cd..8d32ddf37c 100644 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp @@ -897,7 +897,7 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list) // at Discovered -state. void tst_QNetworkSession::outOfProcessSession() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else updateConfigurations(); diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 41ed7d2b93..2671c253cb 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -54,7 +54,6 @@ #endif #include <time.h> -#include <qlibrary.h> #if defined(Q_OS_WIN) #include <windows.h> #else diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 74bffef4f4..a74a056d91 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -904,7 +904,7 @@ void tst_QLocalSocket::processConnection_data() QTest::newRow("30 clients") << 30; } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class ProcessOutputDumper { public: @@ -933,7 +933,7 @@ private: */ void tst_QLocalSocket::processConnection() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #ifdef Q_OS_MAC diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 4bbd0662e4..3b9ef577bd 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -49,7 +49,9 @@ #include <qtcpsocket.h> #include <qtcpserver.h> #include <qhostaddress.h> -#include <qprocess.h> +#if QT_CONFIG(process) +# include <qprocess.h> +#endif #include <qstringlist.h> #include <qplatformdefs.h> #include <qhostinfo.h> @@ -544,7 +546,7 @@ protected: void tst_QTcpServer::addressReusable() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #ifdef Q_OS_LINUX diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 9fd5620cec..7340817ade 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -54,7 +54,9 @@ #include <QHostInfo> #include <QMap> #include <QPointer> -#include <QProcess> +#if QT_CONFIG(process) +# include <QProcess> +#endif #include <QStringList> #include <QTcpServer> #include <QTcpSocket> @@ -2403,7 +2405,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect_data() void tst_QTcpSocket::suddenRemoteDisconnect() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, client); @@ -2459,7 +2461,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() #endif QCOMPARE(clientProcess.readAll().constData(), "SUCCESS\n"); QCOMPARE(serverProcess.readAll().constData(), "SUCCESS\n"); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } //---------------------------------------------------------------------------------- diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index aa01384350..1133a80820 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -956,7 +956,7 @@ void tst_QUdpSocket::writeToNonExistingPeer() void tst_QUdpSocket::outOfProcessConnectedClientServerTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess serverProcess; @@ -1017,7 +1017,7 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess serverProcess; diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 971b9b5fe7..c28812e120 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -263,7 +263,7 @@ void PaintCommands::staticInit() "path_setFillRule pathName Winding"); DECL_PAINTCOMMAND("setBrush", command_setBrush, "^setBrush\\s+(#?[\\w.:\\/]*)\\s*(\\w*)?$", - "setBrush <pixmapFileName>\nsetBrush noBrush\nsetBrush <color> <brush style enum>", + "setBrush <imageFileName>\nsetBrush noBrush\nsetBrush <color> <brush style enum>", "setBrush white SolidPattern"); DECL_PAINTCOMMAND("setBrushOrigin", command_setBrushOrigin, "^setBrushOrigin\\s*(-?\\w*)\\s+(-?\\w*)$", @@ -1752,13 +1752,13 @@ void PaintCommands::command_setBrush(QRegExp re) { QStringList caps = re.capturedTexts(); - QPixmap pm = image_load<QPixmap>(caps.at(1)); - if (!pm.isNull()) { // Assume pixmap + QImage img = image_load<QImage>(caps.at(1)); + if (!img.isNull()) { // Assume image brush if (m_verboseMode) - printf(" -(lance) setBrush(pixmap=%s, width=%d, height=%d)\n", - qPrintable(caps.at(1)), pm.width(), pm.height()); + printf(" -(lance) setBrush(image=%s, width=%d, height=%d)\n", + qPrintable(caps.at(1)), img.width(), img.height()); - m_painter->setBrush(QBrush(pm)); + m_painter->setBrush(QBrush(img)); } else if (caps.at(1).toLower() == "nobrush") { m_painter->setBrush(Qt::NoBrush); if (m_verboseMode) diff --git a/tests/auto/other/lancelot/scripts/brushes.qps b/tests/auto/other/lancelot/scripts/brushes.qps index 82cbff48b9..43a7843601 100644 --- a/tests/auto/other/lancelot/scripts/brushes.qps +++ b/tests/auto/other/lancelot/scripts/brushes.qps @@ -77,3 +77,12 @@ drawRect 0 250 50 50 setBrushOrigin 50 250 drawRect 50 250 50 50 + +setBrush dome_indexed.png +setPen nopen +brushScale 0.7 0.7 +drawRect 20 320 600 200 + +setBrush dome_argb32.png +brushScale 1.5 1.5 +drawRect 20 540 600 200 diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp index b5db966bd9..e8970e6f24 100644 --- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp @@ -284,6 +284,8 @@ void tst_MacNativeEvents::testMouseEnter() void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() { + QSKIP("Modal dialog causes later tests to fail, see QTBUG-58474"); + // Test that a child dialog of a modal parent dialog is // in front of the parent, and active: QDialog parent; diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 68473906b0..3b696604b5 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -961,7 +961,7 @@ void tst_NetworkSelfTest::supportsSsl() #endif } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static const QByteArray msgProcessError(const QProcess &process, const char *what) { QString result; @@ -978,7 +978,7 @@ static void ensureTermination(QProcess &process) process.kill(); } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_NetworkSelfTest::smbServer() { @@ -996,7 +996,7 @@ void tst_NetworkSelfTest::smbServer() QCOMPARE(ret, strlen(contents)); QVERIFY(memcmp(buf, contents, strlen(contents)) == 0); #else -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) enum { sambaTimeOutSecs = 5 }; // try to use Samba const QString progname = "smbclient"; diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index a12f08488d..0e84b187fa 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -56,6 +56,8 @@ cross_compile: SUBDIRS -= \ !qtConfig(accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux +!qtConfig(process): SUBDIRS -= qprocess_and_guieventloop + !mac: SUBDIRS -= \ macgui \ macnativeevents \ @@ -65,8 +67,5 @@ cross_compile: SUBDIRS -= \ !embedded: SUBDIRS -= \ qdirectpainter -winrt: SUBDIRS -= \ - qprocess_and_guieventloop - android: SUBDIRS += \ android diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp index 1fcb77c51b..5842d58fab 100644 --- a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp +++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp @@ -40,9 +40,7 @@ private slots: void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop() { -#if defined(QT_NO_PROCESS) - QSKIP("QProcess not supported"); -#elif defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) QSKIP("Not supported on Android"); #else diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index a2e9140cc8..58648045a3 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2194,7 +2194,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() CHECK_DATABASE(db); // select a record with NULL value - QSqlQuery q(QString::null, db); + QSqlQuery q(QString(), db); QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db) + " where id = 4")); QVERIFY_SQL(q, next()); diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 35b759bcc2..0c078127b4 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -536,7 +536,7 @@ void tst_Selftests::runSubTest_data() } } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static QProcessEnvironment processEnvironment() { @@ -820,11 +820,11 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_Selftests::runSubTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, subdir); @@ -833,7 +833,7 @@ void tst_Selftests::runSubTest() QFETCH(bool, crashes); doRunSubTest(subdir, loggers, arguments, crashes); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } // attribute must contain =" diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 2d7ec2f0b5..8189227cbe 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -749,7 +749,7 @@ void tst_Moc::initTestCase() const QString testHeader = QFINDTESTDATA("backslash-newlines.h"); QVERIFY(!testHeader.isEmpty()); m_sourceDirectory = QFileInfo(testHeader).absolutePath(); -#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_UNIX) && QT_CONFIG(process) QProcess proc; proc.start(qmake, QStringList() << "-query" << "QT_INSTALL_HEADERS"); QVERIFY(proc.waitForFinished()); @@ -793,7 +793,7 @@ void tst_Moc::oldStyleCasts() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); @@ -823,7 +823,7 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/extraqualification.h"); proc.start(m_moc, QStringList(header)); @@ -862,7 +862,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.setWorkingDirectory(m_sourceDirectory + QStringLiteral("/task71021")); proc.start(m_moc, QStringList("../Header")); @@ -1108,7 +1108,7 @@ void tst_Moc::warnOnMultipleInheritance() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/warn-on-multiple-qobject-subclasses.h"); @@ -1131,7 +1131,7 @@ void tst_Moc::ignoreOptionClashes() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/interface-from-include.h"); @@ -1172,7 +1172,7 @@ void tst_Moc::forgottenQInterface() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/forgotten-qinterface.h"); @@ -1254,7 +1254,7 @@ void tst_Moc::frameworkSearchPath() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_UNIX) && QT_CONFIG(process) QStringList args; args << "-F" << m_sourceDirectory + QStringLiteral("/.") << m_sourceDirectory + QStringLiteral("/interface-from-framework.h") @@ -1298,7 +1298,7 @@ void tst_Moc::templateGtGt() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/template-gtgt.h"))); QVERIFY(proc.waitForFinished()); @@ -1314,7 +1314,7 @@ void tst_Moc::templateGtGt() void tst_Moc::defineMacroViaCmdline() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1334,7 +1334,7 @@ void tst_Moc::defineMacroViaCmdline() void tst_Moc::defineMacroViaForcedInclude() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1354,7 +1354,7 @@ void tst_Moc::defineMacroViaForcedInclude() void tst_Moc::defineMacroViaForcedIncludeRelative() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1375,7 +1375,7 @@ void tst_Moc::defineMacroViaForcedIncludeRelative() void tst_Moc::environmentIncludePaths_data() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QTest::addColumn<QString>("cmdline"); QTest::addColumn<QString>("varname"); @@ -1389,7 +1389,7 @@ void tst_Moc::environmentIncludePaths_data() void tst_Moc::environmentIncludePaths() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QFETCH(QString, cmdline); QFETCH(QString, varname); @@ -1582,7 +1582,7 @@ void tst_Moc::warnOnPropertyWithoutREAD() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/warn-on-property-without-read.h"); proc.start(m_moc, QStringList(header)); @@ -1693,7 +1693,7 @@ void tst_Moc::warnOnVirtualSignal() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/pure-virtual-signals.h"); proc.start(m_moc, QStringList(header)); @@ -1825,7 +1825,7 @@ void tst_Moc::notifyError() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/error-on-wrong-notify.h"); proc.start(m_moc, QStringList(header)); @@ -2187,6 +2187,7 @@ void tst_Moc::warnings() expectedStdErr.replace(lineNumberRe, "(\\1):"); #endif +#if QT_CONFIG(process) QProcess proc; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -2209,6 +2210,9 @@ void tst_Moc::warnings() if (expectedStdOut != "IGNORE_ALL_STDOUT") QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardOutput()).trimmed(), expectedStdOut); QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()).trimmed().remove('\r'), expectedStdErr); +#else + QSKIP("Only tested if QProcess is available"); +#endif } class tst_Moc::PrivateClass : public QObject { @@ -2837,6 +2841,21 @@ void tst_Moc::privateSignalConnection() // We can't use function pointer connections to private signals which are overloaded because we would have to cast in this case to: // static_cast<void (ClassWithPrivateSignals::*)(int, ClassWithPrivateSignals::QPrivateSignal)>(&ClassWithPrivateSignals::overloadedMaybePrivate) // Which doesn't work as ClassWithPrivateSignals::QPrivateSignal is private. + + // Connecting from one private signal to another + { + ClassWithPrivateSignals classWithPrivateSignals1; + ClassWithPrivateSignals classWithPrivateSignals2; + SignalConnectionTester tester; + QObject::connect(&classWithPrivateSignals1, &ClassWithPrivateSignals::privateSignal1, + &classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1); + QObject::connect(&classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1, + &tester, &SignalConnectionTester::testSlot); + + QVERIFY(!tester.testPassed); + classWithPrivateSignals1.emitPrivateSignals(); + QVERIFY(tester.testPassed); + } } void tst_Moc::finalClasses_data() @@ -3429,7 +3448,7 @@ void tst_Moc::preprocessorOnly() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList() << "-E" << m_sourceDirectory + QStringLiteral("/pp-dollar-signs.h")); QVERIFY(proc.waitForFinished()); @@ -3450,7 +3469,7 @@ void tst_Moc::unterminatedFunctionMacro() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList() << "-E" << m_sourceDirectory + QStringLiteral("/unterminated-function-macro.h")); QVERIFY(proc.waitForFinished()); @@ -3753,7 +3772,7 @@ void tst_Moc::optionsFileError() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) QFETCH(QString, optionsArgument); QProcess p; p.start(m_moc, QStringList(optionsArgument)); diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected index eb5d9222c8..45e96dccd0 100644 --- a/tests/auto/tools/rcc/data/images/images.expected +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -126,7 +126,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); int QT_RCC_MANGLE_NAMESPACE(qInitResources)() { QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) - (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } @@ -134,7 +134,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() { QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) - (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index d6f3728663..49095b9625 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -35,7 +35,9 @@ #include <QtCore/QAbstractEventDispatcher> #include <QtCore/QFileInfo> #include <QtCore/QDir> -#include <QtCore/QProcess> +#if QT_CONFIG(process) +# include <QtCore/QProcess> +#endif #include <QtCore/private/qeventloop_p.h> #include <QtGui/QFontDatabase> @@ -119,7 +121,7 @@ private slots: void testDeleteLater(); void testDeleteLaterProcessEvents(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void libraryPaths(); void libraryPaths_qt_plugin_path(); void libraryPaths_qt_plugin_path_2(); @@ -883,7 +885,7 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r) return j == r.count(); } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) #define QT_TST_QAPP_DEBUG void tst_QApplication::libraryPaths() { @@ -1432,7 +1434,7 @@ void tst_QApplication::testDeleteLaterProcessEvents() */ void tst_QApplication::desktopSettingsAware() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QString path; { // We need an application object for QFINDTESTDATA to work @@ -2121,7 +2123,7 @@ void tst_QApplication::qtbug_12673() QVERIFY2(!path.isEmpty(), "Cannot locate modal helper application"); path += "modal"; -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess testProcess; QStringList arguments; testProcess.start(path, arguments); @@ -2254,7 +2256,7 @@ void tst_QApplication::settableStyleHints() executed *after* the destruction of QApplication. */ Q_GLOBAL_STATIC(QLocale, tst_qapp_locale); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) Q_GLOBAL_STATIC(QProcess, tst_qapp_process); #endif #ifndef QT_NO_FILESYSTEMWATCHER @@ -2279,7 +2281,7 @@ void tst_QApplication::globalStaticObjectDestruction() int argc = 1; QApplication app(argc, &argv0); QVERIFY(tst_qapp_locale()); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QVERIFY(tst_qapp_process()); #endif #ifndef QT_NO_FILESYSTEMWATCHER diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 62c75cadf3..9d0c939d84 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -701,14 +701,14 @@ void tst_QShortcut::disabledItems() sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); QCOMPARE( currentResult, NoResult ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); currentResult = NoResult; sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 ); QCOMPARE( currentResult, Slot1Triggered ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); #endif clearAllShortcuts(); cut1 = 0; diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index 7641ea6b68..62c3469447 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -606,7 +606,7 @@ void tst_QUndoGroup::addStackAndDie() void tst_QUndoGroup::commandTextFormat() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No QProcess available"); #else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index 11a29b808c..f3185086b8 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -3853,7 +3853,7 @@ void tst_QUndoStack::undoLimit() void tst_QUndoStack::commandTextFormat() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No QProcess available"); #else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index a35ea8eb6e..f127fd98f7 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -97,6 +97,8 @@ private slots: void testDefaultButton(); void task191642_default(); + void testDeletedStandardButton(); + private: qint64 timeStamp; qint64 buttonClicked1TimeStamp; @@ -843,5 +845,22 @@ void tst_QDialogButtonBox::task191642_default() QCOMPARE(clicked.count(), 1); } +void tst_QDialogButtonBox::testDeletedStandardButton() +{ + QDialogButtonBox buttonBox; + delete buttonBox.addButton(QDialogButtonBox::Ok); + QPointer<QPushButton> buttonC = buttonBox.addButton(QDialogButtonBox::Cancel); + delete buttonBox.addButton(QDialogButtonBox::Cancel); + QPointer<QPushButton> buttonA = buttonBox.addButton(QDialogButtonBox::Apply); + delete buttonBox.addButton(QDialogButtonBox::Help); + // A few button have been deleted, they should automatically be removed + QCOMPARE(buttonBox.standardButtons(), QDialogButtonBox::Apply | QDialogButtonBox::Cancel); + + buttonBox.setStandardButtons(QDialogButtonBox::Reset | QDialogButtonBox::Cancel); + // setStanderdButton should delete previous buttons + QVERIFY(!buttonA); + QVERIFY(!buttonC); +} + QTEST_MAIN(tst_QDialogButtonBox) #include "tst_qdialogbuttonbox.moc" diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 4c0ffdc77c..330ce3a836 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -713,8 +713,8 @@ void tst_QLineEdit::clearInputMask() { QLineEdit *testWidget = ensureTestWidget(); testWidget->setInputMask("000.000.000.000"); - QVERIFY(testWidget->inputMask() != QString::null); - testWidget->setInputMask(QString::null); + QVERIFY(!testWidget->inputMask().isNull()); + testWidget->setInputMask(QString()); QCOMPARE(testWidget->inputMask(), QString()); } @@ -2277,7 +2277,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText("foo"); QCOMPARE(changed_count, 1); @@ -2286,7 +2286,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText(""); QCOMPARE(changed_count, 1); @@ -3108,7 +3108,7 @@ void tst_QLineEdit::maxLengthAndInputMask() QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); QCOMPARE(testWidget->maxLength(), 10); - testWidget->setInputMask(QString::null); + testWidget->setInputMask(QString()); QVERIFY(testWidget->inputMask().isNull()); QCOMPARE(testWidget->maxLength(), 10); } diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 3218b8ac68..b037cc2141 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -42,6 +42,7 @@ #include <qmenu.h> #include <qstyle.h> +#include <QStyleHints> #include <QTimer> #include <qdebug.h> @@ -110,6 +111,9 @@ private slots: void QTBUG_37933_ampersands_data(); void QTBUG_37933_ampersands(); #endif + void QTBUG_56917_wideMenuSize(); + void QTBUG_56917_wideMenuScreenNumber(); + void QTBUG_56917_wideSubmenuScreenNumber(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -1311,5 +1315,63 @@ void tst_QMenu::QTBUG_37933_ampersands() } #endif +void tst_QMenu::QTBUG_56917_wideMenuSize() +{ + // menu shouldn't to take on full screen height when menu width is larger than screen width + QMenu menu; + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + menu.addAction(longString); + QSize menuSizeHint = menu.sizeHint(); + menu.popup(QPoint()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QVERIFY(menu.height() <= menuSizeHint.height()); +} + +void tst_QMenu::QTBUG_56917_wideMenuScreenNumber() +{ + if (QApplication::styleHints()->showIsFullScreen()) + QSKIP("The platform defaults to windows being fullscreen."); + // menu must appear on the same screen where show action is triggered + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + + for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { + QMenu menu; + menu.addAction(longString); + menu.popup(QApplication::desktop()->screen(i)->geometry().center()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QCOMPARE(QApplication::desktop()->screenNumber(&menu), i); + } +} + +void tst_QMenu::QTBUG_56917_wideSubmenuScreenNumber() +{ + if (QApplication::styleHints()->showIsFullScreen()) + QSKIP("The platform defaults to windows being fullscreen."); + // submenu must appear on the same screen where its parent menu is shown + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + + for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { + QMenu menu; + QMenu submenu("Submenu"); + submenu.addAction(longString); + QAction *action = menu.addMenu(&submenu); + menu.popup(QApplication::desktop()->screen(i)->geometry().center()); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&submenu)); + QVERIFY(submenu.isVisible()); + QCOMPARE(QApplication::desktop()->screenNumber(&submenu), i); + } +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index a1b585d0d3..778ff1d932 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -284,6 +284,13 @@ protected: void CountingGraphicsView::drawForeground(QPainter *, const QRectF &) { ++m_count; + + // QTBUG-59318: verify that the context's internal default fbo redirection + // is active also when using the QOpenGLWidget as a viewport. + GLint currentFbo = -1; + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFbo); + GLuint defFbo = QOpenGLContext::currentContext()->defaultFramebufferObject(); + QCOMPARE(GLuint(currentFbo), defFbo); } void tst_QOpenGLWidget::asViewport() diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index 31bbcf9c7f..af0ad1a601 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -362,7 +362,7 @@ void tst_QPlainTextEdit::emptyAppend() { ed->appendPlainText("Blah"); QCOMPARE(blockCount(), 1); - ed->appendPlainText(QString::null); + ed->appendPlainText(QString()); QCOMPARE(blockCount(), 2); ed->appendPlainText(QString(" ")); QCOMPARE(blockCount(), 3); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index cecec48113..b9ea310d80 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -676,7 +676,7 @@ void tst_QTextEdit::emptyAppend() { ed->append("Blah"); QCOMPARE(blockCount(), 1); - ed->append(QString::null); + ed->append(QString()); QCOMPARE(blockCount(), 2); ed->append(QString(" ")); QCOMPARE(blockCount(), 3); |