diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-08-06 10:45:40 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-08-06 10:54:01 +0200 |
commit | 77da617dc8e378a631ee8c15b1b414f16b87f147 (patch) | |
tree | 563f4f8e64e416774ea2b1599b896b589385168c /tests/auto/corelib | |
parent | c17134e2db4d364855aa78a0d3c47cb9ef964dd9 (diff) | |
parent | 01f3530650f9f6f4c08520263a3c62281d81e3fc (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
doc/global/qt-cpp-defines.qdocconf
src/3rdparty/forkfd/forkfd.c
src/corelib/codecs/qtextcodec.cpp
src/corelib/kernel/qmetatype.cpp
src/corelib/tools/qset.qdoc
src/gui/accessible/qaccessible.cpp
src/gui/image/qpixmapcache.cpp
src/opengl/qgl.cpp
src/tools/qdoc/generator.cpp
src/widgets/kernel/qwidget.cpp
tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
Change-Id: I4fbe1fa756a54c6843aa75f4ef70a1069ba7b085
Diffstat (limited to 'tests/auto/corelib')
6 files changed, 163 insertions, 14 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 1b7d410beb..db2805ebf0 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -411,18 +411,48 @@ void tst_QDebug::qDebugQString() const qDebug().noquote().nospace() << qSetFieldWidth(8) << string; QCOMPARE(s_msg, " " + string); - string = QLatin1String("\nSm\xF8rg\xE5sbord\\"); + string = "Sm\xc3\xb8rg\xc3\xa5sbord " // Latin script + "\xce\x91\xce\xb8\xce\xae\xce\xbd\xce\xb1 " // Greek script + "\xd0\x9c\xd0\xbe\xd1\x81\xd0\xba\xd0\xb2\xd0\xb0"; // Cyrillic script qDebug().noquote().nospace() << string; QCOMPARE(s_msg, string); + // This string only contains printable characters qDebug() << string; - QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\"")); + QCOMPARE(s_msg, '"' + string + '"'); + + string = "\n\t\\\""; + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, string); + + // This string only contains characters that must be escaped + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\n\\t\\\\\\\"\"")); - // surrogate pairs (including broken pairings) - ushort utf16[] = { 0xDC00, 0xD800, 0xDC00, 'x', 0xD800, 0xDC00, 0xD800, 0 }; + // Unicode escapes, BMP + string = "\1" // U+0001: START OF HEADING (category Cc) + "\x7f" // U+007F: DELETE (category Cc) + "\xc2\xad" // U+00AD: SOFT HYPHEN (category Cf) + "\xef\xbb\xbf"; // U+FEFF: ZERO WIDTH NO-BREAK SPACE / BOM (category Cf) + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\u0001\\u007F\\u00AD\\uFEFF\"")); + + // Unicode printable non-BMP + string = "\xf0\x90\x80\x80"; // U+10000: LINEAR B SYLLABLE B008 A (category Lo) + qDebug() << string; + QCOMPARE(s_msg, '"' + string + '"'); + + // non-BMP and non-printable + string = "\xf3\xa0\x80\x81 " // U+E0001: LANGUAGE TAG (category Cf) + "\xf4\x80\x80\x80"; // U+100000: Plane 16 Private Use (category Co) + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\U000E0001 \\U00100000\"")); + + // broken surrogate pairs + ushort utf16[] = { 0xDC00, 0xD800, 'x', 0xD800, 0 }; string = QString::fromUtf16(utf16); qDebug() << string; - QCOMPARE(s_msg, QString("\"\\uDC00\\U00010000x\\U00010000\\uD800\"")); + QCOMPARE(s_msg, QString("\"\\uDC00\\uD800x\\uD800\"")); } void tst_QDebug::qDebugQStringRef() const @@ -657,5 +687,14 @@ void tst_QDebug::threadSafety() const } } +// Should compile: instentiation of unrelated operator<< should not cause cause compilation +// error in QDebug operators (QTBUG-47375) +class TestClassA {}; +class TestClassB {}; + +template <typename T> +TestClassA& operator<< (TestClassA& s, T&) { return s; }; +template<> TestClassA& operator<< <TestClassB>(TestClassA& s, TestClassB& l); + QTEST_MAIN(tst_QDebug); #include "tst_qdebug.moc" diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index bbee33ac78..8d276b3616 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -144,12 +144,18 @@ inline bool qIsLikelyToBeNfs(int /* handle */) #endif #endif +static QString seedAndTemplate() +{ + qsrand(QDateTime::currentDateTimeUtc().toTime_t()); + return QDir::tempPath() + "/tst_qfileinfo-XXXXXX"; +} class tst_QFileInfo : public QObject { Q_OBJECT public: - tst_QFileInfo() : m_currentDir(QDir::currentPath()) {} + tst_QFileInfo() : m_currentDir(QDir::currentPath()), m_dir(seedAndTemplate()) + {} private slots: void initTestCase(); diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index deef9eecbf..0f2cfd406d 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -376,6 +376,7 @@ private slots: #ifdef Q_COMPILER_VARIADIC_MACROS Q_LOGGING_CATEGORY(TST_MACRO_2, "tst.macro.2", QtDebugMsg) Q_LOGGING_CATEGORY(TST_MACRO_3, "tst.macro.3", QtFatalMsg) + Q_LOGGING_CATEGORY(TST_MACRO_4, "tst.macro.4", QtInfoMsg) #endif void QLoggingCategoryMacro() @@ -383,6 +384,7 @@ private slots: const QLoggingCategory &cat1 = TST_MACRO_1(); QCOMPARE(cat1.categoryName(), "tst.macro.1"); QCOMPARE(cat1.isDebugEnabled(), true); + QCOMPARE(cat1.isInfoEnabled(), true); QCOMPARE(cat1.isWarningEnabled(), true); QCOMPARE(cat1.isCriticalEnabled(), true); @@ -390,14 +392,23 @@ private slots: const QLoggingCategory &cat2 = TST_MACRO_2(); QCOMPARE(cat2.categoryName(), "tst.macro.2"); QCOMPARE(cat2.isDebugEnabled(), true); + QCOMPARE(cat2.isInfoEnabled(), true); QCOMPARE(cat2.isWarningEnabled(), true); QCOMPARE(cat2.isCriticalEnabled(), true); const QLoggingCategory &cat3 = TST_MACRO_3(); QCOMPARE(cat3.categoryName(), "tst.macro.3"); QCOMPARE(cat3.isDebugEnabled(), false); + QCOMPARE(cat3.isInfoEnabled(), false); QCOMPARE(cat3.isWarningEnabled(), false); QCOMPARE(cat3.isCriticalEnabled(), false); + + const QLoggingCategory &cat4 = TST_MACRO_4(); + QCOMPARE(cat4.categoryName(), "tst.macro.4"); + QCOMPARE(cat4.isDebugEnabled(), false); + QCOMPARE(cat4.isInfoEnabled(), true); + QCOMPARE(cat4.isWarningEnabled(), true); + QCOMPARE(cat4.isCriticalEnabled(), true); #endif } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 02501ca9d9..0ffac21186 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -155,6 +155,8 @@ private slots: void failToStart(); void failToStartWithWait(); void failToStartWithEventLoop(); + void failToStartEmptyArgs_data(); + void failToStartEmptyArgs(); protected slots: void readFromProcess(); @@ -1690,6 +1692,42 @@ void tst_QProcess::failToStartWithEventLoop() } } +void tst_QProcess::failToStartEmptyArgs_data() +{ + QTest::addColumn<int>("startOverload"); + QTest::newRow("start(QString, QStringList, OpenMode)") << 0; + QTest::newRow("start(QString, OpenMode)") << 1; + QTest::newRow("start(OpenMode)") << 2; +} + +void tst_QProcess::failToStartEmptyArgs() +{ + QFETCH(int, startOverload); + qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); + + QProcess process; + QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QVERIFY(errorSpy.isValid()); + + switch (startOverload) { + case 0: + process.start(QString(), QStringList(), QIODevice::ReadWrite); + break; + case 1: + process.start(QString(), QIODevice::ReadWrite); + break; + case 2: + process.start(QIODevice::ReadWrite); + break; + default: + QFAIL("Unhandled QProcess::start overload."); + }; + + QVERIFY(!process.waitForStarted()); + QCOMPARE(errorSpy.count(), 1); + QCOMPARE(process.error(), QProcess::FailedToStart); +} + //----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 7c32f2cc12..12abaf47c5 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -73,10 +73,45 @@ static inline QString testSuiteWarning() return result; } +static bool copyResourceFile(const QString &sourceFileName, const QString &targetFileName, + QString *errorMessage) +{ + + QFile sourceFile(sourceFileName); + if (!sourceFile.exists()) { + *errorMessage = QDir::toNativeSeparators(sourceFileName) + QLatin1String(" does not exist."); + return false; + } + if (!sourceFile.copy(targetFileName)) { + *errorMessage = QLatin1String("Cannot copy ") + + QDir::toNativeSeparators(sourceFileName) + QLatin1String(" to ") + + QDir::toNativeSeparators(targetFileName) + QLatin1String(": ") + + sourceFile.errorString(); + return false; + } + // QFile::copy() sets the permissions of the source file which are read-only for + // resource files. Set write permission to enable deletion of the temporary directory. + QFile targetFile(targetFileName); + if (!targetFile.setPermissions(targetFile.permissions() | QFileDevice::WriteUser)) { + *errorMessage = QLatin1String("Cannot set write permission on ") + + QDir::toNativeSeparators(targetFileName) + QLatin1String(": ") + + targetFile.errorString(); + return false; + } + return true; +} + // Set LANG before QCoreApplication is created Q_CONSTRUCTOR_FUNCTION(initializeLang) +static QString seedAndTemplate() +{ + qsrand(QDateTime::currentDateTimeUtc().toTime_t()); + return QDir::tempPath() + "/tst_qmimedatabase-XXXXXX"; +} + tst_QMimeDatabase::tst_QMimeDatabase() + : m_temporaryDir(seedAndTemplate()) { } @@ -103,15 +138,15 @@ void tst_QMimeDatabase::initTestCase() const QString freeDesktopXml = QStringLiteral("freedesktop.org.xml"); const QString xmlFileName = QLatin1String(RESOURCE_PREFIX) + freeDesktopXml; - QVERIFY2(QFileInfo(xmlFileName).exists(), qPrintable(xmlFileName + QStringLiteral(" does not exist"))); - QFile xml(xmlFileName); - QVERIFY(xml.copy(globalPackageDir + '/' + freeDesktopXml)); + const QString xmlTargetFileName = globalPackageDir + QLatin1Char('/') + freeDesktopXml; + QString errorMessage; + QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage)); m_testSuite = QFINDTESTDATA("testfiles"); if (m_testSuite.isEmpty()) qWarning("%s", qPrintable(testSuiteWarning())); - const QString errorMessage = QString::fromLatin1("Cannot find '%1'"); + errorMessage = QString::fromLatin1("Cannot find '%1'"); m_yastMimeTypes = QLatin1String(RESOURCE_PREFIX) + yastFileName; QVERIFY2(QFile::exists(m_yastMimeTypes), qPrintable(errorMessage.arg(yastFileName))); m_qmlAgainFileName = QLatin1String(RESOURCE_PREFIX) + qmlAgainFileName; @@ -836,8 +871,9 @@ void tst_QMimeDatabase::installNewGlobalMimeType() if (!QFileInfo(destDir).isDir()) QVERIFY(QDir(m_globalXdgDir).mkpath(destDir)); - QVERIFY(QFile::copy(m_yastMimeTypes, destFile)); - QVERIFY(QFile::copy(m_qmlAgainFileName, destQmlFile)); + QString errorMessage; + QVERIFY2(copyResourceFile(m_yastMimeTypes, destFile, &errorMessage), qPrintable(errorMessage)); + QVERIFY2(copyResourceFile(m_qmlAgainFileName, destQmlFile, &errorMessage), qPrintable(errorMessage)); if (!waitAndRunUpdateMimeDatabase(mimeDir)) QSKIP("shared-mime-info not found, skipping mime.cache test"); @@ -882,8 +918,9 @@ void tst_QMimeDatabase::installNewLocalMimeType() QFile::remove(destFile); const QString destQmlFile = destDir + QLatin1String(qmlAgainFileName); QFile::remove(destQmlFile); - QVERIFY(QFile::copy(m_yastMimeTypes, destFile)); - QVERIFY(QFile::copy(m_qmlAgainFileName, destQmlFile)); + QString errorMessage; + QVERIFY2(copyResourceFile(m_yastMimeTypes, destFile, &errorMessage), qPrintable(errorMessage)); + QVERIFY2(copyResourceFile(m_qmlAgainFileName, destQmlFile, &errorMessage), qPrintable(errorMessage)); if (!runUpdateMimeDatabase(mimeDir)) { const QString skipWarning = QStringLiteral("shared-mime-info not found, skipping mime.cache test (") + QDir::toNativeSeparators(mimeDir) + QLatin1Char(')'); diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index 2af37eb86e..b511abf670 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -823,6 +823,24 @@ void tst_QTimeZone::tzTest() QCOMPARE(dat.offsetFromUtc, 3600); QCOMPARE(dat.standardTimeOffset, 3600); QCOMPARE(dat.daylightTimeOffset, 0); + + // Test TZ timezone vs UTC timezone for fractionary negative offset + QTzTimeZonePrivate tztz1("America/Caracas"); + QUtcTimeZonePrivate tzutc1("UTC-04:30"); + QVERIFY(tztz1.isValid()); + QVERIFY(tzutc1.isValid()); + QTzTimeZonePrivate::Data datatz1 = tztz1.data(std); + QTzTimeZonePrivate::Data datautc1 = tzutc1.data(std); + QCOMPARE(datatz1.offsetFromUtc, datautc1.offsetFromUtc); + + // Test TZ timezone vs UTC timezone for fractionary positive offset + QTzTimeZonePrivate tztz2("Asia/Calcutta"); + QUtcTimeZonePrivate tzutc2("UTC+05:30"); + QVERIFY(tztz2.isValid()); + QVERIFY(tzutc2.isValid()); + QTzTimeZonePrivate::Data datatz2 = tztz2.data(std); + QTzTimeZonePrivate::Data datautc2 = tzutc2.data(std); + QCOMPARE(datatz2.offsetFromUtc, datautc2.offsetFromUtc); #endif // Q_OS_UNIX } |