summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mkspecs/features/exclusive_builds.prf9
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp89
-rw-r--r--src/testlib/qtest_gui.h16
-rw-r--r--src/testlib/qtestblacklist.cpp2
-rw-r--r--src/testlib/qtestcase.cpp36
-rw-r--r--src/testlib/qtestcase.h6
-rw-r--r--src/testlib/qtestresult.cpp116
-rw-r--r--src/testlib/qtestresult_p.h17
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp10
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h8
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp13
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h55
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp6
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml12
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.tap142
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.teamcity6
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt10
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml12
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml8
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp24
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp5
21 files changed, 397 insertions, 205 deletions
diff --git a/mkspecs/features/exclusive_builds.prf b/mkspecs/features/exclusive_builds.prf
index b28e74146a..a41c5ab415 100644
--- a/mkspecs/features/exclusive_builds.prf
+++ b/mkspecs/features/exclusive_builds.prf
@@ -37,6 +37,9 @@ defineTest(addExclusiveBuilds) {
addExclusiveBuildsProper($$join(ARGS, _and_), $$ARGS)
}
-# Default directories to process
-QMAKE_DIR_REPLACE_SANE += QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR LEX_DIR YACC_DIR
-QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR DESTDIR $$QMAKE_DIR_REPLACE_SANE
+QMAKE_DEFAULT_DIRS_TO_PROCESS = QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR LEX_DIR YACC_DIR
+QMAKE_DIR_REPLACE_SANE += $$QMAKE_DEFAULT_DIRS_TO_PROCESS
+QMAKE_DIR_REPLACE = \
+ OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR DESTDIR \
+ $$QMAKE_DEFAULT_DIRS_TO_PROCESS
+unset(QMAKE_DEFAULT_DIRS_TO_PROCESS)
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 5b4e010cf0..869d6d5959 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -67,6 +67,7 @@
#if defined(Q_OS_UNIX)
#include <QtCore/qdir.h>
#endif
+#include <QtCore/private/qmemory_p.h>
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
#include <link.h>
#endif
@@ -596,8 +597,8 @@ DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, re
DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)
#define RESOLVEFUNC(func) \
- if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \
- && !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
+ if (!(_q_##func = _q_PTR_##func(libs.ssl->resolve(#func))) \
+ && !(_q_##func = _q_PTR_##func(libs.crypto->resolve(#func)))) \
qsslSocketCannotResolveSymbolWarning(#func);
#if !defined QT_LINKED_OPENSSL
@@ -733,34 +734,31 @@ static QStringList findAllLibCrypto()
# endif
#ifdef Q_OS_WIN
-static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, QPair<QSystemLibrary*, QSystemLibrary*> &pair)
-{
- pair.first = 0;
- pair.second = 0;
- QSystemLibrary *ssleay32 = new QSystemLibrary(ssleay32LibName);
+struct LoadedOpenSsl {
+ std::unique_ptr<QSystemLibrary> ssl, crypto;
+};
+
+static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, LoadedOpenSsl &result)
+{
+ auto ssleay32 = qt_make_unique<QSystemLibrary>(ssleay32LibName);
if (!ssleay32->load(false)) {
- delete ssleay32;
return FALSE;
}
- QSystemLibrary *libeay32 = new QSystemLibrary(libeay32LibName);
+ auto libeay32 = qt_make_unique<QSystemLibrary>(libeay32LibName);
if (!libeay32->load(false)) {
- delete ssleay32;
- delete libeay32;
return FALSE;
}
- pair.first = ssleay32;
- pair.second = libeay32;
+ result.ssl = std::move(ssleay32);
+ result.crypto = std::move(libeay32);
return TRUE;
}
-static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
+static LoadedOpenSsl loadOpenSsl()
{
- QPair<QSystemLibrary*,QSystemLibrary*> pair;
- pair.first = 0;
- pair.second = 0;
+ LoadedOpenSsl result;
#if QT_CONFIG(opensslv11)
// With OpenSSL 1.1 the names have changed to libssl-1_1(-x64) and libcrypto-1_1(-x64), for builds using
@@ -773,7 +771,7 @@ static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
#endif // !Q_PROCESSOR_x86_64
tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX),
- QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), pair);
+ QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), result);
#undef QT_SSL_SUFFIX
@@ -782,28 +780,30 @@ static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
// When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'.
// When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version)
// The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007)
- if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32"), QLatin1String("libeay32"), pair)) {
- if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10"), QLatin1String("libcrypto-10"), pair)) {
- if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8"), QLatin1String("libcrypto-8"), pair)) {
- tryToLoadOpenSslWin32Library(QLatin1String("libssl-7"), QLatin1String("libcrypto-7"), pair);
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32"), QLatin1String("libeay32"), result)) {
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10"), QLatin1String("libcrypto-10"), result)) {
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8"), QLatin1String("libcrypto-8"), result)) {
+ tryToLoadOpenSslWin32Library(QLatin1String("libssl-7"), QLatin1String("libcrypto-7"), result);
}
}
}
#endif // !QT_CONFIG(opensslv11)
- return pair;
+ return result;
}
#else
-static QPair<QLibrary*, QLibrary*> loadOpenSsl()
+struct LoadedOpenSsl {
+ std::unique_ptr<QLibrary> ssl, crypto;
+};
+
+static LoadedOpenSsl loadOpenSsl()
{
- QPair<QLibrary*,QLibrary*> pair;
+ LoadedOpenSsl result = {qt_make_unique<QLibrary>(), qt_make_unique<QLibrary>()};
# if defined(Q_OS_UNIX)
- QLibrary *&libssl = pair.first;
- QLibrary *&libcrypto = pair.second;
- libssl = new QLibrary;
- libcrypto = new QLibrary;
+ QLibrary * const libssl = result.ssl.get();
+ QLibrary * const libcrypto = result.crypto.get();
// Try to find the libssl library on the system.
//
@@ -847,7 +847,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
if (libcrypto->load() && libssl->load()) {
// libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
- return pair;
+ return result;
} else {
libssl->unload();
libcrypto->unload();
@@ -866,7 +866,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
libssl->setFileNameAndVersion(QLatin1String("ssl"), fallbackSoname);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), fallbackSoname);
if (libcrypto->load() && libssl->load()) {
- return pair;
+ return result;
} else {
libssl->unload();
libcrypto->unload();
@@ -886,7 +886,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
if (libcrypto->load() && libssl->load()) {
// libssl.so.0 and libcrypto.so.0 found
- return pair;
+ return result;
} else {
libssl->unload();
libcrypto->unload();
@@ -911,7 +911,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
if (libssl->load()) {
// libssl.so.x and libcrypto.so.x found
- return pair;
+ return result;
} else {
libssl->unload();
}
@@ -921,14 +921,12 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
}
// failed to load anything
- delete libssl;
- delete libcrypto;
- libssl = libcrypto = 0;
- return pair;
+ result = {};
+ return result;
# else
// not implemented for this platform yet
- return pair;
+ return result;
# endif
}
#endif
@@ -948,12 +946,8 @@ bool q_resolveOpenSslSymbols()
return false;
triedToResolveSymbols = true;
-#ifdef Q_OS_WIN
- QPair<QSystemLibrary *, QSystemLibrary *> libs = loadOpenSslWin32();
-#else
- QPair<QLibrary *, QLibrary *> libs = loadOpenSsl();
-#endif
- if (!libs.first || !libs.second)
+ LoadedOpenSsl libs = loadOpenSsl();
+ if (!libs.ssl || !libs.crypto)
// failed to load them
return false;
@@ -1002,8 +996,6 @@ bool q_resolveOpenSslSymbols()
if (!_q_OpenSSL_version) {
// Apparently, we were built with OpenSSL 1.1 enabled but are now using
// a wrong library.
- delete libs.first;
- delete libs.second;
qCWarning(lcSsl, "Incompatible version of OpenSSL");
return false;
}
@@ -1125,8 +1117,6 @@ bool q_resolveOpenSslSymbols()
// OpenSSL 1.1 has deprecated and removed SSLeay. We consider a failure to
// resolve this symbol as a failure to resolve symbols.
// The right operand of '||' above is ... a bit of paranoia.
- delete libs.first;
- delete libs.second;
qCWarning(lcSsl, "Incompatible version of OpenSSL");
return false;
}
@@ -1397,10 +1387,7 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(d2i_PKCS12_bio)
RESOLVEFUNC(PKCS12_free)
-
symbolsResolved.storeRelease(true);
- delete libs.first;
- delete libs.second;
return true;
}
#endif // QT_CONFIG(library)
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index e5101e6955..d1efde54b1 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -162,6 +162,14 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
}
if (t1Null && t2Null)
return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line);
+ if (!qFuzzyCompare(t1.devicePixelRatioF(), t2.devicePixelRatioF())) {
+ qsnprintf(msg, 1024, "Compared QImages differ in device pixel ratio.\n"
+ " Actual (%s): %g\n"
+ " Expected (%s): %g",
+ actual, t1.devicePixelRatioF(),
+ expected, t2.devicePixelRatioF());
+ return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line);
+ }
if (t1.width() != t2.width() || t1.height() != t2.height()) {
qsnprintf(msg, 1024, "Compared QImages differ in size.\n"
" Actual (%s): %dx%d\n"
@@ -196,6 +204,14 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
}
if (t1Null && t2Null)
return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line);
+ if (!qFuzzyCompare(t1.devicePixelRatioF(), t2.devicePixelRatioF())) {
+ qsnprintf(msg, 1024, "Compared QPixmaps differ in device pixel ratio.\n"
+ " Actual (%s): %g\n"
+ " Expected (%s): %g",
+ actual, t1.devicePixelRatioF(),
+ expected, t2.devicePixelRatioF());
+ return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line);
+ }
if (t1.width() != t2.width() || t1.height() != t2.height()) {
qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n"
" Actual (%s): %dx%d\n"
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index 6642699758..596788e297 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -169,12 +169,14 @@ static QSet<QByteArray> keywords()
#endif
;
+#if QT_CONFIG(properties)
QCoreApplication *app = QCoreApplication::instance();
if (app) {
const QVariant platformName = app->property("platformName");
if (platformName.isValid())
set << platformName.toByteArray();
}
+#endif
return set;
}
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 619376fd33..ce0abba17b 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2550,9 +2550,9 @@ bool QTest::qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual,
bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected,
const char *file, int line)
{
- return compare_helper(floatingCompare(t1, t2),
- "Compared floats are not the same (fuzzy compare)",
- toString(t1), toString(t2), actual, expected, file, line);
+ return QTestResult::compare(floatingCompare(t1, t2),
+ "Compared floats are not the same (fuzzy compare)",
+ t1, t2, actual, expected, file, line);
}
/*! \fn bool QTest::qCompare(const double &t1, const double &t2, const char *actual, const char *expected, const char *file, int line)
@@ -2561,9 +2561,33 @@ bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const
bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected,
const char *file, int line)
{
- return compare_helper(floatingCompare(t1, t2),
- "Compared doubles are not the same (fuzzy compare)",
- toString(t1), toString(t2), actual, expected, file, line);
+ return QTestResult::compare(floatingCompare(t1, t2),
+ "Compared doubles are not the same (fuzzy compare)",
+ t1, t2, actual, expected, file, line);
+}
+
+/*! \fn bool QTest::qCompare(int t1, int t2, const char *actual, const char *expected, const char *file, int line)
+ \internal
+ \since 5.14
+ */
+bool QTest::qCompare(int t1, int t2, const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return QTestResult::compare(t1 == t2,
+ "Compared values are not the same",
+ t1, t2, actual, expected, file, line);
+}
+
+/*! \fn bool QTest::qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected, const char *file, int line)
+ \internal
+ \since 5.14
+ */
+bool QTest::qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return QTestResult::compare(t1 == t2,
+ "Compared values are not the same",
+ t1, t2, actual, expected, file, line);
}
/*! \fn bool QTest::qCompare(const double &t1, const float &t2, const char *actual, const char *expected, const char *file, int line)
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index af7c0f43b9..40afac37c5 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -363,6 +363,12 @@ namespace QTest
Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2,
const char *actual, const char *expected, const char *file, int line);
+ Q_TESTLIB_EXPORT bool qCompare(int t1, int t2, const char *actual, const char *expected,
+ const char *file, int line);
+
+ Q_TESTLIB_EXPORT bool qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected,
+ const char *file, int line);
+
inline bool compare_ptr_helper(const volatile void *t1, const volatile void *t2, const char *actual,
const char *expected, const char *file, int line)
{
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index a7a4807e06..8d65bff5c4 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -42,6 +42,7 @@
#include <QtTest/private/qtestlog_p.h>
#include <QtTest/qtestdata.h>
+#include <QtTest/qtestcase.h>
#include <QtTest/qtestassert.h>
#include <stdlib.h>
@@ -265,17 +266,54 @@ bool QTestResult::verify(bool statement, const char *statementStr,
return checkStatement(statement, msg, file, line);
}
-bool QTestResult::compare(bool success, const char *failureMsg,
- char *val1, char *val2,
- const char *actual, const char *expected,
- const char *file, int line)
+// Format failures using the toString() template
+template <class Actual, class Expected>
+void formatFailMessage(char *msg, size_t maxMsgLen,
+ const char *failureMsg,
+ const Actual &val1, const Expected &val2,
+ const char *actual, const char *expected)
{
- QTEST_ASSERT(expected);
- QTEST_ASSERT(actual);
+ auto val1S = QTest::toString(val1);
+ auto val2S = QTest::toString(val2);
+
+ size_t len1 = mbstowcs(nullptr, actual, maxMsgLen); // Last parameter is not ignored on QNX
+ size_t len2 = mbstowcs(nullptr, expected, maxMsgLen); // (result is never larger than this).
+ qsnprintf(msg, maxMsgLen, "%s\n Actual (%s)%*s %s\n Expected (%s)%*s %s",
+ failureMsg,
+ actual, qMax(len1, len2) - len1 + 1, ":", val1S ? val1S : "<null>",
+ expected, qMax(len1, len2) - len2 + 1, ":", val2S ? val2S : "<null>");
+
+ delete [] val1S;
+ delete [] val2S;
+}
+// Overload to format failures for "const char *" - no need to strdup().
+void formatFailMessage(char *msg, size_t maxMsgLen,
+ const char *failureMsg,
+ const char *val1, const char *val2,
+ const char *actual, const char *expected)
+{
+ size_t len1 = mbstowcs(nullptr, actual, maxMsgLen); // Last parameter is not ignored on QNX
+ size_t len2 = mbstowcs(nullptr, expected, maxMsgLen); // (result is never larger than this).
+ qsnprintf(msg, maxMsgLen, "%s\n Actual (%s)%*s %s\n Expected (%s)%*s %s",
+ failureMsg,
+ actual, qMax(len1, len2) - len1 + 1, ":", val1 ? val1 : "<null>",
+ expected, qMax(len1, len2) - len2 + 1, ":", val2 ? val2 : "<null>");
+}
+
+template <class Actual, class Expected>
+static bool compareHelper(bool success, const char *failureMsg,
+ const Actual &val1, const Expected &val2,
+ const char *actual, const char *expected,
+ const char *file, int line,
+ bool hasValues = true)
+{
const size_t maxMsgLen = 1024;
char msg[maxMsgLen] = {'\0'};
+ QTEST_ASSERT(expected);
+ QTEST_ASSERT(actual);
+
if (QTestLog::verboseLevel() >= 2) {
qsnprintf(msg, maxMsgLen, "QCOMPARE(%s, %s)", actual, expected);
QTestLog::info(msg, file, line);
@@ -289,20 +327,68 @@ bool QTestResult::compare(bool success, const char *failureMsg,
qsnprintf(msg, maxMsgLen,
"QCOMPARE(%s, %s) returned TRUE unexpectedly.", actual, expected);
}
- } else if (val1 || val2) {
- size_t len1 = mbstowcs(NULL, actual, maxMsgLen); // Last parameter is not ignored on QNX
- size_t len2 = mbstowcs(NULL, expected, maxMsgLen); // (result is never larger than this).
- qsnprintf(msg, maxMsgLen, "%s\n Actual (%s)%*s %s\n Expected (%s)%*s %s",
- failureMsg,
- actual, qMax(len1, len2) - len1 + 1, ":", val1 ? val1 : "<null>",
- expected, qMax(len1, len2) - len2 + 1, ":", val2 ? val2 : "<null>");
- } else
+ return checkStatement(success, msg, file, line);
+ }
+
+
+ if (!hasValues) {
qsnprintf(msg, maxMsgLen, "%s", failureMsg);
+ return checkStatement(success, msg, file, line);
+ }
+
+ formatFailMessage(msg, maxMsgLen, failureMsg, val1, val2, actual, expected);
+
+ return checkStatement(success, msg, file, line);
+}
+
+bool QTestResult::compare(bool success, const char *failureMsg,
+ char *val1, char *val2,
+ const char *actual, const char *expected,
+ const char *file, int line)
+{
+ const bool result = compareHelper(success, failureMsg,
+ val1 != nullptr ? val1 : "<null>",
+ val2 != nullptr ? val2 : "<null>",
+ actual, expected, file, line,
+ val1 != nullptr && val2 != nullptr);
+ // Our caller got these from QTest::toString()
delete [] val1;
delete [] val2;
- return checkStatement(success, msg, file, line);
+ return result;
+}
+
+bool QTestResult::compare(bool success, const char *failureMsg,
+ double val1, double val2,
+ const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
+}
+
+bool QTestResult::compare(bool success, const char *failureMsg,
+ float val1, float val2,
+ const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
+}
+
+bool QTestResult::compare(bool success, const char *failureMsg,
+ int val1, int val2,
+ const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
+}
+
+bool QTestResult::compare(bool success, const char *failureMsg,
+ unsigned val1, unsigned val2,
+ const char *actual, const char *expected,
+ const char *file, int line)
+{
+ return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
}
void QTestResult::addFailure(const char *message, const char *file, int line)
diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h
index 4df75b2805..92f98bb047 100644
--- a/src/testlib/qtestresult_p.h
+++ b/src/testlib/qtestresult_p.h
@@ -79,7 +79,22 @@ public:
char *val1, char *val2,
const char *actual, const char *expected,
const char *file, int line);
-
+ static bool compare(bool success, const char *failureMsg,
+ double val1, double val2,
+ const char *actual, const char *expected,
+ const char *file, int line);
+ static bool compare(bool success, const char *failureMsg,
+ float val1, float val2,
+ const char *actual, const char *expected,
+ const char *file, int line);
+ static bool compare(bool success, const char *failureMsg,
+ int val1, int val2,
+ const char *actual, const char *expected,
+ const char *file, int line);
+ static bool compare(bool success, const char *failureMsg,
+ unsigned val1, unsigned val2,
+ const char *actual, const char *expected,
+ const char *file, int line);
static void setCurrentGlobalTestData(QTestData *data);
static void setCurrentTestData(QTestData *data);
static void setCurrentTestFunction(const char *func);
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index f39ae2b53e..9ab75e0b0a 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -79,14 +79,8 @@ static QString translateDriveName(const QFileInfo &drive)
Creates thread
*/
QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
- : QThread(parent), abort(false),
-#if QT_CONFIG(filesystemwatcher)
- watcher(0),
-#endif
-#ifdef Q_OS_WIN
- m_resolveSymlinks(true),
-#endif
- m_iconProvider(&defaultProvider)
+ : QThread(parent)
+ , m_iconProvider(&defaultProvider)
{
#if QT_CONFIG(filesystemwatcher)
watcher = new QFileSystemWatcher(this);
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 795f60249f..829c620c1e 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -210,13 +210,13 @@ private:
QAtomicInt abort;
#if QT_CONFIG(filesystemwatcher)
- QFileSystemWatcher *watcher;
-#endif
-#ifdef Q_OS_WIN
- bool m_resolveSymlinks; // not accessed by run()
+ QFileSystemWatcher *watcher = nullptr;
#endif
QFileIconProvider *m_iconProvider; // not accessed by run()
QFileIconProvider defaultProvider;
+#ifdef Q_OS_WIN
+ bool m_resolveSymlinks = true; // not accessed by run()
+#endif
};
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index b521f50f40..820fc6e220 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -227,11 +227,9 @@ bool QFileSystemModel::remove(const QModelIndex &aindex)
/*!
Constructs a file system model with the given \a parent.
*/
-QFileSystemModel::QFileSystemModel(QObject *parent)
- : QAbstractItemModel(*new QFileSystemModelPrivate, parent)
+QFileSystemModel::QFileSystemModel(QObject *parent) :
+ QFileSystemModel(*new QFileSystemModelPrivate, parent)
{
- Q_D(QFileSystemModel);
- d->init();
}
/*!
@@ -247,9 +245,7 @@ QFileSystemModel::QFileSystemModel(QFileSystemModelPrivate &dd, QObject *parent)
/*!
Destroys this file system model.
*/
-QFileSystemModel::~QFileSystemModel()
-{
-}
+QFileSystemModel::~QFileSystemModel() = default;
/*!
\reimp
@@ -1945,6 +1941,9 @@ QStringList QFileSystemModelPrivate::unwatchPathsAt(const QModelIndex &index)
void QFileSystemModelPrivate::init()
{
Q_Q(QFileSystemModel);
+
+ delayedSortTimer.setSingleShot(true);
+
qRegisterMetaType<QVector<QPair<QString,QFileInfo> > >();
#if QT_CONFIG(filesystemwatcher)
q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)),
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index d8f9f2b076..844e417e2d 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -99,13 +99,13 @@ public:
class QFileSystemNode
{
public:
+ Q_DISABLE_COPY_MOVE(QFileSystemNode)
+
explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = nullptr)
- : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(nullptr) {}
+ : fileName(filename), parent(p) {}
~QFileSystemNode() {
qDeleteAll(children);
delete info;
- info = nullptr;
- parent = nullptr;
}
QString fileName;
@@ -204,31 +204,16 @@ public:
}
}
- bool populatedChildren;
- bool isVisible;
QHash<QFileSystemModelNodePathKey, QFileSystemNode *> children;
QList<QString> visibleChildren;
- int dirtyChildrenIndex;
+ QExtendedInformation *info = nullptr;
QFileSystemNode *parent;
-
-
- QExtendedInformation *info;
-
+ int dirtyChildrenIndex = -1;
+ bool populatedChildren = false;
+ bool isVisible = false;
};
- QFileSystemModelPrivate() :
- forceSort(true),
- sortColumn(0),
- sortOrder(Qt::AscendingOrder),
- readOnly(true),
- setRootPath(false),
- filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
- nameFilterDisables(true), // false on windows, true on mac and unix
- disableRecursiveSort(false)
- {
- delayedSortTimer.setSingleShot(true);
- }
-
+ QFileSystemModelPrivate() = default;
void init();
/*
\internal
@@ -303,18 +288,7 @@ public:
QFileInfoGatherer fileInfoGatherer;
#endif // filesystemwatcher
QTimer delayedSortTimer;
- bool forceSort;
- int sortColumn;
- Qt::SortOrder sortOrder;
- bool readOnly;
- bool setRootPath;
- QDir::Filters filters;
QHash<const QFileSystemNode*, bool> bypassFilters;
- bool nameFilterDisables;
- //This flag is an optimization for the QFileDialog
- //It enable a sort which is not recursive, it means
- //we sort only what we see.
- bool disableRecursiveSort;
#if QT_CONFIG(regularexpression)
QStringList nameFilters;
#endif
@@ -322,7 +296,6 @@ public:
QFileSystemNode root;
- QBasicTimer fetchingTimer;
struct Fetching {
QString dir;
QString file;
@@ -330,6 +303,18 @@ public:
};
QVector<Fetching> toFetch;
+ QBasicTimer fetchingTimer;
+
+ QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs;
+ int sortColumn = 0;
+ Qt::SortOrder sortOrder = Qt::AscendingOrder;
+ bool forceSort = true;
+ bool readOnly = true;
+ bool setRootPath = false;
+ bool nameFilterDisables = true; // false on windows, true on mac and unix
+ // This flag is an optimization for QFileDialog. It enables a sort which is
+ // not recursive, meaning we sort only what we see.
+ bool disableRecursiveSort = false;
};
Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE);
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 467c53088e..fb01b19d16 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -466,6 +466,8 @@ void tst_Cmptest::compareQPixmaps_data()
const QPixmap pixmap1(xpmPixmapData1);
const QPixmap pixmap2(xpmPixmapData2);
const QPixmap pixmap3(xpmPixmapData3);
+ QPixmap pixmapWrongDpr = pixmap1.scaled(2, 2);
+ pixmapWrongDpr.setDevicePixelRatio(2);
QTest::newRow("both null") << QPixmap() << QPixmap();
QTest::newRow("one null") << QPixmap() << pixmap1;
@@ -473,6 +475,7 @@ void tst_Cmptest::compareQPixmaps_data()
QTest::newRow("equal") << pixmap1 << pixmap1;
QTest::newRow("different size") << pixmap1 << pixmap3;
QTest::newRow("different pixels") << pixmap1 << pixmap2;
+ QTest::newRow("different dpr") << pixmap1 << pixmapWrongDpr;
}
void tst_Cmptest::compareQPixmaps()
@@ -492,6 +495,8 @@ void tst_Cmptest::compareQImages_data()
const QImage image2(QPixmap(xpmPixmapData2).toImage());
const QImage image1Indexed = image1.convertToFormat(QImage::Format_Indexed8);
const QImage image3(QPixmap(xpmPixmapData3).toImage());
+ QImage imageWrongDpr = image1.scaled(2, 2);
+ imageWrongDpr.setDevicePixelRatio(2);
QTest::newRow("both null") << QImage() << QImage();
QTest::newRow("one null") << QImage() << image1;
@@ -500,6 +505,7 @@ void tst_Cmptest::compareQImages_data()
QTest::newRow("different size") << image1 << image3;
QTest::newRow("different format") << image1 << image1Indexed;
QTest::newRow("different pixels") << image1 << image2;
+ QTest::newRow("different dpr") << image1 << imageWrongDpr;
}
void tst_Cmptest::compareQImages()
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 58b5a5e530..f108933585 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -209,6 +209,12 @@
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
+<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <DataTag><![CDATA[different dpr]]></DataTag>
+ <Description><![CDATA[Compared QPixmaps differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2]]></Description>
+</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQImages">
@@ -246,6 +252,12 @@
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
+<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <DataTag><![CDATA[different dpr]]></DataTag>
+ <Description><![CDATA[Compared QImages differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2]]></Description>
+</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQRegion">
diff --git a/tests/auto/testlib/selftests/expected_cmptest.tap b/tests/auto/testlib/selftests/expected_cmptest.tap
index 238db2fc2b..dc9cb5c950 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.tap
+++ b/tests/auto/testlib/selftests/expected_cmptest.tap
@@ -245,9 +245,9 @@ not ok 32 - compareQPixmaps(one null)
found: 1 (opA).isNull()
expected: 0 (opB).isNull()
actual: 1 (opA).isNull()
- at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:483)
+ at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:486)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 483
+ line: 486
...
not ok 33 - compareQPixmaps(other null)
---
@@ -257,9 +257,9 @@ not ok 33 - compareQPixmaps(other null)
found: 0 (opA).isNull()
expected: 1 (opB).isNull()
actual: 0 (opA).isNull()
- at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:483)
+ at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:486)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 483
+ line: 486
...
ok 34 - compareQPixmaps(equal)
not ok 35 - compareQPixmaps(different size)
@@ -270,19 +270,31 @@ not ok 35 - compareQPixmaps(different size)
found: 11x20 (opA)
expected: 20x20 (opB)
actual: 11x20 (opA)
- at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:483)
+ at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:486)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 483
+ line: 486
...
not ok 36 - compareQPixmaps(different pixels)
---
# Compared values are not the same
- at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:483)
+ at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:486)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 483
+ line: 486
...
-ok 37 - compareQImages(both null)
-not ok 38 - compareQImages(one null)
+not ok 37 - compareQPixmaps(different dpr)
+ ---
+ type: QCOMPARE
+ message: Compared QPixmaps differ in device pixel ratio.
+ wanted: 2 (opB)
+ found: 1 (opA)
+ expected: 2 (opB)
+ actual: 1 (opA)
+ at: tst_Cmptest::compareQPixmaps() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:486)
+ file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+ line: 486
+ ...
+ok 38 - compareQImages(both null)
+not ok 39 - compareQImages(one null)
---
type: QCOMPARE
message: Compared QImages differ.
@@ -290,11 +302,11 @@ not ok 38 - compareQImages(one null)
found: 1 (opA).isNull()
expected: 0 (opB).isNull()
actual: 1 (opA).isNull()
- at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:510)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 510
+ line: 516
...
-not ok 39 - compareQImages(other null)
+not ok 40 - compareQImages(other null)
---
type: QCOMPARE
message: Compared QImages differ.
@@ -302,12 +314,12 @@ not ok 39 - compareQImages(other null)
found: 0 (opA).isNull()
expected: 1 (opB).isNull()
actual: 0 (opA).isNull()
- at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:510)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 510
+ line: 516
...
-ok 40 - compareQImages(equal)
-not ok 41 - compareQImages(different size)
+ok 41 - compareQImages(equal)
+not ok 42 - compareQImages(different size)
---
type: QCOMPARE
message: Compared QImages differ in size.
@@ -315,11 +327,11 @@ not ok 41 - compareQImages(different size)
found: 11x20 (opA)
expected: 20x20 (opB)
actual: 11x20 (opA)
- at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:510)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 510
+ line: 516
...
-not ok 42 - compareQImages(different format)
+not ok 43 - compareQImages(different format)
---
type: QCOMPARE
message: Compared QImages differ in format.
@@ -327,19 +339,31 @@ not ok 42 - compareQImages(different format)
found: 6 (opA)
expected: 3 (opB)
actual: 6 (opA)
- at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:510)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 510
+ line: 516
...
-not ok 43 - compareQImages(different pixels)
+not ok 44 - compareQImages(different pixels)
---
# Compared values are not the same
- at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:510)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
+ file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+ line: 516
+ ...
+not ok 45 - compareQImages(different dpr)
+ ---
+ type: QCOMPARE
+ message: Compared QImages differ in device pixel ratio.
+ wanted: 2 (opB)
+ found: 1 (opA)
+ expected: 2 (opB)
+ actual: 1 (opA)
+ at: tst_Cmptest::compareQImages() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:516)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 510
+ line: 516
...
-ok 44 - compareQRegion(equal-empty)
-not ok 45 - compareQRegion(1-empty)
+ok 46 - compareQRegion(equal-empty)
+not ok 47 - compareQRegion(1-empty)
---
type: QCOMPARE
message: Compared values are not the same
@@ -347,12 +371,12 @@ not ok 45 - compareQRegion(1-empty)
found: QRegion(200x50+10+10) (rA)
expected: QRegion(null) (rB)
actual: QRegion(200x50+10+10) (rA)
- at: tst_Cmptest::compareQRegion() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:533)
+ at: tst_Cmptest::compareQRegion() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:539)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 533
+ line: 539
...
-ok 46 - compareQRegion(equal)
-not ok 47 - compareQRegion(different lists)
+ok 48 - compareQRegion(equal)
+not ok 49 - compareQRegion(different lists)
---
type: QCOMPARE
message: Compared values are not the same
@@ -360,11 +384,11 @@ not ok 47 - compareQRegion(different lists)
found: QRegion(200x50+10+10) (rA)
expected: QRegion(2 rectangles, 50x200+100+200, 200x50+10+10) (rB)
actual: QRegion(200x50+10+10) (rA)
- at: tst_Cmptest::compareQRegion() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:533)
+ at: tst_Cmptest::compareQRegion() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:539)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 533
+ line: 539
...
-not ok 48 - compareQVector2D()
+not ok 50 - compareQVector2D()
---
type: QCOMPARE
message: Compared values are not the same
@@ -372,11 +396,11 @@ not ok 48 - compareQVector2D()
found: QVector2D(1, 2) (v2a)
expected: QVector2D(1, 3) (v2b)
actual: QVector2D(1, 2) (v2a)
- at: tst_Cmptest::compareQVector2D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:542)
+ at: tst_Cmptest::compareQVector2D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:548)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 542
+ line: 548
...
-not ok 49 - compareQVector3D()
+not ok 51 - compareQVector3D()
---
type: QCOMPARE
message: Compared values are not the same
@@ -384,11 +408,11 @@ not ok 49 - compareQVector3D()
found: QVector3D(1, 2, 3) (v3a)
expected: QVector3D(1, 3, 3) (v3b)
actual: QVector3D(1, 2, 3) (v3a)
- at: tst_Cmptest::compareQVector3D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:551)
+ at: tst_Cmptest::compareQVector3D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:557)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 551
+ line: 557
...
-not ok 50 - compareQVector4D()
+not ok 52 - compareQVector4D()
---
type: QCOMPARE
message: Compared values are not the same
@@ -396,11 +420,11 @@ not ok 50 - compareQVector4D()
found: QVector4D(1, 2, 3, 4) (v4a)
expected: QVector4D(1, 3, 3, 4) (v4b)
actual: QVector4D(1, 2, 3, 4) (v4a)
- at: tst_Cmptest::compareQVector4D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:560)
+ at: tst_Cmptest::compareQVector4D() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:566)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 560
+ line: 566
...
-not ok 51 - verify()
+not ok 53 - verify()
---
type: QVERIFY
message: Verification failed
@@ -408,11 +432,11 @@ not ok 51 - verify()
found: false (opaqueFunc() < 2)
expected: true (opaqueFunc() < 2)
actual: false (opaqueFunc() < 2)
- at: tst_Cmptest::verify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:572)
+ at: tst_Cmptest::verify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:578)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 572
+ line: 578
...
-not ok 52 - verify2()
+not ok 54 - verify2()
---
type: QVERIFY
message: 42
@@ -420,11 +444,11 @@ not ok 52 - verify2()
found: false (opaqueFunc() < 2)
expected: true (opaqueFunc() < 2)
actual: false (opaqueFunc() < 2)
- at: tst_Cmptest::verify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:578)
+ at: tst_Cmptest::verify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:584)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 578
+ line: 584
...
-not ok 53 - tryVerify()
+not ok 55 - tryVerify()
---
type: QVERIFY
message: Verification failed
@@ -432,11 +456,11 @@ not ok 53 - tryVerify()
found: false (opaqueFunc() < 2)
expected: true (opaqueFunc() < 2)
actual: false (opaqueFunc() < 2)
- at: tst_Cmptest::tryVerify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:584)
+ at: tst_Cmptest::tryVerify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:590)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 584
+ line: 590
...
-not ok 54 - tryVerify2()
+not ok 56 - tryVerify2()
---
type: QVERIFY
message: 42
@@ -444,13 +468,13 @@ not ok 54 - tryVerify2()
found: false (opaqueFunc() < 2)
expected: true (opaqueFunc() < 2)
actual: false (opaqueFunc() < 2)
- at: tst_Cmptest::tryVerify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:590)
+ at: tst_Cmptest::tryVerify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:596)
file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
- line: 590
+ line: 596
...
-ok 55 - verifyExplicitOperatorBool()
-ok 56 - cleanupTestCase()
-1..56
-# tests 56
+ok 57 - verifyExplicitOperatorBool()
+ok 58 - cleanupTestCase()
+1..58
+# tests 58
# pass 18
-# fail 38
+# fail 40
diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity
index 422d0cbfdf..426fddb20f 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.teamcity
+++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity
@@ -95,6 +95,9 @@
##teamcity[testStarted name='compareQPixmaps(different pixels)' flowId='tst_Cmptest']
##teamcity[testFailed name='compareQPixmaps(different pixels)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same' flowId='tst_Cmptest']
##teamcity[testFinished name='compareQPixmaps(different pixels)' flowId='tst_Cmptest']
+##teamcity[testStarted name='compareQPixmaps(different dpr)' flowId='tst_Cmptest']
+##teamcity[testFailed name='compareQPixmaps(different dpr)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared QPixmaps differ in device pixel ratio.|n Actual (opA): 1|n Expected (opB): 2' flowId='tst_Cmptest']
+##teamcity[testFinished name='compareQPixmaps(different dpr)' flowId='tst_Cmptest']
##teamcity[testStarted name='compareQImages(both null)' flowId='tst_Cmptest']
##teamcity[testFinished name='compareQImages(both null)' flowId='tst_Cmptest']
##teamcity[testStarted name='compareQImages(one null)' flowId='tst_Cmptest']
@@ -114,6 +117,9 @@
##teamcity[testStarted name='compareQImages(different pixels)' flowId='tst_Cmptest']
##teamcity[testFailed name='compareQImages(different pixels)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same' flowId='tst_Cmptest']
##teamcity[testFinished name='compareQImages(different pixels)' flowId='tst_Cmptest']
+##teamcity[testStarted name='compareQImages(different dpr)' flowId='tst_Cmptest']
+##teamcity[testFailed name='compareQImages(different dpr)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared QImages differ in device pixel ratio.|n Actual (opA): 1|n Expected (opB): 2' flowId='tst_Cmptest']
+##teamcity[testFinished name='compareQImages(different dpr)' flowId='tst_Cmptest']
##teamcity[testStarted name='compareQRegion(equal-empty)' flowId='tst_Cmptest']
##teamcity[testFinished name='compareQRegion(equal-empty)' flowId='tst_Cmptest']
##teamcity[testStarted name='compareQRegion(1-empty)' flowId='tst_Cmptest']
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index e1aa81c1a1..08877ef74d 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -104,6 +104,10 @@ FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ i
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
+FAIL! : tst_Cmptest::compareQPixmaps(different dpr) Compared QPixmaps differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2
+ Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
PASS : tst_Cmptest::compareQImages(both null)
FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ.
Actual (opA).isNull(): 1
@@ -124,6 +128,10 @@ FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ i
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
+FAIL! : tst_Cmptest::compareQImages(different dpr) Compared QImages differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2
+ Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
PASS : tst_Cmptest::compareQRegion(equal-empty)
FAIL! : tst_Cmptest::compareQRegion(1-empty) Compared values are not the same
Actual (rA): QRegion(200x50+10+10)
@@ -156,5 +164,5 @@ FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)]
PASS : tst_Cmptest::verifyExplicitOperatorBool()
PASS : tst_Cmptest::cleanupTestCase()
-Totals: 18 passed, 38 failed, 0 skipped, 0 blacklisted, 0ms
+Totals: 18 passed, 40 failed, 0 skipped, 0 blacklisted, 0ms
********* Finished testing of tst_Cmptest *********
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index 1c5a17631a..daf2560f1b 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -211,6 +211,12 @@
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
+<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <DataTag><![CDATA[different dpr]]></DataTag>
+ <Description><![CDATA[Compared QPixmaps differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2]]></Description>
+</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQImages">
@@ -248,6 +254,12 @@
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
+<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0">
+ <DataTag><![CDATA[different dpr]]></DataTag>
+ <Description><![CDATA[Compared QImages differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2]]></Description>
+</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQRegion">
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index 99823d1c1c..397db4c3e4 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="38" tests="26" name="tst_Cmptest">
+<testsuite errors="0" failures="40" tests="26" name="tst_Cmptest">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@@ -98,6 +98,9 @@
Actual (opA): 11x20
Expected (opB): 20x20" result="fail"/>
<failure tag="different pixels" message="Compared values are not the same" result="fail"/>
+ <failure tag="different dpr" message="Compared QPixmaps differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2" result="fail"/>
</testcase>
<testcase result="fail" name="compareQImages">
<failure tag="one null" message="Compared QImages differ.
@@ -113,6 +116,9 @@
Actual (opA): 6
Expected (opB): 3" result="fail"/>
<failure tag="different pixels" message="Compared values are not the same" result="fail"/>
+ <failure tag="different dpr" message="Compared QImages differ in device pixel ratio.
+ Actual (opA): 1
+ Expected (opB): 2" result="fail"/>
</testcase>
<testcase result="fail" name="compareQRegion">
<failure tag="1&#x002D;empty" message="Compared values are not the same
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index e71daccf7d..eae752d99a 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -78,24 +78,22 @@ void tst_qdiriterator::data()
}
#ifdef Q_OS_WIN
-static int posix_helper(const wchar_t *dirpath)
+static int posix_helper(const wchar_t *dirpath, size_t length)
{
int count = 0;
HANDLE hSearch;
WIN32_FIND_DATA fd;
- const size_t origDirPathLength = wcslen(dirpath);
-
wchar_t appendedPath[MAX_PATH];
- wcscpy(appendedPath, dirpath);
- wcscat(appendedPath, L"\\*");
+ Q_ASSERT(MAX_PATH > length + 3);
+ wcsncpy(appendedPath, dirpath, length);
+ wcscpy(appendedPath + length, L"\\*");
#ifndef Q_OS_WINRT
hSearch = FindFirstFile(appendedPath, &fd);
#else
hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
#endif
- appendedPath[origDirPathLength] = 0;
if (hSearch == INVALID_HANDLE_VALUE) {
qWarning("FindFirstFile failed");
@@ -107,10 +105,12 @@ static int posix_helper(const wchar_t *dirpath)
!(fd.cFileName[0] == L'.' && fd.cFileName[1] == L'.' && fd.cFileName[2] == 0))
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- wcscat(appendedPath, L"\\");
- wcscat(appendedPath, fd.cFileName);
- count += posix_helper(appendedPath);
- appendedPath[origDirPathLength] = 0;
+ // newLength will "point" to where we put a * earlier, so we overwrite that.
+ size_t newLength = length + 1; // "+ 1" for directory separator
+ Q_ASSERT(newLength + wcslen(fd.cFileName) + 1 < MAX_PATH); // "+ 1" for null-terminator
+ wcscpy(appendedPath + newLength, fd.cFileName);
+ newLength += wcslen(fd.cFileName);
+ count += posix_helper(appendedPath, newLength);
}
else {
++count;
@@ -164,8 +164,8 @@ void tst_qdiriterator::posix()
QBENCHMARK {
#ifdef Q_OS_WIN
wchar_t wPath[MAX_PATH];
- path.toWCharArray(wPath);
- count = posix_helper(wPath);
+ const int end = path.toWCharArray(wPath);
+ count = posix_helper(wPath, end);
#else
count = posix_helper(dirpath.constData());
#endif
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index d68264b78f..6ee8b4e93b 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -218,8 +218,9 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
#ifdef Q_OS_WIN
wchar_t szSearchPath[MAX_PATH];
- QString::fromLatin1(path).toWCharArray(szSearchPath);
- wcscat(szSearchPath, L"\\*");
+ const int end = QString::fromLatin1(path + "\\*").toWCharArray(szSearchPath);
+ Q_ASSERT(end < MAX_PATH);
+ szSearchPath[end] = L'\0';
#ifndef Q_OS_WINRT
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
#else