diff options
Diffstat (limited to 'tests/auto/corelib/io')
37 files changed, 320 insertions, 165 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index b43ea7cfa5..7b8b1df166 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -38,6 +38,13 @@ class tst_QDebug: public QObject { Q_OBJECT +public: + enum EnumType { EnumValue1 = 1, EnumValue2 = 2 }; + enum FlagType { EnumFlag1 = 1, EnumFlag2 = 2 }; + Q_ENUM(EnumType) + Q_DECLARE_FLAGS(Flags, FlagType) + Q_FLAG(Flags) + private slots: void assignment() const; void warningWithoutDebug() const; @@ -637,6 +644,15 @@ void tst_QDebug::qDebugQFlags() const QCOMPARE(s_line, line); QCOMPARE(QString::fromLatin1(s_function), function); + // Test the output of QFlags with an enum not declared with Q_DECLARE_FLAGS and Q_FLAGS + QFlags<EnumType> flags2(EnumValue2); + qDebug() << flags2; + QCOMPARE(s_msg, QString::fromLatin1("QFlags<tst_QDebug::EnumType>(EnumValue2)")); + + // A now for one that was fully declared + tst_QDebug::Flags flags3(EnumFlag1); + qDebug() << flags3; + QCOMPARE(s_msg, QString::fromLatin1("QFlags<tst_QDebug::FlagType>(EnumFlag1)")); } void tst_QDebug::textStreamModifiers() const diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index afa15fe895..30f0e447ad 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -33,7 +33,6 @@ #include <qdebug.h> #include <qdir.h> #include <qfileinfo.h> -#include <qregexp.h> #include <qstringlist.h> #if defined(Q_OS_WIN) diff --git a/tests/auto/corelib/io/qfile/.gitignore b/tests/auto/corelib/io/qfile/.gitignore index c508239722..615264e4d4 100644 --- a/tests/auto/corelib/io/qfile/.gitignore +++ b/tests/auto/corelib/io/qfile/.gitignore @@ -1,6 +1,10 @@ tst_qfile -stdinprocess/stdinprocess -stdinprocess/stdinprocess.exe +stdinprocess_helper +stdinprocess_helper.exe +debug/stdinprocess_helper +debug/stdinprocess_helper.exe +release/stdinprocess_helper +release/stdinprocess_helper.exe readonlyfile newfile.txt appendfile.txt diff --git a/tests/auto/corelib/io/qfile/qfile.pro b/tests/auto/corelib/io/qfile/qfile.pro index 0735daedb3..91c5c15f66 100644 --- a/tests/auto/corelib/io/qfile/qfile.pro +++ b/tests/auto/corelib/io/qfile/qfile.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = test stdinprocess +SUBDIRS = test.pro +!winrt: SUBDIRS += stdinprocess diff --git a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp b/tests/auto/corelib/io/qfile/stdinprocess/main.cpp index 6ff42c2485..77a1932bd5 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp +++ b/tests/auto/corelib/io/qfile/stdinprocess/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) { if (argc < 2) { - printf("usage: stdinprocess <all|line <0|1>>\n"); + printf("usage: stdinprocess_helper <all|line <0|1>>\n"); printf("echos all its input to its output.\n"); return 1; } diff --git a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro index 8e463e4cef..512da8939b 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro +++ b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro @@ -1,8 +1,4 @@ SOURCES += main.cpp QT = core -CONFIG -= app_bundle debug_and_release_target -CONFIG += console -# This app is testdata for tst_qfile -target.path = $$[QT_INSTALL_TESTS]/tst_qfile/$$TARGET -INSTALLS += target +load(qt_test_helper) diff --git a/tests/auto/corelib/io/qfile/test.pro b/tests/auto/corelib/io/qfile/test.pro new file mode 100644 index 0000000000..95389ab3e2 --- /dev/null +++ b/tests/auto/corelib/io/qfile/test.pro @@ -0,0 +1,26 @@ +CONFIG += testcase +QT = core-private testlib +qtHaveModule(network): QT += network +else: DEFINES += QT_NO_NETWORK + +contains(CONFIG, builtin_testdata) { + DEFINES += BUILTIN_TESTDATA +} + +TESTDATA += BLACKLIST + +TARGET = tst_qfile + +SOURCES = tst_qfile.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h + +RESOURCES += qfile.qrc rename-fallback.qrc copy-fallback.qrc + +TESTDATA += \ + dosfile.txt noendofline.txt testfile.txt \ + testlog.txt two.dots.file tst_qfile.cpp \ + Makefile forCopying.txt forRenaming.txt \ + resources/file1.ext1 + +win32:!winrt: LIBS += -lole32 -luuid diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro deleted file mode 100644 index 1472ddbb83..0000000000 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ /dev/null @@ -1,25 +0,0 @@ -CONFIG += testcase -CONFIG -= debug_and_release_target -QT = core-private core testlib -qtHaveModule(network): QT += network -else: DEFINES += QT_NO_NETWORK - -contains(CONFIG, builtin_testdata) { - DEFINES += BUILTIN_TESTDATA -} - -TESTDATA += ../BLACKLIST - -TARGET = ../tst_qfile -SOURCES = ../tst_qfile.cpp -INCLUDEPATH += ../../../../../shared/ -HEADERS += ../../../../../shared/emulationdetector.h - -RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc - -TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ - ../testlog.txt ../two.dots.file ../tst_qfile.cpp \ - ../Makefile ../forCopying.txt ../forRenaming.txt \ - ../resources/file1.ext1 - -win32:!winrt: LIBS+=-lole32 -luuid diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 6665200585..678a80c3f7 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -367,7 +367,7 @@ private: QTemporaryDir m_temporaryDir; const QString m_oldDir; - QString m_stdinProcessDir; + QString m_stdinProcess; QString m_testSourceFile; QString m_testLogFile; QString m_dosFile; @@ -379,12 +379,6 @@ private: QString m_noEndOfLineFile; }; -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) - #define STDINPROCESS_NAME "libstdinprocess.so" -#else // !android || android_embedded - #define STDINPROCESS_NAME "stdinprocess" -#endif // android && !android_embededd - static const char noReadFile[] = "noreadfile"; static const char readOnlyFile[] = "readonlyfile"; @@ -455,11 +449,13 @@ void tst_QFile::initTestCase() QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); #if QT_CONFIG(process) #if defined(Q_OS_ANDROID) - m_stdinProcessDir = QCoreApplication::applicationDirPath(); + m_stdinProcess = QCoreApplication::applicationDirPath() + QLatin1String("/libstdinprocess_helper.so"); +#elif defined(Q_OS_WIN) + m_stdinProcess = QFINDTESTDATA("stdinprocess_helper.exe"); #else - m_stdinProcessDir = QFINDTESTDATA("stdinprocess"); + m_stdinProcess = QFINDTESTDATA("stdinprocess_helper"); #endif - QVERIFY(!m_stdinProcessDir.isEmpty()); + QVERIFY(!m_stdinProcess.isEmpty()); #endif m_testLogFile = QFINDTESTDATA("testlog.txt"); QVERIFY(!m_testLogFile.isEmpty()); @@ -981,7 +977,7 @@ void tst_QFile::readAllStdin() QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), QStringList(QStringLiteral("all"))); + process.start(m_stdinProcess, QStringList(QStringLiteral("all"))); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); @@ -1014,7 +1010,7 @@ void tst_QFile::readLineStdin() for (int i = 0; i < 2; ++i) { QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), + process.start(m_stdinProcess, QStringList() << QStringLiteral("line") << QString::number(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); @@ -1050,7 +1046,7 @@ void tst_QFile::readLineStdin_lineByLine() for (int i = 0; i < 2; ++i) { QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), + process.start(m_stdinProcess, QStringList() << QStringLiteral("line") << QString::number(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); @@ -1297,6 +1293,12 @@ void tst_QFile::append() f.putChar('a'); f.close(); QCOMPARE(int(f.size()), 2); + + QVERIFY2(f.open(QIODevice::Append | QIODevice::Truncate), msgOpenFailed(f).constData()); + QCOMPARE(f.pos(), 0); + f.putChar('a'); + f.close(); + QCOMPARE(int(f.size()), 1); } void tst_QFile::permissions_data() @@ -1833,13 +1835,14 @@ void tst_QFile::encodeName() void tst_QFile::truncate() { - for (int i = 0; i < 2; ++i) { + const QIODevice::OpenModeFlag modes[] = { QFile::ReadWrite, QIODevice::WriteOnly, QIODevice::Append }; + for (auto mode : modes) { QFile file("truncate.txt"); QVERIFY2(file.open(QFile::WriteOnly), msgOpenFailed(file).constData()); file.write(QByteArray(200, '@')); file.close(); - QVERIFY2(file.open((i ? QFile::WriteOnly : QFile::ReadWrite) | QFile::Truncate), msgOpenFailed(file).constData()); + QVERIFY2(file.open(mode | QFile::Truncate), msgOpenFailed(file).constData()); file.write(QByteArray(100, '$')); file.close(); @@ -2210,7 +2213,8 @@ public: uint ownerId(FileOwner) const { return 0; } QString owner(FileOwner) const { return QString(); } QDateTime fileTime(FileTime) const { return QDateTime(); } - bool setFileTime(const QDateTime &newDate, FileTime time) { return false; } + bool setFileTime(const QDateTime &newDate, FileTime time) + { Q_UNUSED(newDate) Q_UNUSED(time) return false; } private: int number; @@ -2755,19 +2759,20 @@ void tst_QFile::renameMultiple() void tst_QFile::appendAndRead() { - QFile writeFile(QLatin1String("appendfile.txt")); - QVERIFY2(writeFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgOpenFailed(writeFile).constData()); + const QString fileName(QStringLiteral("appendfile.txt")); + QFile writeFile(fileName); + QVERIFY2(writeFile.open(QIODevice::Append | QIODevice::Truncate), msgOpenFailed(writeFile).constData()); - QFile readFile(QLatin1String("appendfile.txt")); + QFile readFile(fileName); QVERIFY2(readFile.open(QIODevice::ReadOnly), msgOpenFailed(readFile).constData()); // Write to the end of the file, then read that character back, and so on. for (int i = 0; i < 100; ++i) { char c = '\0'; - writeFile.putChar(char(i % 256)); + writeFile.putChar(char(i)); writeFile.flush(); QVERIFY(readFile.getChar(&c)); - QCOMPARE(c, char(i % 256)); + QCOMPARE(c, char(i)); QCOMPARE(readFile.pos(), writeFile.pos()); } @@ -2778,8 +2783,6 @@ void tst_QFile::appendAndRead() writeFile.flush(); QCOMPARE(readFile.read(size).size(), size); } - - readFile.close(); } void tst_QFile::miscWithUncPathAsCurrentDir() diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 87d5675e7a..017eebe153 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -199,7 +199,8 @@ private slots: void fileTimes_data(); void fileTimes(); - void fileTimes_oldFile(); + void fakeFileTimes_data(); + void fakeFileTimes(); void isSymLink_data(); void isSymLink(); @@ -629,6 +630,16 @@ void tst_QFileInfo::canonicalFilePath() info.canonicalFilePath(); #if defined(Q_OS_UNIX) + // If this file exists, you can't log in to run this test ... + const QString notExtantPath(QStringLiteral("/etc/nologin")); + QFileInfo notExtant(notExtantPath); + QCOMPARE(notExtant.canonicalFilePath(), QString()); + + // A path with a non-directory as a directory component also doesn't exist: + const QString badDirPath(QStringLiteral("/dev/null/sub/dir/n'existe.pas")); + QFileInfo badDir(badDirPath); + QCOMPARE(badDir.canonicalFilePath(), QString()); + // This used to crash on Mac QFileInfo dontCrash(QLatin1String("/")); QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/")); @@ -1212,12 +1223,23 @@ void tst_QFileInfo::fileTimes() QVERIFY(writeTime < beforeRead); } -void tst_QFileInfo::fileTimes_oldFile() +void tst_QFileInfo::fakeFileTimes_data() { + QTest::addColumn<QDateTime>("when"); + // This is 2^{31} seconds before 1970-01-01 15:14:8, // i.e. shortly after the start of time_t, in any time-zone: - const QDateTime early(QDate(1901, 12, 14), QTime(12, 0)); - QFile file("ancientfile.txt"); + 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); +} + +void tst_QFileInfo::fakeFileTimes() +{ + QFETCH(QDateTime, when); + + QFile file("faketimefile.txt"); file.open(QIODevice::WriteOnly); file.write("\n", 1); file.close(); @@ -1228,15 +1250,13 @@ void tst_QFileInfo::fileTimes_oldFile() modification time, so need to re-open for read in order to setFileTime(). */ file.open(QIODevice::ReadOnly); - bool ok = file.setFileTime(early, QFileDevice::FileModificationTime); + bool ok = file.setFileTime(when, QFileDevice::FileModificationTime); file.close(); - if (ok) { - QFileInfo info(file.fileName()); - QCOMPARE(info.lastModified(), early); - } else { - QSKIP("Unable to set file metadata to ancient values"); - } + if (ok) + QCOMPARE(QFileInfo(file.fileName()).lastModified(), when); + else + QSKIP("Unable to set file metadata to contrived values"); } void tst_QFileInfo::isSymLink_data() diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index fed05698fd..da5327594c 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -209,9 +209,6 @@ void tst_QIODevice::read_QByteArray() //-------------------------------------------------------------------- void tst_QIODevice::unget() { -#if defined(Q_OS_MAC) - QSKIP("The unget network test is unstable on Mac. See QTBUG-39983."); -#endif QBuffer buffer; buffer.open(QBuffer::ReadWrite); buffer.write("ZXCV"); diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index 5b61a6007d..a10e706ed7 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp @@ -187,6 +187,13 @@ private slots: "default=false"); QCOMPARE(parser.rules().size(), 1); + // QSettings escapes * to %2A when writing. + parser.setContent("[Rules]\n" + "module.%2A=false"); + QCOMPARE(parser.rules().size(), 1); + QCOMPARE(parser.rules().first().category, QString("module.")); + QCOMPARE(parser.rules().first().flags, QLoggingRule::LeftFilter); + parser.setContent("[OtherSection]\n" "default=false"); QCOMPARE(parser.rules().size(), 0); diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index b78fa29fb6..17c51eaaf4 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -65,7 +65,7 @@ void tst_QNoDebug::streaming() const { QDateTime dt(QDate(1,2,3),QTime(4,5,6)); const QByteArray debugString = dt.toString(QStringViewLiteral("yyyy-MM-dd HH:mm:ss.zzz t")).toLatin1(); - const QByteArray message = "QDateTime(" + debugString + " Qt::TimeSpec(LocalTime))"; + const QByteArray message = "QDateTime(" + debugString + " Qt::LocalTime)"; QTest::ignoreMessage(QtWarningMsg, message.constData()); qWarning() << dt; } diff --git a/tests/auto/corelib/io/qresourceengine/.gitattributes b/tests/auto/corelib/io/qresourceengine/.gitattributes index add3716d81..88edd3681a 100644 --- a/tests/auto/corelib/io/qresourceengine/.gitattributes +++ b/tests/auto/corelib/io/qresourceengine/.gitattributes @@ -1 +1,2 @@ testqrc/test.qrc -crlf +*.txt -crlf diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index e8071297b1..1e12a41dea 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -1,25 +1,2 @@ -CONFIG += testcase -TARGET = tst_qresourceengine - -QT = core testlib -SOURCES = tst_qresourceengine.cpp -RESOURCES += testqrc/test.qrc - -qtPrepareTool(QMAKE_RCC, rcc, _DEP) -runtime_resource.target = runtime_resource.rcc -runtime_resource.depends = $$PWD/testqrc/test.qrc $$QMAKE_RCC_EXE -runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $$PWD/testqrc/test.qrc -o $${runtime_resource.target} -QMAKE_EXTRA_TARGETS = runtime_resource -PRE_TARGETDEPS += $${runtime_resource.target} -QMAKE_DISTCLEAN += $${runtime_resource.target} - -TESTDATA += \ - parentdir.txt \ - testqrc/* -GENERATED_TESTDATA = $${runtime_resource.target} - -android:!android-embedded { - RESOURCES += android_testdata.qrc -} - -builtin_testdata: DEFINES += BUILTIN_TESTDATA +TEMPLATE = subdirs +SUBDIRS = staticplugin qresourceengine_test.pro diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine_test.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine_test.pro new file mode 100644 index 0000000000..3838a72c21 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine_test.pro @@ -0,0 +1,33 @@ +CONFIG += testcase +TARGET = tst_qresourceengine + +QT = core testlib +SOURCES = tst_qresourceengine.cpp +RESOURCES += testqrc/test.qrc + +qtPrepareTool(QMAKE_RCC, rcc, _DEP) +runtime_resource.target = runtime_resource.rcc +runtime_resource.depends = $$PWD/testqrc/test.qrc $$QMAKE_RCC_EXE +runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $$PWD/testqrc/test.qrc -o $${runtime_resource.target} +QMAKE_EXTRA_TARGETS = runtime_resource +PRE_TARGETDEPS += $${runtime_resource.target} +QMAKE_DISTCLEAN += $${runtime_resource.target} + +TESTDATA += \ + parentdir.txt \ + testqrc/* +GENERATED_TESTDATA = $${runtime_resource.target} + +android:!android-embedded { + RESOURCES += android_testdata.qrc +} + +win32 { + CONFIG(debug, debug|release): LIBS += -Lstaticplugin/debug + else: LIBS += -Lstaticplugin/release +} else { + LIBS += -Lstaticplugin +} +LIBS += -lmoctestplugin + +builtin_testdata: DEFINES += BUILTIN_TESTDATA diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/.gitignore b/tests/auto/corelib/io/qresourceengine/staticplugin/.gitignore new file mode 100644 index 0000000000..c397dde6a5 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/staticplugin/.gitignore @@ -0,0 +1 @@ +moctestplugin_plugin_resources.cpp diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp new file mode 100644 index 0000000000..39a3a1e012 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp @@ -0,0 +1,9 @@ +#include <QObject> + +class PluginClass : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.tests.moc" FILE "staticplugin.json") +}; + +#include "main.moc" diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.json b/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.json new file mode 100644 index 0000000000..4103ecb18c --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.json @@ -0,0 +1 @@ +{ "Keys": [ "staticplugin" ] } diff --git a/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.pro b/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.pro new file mode 100644 index 0000000000..e19d884548 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.pro @@ -0,0 +1,8 @@ +TEMPLATE = lib +TARGET = moctestplugin +CONFIG += plugin static +SOURCES = main.cpp +plugin_resource.files = main.cpp +plugin_resource.prefix = /staticplugin +RESOURCES += plugin_resource +QT = core diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt index 21a3dfa0b8..dcf7937f0a 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt @@ -1 +1 @@ -"This is a korean text file" +"This is a korean text file" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt index 436c4d11c3..19f0805d8d 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt @@ -1 +1 @@ -qwerty +qwerty diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt index 38e389979a..65f1f43def 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt @@ -1 +1 @@ -"This is the current dir" +"This is the current dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt index 6ac16a3306..7d89108011 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt @@ -1 +1 @@ -"This is also the current dir" +"This is also the current dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt index b0e4a124ee..e1b430f33b 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt @@ -1 +1 @@ -"This is the other dir" +"This is the other dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt index b6115207a2..4506acf413 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt @@ -1 +1 @@ -"This is in the sub directory" +"This is in the sub directory" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt index adc01d1354..8baef1b4ab 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt @@ -1 +1 @@ -abc +abc diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt index 3f48e3cdc3..24c5735c3e 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt @@ -1 +1 @@ -def +def diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt index 40ee68dccb..b8cb3a8c01 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt @@ -1 +1 @@ -"This is in the test directory" +"This is in the test directory" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt index 051430298a..dccfdc9bcf 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt @@ -1 +1 @@ -"This is another file in this directory" +"This is another file in this directory" diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index b7e85e8f05..0b50c391b8 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -57,6 +58,7 @@ private slots: void doubleSlashInRoot(); void setLocale(); void lastModified(); + void resourcesInStaticPlugins(); private: const QString m_runtimeResourceRcc; @@ -103,7 +105,7 @@ void tst_QResourceEngine::cleanupTestCase() void tst_QResourceEngine::checkStructure_data() { QTest::addColumn<QString>("pathName"); - QTest::addColumn<QString>("contents"); + QTest::addColumn<QByteArray>("contents"); QTest::addColumn<QStringList>("containedFiles"); QTest::addColumn<QStringList>("containedDirs"); QTest::addColumn<QLocale>("locale"); @@ -119,6 +121,7 @@ void tst_QResourceEngine::checkStructure_data() << QLatin1String("searchpath1") << QLatin1String("searchpath2") << QLatin1String("secondary_root") + << QLatin1String("staticplugin") << QLatin1String("test") << QLatin1String("withoutslashes"); @@ -127,12 +130,12 @@ void tst_QResourceEngine::checkStructure_data() #endif #if defined(BUILTIN_TESTDATA) - rootContents.insert(8, QLatin1String("testqrc")); + rootContents.insert(9, QLatin1String("testqrc")); #endif QTest::newRow("root dir") << QString(":/") - << QString() + << QByteArray() << (QStringList() #if defined(BUILTIN_TESTDATA) << "parentdir.txt" @@ -144,7 +147,7 @@ void tst_QResourceEngine::checkStructure_data() << qlonglong(0); QTest::newRow("secondary root") << QString(":/secondary_root/") - << QString() + << QByteArray() << QStringList() << (QStringList() << QLatin1String("runtime_resource")) << QLocale::c() @@ -155,73 +158,73 @@ void tst_QResourceEngine::checkStructure_data() for(int i = 0; i < roots.size(); ++i) { const QString root = roots.at(i); - QTest::newRow(QString(root + "prefix dir").toLatin1().constData()) << QString(root + "test/abc/123/+++") - << QString() + QTest::addRow("%s prefix dir", qPrintable(root)) << QString(root + "test/abc/123/+++") + << QByteArray() << (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt")) << (QStringList() << QLatin1String("subdir")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "parent to prefix").toLatin1().constData()) << QString(root + "test/abc/123") - << QString() + QTest::addRow("%s parent to prefix", qPrintable(root)) << QString(root + "test/abc/123") + << QByteArray() << QStringList() << (QStringList() << QLatin1String("+++")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc") - << QString() + QTest::addRow("%s two parents prefix", qPrintable(root)) << QString(root + "test/abc") + << QByteArray() << QStringList() << QStringList(QLatin1String("123")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "test dir ").toLatin1().constData()) << QString(root + "test") - << QString() + QTest::addRow("%s test dir ", qPrintable(root)) << QString(root + "test") + << QByteArray() << (QStringList() << QLatin1String("testdir.txt")) << (QStringList() << QLatin1String("abc") << QLatin1String("test")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes") - << QString() + QTest::addRow("%s prefix no slashes", qPrintable(root)) << QString(root + "withoutslashes") + << QByteArray() << QStringList("blahblah.txt") << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "other dir").toLatin1().constData()) << QString(root + "otherdir") - << QString() + QTest::addRow("%s other dir", qPrintable(root)) << QString(root + "otherdir") + << QByteArray() << QStringList(QLatin1String("otherdir.txt")) << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "alias dir").toLatin1().constData()) << QString(root + "aliasdir") - << QString() + QTest::addRow("%s alias dir", qPrintable(root)) << QString(root + "aliasdir") + << QByteArray() << QStringList(QLatin1String("aliasdir.txt")) << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "second test dir").toLatin1().constData()) << QString(root + "test/test") - << QString() + QTest::addRow("%s second test dir", qPrintable(root)) << QString(root + "test/test") + << QByteArray() << (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt")) << QStringList() << QLocale::c() << qlonglong(0); info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test1.txt")); - QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt") - << QString("abc") + QTest::addRow("%s test1 text", qPrintable(root)) << QString(root + "test/test/test1.txt") + << QByteArray("abc\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/blahblah.txt")); - QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt") - << QString("qwerty") + QTest::addRow("%s text no slashes", qPrintable(root)) << QString(root + "withoutslashes/blahblah.txt") + << QByteArray("qwerty\n") << QStringList() << QStringList() << QLocale::c() @@ -229,96 +232,96 @@ void tst_QResourceEngine::checkStructure_data() info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test2.txt")); - QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt") - << QString("def") + QTest::addRow("%s test1 text", qPrintable(root)) << QString(root + "test/test/test2.txt") + << QByteArray("def\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt")); - QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt") - << QString("\"This is the current dir\" ") + QTest::addRow("%s currentdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/currentdir.txt") + << QByteArray("\"This is the current dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/currentdir2.txt")); - QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt") - << QString("\"This is also the current dir\" ") + QTest::addRow("%s currentdir text2", qPrintable(root)) << QString(root + "test/abc/123/+++/currentdir2.txt") + << QByteArray("\"This is also the current dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("parentdir.txt")); - QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt") - << QString("abcdefgihklmnopqrstuvwxyz ") + QTest::addRow("%s parentdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/parentdir.txt") + << QByteArray("abcdefgihklmnopqrstuvwxyz \n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/subdir/subdir.txt")); - QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt") - << QString("\"This is in the sub directory\" ") + QTest::addRow("%s subdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/subdir/subdir.txt") + << QByteArray("\"This is in the sub directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir.txt")); - QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt") - << QString("\"This is in the test directory\" ") + QTest::addRow("%s testdir text", qPrintable(root)) << QString(root + "test/testdir.txt") + << QByteArray("\"This is in the test directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/otherdir/otherdir.txt")); - QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt") - << QString("\"This is the other dir\" ") + QTest::addRow("%s otherdir text", qPrintable(root)) << QString(root + "otherdir/otherdir.txt") + << QByteArray("\"This is the other dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir2.txt")); - QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is another file in this directory\" ") + QTest::addRow("%s alias text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is another file in this directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); - QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is a korean text file\" ") + QTest::addRow("%s korean text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is a korean text file\"\n") << QStringList() << QStringList() << QLocale("ko") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); - QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is a korean text file\" ") + QTest::addRow("%s korean text 2", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is a korean text file\"\n") << QStringList() << QStringList() << QLocale("ko_KR") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); - QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("Deutsch") + QTest::addRow("%s german text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("Deutsch\n") << QStringList() << QStringList() << QLocale("de") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); - QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("Deutsch") + QTest::addRow("%s german text 2", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("Deutsch\n") << QStringList() << QStringList() << QLocale("de_DE") @@ -327,8 +330,8 @@ void tst_QResourceEngine::checkStructure_data() QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); file.open(QFile::ReadOnly); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); - QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString(file.readAll()) + QTest::addRow("%s compressed text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << file.readAll() << QStringList() << QStringList() << QLocale("de_CH") @@ -339,7 +342,7 @@ void tst_QResourceEngine::checkStructure_data() void tst_QResourceEngine::checkStructure() { QFETCH(QString, pathName); - QFETCH(QString, contents); + QFETCH(QByteArray, contents); QFETCH(QStringList, containedFiles); QFETCH(QStringList, containedDirs); QFETCH(QLocale, locale); @@ -399,8 +402,18 @@ void tst_QResourceEngine::checkStructure() QFile file(pathName); QVERIFY(file.open(QFile::ReadOnly)); - QByteArray ba = file.readAll(); - QVERIFY(QString(ba).startsWith(contents)); + // check contents + QCOMPARE(file.readAll(), contents); + + // check memory map too + uchar *ptr = file.map(0, file.size(), QFile::MapPrivateOption); + QVERIFY2(ptr, qPrintable(file.errorString())); + QByteArray ba = QByteArray::fromRawData(reinterpret_cast<const char *>(ptr), file.size()); + QCOMPARE(ba, contents); + + // check that it is still valid after closing the file + file.close(); + QCOMPARE(ba, contents); } QLocale::setDefault(QLocale::system()); } @@ -520,6 +533,16 @@ void tst_QResourceEngine::lastModified() } } +Q_IMPORT_PLUGIN(PluginClass) +void tst_QResourceEngine::resourcesInStaticPlugins() +{ + // We built a separate static plugin and attempted linking against + // it. That should successfully register the resources linked into + // the plugin via moc generated Q_INIT_RESOURCE calls in a + // Q_CONSTRUCTOR_FUNCTION. + QVERIFY(QFile::exists(":/staticplugin/main.cpp")); +} + QTEST_MAIN(tst_QResourceEngine) #include "tst_qresourceengine.moc" diff --git a/tests/auto/corelib/io/qsettings/BLACKLIST b/tests/auto/corelib/io/qsettings/BLACKLIST deleted file mode 100644 index 36d68bd918..0000000000 --- a/tests/auto/corelib/io/qsettings/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[isWritable:native] -osx-10.11 diff --git a/tests/auto/corelib/io/qsettings/qsettings.pro b/tests/auto/corelib/io/qsettings/qsettings.pro index 5b4cc8a691..79552b62df 100644 --- a/tests/auto/corelib/io/qsettings/qsettings.pro +++ b/tests/auto/corelib/io/qsettings/qsettings.pro @@ -6,4 +6,6 @@ RESOURCES += qsettings.qrc INCLUDEPATH += $$PWD/../../kernel/qmetatype msvc: LIBS += advapi32.lib +darwin: LIBS += -framework CoreFoundation + DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index db756ada39..5357194406 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -531,7 +531,7 @@ void tst_QSettings::ctor() // more details in QMacSettingsPrivate::QMacSettingsPrivate(), organization was comify()-ed caseSensitive = settings5.fileName().contains("SoftWare.ORG");; } else { - caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); + caseSensitive = pathconf(settings5.fileName().toLatin1().constData(), _PC_CASE_SENSITIVE); } #elif defined(Q_OS_WIN32) || defined(Q_OS_WINRT) caseSensitive = false; @@ -1186,6 +1186,10 @@ static void testMetaTypesHelper(QSettings::Format format) F(QJsonArray) \ F(QJsonDocument) \ F(QPersistentModelIndex) \ + F(QCborSimpleType) \ + F(QCborValue) \ + F(QCborArray) \ + F(QCborMap) \ #define EXCLUDE_NON_SUPPORTED_METATYPES(MetaTypeName) \ template<> void testMetaTypesHelper<QMetaType::MetaTypeName>(QSettings::Format) \ diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index e316ce9acb..1379c788d1 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -183,12 +183,14 @@ void tst_qstandardpaths::testDefaultLocations() #endif } +#ifdef Q_XDG_PLATFORM static void createTestFile(const QString &fileName) { QFile file(fileName); QVERIFY(file.open(QIODevice::WriteOnly)); QVERIFY(file.write("Hello")); } +#endif void tst_qstandardpaths::testCustomLocations() { diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 8b1aa105de..1317489e2f 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -80,7 +80,7 @@ static int qInfoPrinter(const char *format, ...) // flush QtMessageHandler qt_message_print = qInstallMessageHandler(0); qInstallMessageHandler(qt_message_print); // restore the handler - qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf)); + qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf).trimmed()); bufuse = 0; } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 62af907037..84af1c255a 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -180,6 +180,8 @@ private slots: void testThreading(); void matches_data(); void matches(); + void ipv6_zoneId_data(); + void ipv6_zoneId(); private: void testThreadingHelper(); @@ -1876,6 +1878,24 @@ void tst_QUrl::ipv6_data() QTest::newRow("encoded-digit") << "//[::%31]" << true << "//[::1]"; QTest::newRow("encoded-colon") << "//[%3A%3A]" << true << "//[::]"; + + QTest::newRow("full ipv6 with zone id (decoded %)") << QString::fromLatin1("//[56:56:56:56:56:56:56:56%eth0]") << true + << "//[56:56:56:56:56:56:56:56%25eth0]"; + + QTest::newRow("full ipv6 with zone id (encoded %)") << QString::fromLatin1("//[56:56:56:56:56:56:56:56%25eth0]") << true + << "//[56:56:56:56:56:56:56:56%25eth0]"; + + QTest::newRow("full ipv6 with invalid zone id") << QString::fromLatin1("//[56:56:56:56:56:56:56:56%]") << false << ""; + + QTest::newRow("full ipv6 with invalid zone id (encoded)") << QString::fromLatin1("//[56:56:56:56:56:56:56:56%25]") << false << ""; + + QTest::newRow("full ipv6 with zone id 25 (encoded)") << QString::fromLatin1("//[56:56:56:56:56:56:56:56%2525]") << true << "//[56:56:56:56:56:56:56:56%2525]"; + + QTest::newRow("case 4 with less and ip4 and port and useinfo and zone id") + << QString::fromLatin1("//user:pass@[56::56:56:56:127.0.0.1%ethernet_1]:99") << true + << "//user:pass@[56::56:56:56:7f00:1%25ethernet_1]:99"; + + QTest::newRow("encoded-digit including zone id") << "//[::%31%25eth0]" << true << "//[::1%25eth0]"; } void tst_QUrl::ipv6() @@ -4149,6 +4169,38 @@ void tst_QUrl::matches() QCOMPARE(urlOne.matches(urlTwo, QUrl::FormattingOptions(options)), matches); } +void tst_QUrl::ipv6_zoneId_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QString>("decodedHost"); + QTest::addColumn<QString>("prettyHost"); + QTest::addColumn<QString>("encodedHost"); + + QTest::newRow("digit") << QUrl("x://[::%251]") << "::%1" << "::%251" << "::%251"; + QTest::newRow("eth0") << QUrl("x://[::%25eth0]") << "::%eth0" << "::%25eth0" << "::%25eth0"; + QTest::newRow("space") << QUrl("x://[::%25%20]") << "::% " << "::%25 " << "::%25%20"; + QTest::newRow("subdelims") << QUrl("x://[::%25eth%2B]") << "::%eth+" << "::%25eth%2B" << "::%25eth%2B"; + QTest::newRow("other") << QUrl("x://[::%25^]") << "::%^" << "::%25%5E" << "::%25%5E"; + QTest::newRow("control") << QUrl("x://[::%25%7F]") << "::%\x7f" << "::%25%7F" << "::%25%7F"; + QTest::newRow("unicode") << QUrl("x://[::%25wlán0]") << "::%wlán0" << "::%25wlán0" << "::%25wl%C3%A1n0"; + QTest::newRow("non-utf8") << QUrl("x://[::%25%80]") << QString("::%") + QChar(QChar::ReplacementCharacter) << "::%25%80" << "::%25%80"; + } + +void tst_QUrl::ipv6_zoneId() +{ + QFETCH(QUrl, url); + QFETCH(QString, decodedHost); + QFETCH(QString, prettyHost); + QFETCH(QString, encodedHost); + + QVERIFY2(url.isValid(), qPrintable(url.errorString())); + QCOMPARE(url.host(QUrl::FullyDecoded), decodedHost); + QCOMPARE(url.host(), decodedHost); + QCOMPARE(url.host(QUrl::FullyEncoded), encodedHost); + QCOMPARE(url.toString(), "x://[" + prettyHost + "]"); + QCOMPARE(url.toString(QUrl::FullyEncoded), "x://[" + encodedHost + "]"); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" |