diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-08 12:32:29 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-08 16:26:36 +0200 |
commit | f44850b5c3464cdda0ee9b1ee858d95f3ffaa3e2 (patch) | |
tree | 580aa25716bfc88d57f15ad68f7bfa727aebc400 /tests/auto | |
parent | f955bd8ced8b93d142b7f755665946424c6d3644 (diff) | |
parent | 3622ebaac51abd2e4d1541120ae3b6e42932359f (diff) |
Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6"
Diffstat (limited to 'tests/auto')
71 files changed, 1260 insertions, 620 deletions
diff --git a/tests/auto/corelib/global/qglobal/qglobal.pro b/tests/auto/corelib/global/qglobal/qglobal.pro index b105769430..e4453affa5 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.pro +++ b/tests/auto/corelib/global/qglobal/qglobal.pro @@ -2,4 +2,6 @@ CONFIG += testcase TARGET = tst_qglobal QT = core testlib SOURCES = tst_qglobal.cpp qglobal.c -contains(QT_CONFIG, c++1z): CONFIG += c++1z +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 5e5492de59..b33dec8a61 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -464,7 +464,7 @@ typedef int (Empty::*memFun) (); QCOMPARE(Q_ALIGNOF(type), size_t(alignment)); \ /* Compare to native operator for compilers that support it, otherwise... erm... check consistency! :-) */ \ - QCOMPARE(QT_EMULATED_ALIGNOF(type), Q_ALIGNOF(type)); \ + QCOMPARE(alignof(type), Q_ALIGNOF(type)); \ } while (false) /**/ @@ -517,7 +517,7 @@ void tst_QGlobal::qAlignOf() TEST_AlignOf_impl(AlignmentInStruct<double>, Q_ALIGNOF(AlignmentInStruct<qint64>)); // 32-bit x86 ABI, Clang disagrees with gcc -#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) +#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) || defined(Q_OS_ANDROID) TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(qint64)); #else TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(AlignmentInStruct<qint64>)); diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 23507ec2e6..7dd2a46807 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -48,7 +48,9 @@ private slots: void defaultHandler(); void installMessageHandler(); +#if QT_DEPRECATED_SINCE(5, 0) void installMsgHandler(); +#endif void installBothHandler(); #ifdef QT_BUILD_INTERNAL @@ -112,7 +114,9 @@ void tst_qmessagehandler::initTestCase() void tst_qmessagehandler::cleanup() { +#if QT_DEPRECATED_SINCE(5, 0) qInstallMsgHandler(0); +#endif qInstallMessageHandler((QtMessageHandler)0); s_type = QtFatalMsg; s_file = 0; @@ -143,6 +147,7 @@ void tst_qmessagehandler::installMessageHandler() QCOMPARE((void*)myHandler, (void*)customMessageHandler); } +#if QT_DEPRECATED_SINCE(5, 0) void tst_qmessagehandler::installMsgHandler() { QtMsgHandler oldHandler = qInstallMsgHandler(customMsgHandler); @@ -158,6 +163,7 @@ void tst_qmessagehandler::installMsgHandler() QtMsgHandler myHandler = qInstallMsgHandler(oldHandler); QCOMPARE((void*)myHandler, (void*)customMsgHandler); } +#endif void tst_qmessagehandler::installBothHandler() { diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index f459f62c91..e6d2f10c16 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -28,7 +28,6 @@ #include <QTest> -#include <QtAlgorithms> #include <QFile> #include <QFileInfo> #include <QRandomGenerator> diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 4428be08d4..734694abeb 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1036,7 +1036,9 @@ void tst_QFileInfo::systemFiles() QCOMPARE(fi.metadataChangeTime(), fi.lastModified()); // On Windows, they're the same QVERIFY(fi.birthTime().isValid()); QVERIFY(fi.birthTime() <= fi.lastModified()); +#if QT_DEPRECATED_SINCE(5, 10) QCOMPARE(fi.created(), fi.birthTime()); // On Windows, they're the same +#endif } void tst_QFileInfo::compare_data() @@ -1261,7 +1263,7 @@ void tst_QFileInfo::fakeFileTimes_data() QTest::newRow("early") << QDateTime(QDate(1901, 12, 14), QTime(12, 0)); // QTBUG-12006 claims XP handled this (2010-Mar-26 8:46:10) wrong due to an MS API bug: - QTest::newRow("XP-bug") << QDateTime::fromTime_t(1269593170); + QTest::newRow("XP-bug") << QDateTime::fromSecsSinceEpoch(1269593170); } void tst_QFileInfo::fakeFileTimes() @@ -1915,7 +1917,8 @@ void tst_QFileInfo::owner() DWORD bufSize = 1024; if (GetUserNameW(usernameBuf, &bufSize)) { userName = QString::fromWCharArray(usernameBuf); - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && IsUserAdmin()) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista + && IsUserAdmin()) { // Special case : If the user is a member of Administrators group, all files // created by the current user are owned by the Administrators group. LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; @@ -2042,7 +2045,9 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr QCOMPARE(info.permissions(), QFile::Permissions()); +#if QT_DEPRECATED_SINCE(5, 10) QVERIFY(!info.created().isValid()); +#endif QVERIFY(!info.birthTime().isValid()); QVERIFY(!info.metadataChangeTime().isValid()); QVERIFY(!info.lastRead().isValid()); diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index eeeb3bc6e2..8703b15dda 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -496,7 +496,7 @@ void tst_QLockFile::noPermissionsWindows() QSKIP("This test is for desktop Windows only"); #endif #ifdef Q_OS_WIN - if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows7) QSKIP("This test requires at least Windows 7"); #endif if (const int p = processProperties()) { diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index e4ff3c2a08..e799369c8a 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -151,6 +151,13 @@ private slots: void failToStartEmptyArgs_data(); void failToStartEmptyArgs(); +#if QT_DEPRECATED_SINCE(5, 13) + void crashTest2_deprecated(); + void restartProcessDeadlock_deprecated(); + void waitForReadyReadInAReadyReadSlot_deprecated(); + void finishProcessBeforeReadingDone_deprecated(); +#endif + protected slots: void readFromProcess(); void exitLoopSlot(); @@ -187,12 +194,20 @@ void tst_QProcess::getSetCheck() QProcess obj1; // ProcessChannelMode QProcess::readChannelMode() // void QProcess::setProcessChannelMode(ProcessChannelMode) +#if QT_DEPRECATED_SINCE(5, 13) obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.readChannelMode()); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.readChannelMode()); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.readChannelMode()); +#endif + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.processChannelMode()); + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.processChannelMode()); + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.processChannelMode()); // ProcessChannel QProcess::readChannel() // void QProcess::setReadChannel(ProcessChannel) @@ -335,12 +350,14 @@ void tst_QProcess::crashTest() qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); QSignalSpy spy(process.data(), &QProcess::errorOccurred); - QSignalSpy spy2(process.data(), static_cast<QProcessErrorSignal>(&QProcess::error)); - QSignalSpy spy3(process.data(), static_cast<QProcessFinishedSignal2>(&QProcess::finished)); - + QSignalSpy spy2(process.data(), static_cast<QProcessFinishedSignal2>(&QProcess::finished)); QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy3(process.data(), static_cast<QProcessErrorSignal>(&QProcess::error)); QVERIFY(spy3.isValid()); +#endif QVERIFY(process->waitForFinished(30000)); @@ -348,10 +365,12 @@ void tst_QProcess::crashTest() QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); QCOMPARE(spy2.count(), 1); - QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed); + QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy3.count(), 1); - QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy3.at(0).at(1).constData()), QProcess::CrashExit); + QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy3.at(0).at(0).constData()), QProcess::Crashed); +#endif QCOMPARE(process->exitStatus(), QProcess::CrashExit); @@ -379,7 +398,7 @@ void tst_QProcess::crashTest2() QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); - QObject::connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + QObject::connect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), this, &tst_QProcess::exitLoopSlot); QTestEventLoop::instance().enterLoop(30); @@ -645,9 +664,11 @@ void tst_QProcess::readTimeoutAndThenCrash() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); QSignalSpy spy(&process, &QProcess::errorOccurred); - QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); QVERIFY(spy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); QVERIFY(spy2.isValid()); +#endif process.kill(); @@ -656,8 +677,10 @@ void tst_QProcess::readTimeoutAndThenCrash() QCOMPARE(spy.count(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy2.count(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed); +#endif } void tst_QProcess::waitForFinished() @@ -697,12 +720,11 @@ void tst_QProcess::deadWhileReading() void tst_QProcess::restartProcessDeadlock() { - // The purpose of this test is to detect whether restarting a // process in the finished() connected slot causes a deadlock // because of the way QProcessManager uses its locks. QProcess process; - connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + connect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), this, &tst_QProcess::restartProcess); process.start("testProcessEcho/testProcessEcho"); @@ -710,7 +732,7 @@ void tst_QProcess::restartProcessDeadlock() QCOMPARE(process.write("", 1), qlonglong(1)); QVERIFY(process.waitForFinished(5000)); - QObject::disconnect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), nullptr, nullptr); + QObject::disconnect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), nullptr, nullptr); QCOMPARE(process.write("", 1), qlonglong(1)); QVERIFY(process.waitForFinished(5000)); @@ -1027,7 +1049,7 @@ void tst_QProcess::mergedChannels() { QProcess process; process.setProcessChannelMode(QProcess::MergedChannels); - QCOMPARE(process.readChannelMode(), QProcess::MergedChannels); + QCOMPARE(process.processChannelMode(), QProcess::MergedChannels); process.start("testProcessEcho2/testProcessEcho2"); @@ -1155,7 +1177,7 @@ protected: exitCode = 90210; QProcess process; - connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + connect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), this, &TestThread::catchExitCode, Qt::DirectConnection); process.start("testProcessEcho/testProcessEcho"); @@ -1229,7 +1251,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() { QProcess process; connect(&process, &QIODevice::readyRead, this, &tst_QProcess::waitForReadyReadInAReadyReadSlotSlot); - connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + connect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), this, &tst_QProcess::exitLoopSlot); bytesAvailable = 0; @@ -1468,15 +1490,19 @@ void tst_QProcess::failToStart() QProcess process; QSignalSpy stateSpy(&process, &QProcess::stateChanged); QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); QVERIFY(stateSpy.isValid()); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif // OS X and HP-UX have a really low default process limit (~100), so spawning // to many processes here will cause test failures later on. @@ -1491,7 +1517,9 @@ void tst_QProcess::failToStart() for (int j = 0; j < 8; ++j) { for (int i = 0; i < attempts; ++i) { QCOMPARE(errorSpy.count(), j * attempts + i); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(errorSpy2.count(), j * attempts + i); +#endif process.start("/blurp"); switch (j) { @@ -1516,9 +1544,13 @@ void tst_QProcess::failToStart() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), j * attempts + i + 1); - QCOMPARE(errorSpy2.count(), j * attempts + i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), j * attempts + i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif int it = j * attempts + i + 1; @@ -1537,14 +1569,18 @@ void tst_QProcess::failToStartWithWait() QProcess process; QEventLoop loop; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif for (int i = 0; i < 50; ++i) { process.start("/blurp", QStringList() << "-v" << "-debug"); @@ -1552,9 +1588,14 @@ void tst_QProcess::failToStartWithWait() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif + } } @@ -1566,14 +1607,18 @@ void tst_QProcess::failToStartWithEventLoop() QProcess process; QEventLoop loop; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif // The error signal may be emitted before start() returns connect(&process, &QProcess::errorOccurred, &loop, &QEventLoop::quit, Qt::QueuedConnection); @@ -1586,9 +1631,13 @@ void tst_QProcess::failToStartWithEventLoop() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif } } @@ -1606,8 +1655,12 @@ void tst_QProcess::failToStartEmptyArgs() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); QProcess process; - QSignalSpy errorSpy(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QSignalSpy errorSpy(&process, static_cast<QProcessErrorSignal>(&QProcess::errorOccurred)); QVERIFY(errorSpy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif switch (startOverload) { case 0: @@ -1625,6 +1678,9 @@ void tst_QProcess::failToStartEmptyArgs() QVERIFY(!process.waitForStarted()); QCOMPARE(errorSpy.count(), 1); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), 1); +#endif QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -1856,24 +1912,32 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QProcess process; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QSignalSpy finishedSpy(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); + QVERIFY(errorSpy.isValid()); + QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) QSignalSpy errorSpy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QSignalSpy finishedSpy1(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); - - QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy1.isValid()); - QVERIFY(finishedSpy2.isValid()); +#endif QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); + QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(errorSpy2.count(), 1); QCOMPARE(errorSpy2.at(0).at(0).toInt(), 0); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy1.count(), 0); - QCOMPARE(finishedSpy2.count(), 0); +#endif } void tst_QProcess::setStandardInputFile() @@ -2304,14 +2368,18 @@ void tst_QProcess::invalidProgramString() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); QSignalSpy spy(&process, &QProcess::errorOccurred); - QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); QVERIFY(spy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy2(&process, static_cast<QProcessErrorSignal>(&QProcess::error)); QVERIFY(spy2.isValid()); +#endif process.start(programString); QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(spy.count(), 1); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy2.count(), 1); +#endif QVERIFY(!QProcess::startDetached(programString)); } @@ -2365,7 +2433,7 @@ void tst_QProcess::finishProcessBeforeReadingDone() QProcess process; BlockOnReadStdOut blocker(&process); QEventLoop loop; - connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + connect(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished), &loop, &QEventLoop::quit); process.start("testProcessOutput/testProcessOutput"); QVERIFY(process.waitForStarted()); @@ -2511,5 +2579,106 @@ void tst_QProcess::processEventsInAReadyReadSlot() QVERIFY(process.waitForFinished()); } +#if QT_DEPRECATED_SINCE(5, 13) + +void tst_QProcess::crashTest2_deprecated() +{ + QProcess process; + process.start("testProcessCrash/testProcessCrash"); + QVERIFY(process.waitForStarted(5000)); + + qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); + qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); + + QSignalSpy spy(&process, static_cast<QProcessErrorSignal>(&QProcess::errorOccurred)); + QSignalSpy spy2(&process, static_cast<QProcessFinishedSignal2>(&QProcess::finished)); + + QVERIFY(spy.isValid()); + QVERIFY(spy2.isValid()); + + QObject::connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + this, &tst_QProcess::exitLoopSlot); + + QTestEventLoop::instance().enterLoop(30); + if (QTestEventLoop::instance().timeout()) + QFAIL("Failed to detect crash : operation timed out"); + + QCOMPARE(spy.count(), 1); + QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); + + QCOMPARE(spy2.count(), 1); + QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit); + + QCOMPARE(process.exitStatus(), QProcess::CrashExit); +} + +void tst_QProcess::restartProcessDeadlock_deprecated() +{ + // The purpose of this test is to detect whether restarting a + // process in the finished() connected slot causes a deadlock + // because of the way QProcessManager uses its locks. + QProcess process; + connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + this, &tst_QProcess::restartProcess); + + process.start("testProcessEcho/testProcessEcho"); + + QCOMPARE(process.write("", 1), qlonglong(1)); + QVERIFY(process.waitForFinished(5000)); + + QObject::disconnect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), nullptr, nullptr); + + QCOMPARE(process.write("", 1), qlonglong(1)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +} + +void tst_QProcess::waitForReadyReadInAReadyReadSlot_deprecated() +{ + QProcess process; + connect(&process, &QIODevice::readyRead, this, &tst_QProcess::waitForReadyReadInAReadyReadSlotSlot); + connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + this, &tst_QProcess::exitLoopSlot); + bytesAvailable = 0; + + process.start("testProcessEcho/testProcessEcho"); + QVERIFY(process.waitForStarted(5000)); + + QSignalSpy spy(&process, &QProcess::readyRead); + QVERIFY(spy.isValid()); + process.write("foo"); + QTestEventLoop::instance().enterLoop(30); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spy.count(), 1); + + process.disconnect(); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); + QVERIFY(process.bytesAvailable() > bytesAvailable); +} + +void tst_QProcess::finishProcessBeforeReadingDone_deprecated() +{ + QProcess process; + BlockOnReadStdOut blocker(&process); + QEventLoop loop; + connect(&process, static_cast<QProcessFinishedSignal1>(&QProcess::finished), + &loop, &QEventLoop::quit); + process.start("testProcessOutput/testProcessOutput"); + QVERIFY(process.waitForStarted()); + loop.exec(); + QStringList lines = QString::fromLocal8Bit(process.readAllStandardOutput()).split( + QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts); + QVERIFY(!lines.isEmpty()); + QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number")); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +} + +#endif + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 0b50c391b8..df1dbebbf2 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -55,6 +55,10 @@ private slots: void checkStructure(); void searchPath_data(); void searchPath(); +#if QT_DEPRECATED_SINCE(5, 13) + void searchPath_deprecated_data(); + void searchPath_deprecated(); +#endif void doubleSlashInRoot(); void setLocale(); void lastModified(); @@ -420,6 +424,58 @@ void tst_QResourceEngine::checkStructure() void tst_QResourceEngine::searchPath_data() { + auto searchPath = QFileInfo(QFINDTESTDATA("testqrc")).canonicalFilePath(); + + QTest::addColumn<QString>("searchPathPrefix"); + QTest::addColumn<QString>("searchPath"); + QTest::addColumn<QString>("file"); + QTest::addColumn<QByteArray>("expected"); + + QTest::newRow("no_search_path") + << QString() + << QString() + << ":search_file.txt" + << QByteArray("root\n"); + QTest::newRow("path1") + << "searchpath1" + << searchPath + << "searchpath1:searchpath1/search_file.txt" + << QByteArray("path1\n"); + QTest::newRow("no_search_path2") + << QString() + << QString() + << ":/search_file.txt" + << QByteArray("root\n"); + QTest::newRow("path2") + << "searchpath2" + << searchPath + "/searchpath2" + << "searchpath2:search_file.txt" + << QByteArray("path2\n"); +} + +void tst_QResourceEngine::searchPath() +{ + QFETCH(QString, searchPathPrefix); + QFETCH(QString, searchPath); + QFETCH(QString, file); + QFETCH(QByteArray, expected); + + if (!searchPath.isEmpty()) + QDir::addSearchPath(searchPathPrefix, searchPath); + QFile qf(file); + QVERIFY(qf.open(QFile::ReadOnly)); + QByteArray actual = qf.readAll(); + + actual.replace('\r', ""); + + QCOMPARE(actual, expected); + qf.close(); +} + +#if QT_DEPRECATED_SINCE(5, 13) + +void tst_QResourceEngine::searchPath_deprecated_data() +{ QTest::addColumn<QString>("searchPath"); QTest::addColumn<QString>("file"); QTest::addColumn<QByteArray>("expected"); @@ -438,7 +494,7 @@ void tst_QResourceEngine::searchPath_data() << QByteArray("path2\n"); } -void tst_QResourceEngine::searchPath() +void tst_QResourceEngine::searchPath_deprecated() { QFETCH(QString, searchPath); QFETCH(QString, file); @@ -456,6 +512,8 @@ void tst_QResourceEngine::searchPath() qf.close(); } +#endif + void tst_QResourceEngine::checkUnregisterResource_data() { QTest::addColumn<QString>("rcc_file"); diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 8b69518ef7..a71a68e457 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -311,8 +311,11 @@ void tst_QSettings::initTestCase() void tst_QSettings::cleanupTestFiles() { - QSettings::setSystemIniPath(settingsPath("__system__")); - QSettings::setUserIniPath(settingsPath("__user__")); + QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, settingsPath("__system__")); + QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, settingsPath("__system__")); + + QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath("__user__")); + QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, settingsPath("__user__")); QDir settingsDir(settingsPath()); if (settingsDir.exists()) diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 67d8c55b04..00417fffa0 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -569,13 +569,7 @@ void tst_QTemporaryFile::rename() void tst_QTemporaryFile::renameFdLeak() { -#ifdef Q_OS_UNIX - -# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) - ChdirOnReturn cor(QDir::currentPath()); - QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); -# endif - +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__)); QVERIFY(!sourceFile.isEmpty()); // Test this on Unix only diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 89a06b358e..026c6a6324 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -520,7 +520,7 @@ public slots: QVector<QtTestObject *> o5, QList<QtTestObject *> o6) { slotResult = QLatin1String("slotWithRegistrableArgument:") + o1->slotResult + o2->slotResult - + o3->slotResult + o4.data()->slotResult + QString::number(o5.size()) + + o3->slotResult + o4.toStrongRef()->slotResult + QString::number(o5.size()) + QString::number(o6.size()); } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 28458c43c7..12c29a6e13 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1807,16 +1807,36 @@ void tst_QMetaType::automaticTemplateRegistration() QCOMPARE(extractedPtr.data()->objectName(), sp.data()->objectName()); \ } +#if QT_DEPRECATED_SINCE(5, 0) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QObject, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QFile, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QTemporaryFile, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, MyObject, WeakPointerToQObject, qWeakPointerFromVariant) +#endif TEST_NONOWNING_SMARTPOINTER(QPointer, QObject, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, QFile, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, QTemporaryFile, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, MyObject, TrackingPointerToQObject, qPointerFromVariant) #undef TEST_NONOWNING_SMARTPOINTER + + +#define TEST_WEAK_SMARTPOINTER(ELEMENT_TYPE, FLAG_TEST) \ + { \ + ELEMENT_TYPE elem; \ + QSharedPointer < ELEMENT_TYPE > shared(new ELEMENT_TYPE); \ + QWeakPointer < ELEMENT_TYPE > sp(shared); \ + sp.toStrongRef()->setObjectName("Test name"); \ + QVariant v = QVariant::fromValue(sp); \ + QCOMPARE(v.typeName(), "QWeakPointer<" #ELEMENT_TYPE ">"); \ + QVERIFY(QMetaType::typeFlags(::qMetaTypeId<QWeakPointer < ELEMENT_TYPE > >()) & QMetaType::FLAG_TEST); \ + } + + TEST_WEAK_SMARTPOINTER(QObject, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(QFile, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(QTemporaryFile, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(MyObject, WeakPointerToQObject) +#undef TEST_WEAK_SMARTPOINTER } template <typename T> diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 7c9d8a476a..1778bf24bc 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,7 +81,9 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); +#ifndef QT_NO_USERDATA void testUserData(); +#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -2338,6 +2340,7 @@ void tst_QObject::declareInterface() } +#ifndef QT_NO_USERDATA class CustomData : public QObjectUserData { public: @@ -2380,6 +2383,7 @@ void tst_QObject::testUserData() QCOMPARE(data->id, id); } } +#endif // QT_NO_USERDATA class DestroyedListener : public QObject { diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index c75e4ef035..5d06f6e8c8 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -402,6 +402,8 @@ QT_WARNING_POP QVERIFY( var6.isNull() ); QVariant varLL( (qlonglong)0 ); QVERIFY( !varLL.isNull() ); + +#if QT_DEPRECATED_SINCE(5, 9) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QVariant var7(QString::null); @@ -412,6 +414,7 @@ QT_WARNING_DISABLE_DEPRECATED var7 = QVariant::fromValue<QString>(QString::null); QT_WARNING_POP QVERIFY(var7.isNull()); +#endif QVariant var8(QMetaType::Nullptr, nullptr); QVERIFY(var8.isNull()); @@ -433,6 +436,9 @@ QT_WARNING_POP QVERIFY(var11.isNull()); QVERIFY(QVariant::fromValue<int*>(nullptr).isNull()); + + QVariant var12(QVariant::fromValue<QString>(QString())); + QVERIFY(var12.isNull()); } void tst_QVariant::swap() @@ -2871,6 +2877,7 @@ void tst_QVariant::qvariant_cast_QObject_wrapper() QVERIFY(spVar.canConvert<QObject*>()); QCOMPARE(f, spVar.value<QObject*>()); } +#if QT_DEPRECATED_SINCE(5, 0) { QFile *f = new QFile(this); QT_WARNING_PUSH @@ -2881,6 +2888,15 @@ QT_WARNING_POP QVERIFY(spVar.canConvert<QObject*>()); QCOMPARE(f, spVar.value<QObject*>()); } +#endif + { + QFile *f = new QFile(this); + QSharedPointer<QObject> sp(f); + QWeakPointer<QObject> wp = sp; + QVariant wpVar = QVariant::fromValue(wp); + QVERIFY(wpVar.canConvert<QObject*>()); + QCOMPARE(f, wpVar.value<QObject*>()); + } { QFile *f = new QFile(this); QSharedPointer<QFile> sp(f); diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index a290c012df..aa85a7c35b 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -41,7 +41,6 @@ class tst_QPlugin : public QObject Q_OBJECT QDir dir; - QString invalidPluginName; public: tst_QPlugin(); @@ -64,15 +63,14 @@ void tst_QPlugin::initTestCase() QVERIFY2(dir.exists(), qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). arg(QDir::toNativeSeparators(QDir::currentPath())))); - - const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files); - if (!fileNames.isEmpty()) - invalidPluginName = dir.absoluteFilePath(fileNames.first()); } void tst_QPlugin::loadDebugPlugin() { const auto fileNames = dir.entryList(QStringList() << "*debug*", QDir::Files); + if (fileNames.isEmpty()) + QSKIP("No debug plugins found - skipping test"); + for (const QString &fileName : fileNames) { if (!QLibrary::isLibrary(fileName)) continue; @@ -100,6 +98,9 @@ void tst_QPlugin::loadDebugPlugin() void tst_QPlugin::loadReleasePlugin() { const auto fileNames = dir.entryList(QStringList() << "*release*", QDir::Files); + if (fileNames.isEmpty()) + QSKIP("No release plugins found - skipping test"); + for (const QString &fileName : fileNames) { if (!QLibrary::isLibrary(fileName)) continue; @@ -227,7 +228,13 @@ static qsizetype locateMetadata(const uchar *data, qsizetype len) void tst_QPlugin::scanInvalidPlugin() { - QVERIFY(!invalidPluginName.isEmpty()); + const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files); + QString invalidPluginName; + if (fileNames.isEmpty()) + QSKIP("No invalid plugin found - skipping test"); + else + invalidPluginName = dir.absoluteFilePath(fileNames.first()); + // copy the file QFileInfo fn(invalidPluginName); diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index b06000d9c4..c4a366d7c6 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -549,7 +549,8 @@ void tst_QPluginLoader::staticPlugins() } QVERIFY(found); - QCOMPARE(metaData.value("version").toInt(), QT_VERSION); + // We don't store the patch release version anymore (since 5.13) + QCOMPARE(metaData.value("version").toInt() / 0x100, QT_VERSION / 0x100); QCOMPARE(metaData.value("IID").toString(), "SomeIID"); QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); QCOMPARE(metaData.value("URI").toString(), "qt.test.pluginloader.staticplugin"); diff --git a/tests/auto/corelib/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro index b1667760d6..1f21130af7 100644 --- a/tests/auto/corelib/thread/qfuture/qfuture.pro +++ b/tests/auto/corelib/thread/qfuture/qfuture.pro @@ -3,3 +3,4 @@ TARGET = tst_qfuture QT = core core-private testlib SOURCES = tst_qfuture.cpp DEFINES += QT_STRICT_ITERATORS +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 37c5874c02..749aa45916 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -69,7 +69,8 @@ private slots: static const int iterations = 100; QAtomicInt lockCount(0); -QMutex normalMutex, recursiveMutex(QMutex::Recursive); +QMutex normalMutex; +QRecursiveMutex recursiveMutex; QSemaphore testsTurn; QSemaphore threadsTurn; @@ -993,9 +994,9 @@ public: QMutex mutex; QWaitCondition cond; - QMutex &test_mutex; + QRecursiveMutex &test_mutex; - inline rmutex_Thread(QMutex &m) : test_mutex(m) { } + inline rmutex_Thread(QRecursiveMutex &m) : test_mutex(m) { } void run() { @@ -1024,7 +1025,7 @@ void tst_QMutex::lock_unlock_locked_tryLock() QMutex mutex; mutex_Thread thread(mutex); - QMutex rmutex(QMutex::Recursive); + QRecursiveMutex rmutex; rmutex_Thread rthread(rmutex); for (int i = 0; i < iterations; ++i) { diff --git a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp index 67db5d1458..c83e186ca7 100644 --- a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp +++ b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp @@ -36,7 +36,7 @@ class tst_QMutexLockerThread : public QThread { public: - QMutex mutex; + QRecursiveMutex mutex; QSemaphore semaphore, testSemaphore; void waitForTest() @@ -45,10 +45,6 @@ public: testSemaphore.acquire(); } - tst_QMutexLockerThread() - : mutex(QMutex::Recursive) - { - } }; class tst_QMutexLocker : public QObject diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST index d75249454f..ccf530362c 100644 --- a/tests/auto/corelib/thread/qthread/BLACKLIST +++ b/tests/auto/corelib/thread/qthread/BLACKLIST @@ -1,2 +1,4 @@ [wait3_slowDestructor] windows +[sleep] +windows ci diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index baec4a22a5..7be2f48758 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -110,6 +110,12 @@ private slots: enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; +template <class Int> +static QString msgElapsed(Int elapsed) +{ + return QString::fromLatin1("elapsed: %1").arg(elapsed); +} + class SignalRecorder : public QObject { Q_OBJECT @@ -591,7 +597,7 @@ void tst_QThread::sleep() thread.interval = 2; thread.start(); QVERIFY(thread.wait(five_minutes)); - QVERIFY(thread.elapsed >= 2000); + QVERIFY2(thread.elapsed >= 2000, qPrintable(msgElapsed(thread.elapsed))); } void tst_QThread::msleep() @@ -602,9 +608,9 @@ void tst_QThread::msleep() thread.start(); QVERIFY(thread.wait(five_minutes)); #if defined (Q_OS_WIN) // May no longer be needed - QVERIFY(thread.elapsed >= 100); + QVERIFY2(thread.elapsed >= 100, qPrintable(msgElapsed(thread.elapsed))); #else - QVERIFY(thread.elapsed >= 120); + QVERIFY2(thread.elapsed >= 120, qPrintable(msgElapsed(thread.elapsed))); #endif } @@ -616,9 +622,9 @@ void tst_QThread::usleep() thread.start(); QVERIFY(thread.wait(five_minutes)); #if defined (Q_OS_WIN) // May no longer be needed - QVERIFY(thread.elapsed >= 100); + QVERIFY2(thread.elapsed >= 100, qPrintable(msgElapsed(thread.elapsed))); #else - QVERIFY(thread.elapsed >= 120); + QVERIFY2(thread.elapsed >= 120, qPrintable(msgElapsed(thread.elapsed))); #endif } @@ -1065,13 +1071,15 @@ void tst_QThread::wait2() timer.start(); QVERIFY(!thread.wait(Waiting_Thread::WaitTime)); qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 9). - QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); + QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, + qPrintable(msgElapsed(elapsed))); timer.start(); thread.cond1.wakeOne(); QVERIFY(thread.wait(/*Waiting_Thread::WaitTime * 1.4*/)); elapsed = timer.elapsed(); - QVERIFY2(elapsed - Waiting_Thread::WaitTime >= -1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); + QVERIFY2(elapsed - Waiting_Thread::WaitTime >= -1, + qPrintable(msgElapsed(elapsed))); } diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp index d27884197a..3826fa148e 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp @@ -32,7 +32,7 @@ #include "qmutex.h" -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, onceInitializationMutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, onceInitializationMutex) enum QOnceExtra { MustRunCode = 0x01, diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 0ef494b229..73384c35f4 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -91,7 +91,7 @@ private slots: void negativeYear() const; void printNegativeYear() const; void roundtripGermanLocale() const; -#if QT_CONFIG(textdate) +#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) void shortDayName() const; void standaloneShortDayName() const; void longDayName() const; @@ -1473,7 +1473,7 @@ void tst_QDate::roundtripGermanLocale() const theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); } -#if QT_CONFIG(textdate) +#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) QT_WARNING_PUSH // the methods tested here are all deprecated QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 6f0aebb071..ac1b903aa1 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -61,6 +61,10 @@ private slots: void timeSpec(); void toSecsSinceEpoch_data(); void toSecsSinceEpoch(); +#if QT_DEPRECATED_SINCE(5, 8) + void toTime_t_data(); + void toTime_t(); +#endif void daylightSavingsTimeChange_data(); void daylightSavingsTimeChange(); void springForward_data(); @@ -147,6 +151,7 @@ private slots: void systemTimeZoneChange() const; void invalid() const; + void range() const; void macTypes(); @@ -1689,6 +1694,34 @@ void tst_QDateTime::toSecsSinceEpoch() QDateTime datetime = dt( dateTimeStr ); qint64 asSecsSinceEpoch = datetime.toSecsSinceEpoch(); + QCOMPARE(asSecsSinceEpoch, datetime.toMSecsSinceEpoch() / 1000); + + QDateTime datetime2 = QDateTime::fromSecsSinceEpoch(asSecsSinceEpoch); + QCOMPARE(datetime, datetime2); +} + +#if QT_DEPRECATED_SINCE(5, 8) +void tst_QDateTime::toTime_t_data() +{ + QTest::addColumn<QString>("dateTimeStr"); + QTest::addColumn<bool>("res"); + + QTest::newRow( "data1" ) << str( 1800, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data2" ) << str( 1969, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data3" ) << str( 2002, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data4" ) << str( 2002, 6, 1, 12, 0, 0 ) << true; + QTest::newRow( "data5" ) << QString("INVALID") << false; + QTest::newRow( "data6" ) << str( 2038, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data7" ) << str( 2063, 4, 5, 12, 0, 0 ) << true; // the day of First Contact + QTest::newRow( "data8" ) << str( 2107, 1, 1, 12, 0, 0 ) + << bool( sizeof(uint) > 32 && sizeof(time_t) > 32 ); +} + +void tst_QDateTime::toTime_t() +{ + QFETCH( QString, dateTimeStr ); + QDateTime datetime = dt( dateTimeStr ); + uint asTime_t = datetime.toTime_t(); QFETCH( bool, res ); if (res) { @@ -1696,15 +1729,13 @@ void tst_QDateTime::toSecsSinceEpoch() } else { QVERIFY( asTime_t == (uint)-1 ); } - QCOMPARE(asSecsSinceEpoch, datetime.toMSecsSinceEpoch() / 1000); if ( asTime_t != (uint) -1 ) { QDateTime datetime2 = QDateTime::fromTime_t( asTime_t ); QCOMPARE(datetime, datetime2); } - QDateTime datetime2 = QDateTime::fromSecsSinceEpoch(asSecsSinceEpoch); - QCOMPARE(datetime, datetime2); } +#endif void tst_QDateTime::daylightSavingsTimeChange_data() { @@ -2489,17 +2520,20 @@ void tst_QDateTime::fromString_LOCALE_ILDATE() void tst_QDateTime::fromStringToStringLocale_data() { + QTest::addColumn<QLocale>("locale"); QTest::addColumn<QDateTime>("dateTime"); - QTest::newRow("data0") << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); + QTest::newRow("frFR") << QLocale(QLocale::French, QLocale::France) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); + QTest::newRow("spCO") << QLocale(QLocale::Spanish, QLocale::Colombia) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); } void tst_QDateTime::fromStringToStringLocale() { + QFETCH(QLocale, locale); QFETCH(QDateTime, dateTime); QLocale def; - QLocale::setDefault(QLocale(QLocale::French, QLocale::France)); + QLocale::setDefault(locale); #define ROUNDTRIP(format) \ QCOMPARE(QDateTime::fromString(dateTime.toString(format), format), dateTime) @@ -3472,6 +3506,15 @@ void tst_QDateTime::invalid() const QCOMPARE(tzDate.timeSpec(), Qt::TimeZone); } +void tst_QDateTime::range() const +{ + using Bounds = std::numeric_limits<qint64>; + QCOMPARE(QDateTime::fromMSecsSinceEpoch(Bounds::min() + 1, Qt::UTC).date().year(), + int(QDateTime::YearRange::First)); + QCOMPARE(QDateTime::fromMSecsSinceEpoch(Bounds::max() - 1, Qt::UTC).date().year(), + int(QDateTime::YearRange::Last)); +} + void tst_QDateTime::macTypes() { #ifndef Q_OS_MAC diff --git a/tests/auto/corelib/tools/collections/collections.pro b/tests/auto/corelib/tools/collections/collections.pro index 5c04515fa0..b074fa9338 100644 --- a/tests/auto/corelib/tools/collections/collections.pro +++ b/tests/auto/corelib/tools/collections/collections.pro @@ -5,3 +5,4 @@ QT = core testlib # This test does not work with strict iterators DEFINES -= QT_STRICT_ITERATORS +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index b911be3ffb..e79a4dba29 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -67,7 +67,6 @@ void foo() #include <algorithm> -#include "qalgorithms.h" #include "qbitarray.h" #include "qbytearray.h" #include "qcache.h" @@ -191,16 +190,6 @@ void tst_Collections::list() QVERIFY(list.size() == 6); QVERIFY(list.end() - list.begin() == list.size()); -#if !defined(Q_CC_MSVC) && !defined(Q_CC_SUN) - QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true); - QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false); -#endif - QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qUpperBound(list.begin(), list.end(), 2) == list.begin() + 2); - QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qUpperBound(list.begin(), list.end(), 9) == list.end()); { int sum = 0; QListIterator<int> i(list); @@ -996,16 +985,8 @@ void tst_Collections::vector() v.append(2); QVERIFY(*v.begin() == 2); v.prepend(1); - - v << 3 << 4 << 5 << 6; - QVERIFY(std::binary_search(v.begin(), v.end(), 2) == true); - QVERIFY(std::binary_search(v.begin(), v.end(), 9) == false); - QVERIFY(qBinaryFind(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qLowerBound(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qUpperBound(v.begin(), v.end(), 2) == v.begin() + 2); - QVERIFY(qBinaryFind(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qLowerBound(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qUpperBound(v.begin(), v.end(), 9) == v.end()); + QVERIFY(*v.begin() == 1); + QVERIFY(*(v.begin() + 1) == 2); v.clear(); v << 1 << 2 << 3; @@ -1370,7 +1351,7 @@ void tst_Collections::hash() { typedef QHash<QString, QString> Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { @@ -2013,13 +1994,17 @@ void tst_Collections::qstring() QString nonNull = ""; QVERIFY(null.left(10).isNull()); QVERIFY(null.mid(0).isNull()); + QVERIFY(null.isNull()); + QVERIFY(!nonNull.isNull()); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(null == QString::null); QVERIFY(QString::null == null); QVERIFY(nonNull != QString::null); QVERIFY(QString::null != nonNull); QVERIFY(null == nonNull); QVERIFY(QString::null == QString::null); +#endif QString fill = "123"; fill.fill('a'); diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 06db0e8546..18432e51a6 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -48,6 +48,11 @@ class tst_QAlgorithms : public QObject { Q_OBJECT private slots: + void swap(); + void swap2(); + void convenienceAPI(); + +#if QT_DEPRECATED_SINCE(5, 2) void test_qLowerBound_data(); void test_qLowerBound(); void test_qUpperBound_data(); @@ -55,19 +60,23 @@ private slots: void test_qBinaryFind_data(); void test_qBinaryFind(); void qBinaryFindOneEntry(); - void swap(); - void swap2(); void sortEmptyList(); void sortedList(); void sortAPItest(); void stableSortTest(); void stableSortCorrectnessTest_data(); void stableSortCorrectnessTest(); - void convenienceAPI(); + void convenienceAPI_deprecated(); void qCountIterators() const; void qCountContainer() const; void binaryFindOnLargeContainer() const; +#if Q_TEST_PERFORMANCE + void performance(); +#endif + +#endif // QT_DEPRECATED_SINCE(5, 2) + void popCount08_data() { popCount_data_impl(sizeof(quint8 )); } void popCount16_data() { popCount_data_impl(sizeof(quint16)); } void popCount32_data() { popCount_data_impl(sizeof(quint32)); } @@ -96,9 +105,6 @@ private slots: void countLeading64() { countLeading_impl<quint64>(); } private: -#if Q_TEST_PERFORMANCE - void performance(); -#endif void popCount_data_impl(size_t sizeof_T_Int); template <typename T_Int> void popCount_impl(); @@ -112,6 +118,8 @@ private: void countLeading_impl(); }; +#if QT_DEPRECATED_SINCE(5, 2) + class TestInt { public: @@ -172,7 +180,7 @@ ResultSet testRun(ContainerType &container, Algorithm &algorithm, int millisecs) { TestInt::lessThanRefCount = 0; int count = 0; - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() < millisecs) { ++count; @@ -257,6 +265,8 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes) } #endif +#endif // QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::swap() { { @@ -391,6 +401,17 @@ void tst_QAlgorithms::swap2() } } +void tst_QAlgorithms::convenienceAPI() +{ + // Compile-test for QAlgorithm convenience functions. + + QList<int *> pointerList; + qDeleteAll(pointerList); + qDeleteAll(pointerList.begin(), pointerList.end()); +} + +#if QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::sortEmptyList() { // Only test if it crashes @@ -676,7 +697,7 @@ void tst_QAlgorithms::stableSortCorrectnessTest() QVERIFY(isSorted(sorted)); } -void tst_QAlgorithms::convenienceAPI() +void tst_QAlgorithms::convenienceAPI_deprecated() { // Compile-test for QAlgorithm convenience functions. QList<int> list, list2; @@ -716,10 +737,6 @@ void tst_QAlgorithms::convenienceAPI() qBinaryFind(list, 1); qBinaryFind(list.begin(), list.end(), 1); qBinaryFind(list.begin(), list.end(), 1, qLess<int>()); - - QList<int *> pointerList; - qDeleteAll(pointerList); - qDeleteAll(pointerList.begin(), pointerList.end()); } template <typename DataType> @@ -1041,6 +1058,8 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const QCOMPARE(foundIt.pos(), 1073987655); } +#endif // QT_DEPRECATED_SINCE(5, 2) + // alternative implementation of qPopulationCount for comparison: static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 7db7d71b1f..25e2f21d03 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -1625,6 +1625,18 @@ void tst_QArrayData::literals() QCOMPARE(const_(v)[i], char('A' + i)); QCOMPARE(const_(v)[10], char('\0')); } + + { + struct LiteralType { + int value; + Q_DECL_CONSTEXPR LiteralType(int v = 0) : value(v) {} + }; + + QArrayDataPointer<LiteralType> d = Q_ARRAY_LITERAL(LiteralType, LiteralType(0), LiteralType(1), LiteralType(2)); + QCOMPARE(d->size, 3); + for (int i = 0; i < 3; ++i) + QCOMPARE(d->data()[i].value, i); + } } // Variadic Q_ARRAY_LITERAL need to be available in the current configuration. diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index b9bcecd607..513c811788 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -74,10 +74,12 @@ int main(int argc, char *argv[]) hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR")); hiddenOption.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(hiddenOption); +#if QT_DEPRECATED_SINCE(5, 8) QCommandLineOption hiddenOption2(QStringList() << QStringLiteral("hidden2")); hiddenOption2.setDescription(QStringLiteral("NEITHER SHOULD THIS")); hiddenOption2.setHidden(true); parser.addOption(hiddenOption2); +#endif // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. diff --git a/tests/auto/corelib/tools/qhash/qhash.pro b/tests/auto/corelib/tools/qhash/qhash.pro index 79ffd4e9d1..e96c0d1bf1 100644 --- a/tests/auto/corelib/tools/qhash/qhash.pro +++ b/tests/auto/corelib/tools/qhash/qhash.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qhash QT = core testlib SOURCES = $$PWD/tst_qhash.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index d70d488e96..f0aaad98bd 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -273,7 +273,7 @@ void tst_QHash::insert1() { typedef QHash<QString, QString> Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 915a24a1f6..0418daf640 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -53,8 +53,10 @@ private slots: void testNormalVector(); void testNormalVector_data(); +#if QT_DEPRECATED_SINCE(5, 14) void testAngle(); void testAngle_data(); +#endif void testAngle2(); void testAngle2_data(); @@ -378,6 +380,7 @@ void tst_QLine::testNormalVector() QCOMPARE(n.dy(), qreal(nvy)); } +#if QT_DEPRECATED_SINCE(5, 14) void tst_QLine::testAngle_data() { QTest::addColumn<double>("xa1"); @@ -426,6 +429,7 @@ void tst_QLine::testAngle() double resultAngle = a.angle(b); QCOMPARE(qRound(resultAngle), qRound(angle)); } +#endif void tst_QLine::testAngle2_data() { diff --git a/tests/auto/corelib/tools/qmap/qmap.pro b/tests/auto/corelib/tools/qmap/qmap.pro index 27820a76c8..2cc772720d 100644 --- a/tests/auto/corelib/tools/qmap/qmap.pro +++ b/tests/auto/corelib/tools/qmap/qmap.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qmap QT = core testlib SOURCES = $$PWD/tst_qmap.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro index 10ae3307d1..d0c6337147 100644 --- a/tests/auto/corelib/tools/qset/qset.pro +++ b/tests/auto/corelib/tools/qset/qset.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qset QT = core testlib SOURCES = tst_qset.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 187b73eeec..f3c647515a 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -75,8 +75,10 @@ private slots: void functionCallDownCast(); void upCast(); void qobjectWeakManagement(); +#if QT_DEPRECATED_SINCE(5, 0) void noSharedPointerFromWeakQObject(); void sharedPointerFromQObjectWithWeak(); +#endif void weakQObjectFromSharedPointer(); void objectCast(); void objectCastStdSharedPtr(); @@ -882,6 +884,78 @@ void tst_QSharedPointer::qobjectWeakManagement() QWeakPointer<QObject> weak; weak = QWeakPointer<QObject>(); QVERIFY(weak.isNull()); + QVERIFY(weak.toStrongRef().isNull()); + } + + { + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, bit with operator= + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak; + weak = shared; + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // with two QWeakPointers + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + + { + QWeakPointer<QObject> weak2(shared); + QVERIFY(!weak2.isNull()); + QVERIFY(weak == weak2); + } + QVERIFY(!weak.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, but delete the pointer while two QWeakPointers exist + QObject *obj = new QObject; + QSharedPointer<QObject> shared(obj); + QWeakPointer<QObject> weak(shared); + + { + QWeakPointer<QObject> weak2(shared); + QVERIFY(!weak2.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + QVERIFY(weak2.isNull()); + } + QVERIFY(weak.isNull()); + } + safetyCheck(); + +#if QT_DEPRECATED_SINCE(5, 0) + { + QWeakPointer<QObject> weak; + weak = QWeakPointer<QObject>(); + QVERIFY(weak.isNull()); QVERIFY(!weak.data()); } @@ -972,8 +1046,10 @@ void tst_QSharedPointer::qobjectWeakManagement() QVERIFY(weak.isNull()); } safetyCheck(); +#endif } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QSharedPointer::noSharedPointerFromWeakQObject() { // you're not allowed to create a QSharedPointer from an unmanaged QObject @@ -1007,18 +1083,32 @@ void tst_QSharedPointer::sharedPointerFromQObjectWithWeak() } QVERIFY(weak.isNull()); } +#endif void tst_QSharedPointer::weakQObjectFromSharedPointer() { - // this is the inverse of the above: you're allowed to create a QWeakPointer - // from a managed QObject - QSharedPointer<QObject> shared(new QObject); - QWeakPointer<QObject> weak = shared.data(); - QVERIFY(!weak.isNull()); +#if QT_DEPRECATED_SINCE(5, 0) + { + // this is the inverse of the above: you're allowed to create a QWeakPointer + // from a managed QObject + QSharedPointer<QObject> shared(new QObject); + QWeakPointer<QObject> weak = shared.data(); + QVERIFY(!weak.isNull()); - // delete: - shared.clear(); - QVERIFY(weak.isNull()); + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } +#endif + { + QSharedPointer<QObject> shared(new QObject); + QWeakPointer<QObject> weak = shared; + QVERIFY(!weak.isNull()); + + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } } void tst_QSharedPointer::objectCast() @@ -2376,6 +2466,7 @@ void tst_QSharedPointer::qvariantCast() // Intentionally does not compile. // QSharedPointer<int> sop = qSharedPointerFromVariant<int>(v); +#if QT_DEPRECATED_SINCE(5, 0) v = QVariant::fromValue(sp.toWeakRef()); { @@ -2419,6 +2510,7 @@ void tst_QSharedPointer::qvariantCast() QWeakPointer<QThread> other = qWeakPointerFromVariant<QThread>(v); QVERIFY(!other); } +#endif } class SomeClass : public QEnableSharedFromThis<SomeClass> diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 79f5a8c46d..e4aa00f500 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -521,7 +521,9 @@ private slots: void stringRef_local8Bit_data(); void stringRef_local8Bit(); void fromLatin1(); +#if QT_DEPRECATED_SINCE(5, 0) void fromAscii(); +#endif void fromUcs4(); void toUcs4(); void arg(); @@ -4284,9 +4286,9 @@ void tst_QString::fromLocal8Bit_data() //QTest::newRow("null5") << QByteArray() << 5 << QString(); //QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << -1 << QString(); //QTest::newRow("empty0") << QByteArray() << 0 << QString(); - //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromAscii("\0abcd", 5); - //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromAscii("ab"); - //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromAscii("ab\0cd", 5); + //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromLatin1("\0abcd", 5); + //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromLatin1("ab"); + //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromLatin1("ab\0cd", 5); } void tst_QString::fromLocal8Bit() @@ -4590,6 +4592,7 @@ void tst_QString::fromLatin1() QVERIFY(a.size() == 5); } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QString::fromAscii() { QString a; @@ -4610,6 +4613,7 @@ void tst_QString::fromAscii() a = QString::fromAscii("\0abcd", 5); QVERIFY(a.size() == 5); } +#endif void tst_QString::fromUcs4() { diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 2b5aa8e98b..66d4744454 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -259,6 +259,12 @@ void tst_QStringList::filter() list5 = list5.filter( QRegularExpression("[i]ll") ); list6 << "Bill Gates" << "Bill Clinton"; QCOMPARE( list5, list6 ); + + QStringList list7, list8; + list7 << "Bill Gates" << "Joe Blow" << "Bill Clinton"; + list7 = list7.filter( QStringView(QString("Bill")) ); + list8 << "Bill Gates" << "Bill Clinton"; + QCOMPARE( list7, list8 ); } void tst_QStringList::sort() @@ -316,6 +322,16 @@ void tst_QStringList::replaceInStrings() list10 << "Bill Clinton" << "Bill Gates"; list9.replaceInStrings( QRegularExpression("^(.*), (.*)$"), "\\2 \\1" ); QCOMPARE( list9, list10 ); + + QStringList list11, list12, list13, list14; + list11 << "alpha" << "beta" << "gamma" << "epsilon"; + list12 << "alpha" << "beta" << "gamma" << "epsilon"; + list13 << "alpha" << "beta" << "gamma" << "epsilon"; + list11.replaceInStrings( QStringView(QString("a")), QStringView(QString("o")) ); + list12.replaceInStrings( QStringView(QString("a")), QString("o") ); + list13.replaceInStrings( QString("a"), QStringView(QString("o")) ); + list14 << "olpho" << "beto" << "gommo" << "epsilon"; + QCOMPARE( list11, list12 ); } void tst_QStringList::contains() @@ -427,6 +443,7 @@ void tst_QStringList::join() const QCOMPARE(input.join(separator), expectedResult); QCOMPARE(input.join(QLatin1String(separator.toLatin1())), expectedResult); + QCOMPARE(input.join(QStringView(separator)), expectedResult); } void tst_QStringList::join_data() const diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index 581e9152e6..6f01947131 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -596,7 +596,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("C")); QVERIFY(!ref.startsWith("ABCDEF")); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(ref.startsWith('A')); QVERIFY(ref.startsWith(QLatin1Char('A'))); QVERIFY(ref.startsWith(QChar('A'))); @@ -623,7 +626,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.startsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.startsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.startsWith('a', Qt::CaseInsensitive)); QVERIFY(ref.startsWith('A', Qt::CaseInsensitive)); QVERIFY(ref.startsWith(QLatin1Char('a'), Qt::CaseInsensitive)); @@ -656,7 +662,10 @@ void tst_QStringRef::startsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(ref.startsWith(QLatin1String(""))); @@ -670,7 +679,10 @@ void tst_QStringRef::startsWith() { const QStringRef ref; QVERIFY(!ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(!ref.startsWith(QLatin1String(""))); @@ -693,7 +705,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("C")); QVERIFY(!ref.endsWith("ABCDEF")); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(ref.endsWith('B')); QVERIFY(ref.endsWith(QLatin1Char('B'))); QVERIFY(ref.endsWith(QChar('B'))); @@ -720,7 +735,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.endsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.endsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.endsWith('b', Qt::CaseInsensitive)); QVERIFY(ref.endsWith('B', Qt::CaseInsensitive)); QVERIFY(ref.endsWith(QLatin1Char('b'), Qt::CaseInsensitive)); @@ -754,7 +772,10 @@ void tst_QStringRef::endsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1Char(0))); QVERIFY(!ref.endsWith(QLatin1Char('x'))); @@ -768,7 +789,10 @@ void tst_QStringRef::endsWith() { QStringRef ref; QVERIFY(!ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1String(""))); diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 5467d438a3..a46011ff6c 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -192,7 +192,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea // test toPreviousBoundary() { QList<int> expectedBreakPositionsRev = expectedBreakPositions; - std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), qGreater<int>()); + std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), std::greater<int>()); QList<int> actualBreakPositions; boundaryFinder.toEnd(); @@ -539,6 +539,13 @@ void tst_QTextBoundaryFinder::sentenceBoundaries_manual_data() QTest::newRow("data3") << testString << expectedBreakPositions; } + { + QString testString(QString::fromUtf8("Doing TEST, doing another test.")); + QList<int> expectedBreakPositions; + expectedBreakPositions << 0 << 31; + + QTest::newRow("data4") << testString << expectedBreakPositions; + } } void tst_QTextBoundaryFinder::sentenceBoundaries_manual() diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index fff8c75a90..070c25368b 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -57,6 +57,7 @@ private slots: void initializeListComplex(); void insertMove(); void nonCopyable(); + void implicitDefaultCtor(); private: template<typename T> @@ -1078,5 +1079,11 @@ void tst_QVarLengthArray::nonCopyable() QVERIFY(ptr6 == vec.at(5).get()); } +void tst_QVarLengthArray::implicitDefaultCtor() +{ + QVarLengthArray<int> def = {}; + QCOMPARE(def.size(), 0); +} + QTEST_APPLESS_MAIN(tst_QVarLengthArray) #include "tst_qvarlengtharray.moc" diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index 2deb84fa5f..b6921fc0bb 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -311,12 +311,14 @@ void tst_QStandardItem::getSetFlags() item.setCheckable(true); QCOMPARE(item.checkState(), Qt::Checked); +#if QT_DEPRECATED_SINCE(5, 6) // deprecated API item.setTristate(true); QVERIFY(item.isTristate()); QVERIFY(item.flags() & Qt::ItemIsTristate); item.setTristate(false); QVERIFY(!(item.flags() & Qt::ItemIsTristate)); +#endif } void tst_QStandardItem::getSetRowAndColumnCount() diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index 9a4c560a08..87a47bd93b 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -155,7 +155,7 @@ void tst_QKeyEvent::modifiers_data() modifierCombinations.append(modifierCombination); } - qSort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier); + std::sort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier); QTest::addColumn<Qt::KeyboardModifiers>("modifiers"); foreach (const QVector<int> combination, modifierCombinations) { diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index f8b6bf064a..874468c954 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -86,7 +86,7 @@ static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntrie static QChar macSymbolForQtKey(int key) { - const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key); + const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key); if (i == MacSpecialKeyEntriesEnd) return QChar(); return QChar(i->macSymbol); diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 69c961c1a1..c90348e91a 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -189,6 +189,10 @@ void tst_QPainterPath::reserveAndCapacity() p.reserve(0); QVERIFY(p.capacity() >= 1000); + + QPainterPath p2; + p2.reserve(10); + QVERIFY(p.capacity() >= 10); } Q_DECLARE_METATYPE(QPainterPath) diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index a07181c199..591fafc7fb 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -188,6 +188,9 @@ private slots: void lineHeightType(); void cssLineHeightMultiplier(); + + void fontTagFace(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -864,6 +867,18 @@ void tst_QTextDocument::toHtml_data() { CREATE_DOC_AND_CURSOR(); + QTextCharFormat fmt; + fmt.setFontFamily("Times"); + fmt.setFontFamilies(QStringList{ "Times", "serif" }); + cursor.insertText("Blah", fmt); + + QTest::newRow("font-family-with-fallback") << QTextDocumentFragment(&doc) + << QString("<p DEFAULTBLOCKSTYLE><span style=\" font-family:'Times','serif';\">Blah</span></p>"); + } + + { + CREATE_DOC_AND_CURSOR(); + QTextBlockFormat fmt; fmt.setNonBreakableLines(true); cursor.insertBlock(fmt); @@ -3486,5 +3501,26 @@ void tst_QTextDocument::cssLineHeightMultiplier() } } +void tst_QTextDocument::fontTagFace() +{ + { + QTextDocument td; + td.setHtml("<html><body><font face='Times'>Foobar</font></body></html>"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + } + + { + QTextDocument td; + td.setHtml("<html><body><font face='Times, serif'>Foobar</font></body></html>"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + QStringList expectedFamilies = { QLatin1String("Times"), QLatin1String("serif") }; + QCOMPARE(format.fontFamilies().toStringList(), expectedFamilies); + } +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index e85147095c..1afd8af7b0 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5039,9 +5039,6 @@ public: // very similar to ioPostToHttpUploadProgress but for SSL void tst_QNetworkReply::ioPostToHttpsUploadProgress() { -#ifdef Q_OS_WIN - QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); -#endif //QFile sourceFile(testDataDir + "/bigfile"); //QVERIFY(sourceFile.open(QIODevice::ReadOnly)); qint64 wantedSize = 2*1024*1024; // 2 MB @@ -6423,10 +6420,6 @@ void tst_QNetworkReply::encrypted() void tst_QNetworkReply::abortOnEncrypted() { -#ifdef Q_OS_WIN - QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); -#endif - SslServer server; server.listen(); if (!server.isListening()) @@ -8507,9 +8500,7 @@ void tst_QNetworkReply::ioHttpRedirectErrors_data() QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError; -#endif // Q_OS_WIN #endif QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError; } @@ -8586,11 +8577,9 @@ void tst_QNetworkReply::ioHttpRedirectPolicy_data() QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200; QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307; QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200; QTest::newRow("same-origin-ssl") << QNetworkRequest::SameOriginRedirectPolicy << true << 1 << 200; -#endif // Q_OS_WIN #endif } @@ -8644,41 +8633,33 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data() QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("nolesssafe-ssl-ssl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("https:/localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("nolesssafe-ssl-nossl-insecure-redirect") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; -#endif // Q_OS_WIN #endif // 2. SameOriginRedirectsPolicy QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-ssl-ssl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("same-origin-https-http-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; -#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-https-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("https://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; QTest::newRow("same-origin-http-http-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; -#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) -#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; -#endif // Q_OS_WIN #endif } @@ -9153,10 +9134,6 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately() for (int s = 0; s <= 1; s++) { withSsl = (s == 1); -#ifdef Q_OS_WIN - if (withSsl) - QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); -#endif // Q_OS_WIN // Test also needs to run several times because of 9c2ecf89 for (int j = 0; j < 20; j++) { // emulate a minimal https server diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 22ac9aa076..fc5a7d1fab 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -882,7 +882,7 @@ void tst_QTcpServer::serverAddress_data() QTest::addColumn<QHostAddress>("listenAddress"); QTest::addColumn<QHostAddress>("serverAddress"); #ifdef Q_OS_WIN - if (QSysInfo::windowsVersion() < QSysInfo::WV_6_0) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista) QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4); //windows XP doesn't support dual stack sockets else #endif diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c500c6b3c3..7733b0a62b 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -326,8 +326,8 @@ void tst_QTcpSocket::initTestCase_data() QTest::addColumn<bool>("ssl"); QTest::newRow("WithoutProxy") << false << 0 << false; - //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; + QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; @@ -335,8 +335,8 @@ void tst_QTcpSocket::initTestCase_data() #ifndef QT_NO_SSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; - //QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; + QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; @@ -865,7 +865,8 @@ void tst_QTcpSocket::hostNotFound() QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); #ifdef QT_TEST_SERVER QFETCH_GLOBAL(bool, setProxy); - if (setProxy) { + QFETCH_GLOBAL(int, proxyType); + if (setProxy && (proxyType & HttpProxy) == HttpProxy) { QEXPECT_FAIL("", "QTBUG-73953: The version of Squid in the docker container behaves " "differently to the one in the network testing server, returning 503 " "when we expect 404", Continue); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b05f989b5c..4035dfbf5f 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -711,7 +711,7 @@ void tst_QSslSocket::sslErrors() const auto socketSslErrors = socket->sslErrors(); for (const QSslError &err : socketSslErrors) sslErrors << err.error(); - qSort(sslErrors); + std::sort(sslErrors.begin(), sslErrors.end()); QVERIFY(sslErrors.contains(QSslError::HostNameMismatch)); QVERIFY(sslErrors.contains(FLUKE_CERTIFICATE_ERROR)); @@ -721,7 +721,7 @@ void tst_QSslSocket::sslErrors() const auto sslErrorsSpyErrors = qvariant_cast<QList<QSslError> >(qAsConst(sslErrorsSpy).first().first()); for (const QSslError &err : sslErrorsSpyErrors) emittedErrors << err.error(); - qSort(emittedErrors); + std::sort(emittedErrors.begin(), emittedErrors.end()); QCOMPARE(sslErrors, emittedErrors); // check the same errors were emitted by peerVerifyError @@ -730,7 +730,7 @@ void tst_QSslSocket::sslErrors() const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy; for (const QVariantList &args : peerVerifyList) peerErrors << qvariant_cast<QSslError>(args.first()).error(); - qSort(peerErrors); + std::sort(peerErrors.begin(), peerErrors.end()); QCOMPARE(sslErrors, peerErrors); } diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index ec4a44e672..b88d929ca9 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -149,6 +149,17 @@ namespace TestQNamespace { Q_FLAG_NS(TestFlag2) } + +#define TESTEXPORTMACRO Q_DECL_EXPORT + +namespace TestExportNamespace { + Q_NAMESPACE_EXPORT(TESTEXPORTMACRO) + enum class MyEnum { + Key1, Key2 + }; + Q_ENUM_NS(MyEnum) +} + QT_USE_NAMESPACE template <bool b> struct QTBUG_31218 {}; @@ -3893,6 +3904,10 @@ void tst_Moc::testQNamespace() QCOMPARE(meta.enclosingMetaObject(), &TestQNamespace::staticMetaObject); QCOMPARE(meta.keyCount(), 2); + QCOMPARE(TestExportNamespace::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestExportNamespace::staticMetaObject.enumerator(0), "MyEnum", + {{"Key1", 0}, {"Key2", 1}}); + QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index cacee30c86..1df31904d6 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -422,7 +422,7 @@ void tst_qmake::prompt() { #if 0 QProcess qmake; - qmake.setReadChannelMode(QProcess::MergedChannels); + qmake.setProcessChannelMode(QProcess::MergedChannels); qmake.setWorkingDirectory(QLatin1String("testdata/prompt")); qmake.start(QLatin1String("qmake CONFIG-=debug_and_release CONFIG-=debug CONFIG+=release"), QIODevice::Text | QIODevice::ReadWrite); diff --git a/tests/auto/tools/rcc/data/depfile/simple.d.expected b/tests/auto/tools/rcc/data/depfile/simple.d.expected new file mode 100644 index 0000000000..a89b61bdc7 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.d.expected @@ -0,0 +1 @@ +simple.qrc.cpp: ../images/images/circle.png ../images/images/square.png diff --git a/tests/auto/tools/rcc/data/depfile/simple.qrc b/tests/auto/tools/rcc/data/depfile/simple.qrc new file mode 100644 index 0000000000..521dc4d4a0 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>../images/images/circle.png</file> + <file>../images/images/square.png</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/data/depfile/specialchar$file.txt b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt new file mode 100644 index 0000000000..5da849b5c6 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt @@ -0,0 +1 @@ +ABC diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.d.expected b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected new file mode 100644 index 0000000000..9dd1af0958 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected @@ -0,0 +1 @@ +specialchar.qrc.cpp: specialchar$$file.txt ../images/images/subdir/triangle.png diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.qrc b/tests/auto/tools/rcc/data/depfile/specialchar.qrc new file mode 100644 index 0000000000..133cbc7655 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>../images/images/subdir/triangle.png</file> + <file>specialchar$file.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 24fd79cf19..42a4134e5f 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -89,6 +89,9 @@ private slots: void readback_data(); void readback(); + void depFileGeneration_data(); + void depFileGeneration(); + void python(); void cleanupTestCase(); @@ -416,6 +419,49 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::depFileGeneration_data() +{ + QTest::addColumn<QString>("qrcfile"); + QTest::addColumn<QString>("depfile"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("simple") << "simple.qrc" << "simple.d" << "simple.d.expected"; + QTest::newRow("specialchar") << "specialchar.qrc" << "specialchar.d" << "specialchar.d.expected"; +} + +void tst_rcc::depFileGeneration() +{ + QFETCH(QString, qrcfile); + QFETCH(QString, depfile); + QFETCH(QString, expected); + const QString directory = m_dataPath + QLatin1String("/depfile"); + + QProcess process; + process.setWorkingDirectory(directory); + process.start(m_rcc, { "-d", depfile, "-o", qrcfile + ".cpp", qrcfile }); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + QFile depFileOutput(directory + QLatin1String("/") + depfile); + QVERIFY(depFileOutput.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray depFileData = depFileOutput.readAll(); + depFileOutput.close(); + + QFile depFileExpected(directory + QLatin1String("/") + expected); + QVERIFY(depFileExpected.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray expectedData = depFileExpected.readAll(); + depFileExpected.close(); + + QCOMPARE(depFileData, expectedData); +} + void tst_rcc::python() { const QString path = m_dataPath + QLatin1String("/sizes"); @@ -450,6 +496,8 @@ void tst_rcc::cleanupTestCase() { QDir dataDir(m_dataPath + QLatin1String("/binary")); QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); + QDir dataDepDir(m_dataPath + QLatin1String("/depfile")); + entries += dataDepDir.entryInfoList({QLatin1String("*.d"), QLatin1String("*.qrc.cpp")}); foreach (const QFileInfo &entry, entries) QFile::remove(entry.absoluteFilePath()); } diff --git a/tests/auto/tools/uic/baseline/dialog.ui b/tests/auto/tools/uic/baseline/dialog.ui index e99d6fb3c4..936cc2eee8 100644 --- a/tests/auto/tools/uic/baseline/dialog.ui +++ b/tests/auto/tools/uic/baseline/dialog.ui @@ -1,4 +1,4 @@ -<ui version="4.0" > +<ui version="4.0" connectslotsbyname="false"> <class>Dialog</class> <widget class="QDialog" name="Dialog" > <property name="geometry" > diff --git a/tests/auto/tools/uic/baseline/dialog.ui.h b/tests/auto/tools/uic/baseline/dialog.ui.h index aeed71d058..cd6449873e 100644 --- a/tests/auto/tools/uic/baseline/dialog.ui.h +++ b/tests/auto/tools/uic/baseline/dialog.ui.h @@ -52,8 +52,6 @@ public: retranslateUi(Dialog); - - QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 0cfdecbcab..4f3ff15ae0 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -5055,6 +5055,12 @@ public: void tst_QGraphicsItem::paint() { +#if defined(Q_OS_MACOS) + if (QSysInfo::productVersion() == QLatin1String("10.12")) { + QSKIP("Test is very flaky on MacOS_10_12, see QTBUG-76566"); + } +#endif + QGraphicsScene scene; PaintTester paintTester; diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 4a301337ef..530c3bb464 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -330,7 +330,7 @@ public: { // Make sure QGraphicsProxyWidget::paint does not modify the render hints set on the painter. painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::NonCosmeticDefaultPen | QPainter::TextAntialiasing); + | QPainter::TextAntialiasing); const QPainter::RenderHints oldRenderHints = painter->renderHints(); QGraphicsProxyWidget::paint(painter, option, widget); QCOMPARE(painter->renderHints(), oldRenderHints); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 6e42758122..52cc7ed128 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -352,8 +352,8 @@ void tst_QGraphicsView::renderHints() view.setScene(&scene); - view.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); - QCOMPARE(view.renderHints(), QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); + view.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing); + QCOMPARE(view.renderHints(), QPainter::TextAntialiasing | QPainter::Antialiasing); QCOMPARE(item->hints, 0); view.show(); @@ -361,8 +361,8 @@ void tst_QGraphicsView::renderHints() view.repaint(); QTRY_COMPARE(item->hints, view.renderHints()); - view.setRenderHints(QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); - QCOMPARE(view.renderHints(), QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); + view.setRenderHints(QPainter::Antialiasing); + QCOMPARE(view.renderHints(), QPainter::Antialiasing); view.repaint(); QTRY_COMPARE(item->hints, view.renderHints()); diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 3d68e42baf..0d62c2cd4b 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -70,7 +70,7 @@ private slots: void shortcutFromKeyEvent(); // QTBUG-48325 private: - int m_lastEventType; + QEvent::Type m_lastEventType; const int m_keyboardScheme; QAction *m_lastAction; }; @@ -82,7 +82,7 @@ tst_QAction::tst_QAction() void tst_QAction::init() { - m_lastEventType = 0; + m_lastEventType = QEvent::None; m_lastAction = nullptr; } @@ -94,23 +94,23 @@ void tst_QAction::cleanup() // Testing get/set functions void tst_QAction::getSetCheck() { - QAction obj1(0); + QAction obj1(nullptr); // QActionGroup * QAction::actionGroup() // void QAction::setActionGroup(QActionGroup *) - QActionGroup *var1 = new QActionGroup(0); + QActionGroup *var1 = new QActionGroup(nullptr); obj1.setActionGroup(var1); QCOMPARE(var1, obj1.actionGroup()); - obj1.setActionGroup((QActionGroup *)0); - QCOMPARE((QActionGroup *)0, obj1.actionGroup()); + obj1.setActionGroup(nullptr); + QCOMPARE(obj1.actionGroup(), nullptr); delete var1; // QMenu * QAction::menu() // void QAction::setMenu(QMenu *) - QMenu *var2 = new QMenu(0); + QMenu *var2 = new QMenu(nullptr); obj1.setMenu(var2); QCOMPARE(var2, obj1.menu()); - obj1.setMenu((QMenu *)0); - QCOMPARE((QMenu *)0, obj1.menu()); + obj1.setMenu(nullptr); + QCOMPARE(obj1.menu(), nullptr); delete var2; QCOMPARE(obj1.priority(), QAction::NormalPriority); @@ -148,7 +148,7 @@ void tst_QAction::setText() { QFETCH(QString, text); - QAction action(0); + QAction action(nullptr); action.setText(text); QCOMPARE(action.text(), text); @@ -161,7 +161,7 @@ void tst_QAction::setIconText() { QFETCH(QString, iconText); - QAction action(0); + QAction action(nullptr); action.setIconText(iconText); QCOMPARE(action.iconText(), iconText); @@ -171,7 +171,7 @@ void tst_QAction::setIconText() void tst_QAction::setUnknownFont() // QTBUG-42728 { - QAction action(0); + QAction action(nullptr); QFont font("DoesNotExist", 11); action.setFont(font); @@ -182,17 +182,17 @@ void tst_QAction::setUnknownFont() // QTBUG-42728 void tst_QAction::updateState(QActionEvent *e) { if (!e) { - m_lastEventType = 0; - m_lastAction = 0; + m_lastEventType = QEvent::None; + m_lastAction = nullptr; } else { - m_lastEventType = (int)e->type(); + m_lastEventType = e->type(); m_lastAction = e->action(); } } void tst_QAction::actionEvent() { - QAction a(0); + QAction a(nullptr); a.setText("action text"); // add action @@ -202,33 +202,33 @@ void tst_QAction::actionEvent() testWidget.addAction(&a); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionAdded); + QCOMPARE(m_lastEventType, QEvent::ActionAdded); QCOMPARE(m_lastAction, &a); // change action a.setText("new action text"); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionChanged); + QCOMPARE(m_lastEventType, QEvent::ActionChanged); QCOMPARE(m_lastAction, &a); // remove action testWidget.removeAction(&a); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionRemoved); + QCOMPARE(m_lastEventType, QEvent::ActionRemoved); QCOMPARE(m_lastAction, &a); } //basic testing of standard keys void tst_QAction::setStandardKeys() { - QAction act(0); + QAction act(nullptr); act.setShortcut(QKeySequence("CTRL+L")); QList<QKeySequence> list; act.setShortcuts(list); act.setShortcuts(QKeySequence::Copy); - QCOMPARE(act.shortcut(), act.shortcuts().first()); + QCOMPARE(act.shortcut(), act.shortcuts().constFirst()); QList<QKeySequence> expected; const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); @@ -263,7 +263,7 @@ void tst_QAction::alternateShortcuts() QList<QKeySequence> shlist = QList<QKeySequence>() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A"); act.setShortcuts(shlist); - QSignalSpy spy(&act, SIGNAL(triggered())); + QSignalSpy spy(&act, &QAction::triggered); act.setAutoRepeat(true); QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); @@ -322,7 +322,7 @@ void tst_QAction::enabledVisibleInteraction() testWidget.show(); QApplication::setActiveWindow(&testWidget); - QAction act(0); + QAction act(nullptr); // check defaults QVERIFY(act.isEnabled()); QVERIFY(act.isVisible()); @@ -370,7 +370,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup() { // test without a group const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr)); - QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool))); + QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered)); QCOMPARE(spyWithoutGroup.count(), 0); actionWithoutGroup->trigger(); // signal should be emitted @@ -388,7 +388,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup() void tst_QAction::task229128TriggeredSignalWhenInActiongroup() { - QActionGroup ag(0); + QActionGroup ag(nullptr); QAction *action = new QAction("Test", &ag); QAction *checkedAction = new QAction("Test 2", &ag); ag.addAction(action); @@ -397,8 +397,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() checkedAction->setCheckable(true); checkedAction->setChecked(true); - QSignalSpy actionSpy(checkedAction, SIGNAL(triggered(bool))); - QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction*))); + QSignalSpy actionSpy(checkedAction, QOverload<bool>::of(&QAction::triggered)); + QSignalSpy actionGroupSpy(&ag, QOverload<QAction*>::of(&QActionGroup::triggered)); QCOMPARE(actionGroupSpy.count(), 0); QCOMPARE(actionSpy.count(), 0); checkedAction->trigger(); @@ -513,10 +513,10 @@ void tst_QAction::disableShortcutsWithBlockedWidgets() class ShortcutOverrideWidget : public QWidget { public: - ShortcutOverrideWidget(QWidget *parent = 0) : QWidget(parent), shortcutOverrideCount(0) {} - int shortcutOverrideCount; + using QWidget::QWidget; + int shortcutOverrideCount = 0; protected: - bool event(QEvent *e) + bool event(QEvent *e) override { if (e->type() == QEvent::ShortcutOverride) ++shortcutOverrideCount; diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 64e5b969e7..524040d003 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -49,11 +49,11 @@ private slots: void tst_QActionGroup::enabledPropagation() { - QActionGroup testActionGroup( 0 ); + QActionGroup testActionGroup(nullptr); QAction* childAction = new QAction( &testActionGroup ); QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(0); + QAction* freeAction = new QAction(nullptr); QVERIFY( testActionGroup.isEnabled() ); QVERIFY( childAction->isEnabled() ); @@ -88,11 +88,11 @@ void tst_QActionGroup::enabledPropagation() void tst_QActionGroup::visiblePropagation() { - QActionGroup testActionGroup( 0 ); + QActionGroup testActionGroup(nullptr); QAction* childAction = new QAction( &testActionGroup ); QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(0); + QAction* freeAction = new QAction(nullptr); QVERIFY( testActionGroup.isVisible() ); QVERIFY( childAction->isVisible() ); @@ -125,7 +125,7 @@ void tst_QActionGroup::visiblePropagation() void tst_QActionGroup::exclusive() { - QActionGroup group(0); + QActionGroup group(nullptr); group.setExclusive(false); QVERIFY( !group.isExclusive() ); @@ -215,7 +215,7 @@ void tst_QActionGroup::separators() menu.addActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 2); + QCOMPARE(menu.actions().size(), 2); const auto removeActions = [&menu](const QList<QAction *> &actions) { for (QAction *action : actions) @@ -223,14 +223,14 @@ void tst_QActionGroup::separators() }; removeActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 0); + QCOMPARE(menu.actions().size(), 0); action = new QAction(&actGroup); action->setText("test two"); menu.addActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 3); + QCOMPARE(menu.actions().size(), 3); } void tst_QActionGroup::testActionInTwoQActionGroup() @@ -250,7 +250,7 @@ void tst_QActionGroup::testActionInTwoQActionGroup() void tst_QActionGroup::unCheckCurrentAction() { - QActionGroup group(0); + QActionGroup group(nullptr); QAction action1(&group) ,action2(&group); action1.setCheckable(true); action2.setCheckable(true); diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index b78287f84b..8c262ff3a5 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -30,6 +30,8 @@ #include <QtTest/QtTest> #include <qapplication.h> #include <qtextedit.h> +#include <qlineedit.h> +#include <qcompleter.h> #include <qpushbutton.h> #include <qmainwindow.h> #include <qstatusbar.h> @@ -39,7 +41,6 @@ #include <qshortcut.h> #include <qscreen.h> -class AccelForm; QT_BEGIN_NAMESPACE class QMainWindow; class QTextEdit; @@ -49,15 +50,14 @@ class tst_QShortcut : public QObject { Q_OBJECT public: - tst_QShortcut(); - virtual ~tst_QShortcut(); - enum Action { SetupAccel, TestAccel, - ClearAll - } currentAction; + ClearAll, + TestEnd + }; + Q_ENUM(Action) enum Widget { NoWidget, @@ -68,8 +68,8 @@ public: TriggerSlot5, TriggerSlot6, TriggerSlot7, - SendKeyEvent }; + Q_ENUM(Widget) enum Result { NoResult, @@ -82,7 +82,8 @@ public: Slot7Triggered, SentKeyEvent, Ambiguous - } currentResult; + } currentResult = NoResult; + Q_ENUM(Result) public slots: void slotTrig1() { currentResult = Slot1Triggered; } @@ -99,16 +100,9 @@ public slots: void ambigSlot5() { currentResult = Ambiguous; ambigResult = Slot5Triggered; } void ambigSlot6() { currentResult = Ambiguous; ambigResult = Slot6Triggered; } void ambigSlot7() { currentResult = Ambiguous; ambigResult = Slot7Triggered; } - void statusMessage( const QString& message ) { sbText = message; } - void shortcutDestroyed(QObject* obj); - void sendKeyEvent() { sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); currentResult = SentKeyEvent; } - -public slots: - void initTestCase(); - void cleanupTestCase(); - void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); } private slots: + void cleanup(); void number_data(); void number(); void text_data(); @@ -120,34 +114,25 @@ private slots: void unicodeCompare(); void context(); void duplicatedShortcutOverride(); + void shortcutToFocusProxy(); protected: static Qt::KeyboardModifiers toButtons( int key ); void defElements(); - void clearAllShortcuts(); - QShortcut *setupShortcut(int testWidget, const QKeySequence &ks); - QShortcut *setupShortcut(int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); - - QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); - QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); + QShortcut *setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks, + Qt::ShortcutContext context = Qt::WindowShortcut); + QShortcut *setupShortcut(QWidget *parent, const QString &name, Widget testWidget, + const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); - void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); - void sendKeyEvents(int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); + static void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, + int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); void testElement(); - QMainWindow *mainW; - QList<QShortcut*> shortcuts; - QTextEdit *edit; - QString sbText; Result ambigResult; }; -Q_DECLARE_METATYPE(tst_QShortcut::Widget); -Q_DECLARE_METATYPE(tst_QShortcut::Result); -Q_DECLARE_METATYPE(tst_QShortcut::Action); - class TestEdit : public QTextEdit { Q_OBJECT @@ -159,7 +144,8 @@ public: } protected: - bool event(QEvent *e) { + bool event(QEvent *e) override + { // Make testedit allow any Ctrl+Key as shortcut if (e->type() == QEvent::ShortcutOverride) { QKeyEvent *ke = static_cast<QKeyEvent*>(e); @@ -192,33 +178,28 @@ protected: } }; -tst_QShortcut::tst_QShortcut(): mainW( 0 ) +class MainWindow : public QMainWindow { -} +public: + MainWindow(); -tst_QShortcut::~tst_QShortcut() -{ - clearAllShortcuts(); -} + TestEdit *testEdit() const { return m_testEdit; } + +private: + TestEdit *m_testEdit; +}; -void tst_QShortcut::initTestCase() +MainWindow::MainWindow() { - currentResult = NoResult; - mainW = new QMainWindow(0); - mainW->setWindowFlags(Qt::X11BypassWindowManagerHint); - edit = new TestEdit(mainW, "test_edit"); - mainW->setFixedSize( 200, 200 ); - mainW->setCentralWidget( edit ); - mainW->show(); - mainW->activateWindow(); - QVERIFY(QTest::qWaitForWindowActive(mainW)); - connect( mainW->statusBar(), SIGNAL(messageChanged(QString)), - this, SLOT(statusMessage(QString)) ); + setWindowFlags(Qt::X11BypassWindowManagerHint); + m_testEdit = new TestEdit(this, "test_edit"); + setCentralWidget(m_testEdit); + setFixedSize(200, 200); } -void tst_QShortcut::cleanupTestCase() +void tst_QShortcut::cleanup() { - delete mainW; + QVERIFY(QApplication::topLevelWidgets().size() <= 1); // The data driven tests keep a widget around } Qt::KeyboardModifiers tst_QShortcut::toButtons( int key ) @@ -273,7 +254,7 @@ void tst_QShortcut::number_data() defElements(); // Clear all - QTest::newRow("N00 - clear") << ClearAll << NoWidget <<QString("")<<0<<0<<0<<0<<0<<0<<0<<0<<NoResult; + QTest::newRow("N00 - clear") << ClearAll << NoWidget <<QString()<<0<<0<<0<<0<<0<<0<<0<<0<<NoResult; //=========================================== // [Shift + key] on non-shift shortcuts testing @@ -285,15 +266,15 @@ void tst_QShortcut::number_data() Shift + Qt::Key_Plus on Qt::Key_Pluss Qt::Key_Plus on Qt::Key_Pluss */ - QTest::newRow("N001 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N001 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("N001:Shift + M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N001:M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N001 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + //QTest::newRow("N001:Shift + M - [M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N001:M - [M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N001 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("N001:Shift++ [+]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N001:+ [+]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N001 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("N001:Shift++ [+]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N001:+ [+]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N001 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_M on Shift + Qt::Key_M @@ -301,32 +282,32 @@ void tst_QShortcut::number_data() Shift + Qt::Key_Plus on Shift + Qt::Key_Pluss Qt::Key_Plus on Shift + Qt::Key_Pluss */ - QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_F1 on Qt::Key_F1 Qt::Key_F1 on Qt::Key_F1 */ - QTest::newRow("N003 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N003 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("N003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N003:F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N003 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("N003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N003:F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N003 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_F1 on Shift + Qt::Key_F1 Qt::Key_F1 on Shift + Qt::Key_F1 */ - QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_Tab on Qt::Key_Tab @@ -334,14 +315,14 @@ void tst_QShortcut::number_data() Qt::Key_Backtab on Qt::Key_Tab Shift + Qt::Key_Backtab on Qt::Key_Tab */ - QTest::newRow("N005a - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005a:Tab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N005a - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005a:Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + //QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; // (Shift+)BackTab != Tab, but Shift+BackTab == Shift+Tab - QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_Tab on Shift + Qt::Key_Tab @@ -349,12 +330,12 @@ void tst_QShortcut::number_data() Qt::Key_Backtab on Shift + Qt::Key_Tab Shift + Qt::Key_Backtab on Shift + Qt::Key_Tab */ - QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_Tab on Qt::Key_Backtab @@ -362,15 +343,15 @@ void tst_QShortcut::number_data() Qt::Key_Backtab on Qt::Key_Backtab Shift + Qt::Key_Backtab on Qt::Key_Backtab */ - QTest::newRow("N006a - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N006a - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // This should work, since platform dependent code will transform the // Shift+Tab into a Shift+BackTab, which should trigger the shortcut - QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL - QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL + QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N006a - clear") << ClearAll << NoWidget<< QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N006a - clear") << ClearAll << NoWidget<< QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_Tab on Shift + Qt::Key_Backtab @@ -378,12 +359,12 @@ void tst_QShortcut::number_data() Qt::Key_Backtab on Shift + Qt::Key_Backtab Shift + Qt::Key_Backtab on Shift + Qt::Key_Backtab */ - QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL - QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL + QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all //=========================================== // [Shift + key] and [key] on shortcuts with @@ -394,11 +375,11 @@ void tst_QShortcut::number_data() Qt::Key_F1 Shift + Qt::Key_F1 */ - QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N007:F1") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_M @@ -406,51 +387,51 @@ void tst_QShortcut::number_data() Ctrl + Qt::Key_M Alt + Qt::Key_M */ - QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; /* Testing Single Sequence Ambiguity Qt::Key_M on shortcut2 */ - QTest::newRow("N05 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N:Qt::Key_M on slot") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous; - QTest::newRow("N05 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N05 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N:Qt::Key_M on slot") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous; + QTest::newRow("N05 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Specialkeys Qt::Key_aring Qt::Key_Aring Qt::UNICODE_ACCEL + Qt::Key_K */ - QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString("") << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Multiple Sequences Qt::Key_M Qt::Key_I, Qt::Key_M Shift+Qt::Key_I, Qt::Key_M */ - QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString("") << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString("") << int(Qt::SHIFT + Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult; - - QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N13 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult; + + QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("N:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; } // ------------------------------------------------------------------ @@ -460,7 +441,7 @@ void tst_QShortcut::text_data() { defElements(); // Clear all - QTest::newRow("T00 - clear") << ClearAll << NoWidget <<QString("")<<0<<0<<0<<0<<0<<0<<0<<0<< NoResult; + QTest::newRow("T00 - clear") << ClearAll << NoWidget <<QString()<<0<<0<<0<<0<<0<<0<<0<<0<< NoResult; //=========================================== // [Shift + key] on non-shift shortcuts testing @@ -474,13 +455,13 @@ void tst_QShortcut::text_data() */ QTest::newRow("T001 - slot1") << SetupAccel << TriggerSlot1 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("T001:Shift+M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T001:M - [M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + //QTest::newRow("T001:Shift+M - [M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T001:M - [M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; QTest::newRow("T001 - slot2") << SetupAccel << TriggerSlot2 << QString("+") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("T001:Shift++ [+]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T001:+ [+]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T001 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("T001:Shift++ [+]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T001:+ [+]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T001 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_M on Shift + Qt::Key_M @@ -491,12 +472,12 @@ void tst_QShortcut::text_data() Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Pluss */ QTest::newRow("T002 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T002 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Plus @@ -505,10 +486,10 @@ void tst_QShortcut::text_data() */ QTest::newRow("T002b - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString("") << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_F1 on Qt::Key_F1 @@ -516,18 +497,18 @@ void tst_QShortcut::text_data() */ QTest::newRow("T003 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; //commented out because the behaviour changed, those tests should be updated - //QTest::newRow("T003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T003:F1 - [F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T003 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + //QTest::newRow("T003:Shift+F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T003:F1 - [F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T003 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Shift + Qt::Key_F1 on Shift + Qt::Key_F1 Qt::Key_F1 on Shift + Qt::Key_F1 */ QTest::newRow("T004 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all //=========================================== // [Shift + key] and [key] on shortcuts with @@ -540,9 +521,9 @@ void tst_QShortcut::text_data() */ QTest::newRow("T007 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T007 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T007:F1") << TestAccel << NoWidget << QString("") << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Sequences Qt::Key_M @@ -555,17 +536,17 @@ void tst_QShortcut::text_data() QTest::newRow("T03 - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T04 - slot2") << SetupAccel << TriggerSlot2 << QString("Alt+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; /* Testing Single Sequence Ambiguity Qt::Key_M on shortcut2 */ QTest::newRow("T05 - slot2") << SetupAccel << TriggerSlot2 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T:Qt::Key_M on TriggerSlot2") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous; - QTest::newRow("T06 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T:Qt::Key_M on TriggerSlot2") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Ambiguous; + QTest::newRow("T06 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Single Specialkeys Qt::Key_aring @@ -576,12 +557,12 @@ void tst_QShortcut::text_data() QTest::newRow("T06 - slot1") << SetupAccel << TriggerSlot1 << QString::fromLatin1("\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString::fromLatin1("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T08 - slot2") << SetupAccel << TriggerSlot1 << QString("K") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString("") << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString("") << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all /* Testing Multiple Sequences Qt::Key_M @@ -591,10 +572,38 @@ void tst_QShortcut::text_data() QTest::newRow("T10 - slot1") << SetupAccel << TriggerSlot1 << QString("M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T11 - slot2") << SetupAccel << TriggerSlot2 << QString("I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T12 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString("") << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; - QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T13 - clear") << ClearAll << NoWidget << QString("") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; + QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; + QTest::newRow("T:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; +} + +class ButtonWidget : public QWidget +{ +public: + ButtonWidget(); + + QPushButton *pushButton1() const { return m_pb1; } + QPushButton *pushButton2() const { return m_pb2; } + +private: + QPushButton *m_pb1; + QPushButton *m_pb2; +}; + +ButtonWidget::ButtonWidget() +{ + // Setup two identical shortcuts on different pushbuttons + QString name = QLatin1String("pushbutton-1"); + m_pb1 = new QPushButton(name, this); + m_pb1->setObjectName(name); + name = QLatin1String("pushbutton-2"); + m_pb2 = new QPushButton(name, this); + m_pb2->setObjectName(name); + auto hLayout = new QHBoxLayout(this); + hLayout->addWidget(m_pb1); + hLayout->addWidget(m_pb2); + hLayout->addStretch(); } // ------------------------------------------------------------------ @@ -602,9 +611,11 @@ void tst_QShortcut::text_data() // ------------------------------------------------------------------ void tst_QShortcut::disabledItems() { - clearAllShortcuts(); - mainW->activateWindow(); - QVERIFY(QTest::qWaitForWindowActive(mainW)); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); /* Testing Disabled Shortcuts Qt::Key_M on slot1 @@ -614,27 +625,27 @@ void tst_QShortcut::disabledItems() */ // Setup two identical shortcuts on different pushbuttons - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); - - QShortcut *cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M"); - QShortcut *cut2 = setupShortcut(&pb1, "shortcut2-pb1", TriggerSlot1, "Shift+M"); - QShortcut *cut3 = setupShortcut(&pb2, "shortcut3-pb2", TriggerSlot2, "M"); - QShortcut *cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+M"); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); + const int shiftM = Qt::SHIFT + Qt::Key_M; + QShortcut *cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, + QKeySequence(Qt::Key_M)); + QShortcut *cut2 = setupShortcut(pb1, "shortcut2-pb1", TriggerSlot1, + QKeySequence(shiftM)); + QShortcut *cut3 = setupShortcut(pb2, "shortcut3-pb2", TriggerSlot2, + QKeySequence(Qt::Key_M)); + QShortcut *cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, + QKeySequence(shiftM)); cut3->setEnabled(false); cut4->setEnabled(false); currentResult = NoResult; - sendKeyEvents(Qt::Key_M, 'm'); + sendKeyEvents(&mainW, Qt::Key_M, 'm'); QCOMPARE(currentResult, Slot1Triggered); currentResult = NoResult; - sendKeyEvents(Qt::SHIFT+Qt::Key_M, 'M'); + sendKeyEvents(&mainW, shiftM, 'M'); QCOMPARE(currentResult, Slot1Triggered); cut2->setEnabled(false); @@ -647,11 +658,11 @@ void tst_QShortcut::disabledItems() Shift + Qt::Key_M on slot2 */ currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::SHIFT+Qt::Key_M, 'M' ); + sendKeyEvents(&mainW, shiftM, 'M' ); QCOMPARE( currentResult, Slot2Triggered ); @@ -659,67 +670,34 @@ void tst_QShortcut::disabledItems() Qt::Key_F5 on slot1 Shift + Qt::Key_F5 on slot2 (disabled) */ - clearAllShortcuts(); - cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "F5"); - cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+F5"); - - cut1->setKey(QKeySequence("F5")); - cut4->setKey(QKeySequence("Shift+F5")); + qDeleteAll(mainW.findChildren<QShortcut *>()); + const int shiftF5 = Qt::SHIFT + Qt::Key_F5; + cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_F5)); + cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, QKeySequence(shiftF5)); cut1->setEnabled(true); cut4->setEnabled(false); currentResult = NoResult; - sendKeyEvents( Qt::Key_F5, 0 ); + sendKeyEvents(&mainW, Qt::Key_F5, 0 ); QCOMPARE( currentResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::SHIFT+Qt::Key_F5, 0 ); + sendKeyEvents(&mainW, shiftF5, 0 ); QCOMPARE( currentResult, NoResult ); - -#if 0 - qFatal("Not testing statusbar text feedback yet, since not implemented"); - /* Testing Disabled Accel, and the corresponding statusbar feedback - Ctrl + Qt::Key_K, Ctrl + Qt::Key_L on slot1 - Ctrl + Qt::Key_K, Ctrl + Qt::Key_M on slot2 (disabled) - */ - cut1->setKey(QKeySequence("Ctrl+K, Ctrl+L")); - cut4->setKey(QKeySequence("Ctrl+K, Ctrl+M")); - - cut1->setEnabled(true); - cut4->setEnabled(false); - - currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); - sendKeyEvents( Qt::CTRL+Qt::Key_Q, 0 ); - QCOMPARE( currentResult, NoResult ); - if (over_330) - QCOMPARE( sbText, QString("Ctrl+K, Ctrl+Q not defined") ); - - currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); - sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); - QCOMPARE( currentResult, NoResult ); - if (over_330) - 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() ); -#endif - clearAllShortcuts(); - cut1 = 0; - cut4 = 0; } // ------------------------------------------------------------------ // Ambiguous Elements ----------------------------------------------- // ------------------------------------------------------------------ void tst_QShortcut::ambiguousRotation() { - clearAllShortcuts(); + MainWindow mainW; + const QString name = QLatin1String(QTest::currentTestFunction()); + mainW.setWindowTitle(name); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Shortcut rotation scheme Ctrl + Qt::Key_A on slot1 (disabled) Ctrl + Qt::Key_A on slot2 (disabled) @@ -729,13 +707,15 @@ void tst_QShortcut::ambiguousRotation() Ctrl + Qt::Key_A on slot6 Ctrl + Qt::Key_A on slot7 (disabled) */ - QShortcut *cut1 = setupShortcut(TriggerSlot1, "Ctrl+A"); - QShortcut *cut2 = setupShortcut(TriggerSlot2, "Ctrl+A"); - QShortcut *cut3 = setupShortcut(TriggerSlot3, "Ctrl+A"); - QShortcut *cut4 = setupShortcut(TriggerSlot4, "Ctrl+A"); - QShortcut *cut5 = setupShortcut(TriggerSlot5, "Ctrl+A"); - QShortcut *cut6 = setupShortcut(TriggerSlot6, "Ctrl+A"); - QShortcut *cut7 = setupShortcut(TriggerSlot7, "Ctrl+A"); + const int ctrlA = Qt::CTRL + Qt::Key_A; + QKeySequence ctrlA_Sequence(ctrlA); + QShortcut *cut1 = setupShortcut(&mainW, name, TriggerSlot1, ctrlA_Sequence); + QShortcut *cut2 = setupShortcut(&mainW, name, TriggerSlot2, ctrlA_Sequence); + QShortcut *cut3 = setupShortcut(&mainW, name, TriggerSlot3, ctrlA_Sequence); + QShortcut *cut4 = setupShortcut(&mainW, name, TriggerSlot4, ctrlA_Sequence); + QShortcut *cut5 = setupShortcut(&mainW, name, TriggerSlot5, ctrlA_Sequence); + QShortcut *cut6 = setupShortcut(&mainW, name, TriggerSlot6, ctrlA_Sequence); + QShortcut *cut7 = setupShortcut(&mainW, name, TriggerSlot7, ctrlA_Sequence); cut1->setEnabled(false); cut2->setEnabled(false); @@ -749,37 +729,37 @@ void tst_QShortcut::ambiguousRotation() // Continue... currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot3Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot4Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot6Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot3Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot4Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot6Triggered); @@ -804,94 +784,87 @@ void tst_QShortcut::ambiguousRotation() currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot1Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot2Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot5Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot7Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot1Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot2Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot5Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot7Triggered); - - clearAllShortcuts(); - cut1 = 0; cut2 = 0; - cut3 = 0; cut4 = 0; - cut5 = 0; cut6 = 0; - cut7 = 0; } void tst_QShortcut::ambiguousItems() { - clearAllShortcuts(); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Ambiguous Shortcuts Qt::Key_M on Pushbutton 1 Qt::Key_M on Pushbutton 2 */ // Setup two identical shortcuts on different pushbuttons - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); - setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M"); - setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, "M"); + setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_M)); + setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, QKeySequence(Qt::Key_M)); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot2Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot1Triggered ); - - clearAllShortcuts(); } @@ -900,32 +873,31 @@ void tst_QShortcut::ambiguousItems() // ------------------------------------------------------------------ void tst_QShortcut::unicodeCompare() { - clearAllShortcuts(); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Unicode/non-Unicode Shortcuts Qt::Key_M on Pushbutton 1 Qt::Key_M on Pushbutton 2 */ - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); QKeySequence ks1("Ctrl+M"); // Unicode QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode - setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1); - setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, ks2); + setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, ks1); + setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, ks2); currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); + sendKeyEvents(&mainW, Qt::CTRL + Qt::Key_M, 0); QCOMPARE( currentResult, Ambiguous ); // They _are_ ambiguous, so the QKeySequence operator== // should indicate the same QVERIFY( ks1 == ks2 ); QVERIFY( !(ks1 != ks2) ); - - clearAllShortcuts(); } // ------------------------------------------------------------------ @@ -933,25 +905,29 @@ void tst_QShortcut::unicodeCompare() // ------------------------------------------------------------------ void tst_QShortcut::keypressConsumption() { - clearAllShortcuts(); - edit->clear(); - QCOMPARE(edit->toPlainText().size(), 0); + MainWindow mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + auto edit = mainW.testEdit(); - QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, "Ctrl+I, A"); - QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, "Ctrl+I, B"); + const int ctrlI = Qt::CTRL + Qt::Key_I; + QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, QKeySequence(ctrlI, Qt::Key_A)); + QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, QKeySequence(ctrlI, Qt::Key_B)); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(edit, Qt::CTRL + Qt::Key_I, 0); // Send key to edit + sendKeyEvents(edit, ctrlI, 0); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); // Make sure next keypress is eaten (failing multiple keysequence) sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); // Next keypress should be normal sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit @@ -979,11 +955,15 @@ void tst_QShortcut::keypressConsumption() QCOMPARE( ambigResult, NoResult ); QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>a")); - clearAllShortcuts(); + qDeleteAll(mainW.findChildren<QShortcut *>()); edit->clear(); QCOMPARE(edit->toPlainText().size(), 0); - setupShortcut(edit, "first", SendKeyEvent, "Ctrl+A"); + auto cut = setupShortcut(edit, QLatin1String("first"), QKeySequence(Qt::CTRL + Qt::Key_A)); + connect(cut, &QShortcut::activated, edit, [this, edit] () { + this->sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); + this->currentResult = tst_QShortcut::SentKeyEvent; + }); // Verify reentrancy when a non-shortcut is triggered as part // of shortcut processing. @@ -992,7 +972,7 @@ void tst_QShortcut::keypressConsumption() sendKeyEvents(edit, Qt::CTRL + Qt::Key_A, 0); QCOMPARE(currentResult, SentKeyEvent); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString(QString("<Ctrl+B>"))); + QCOMPARE(edit->toPlainText(), QLatin1String("<Ctrl+B>")); } // ------------------------------------------------------------------ @@ -1000,12 +980,17 @@ void tst_QShortcut::keypressConsumption() // ------------------------------------------------------------------ void tst_QShortcut::context() { - clearAllShortcuts(); + const QString name = QLatin1String(QTest::currentTestFunction()); + MainWindow mainW; + mainW.setWindowTitle(name + QLatin1String("_Helper")); + mainW.show(); + auto edit = mainW.testEdit(); QWidget myBox; - TestEdit *other1 = new TestEdit(&myBox, "test_edit_other1"); - TestEdit *other2 = new TestEdit(&myBox, "test_edit_other2"); - QHBoxLayout *layout = new QHBoxLayout(&myBox); + myBox.setWindowTitle(name); + auto other1 = new TestEdit(&myBox, "test_edit_other1"); + auto other2 = new TestEdit(&myBox, "test_edit_other2"); + auto layout = new QHBoxLayout(&myBox); layout->addWidget(other1); layout->addWidget(other2); myBox.show(); @@ -1030,8 +1015,8 @@ void tst_QShortcut::context() // Focus on 'other1' edit, so Active Window context should trigger other1->activateWindow(); // <--- QApplication::setActiveWindow(other1); - QCOMPARE(qApp->activeWindow(), other1->window()); - QCOMPARE(qApp->focusWidget(), (QWidget *)other1); + QCOMPARE(QApplication::activeWindow(), other1->window()); + QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other1)); currentResult = NoResult; ambigResult = NoResult; @@ -1039,13 +1024,13 @@ void tst_QShortcut::context() other1->clear(); other2->clear(); - QCOMPARE(qApp->focusWidget(), (QWidget *)other1); + QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other1)); sendKeyEvents(other1, Qt::ALT+Qt::Key_1); QCOMPARE(currentResult, Slot1Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); // ..but not Focus context on 'other2'.. currentResult = NoResult; @@ -1057,9 +1042,9 @@ void tst_QShortcut::context() sendKeyEvents(other1, Qt::ALT+Qt::Key_2); QCOMPARE(currentResult, NoResult); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); QCOMPARE(other1->toPlainText(), QString("<Alt+2>")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(other2->toPlainText(), QString()); // ..however, application global context on 'edit' should.. currentResult = NoResult; @@ -1071,15 +1056,15 @@ void tst_QShortcut::context() sendKeyEvents(other1, Qt::ALT+Qt::Key_3); QCOMPARE(currentResult, Slot3Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); // Changing focus to 'other2' should make the Focus context there work other2->activateWindow(); other2->setFocus(); // ### - QTRY_COMPARE(qApp->activeWindow(), other2->window()); - QCOMPARE(qApp->focusWidget(), (QWidget *)other2); + QTRY_COMPARE(QApplication::activeWindow(), other2->window()); + QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other2)); currentResult = NoResult; ambigResult = NoResult; @@ -1090,20 +1075,18 @@ void tst_QShortcut::context() sendKeyEvents(other2, Qt::ALT+Qt::Key_2); QCOMPARE(currentResult, Slot2Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); - - clearAllShortcuts(); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); } // QTBUG-38986, do not generate duplicated QEvent::ShortcutOverride in event processing. class OverrideCountingWidget : public QWidget { public: - OverrideCountingWidget(QWidget *parent = 0) : QWidget(parent), overrideCount(0) {} + using QWidget::QWidget; - int overrideCount; + int overrideCount = 0; bool event(QEvent *e) override { @@ -1127,95 +1110,55 @@ void tst_QShortcut::duplicatedShortcutOverride() QCOMPARE(w.overrideCount, 1); } -// ------------------------------------------------------------------ -// Element Testing helper functions --------------------------------- -// ------------------------------------------------------------------ -void tst_QShortcut::clearAllShortcuts() +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks, Qt::ShortcutContext context) { - QList<QShortcut *> shortcutsCpy = shortcuts; - qDeleteAll(shortcutsCpy); - shortcuts.clear(); -} - -QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QKeySequence &ks) -{ - return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, ks); -} - -QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QString &txt, int k1, int k2, int k3, int k4) -{ - return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, - (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); -} - -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1, int k2, int k3, int k4) -{ - return setupShortcut(parent, name, testWidget, - (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); + // Set up shortcut for next test + auto cut = new QShortcut(ks, parent, nullptr, nullptr, context); + cut->setObjectName(name); + return cut; } -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget, +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, Widget testWidget, const QKeySequence &ks, Qt::ShortcutContext context) { // Set up shortcut for next test - QShortcut *cut = new QShortcut(QKeySequence(), parent, 0, 0, context); - cut->setObjectName(name); - cut->setKey(ks); + auto cut = setupShortcut(parent, name, ks, context); - const char *normal = 0; - const char *ambig = 0; - switch(testWidget) - { + switch (testWidget) { case TriggerSlot1: - normal = SLOT(slotTrig1()); - ambig = SLOT(ambigSlot1()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig1); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot1); break; case TriggerSlot2: - normal = SLOT(slotTrig2()); - ambig = SLOT(ambigSlot2()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig2); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot2); break; case TriggerSlot3: - normal = SLOT(slotTrig3()); - ambig = SLOT(ambigSlot3()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig3); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot3); break; case TriggerSlot4: - normal = SLOT(slotTrig4()); - ambig = SLOT(ambigSlot4()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig4); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot4); break; case TriggerSlot5: - normal = SLOT(slotTrig5()); - ambig = SLOT(ambigSlot5()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig5); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot5); break; case TriggerSlot6: - normal = SLOT(slotTrig6()); - ambig = SLOT(ambigSlot6()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig6); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot6); break; case TriggerSlot7: - normal = SLOT(slotTrig7()); - ambig = SLOT(ambigSlot7()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig7); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot7); + break; + case NoWidget: break; - case SendKeyEvent: - normal = SLOT(sendKeyEvent()); } - connect(cut, SIGNAL(activated()), this, normal); - if (ambig) - connect(cut, SIGNAL(activatedAmbiguously()), this, ambig); - connect(cut, SIGNAL(destroyed(QObject*)), this, SLOT(shortcutDestroyed(QObject*))); - shortcuts.append(cut); return cut; } -void tst_QShortcut::shortcutDestroyed(QObject* obj) -{ - shortcuts.erase(std::remove(shortcuts.begin(), shortcuts.end(), obj), - shortcuts.end()); -} - -void tst_QShortcut::sendKeyEvents(int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4) -{ - sendKeyEvents(mainW, k1, c1, k2, c2, k3, c3, k4, c4); -} - void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4) { Qt::KeyboardModifiers b1 = toButtons( k1 ); @@ -1255,6 +1198,8 @@ void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2 void tst_QShortcut::testElement() { + static QScopedPointer<MainWindow> mainW; + currentResult = NoResult; QFETCH(tst_QShortcut::Action, action); QFETCH(tst_QShortcut::Widget, testWidget); @@ -1269,15 +1214,54 @@ void tst_QShortcut::testElement() QFETCH(int, c4); QFETCH(tst_QShortcut::Result, result); - if (action == ClearAll) { - clearAllShortcuts(); - } else if (action == SetupAccel) { - setupShortcut(testWidget, txt, k1, k2, k3, k4); - } else { - sendKeyEvents(k1, c1, k2, c2, k3, c3, k4, c4); - QCOMPARE((int)currentResult, (int)result); + if (mainW.isNull()) { + mainW.reset(new MainWindow); + mainW->setWindowTitle(QTest::currentTestFunction()); + mainW->show(); + mainW->activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(mainW.data())); + } + + switch (action) { + case ClearAll: + qDeleteAll(mainW->findChildren<QShortcut *>()); + break; + case SetupAccel: + setupShortcut(mainW.data(), txt, testWidget, txt.isEmpty() + ? QKeySequence(k1, k2, k3, k4) : QKeySequence::fromString(txt)); + break; + case TestAccel: + sendKeyEvents(mainW.data(), k1, c1, k2, c2, k3, c3, k4, c4); + QCOMPARE(currentResult, result); + break; + case TestEnd: + mainW.reset(); + break; } } +void tst_QShortcut::shortcutToFocusProxy() +{ + QLineEdit le; + QCompleter completer; + QStringListModel *slm = new QStringListModel(QStringList() << "a0" << "a1" << "a2", &completer); + completer.setModel(slm); + completer.setCompletionMode(QCompleter::PopupCompletion); + le.setCompleter(&completer); + QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le); + QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear); + le.setFocus(); + le.show(); + + QVERIFY(QTest::qWaitForWindowActive(&le)); + QCOMPARE(QApplication::focusWidget(), &le); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_A); + + QCOMPARE(le.text(), QString::fromLocal8Bit("a")); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Alt); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_S, Qt::AltModifier); + QCOMPARE(le.text(), QString()); +} + QTEST_MAIN(tst_QShortcut) #include "tst_qshortcut.moc" diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index fb40674d98..103be88f86 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -54,6 +54,7 @@ #include <qrandom.h> #include <qtoolbar.h> #include <qtoolbutton.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtGui/qpaintengine.h> #include <QtGui/qbackingstore.h> #include <QtGui/qguiapplication.h> @@ -7056,7 +7057,7 @@ void tst_QWidget::renderWithPainter() // Make sure QWidget::render does not modify the render hints set on the painter. painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::NonCosmeticDefaultPen | QPainter::TextAntialiasing); + | QPainter::TextAntialiasing); QPainter::RenderHints oldRenderHints = painter.renderHints(); widget.render(&painter); QCOMPARE(painter.renderHints(), oldRenderHints); @@ -7654,7 +7655,7 @@ void tst_QWidget::moveWindowInShowEvent() void tst_QWidget::repaintWhenChildDeleted() { #ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) { QTest::qWait(1000); } #endif @@ -8853,7 +8854,7 @@ void tst_QWidget::translucentWidget() #ifdef Q_OS_WIN QWidget *desktopWidget = QApplication::desktop()->screen(0); - if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height()); else #endif @@ -8864,6 +8865,12 @@ void tst_QWidget::translucentWidget() QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size()); QCOMPARE(actual,expected); + + const QWindow *window = label.windowHandle(); + const QSurfaceFormat translucentFormat = window->requestedFormat(); + label.setAttribute(Qt::WA_TranslucentBackground, false); + const QSurfaceFormat opaqueFormat = window->requestedFormat(); + QVERIFY(translucentFormat != opaqueFormat); } class MaskResizeTestWidget : public QWidget diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index a552c91928..68e672e16d 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -353,7 +353,10 @@ void tst_QStyle::testWindowsVistaStyle() QStyle *vistastyle = QStyleFactory::create("WindowsVista"); QVERIFY(testAllFunctions(vistastyle)); - if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current().majorVersion() + == QOperatingSystemVersion::WindowsVista.majorVersion() + && QOperatingSystemVersion::current().minorVersion() + == QOperatingSystemVersion::WindowsVista.minorVersion()) testPainting(vistastyle, "vista"); delete vistastyle; } diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index c6f6900def..cd045e476c 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -3454,7 +3454,7 @@ void tst_QDateTimeEdit::timeSpec() } QVERIFY(edit.minimumTime() != min.time()); QVERIFY(edit.minimumDateTime().timeSpec() != min.timeSpec()); - QCOMPARE(edit.minimumDateTime().toTime_t(), min.toTime_t()); + QCOMPARE(edit.minimumDateTime().toSecsSinceEpoch(), min.toSecsSinceEpoch()); } else { QSKIP("Not tested in the GMT timezone"); } diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index df5ff9d448..3408fc0946 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -174,7 +174,7 @@ void tst_QProgressBar::format() #ifndef Q_OS_MAC // Animated scroll bars get paint events all the time #ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista) #endif QVERIFY(!bar.repainted); #endif diff --git a/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md new file mode 100644 index 0000000000..6bad9cb95b --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md @@ -0,0 +1 @@ +you’ll hope to see ❝quotes❞ ﹠1½ ⅔ ¼ ⅗ ⅚ ⅝ some “vulgar” fractions (pardon my «French») diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index 083e297941..27bf0ce7be 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -94,6 +94,8 @@ private slots: void urlEncoding(); void sourceType_data(); void sourceType(); + void unicode_data(); + void unicode(); private: TestBrowser *browser; @@ -721,5 +723,31 @@ void tst_QTextBrowser::sourceType() QCOMPARE(maxHeadingLevel, expectedMaxHeadingLevel); } +void tst_QTextBrowser::unicode_data() +{ + QTest::addColumn<QString>("sourceFile"); + QTest::addColumn<QTextDocument::ResourceType>("sourceType"); + QTest::addColumn<QString>("expectedText"); + +#if QT_CONFIG(textmarkdownreader) + QTest::newRow("markdown with quotes and fractions") << "quotesAndFractions.md" << QTextDocument::MarkdownResource << + "you\u2019ll hope to see \u275Dquotes\u275E \uFE601\u00BD \u2154 \u00BC \u2157 \u215A \u215D some \u201Cvulgar\u201D fractions (pardon my \u00ABFrench\u00BB)"; +#endif +} + +void tst_QTextBrowser::unicode() +{ + QFETCH(QString, sourceFile); + QFETCH(QTextDocument::ResourceType, sourceType); + QFETCH(QString, expectedText); + browser->setSource(QUrl::fromLocalFile(QFINDTESTDATA(sourceFile)), sourceType); + QTextFrame::iterator iterator = browser->document()->rootFrame()->begin(); + while (!iterator.atEnd()) { + QString blockText = iterator++.currentBlock().text(); + if (!blockText.isEmpty()) + QCOMPARE(blockText, expectedText); + } +} + QTEST_MAIN(tst_QTextBrowser) #include "tst_qtextbrowser.moc" |