summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp16
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp1
-rw-r--r--tests/auto/corelib/io/qfile/.gitignore8
-rw-r--r--tests/auto/corelib/io/qfile/qfile.pro3
-rw-r--r--tests/auto/corelib/io/qfile/stdinprocess/main.cpp2
-rw-r--r--tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro6
-rw-r--r--tests/auto/corelib/io/qfile/test.pro26
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro25
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp49
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp42
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp3
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp7
-rw-r--r--tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp2
-rw-r--r--tests/auto/corelib/io/qresourceengine/qresourceengine.pro27
-rw-r--r--tests/auto/corelib/io/qresourceengine/qresourceengine_test.pro33
-rw-r--r--tests/auto/corelib/io/qresourceengine/staticplugin/.gitignore1
-rw-r--r--tests/auto/corelib/io/qresourceengine/staticplugin/main.cpp9
-rw-r--r--tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.json1
-rw-r--r--tests/auto/corelib/io/qresourceengine/staticplugin/staticplugin.pro8
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp14
-rw-r--r--tests/auto/corelib/io/qsettings/qsettings.pro2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp6
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp2
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp2
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp52
25 files changed, 246 insertions, 101 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/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/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index b7e85e8f05..ab49dea6d8 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -57,6 +57,7 @@ private slots:
void doubleSlashInRoot();
void setLocale();
void lastModified();
+ void resourcesInStaticPlugins();
private:
const QString m_runtimeResourceRcc;
@@ -119,6 +120,7 @@ void tst_QResourceEngine::checkStructure_data()
<< QLatin1String("searchpath1")
<< QLatin1String("searchpath2")
<< QLatin1String("secondary_root")
+ << QLatin1String("staticplugin")
<< QLatin1String("test")
<< QLatin1String("withoutslashes");
@@ -127,7 +129,7 @@ void tst_QResourceEngine::checkStructure_data()
#endif
#if defined(BUILTIN_TESTDATA)
- rootContents.insert(8, QLatin1String("testqrc"));
+ rootContents.insert(9, QLatin1String("testqrc"));
#endif
@@ -520,6 +522,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/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 3de777653e..5cb130f631 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"