summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
commit6630937e63ae5797487b86743a7733c8ae5cc42c (patch)
tree3d53dacf6430f9099e1fb20835881205de674961 /tests/auto/corelib
parent37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff)
parentc7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff)
Merge commit 'dev' into 'wip/cmake-merge'
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp8
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.c2
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.pro1
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp40
-rw-r--r--tests/auto/corelib/global/qlogging/BLACKLIST4
-rw-r--r--tests/auto/corelib/global/qlogging/app/app.pro3
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp8
-rw-r--r--tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp65
-rw-r--r--tests/auto/corelib/global/qtendian/tst_qtendian.cpp40
-rw-r--r--tests/auto/corelib/io/io.pro3
-rw-r--r--tests/auto/corelib/io/qdir/Info.plist41
-rw-r--r--tests/auto/corelib/io/qdir/qdir.pro1
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp46
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp2
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp3
-rw-r--r--tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.pro3
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp4
-rw-r--r--tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp1
-rw-r--r--tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro3
-rw-r--r--tests/auto/corelib/io/qprocess/testDetached/testDetached.pro3
-rw-r--r--tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro3
-rw-r--r--tests/auto/corelib/io/qprocess/testForwardingHelper/testForwardingHelper.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro3
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro6
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro3
-rw-r--r--tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro6
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp18
-rw-r--r--tests/auto/corelib/io/qresourceengine/.gitattributes1
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt2
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp115
-rw-r--r--tests/auto/corelib/io/qsettings/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qsettings/qsettings.qrc1
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp29
-rw-r--r--tests/auto/corelib/io/qsettings/withcomments.ini19
-rw-r--r--tests/auto/corelib/io/qstandardpaths/BLACKLIST3
-rw-r--r--tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro3
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp6
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp4
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp59
-rw-r--r--tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp8
-rw-r--r--tests/auto/corelib/itemmodels/itemmodels.pro5
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp5
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp4
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp7
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp45
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h3
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp22
-rw-r--r--tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro6
-rw-r--r--tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp915
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp6
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h1
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST3
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp179
-rw-r--r--tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp10
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp113
-rw-r--r--tests/auto/corelib/kernel/qmetatype/qmetatype.pro2
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp43
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp277
-rw-r--r--tests/auto/corelib/kernel/qtimer/BLACKLIST2
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp160
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp36
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp26
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/lib.pro2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/lib/lib.pro2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri13
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro73
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro41
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro3
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro9
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro2
-rw-r--r--tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp4
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp61
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp127
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro4
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp68
-rw-r--r--tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/test/test.pro2
-rw-r--r--tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp102
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp2
-rw-r--r--tests/auto/corelib/serialization/serialization.pro1
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp8
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp8
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp2
-rw-r--r--tests/auto/corelib/thread/qthreadpool/BLACKLIST1
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp1
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro3
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp6
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp23
-rw-r--r--tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp36
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp25
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.pro3
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp32
-rw-r--r--tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp2
-rw-r--r--tests/auto/corelib/tools/qdate/tst_qdate.cpp32
-rw-r--r--tests/auto/corelib/tools/qdatetime/qdatetime.pro2
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp13
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp33
-rw-r--r--tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro3
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp169
-rw-r--r--tests/auto/corelib/tools/qpair/qpair.pro3
-rw-r--r--tests/auto/corelib/tools/qpair/tst_qpair.cpp30
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp85
-rw-r--r--tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp13
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/externaltests.cpp3
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp10
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp235
-rw-r--r--tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp64
-rw-r--r--tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp6
-rw-r--r--tests/auto/corelib/tools/qtime/tst_qtime.cpp5
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp15
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp42
-rw-r--r--tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp12
-rw-r--r--tests/auto/corelib/tools/tools.pro1
142 files changed, 3198 insertions, 783 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 6129184738..8265d21350 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -121,7 +121,7 @@ void tst_QFlags::constExpr()
QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) & 0xff)>(Qt::RightButton));
QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) | 0xff)>(0xff));
- QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton)));
+ QVERIFY(!verifyConstExpr<Qt::RightButton>(~Qt::MouseButtons(Qt::LeftButton)));
#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
QVERIFY(verifyConstExpr<uint(testRelaxedConstExpr())>(Qt::MiddleButton));
@@ -142,7 +142,6 @@ void tst_QFlags::signedness()
std::is_signed<Qt::Alignment::Int>::value));
}
-#if defined(Q_COMPILER_CLASS_ENUM)
enum class MyStrictEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
Q_DECLARE_FLAGS( MyStrictFlags, MyStrictEnum )
Q_DECLARE_OPERATORS_FOR_FLAGS( MyStrictFlags )
@@ -154,11 +153,9 @@ Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isComplex );
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isStatic );
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isLarge );
Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isPointer );
-#endif
void tst_QFlags::classEnum()
{
-#if defined(Q_COMPILER_CLASS_ENUM)
// The main aim of the test is making sure it compiles
// The QCOMPARE are there as an extra
MyStrictEnum e1 = MyStrictEnum::StrictOne;
@@ -257,7 +254,6 @@ void tst_QFlags::classEnum()
// Just to make sure it compiles
if (false)
qDebug() << f3;
-#endif
}
void tst_QFlags::initializerLists()
@@ -268,12 +264,10 @@ void tst_QFlags::initializerLists()
QVERIFY(bts.testFlag(Qt::RightButton));
QVERIFY(!bts.testFlag(Qt::MiddleButton));
-#if defined(Q_COMPILER_CLASS_ENUM)
MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour };
QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne));
QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour));
QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo));
-#endif // Q_COMPILER_CLASS_ENUM
#else
QSKIP("This test requires C++11 initializer_list support.");
diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c
index 0719c4b921..c7124454d0 100644
--- a/tests/auto/corelib/global/qglobal/qglobal.c
+++ b/tests/auto/corelib/global/qglobal/qglobal.c
@@ -85,7 +85,7 @@ int tst_QtVersion()
return QT_VERSION;
}
-const char *tst_qVersion() Q_DECL_NOTHROW
+const char *tst_qVersion() Q_DECL_NOEXCEPT
{
#if !defined(QT_NAMESPACE)
return qVersion();
diff --git a/tests/auto/corelib/global/qglobal/qglobal.pro b/tests/auto/corelib/global/qglobal/qglobal.pro
index a40cb9a288..b105769430 100644
--- a/tests/auto/corelib/global/qglobal/qglobal.pro
+++ b/tests/auto/corelib/global/qglobal/qglobal.pro
@@ -2,3 +2,4 @@ CONFIG += testcase
TARGET = tst_qglobal
QT = core testlib
SOURCES = tst_qglobal.cpp qglobal.c
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 78b954f373..56da047147 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -126,6 +126,46 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());
+
+ // Should also work with an existing variable
+ int local;
+ counter = 0;
+ foreach (local, list) {
+ QCOMPARE(local, counter++);
+ }
+ QCOMPARE(counter, list.count());
+ QCOMPARE(local, counter - 1);
+
+ // Test the macro does not mess if/else conditions
+ counter = 0;
+ if (true)
+ foreach (int i, list)
+ QCOMPARE(i, counter++);
+ else
+ QFAIL("If/Else mismatch");
+ QCOMPARE(counter, list.count());
+
+ counter = 0;
+ if (false)
+ foreach (int i, list)
+ if (i) QFAIL("If/Else mismatch");
+ else QFAIL("If/Else mismatch");
+ else
+ foreach (int i, list)
+ if (false) { }
+ else QCOMPARE(i, counter++);
+ QCOMPARE(counter, list.count());
+
+ // break and continue
+ counter = 0;
+ foreach (int i, list) {
+ if (i == 0)
+ continue;
+ QCOMPARE(i, (counter++) + 1);
+ if (i == 3)
+ break;
+ }
+ QCOMPARE(counter, 3);
}
void tst_QGlobal::qassert()
diff --git a/tests/auto/corelib/global/qlogging/BLACKLIST b/tests/auto/corelib/global/qlogging/BLACKLIST
index 1dcee92361..e474064f54 100644
--- a/tests/auto/corelib/global/qlogging/BLACKLIST
+++ b/tests/auto/corelib/global/qlogging/BLACKLIST
@@ -1,3 +1,7 @@
+[qMessagePattern:backtrace]
+# QTBUG-63915
+b2qt 64bit
+
[qMessagePattern:backtrace depth,separator]
# QTBUG-63915
b2qt 64bit
diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro
index b90b685749..3ada382ff4 100644
--- a/tests/auto/corelib/global/qlogging/app/app.pro
+++ b/tests/auto/corelib/global/qlogging/app/app.pro
@@ -14,8 +14,7 @@ QT = core
DESTDIR = ./
-CONFIG -= app_bundle
-CONFIG += console
+CONFIG += cmdline
SOURCES += main.cpp
DEFINES += QT_MESSAGELOGCONTEXT
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 9df54e17d3..d10d879130 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -254,19 +254,15 @@ public:
int rvalue() && { ADD("TestClass1::rvalue"); return 0; }
int const_rvalue() const && { ADD("TestClass1::const_rvalue"); return 0; }
#endif
-#ifdef Q_COMPILER_DECLTYPE
int decltype_param(int x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_param"); return x; }
template<typename T> int decltype_template_param(T x = 0, decltype(x) = 0)
{ ADD("TestClass1::decltype_template_param"); return x; }
template<typename T> void decltype_template_param2(T x, decltype(x + QString()))
{ ADD("TestClass1::decltype_template_param2"); }
-# ifdef Q_COMPILER_AUTO_FUNCTION
auto decltype_return(int x = 0) -> decltype(x)
{ ADD("TestClass1::decltype_return"); return x; }
template <typename T> auto decltype_template_return(T x = 0) -> decltype(x)
{ ADD("TestClass1::decltype_template_return"); return x; }
-# endif
-#endif
public:
TestClass1()
@@ -323,15 +319,11 @@ public:
std::move(*this).rvalue();
std::move(*this).const_rvalue();
#endif
-#ifdef Q_COMPILER_DECLTYPE
decltype_param();
decltype_template_param(0);
decltype_template_param2(QByteArray(), QString());
-# ifdef Q_COMPILER_AUTO_FUNCTION
decltype_return();
decltype_template_return(0);
-# endif
-#endif
}
};
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
index 03300c6dbe..0a84b1fdd8 100644
--- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
+++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -42,7 +42,8 @@ class tst_QNumeric: public QObject
private slots:
void fuzzyCompare_data();
void fuzzyCompare();
- void qNan();
+ void qNanInf();
+ void classifyfp();
void floatDistance_data();
void floatDistance();
void floatDistance_double_data();
@@ -91,7 +92,7 @@ void tst_QNumeric::fuzzyCompare()
# pragma GCC optimize "no-fast-math"
#endif
-void tst_QNumeric::qNan()
+void tst_QNumeric::qNanInf()
{
#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404)
QSKIP("Non-conformant fast math mode is enabled, cannot run test");
@@ -99,9 +100,16 @@ void tst_QNumeric::qNan()
double nan = qQNaN();
QVERIFY(!(0 > nan));
QVERIFY(!(0 < nan));
+ QVERIFY(!(0 == nan));
+ QVERIFY(!(nan == nan));
QVERIFY(qIsNaN(nan));
QVERIFY(qIsNaN(nan + 1));
QVERIFY(qIsNaN(-nan));
+ QVERIFY(qIsNaN(1.0 / nan));
+ QVERIFY(qIsNaN(0.0 / nan));
+ QVERIFY(qIsNaN(0.0 * nan));
+ QCOMPARE(nan, nan);
+ QCOMPARE(nan, -nan);
Q_STATIC_ASSERT(sizeof(double) == 8);
#ifdef Q_LITTLE_ENDIAN
@@ -113,17 +121,56 @@ void tst_QNumeric::qNan()
QVERIFY(!qIsFinite(nan));
QVERIFY(!qIsInf(nan));
QVERIFY(qIsNaN(nan));
+ QVERIFY(qIsNaN(-nan));
+ QVERIFY(!(nan == nan));
+ QVERIFY(qIsNaN(0.0 * nan));
+ QCOMPARE(qFpClassify(nan), FP_NAN);
+ QCOMPARE(nan, nan);
+ QCOMPARE(nan, -nan);
+ QCOMPARE(nan, qQNaN());
double inf = qInf();
QVERIFY(inf > 0);
QVERIFY(-inf < 0);
QVERIFY(qIsInf(inf));
+ QCOMPARE(inf, inf);
+ QCOMPARE(-inf, -inf);
QVERIFY(qIsInf(-inf));
- QVERIFY(qIsInf(2*inf));
- QCOMPARE(1/inf, 0.0);
- QVERIFY(qIsNaN(0*nan));
- QVERIFY(qIsNaN(0*inf));
- QVERIFY(qFuzzyCompare(1/inf, 0.0));
+ QVERIFY(qIsInf(inf + 1));
+ QVERIFY(qIsInf(inf - 1));
+ QVERIFY(qIsInf(inf * 2.0));
+ QVERIFY(qIsInf(inf / 2.0));
+ QVERIFY(qFuzzyCompare(1.0 / inf, 0.0));
+ QCOMPARE(1.0 / inf, 0.0);
+ QVERIFY(qIsNaN(0.0 * inf));
+}
+
+void tst_QNumeric::classifyfp()
+{
+ QCOMPARE(qFpClassify(qQNaN()), FP_NAN);
+
+ QCOMPARE(qFpClassify(qInf()), FP_INFINITE);
+ QCOMPARE(qFpClassify(-qInf()), FP_INFINITE);
+ QCOMPARE(qFpClassify(DBL_MAX * 2.0), FP_INFINITE);
+ QCOMPARE(qFpClassify(FLT_MAX * 2.f), FP_INFINITE);
+ QCOMPARE(qFpClassify(DBL_MAX * -2.0), FP_INFINITE);
+ QCOMPARE(qFpClassify(FLT_MAX * -2.f), FP_INFINITE);
+
+ QCOMPARE(qFpClassify(1.0), FP_NORMAL);
+ QCOMPARE(qFpClassify(DBL_MAX), FP_NORMAL);
+ QCOMPARE(qFpClassify(-DBL_MAX), FP_NORMAL);
+ QCOMPARE(qFpClassify(DBL_MIN), FP_NORMAL);
+ QCOMPARE(qFpClassify(-DBL_MIN), FP_NORMAL);
+ QCOMPARE(qFpClassify(DBL_MIN / 2.0), FP_SUBNORMAL);
+ QCOMPARE(qFpClassify(DBL_MIN / -2.0), FP_SUBNORMAL);
+
+ QCOMPARE(qFpClassify(1.f), FP_NORMAL);
+ QCOMPARE(qFpClassify(FLT_MAX), FP_NORMAL);
+ QCOMPARE(qFpClassify(-FLT_MAX), FP_NORMAL);
+ QCOMPARE(qFpClassify(FLT_MIN), FP_NORMAL);
+ QCOMPARE(qFpClassify(-FLT_MIN), FP_NORMAL);
+ QCOMPARE(qFpClassify(FLT_MIN / 2.f), FP_SUBNORMAL);
+ QCOMPARE(qFpClassify(FLT_MIN / -2.f), FP_SUBNORMAL);
}
void tst_QNumeric::floatDistance_data()
@@ -461,13 +508,13 @@ template <typename Int> static void mulOverflow_template()
QCOMPARE(mul_overflow(Int(max / 2), Int(3), &r), true);
QCOMPARE(mul_overflow(mid1, Int(mid2 + 1), &r), true);
QCOMPARE(mul_overflow(Int(max / 2 + 2), Int(2), &r), true);
+ QCOMPARE(mul_overflow(Int(max - max / 2), Int(2), &r), true);
QCOMPARE(mul_overflow(Int(1ULL << (std::numeric_limits<Int>::digits - 1)), Int(2), &r), true);
if (min) {
QCOMPARE(mul_overflow(min, Int(2), &r), true);
QCOMPARE(mul_overflow(Int(min / 2), Int(3), &r), true);
QCOMPARE(mul_overflow(Int(min / 2 - 1), Int(2), &r), true);
- QCOMPARE(mul_overflow(Int(min + min/2), Int(2), &r), true);
}
#endif
}
diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp
index 7043969c2f..2345bb39c1 100644
--- a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp
+++ b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp
@@ -64,6 +64,9 @@ struct TestData
quint16 data16;
quint8 data8;
+ float dataFloat;
+ double dataDouble;
+
quint8 reserved;
};
@@ -72,6 +75,7 @@ template <> quint8 getData(const TestData &d) { return d.data8; }
template <> quint16 getData(const TestData &d) { return d.data16; }
template <> quint32 getData(const TestData &d) { return d.data32; }
template <> quint64 getData(const TestData &d) { return d.data64; }
+template <> float getData(const TestData &d) { return d.dataFloat; }
union RawTestData
{
@@ -79,9 +83,39 @@ union RawTestData
TestData data;
};
-static const TestData inNativeEndian = { Q_UINT64_C(0x0123456789abcdef), 0x00c0ffee, 0xcafe, 0xcf, '\0' };
-static const RawTestData inBigEndian = { "\x01\x23\x45\x67\x89\xab\xcd\xef" "\x00\xc0\xff\xee" "\xca\xfe" "\xcf" };
-static const RawTestData inLittleEndian = { "\xef\xcd\xab\x89\x67\x45\x23\x01" "\xee\xff\xc0\x00" "\xfe\xca" "\xcf" };
+template <typename Float>
+Float int2Float(typename QIntegerForSizeof<Float>::Unsigned i)
+{
+ Float result = 0;
+ memcpy(reinterpret_cast<char *>(&result), reinterpret_cast<const char *>(&i), sizeof (Float));
+ return result;
+}
+
+static const TestData inNativeEndian = {
+ Q_UINT64_C(0x0123456789abcdef),
+ 0x00c0ffee,
+ 0xcafe,
+ 0xcf,
+ int2Float<float>(0x00c0ffeeU),
+ int2Float<double>(Q_UINT64_C(0x0123456789abcdef)),
+ '\0'
+};
+static const RawTestData inBigEndian = {
+ "\x01\x23\x45\x67\x89\xab\xcd\xef"
+ "\x00\xc0\xff\xee"
+ "\xca\xfe"
+ "\xcf"
+ "\x00\xc0\xff\xee"
+ "\x01\x23\x45\x67\x89\xab\xcd\xef"
+};
+static const RawTestData inLittleEndian = {
+ "\xef\xcd\xab\x89\x67\x45\x23\x01"
+ "\xee\xff\xc0\x00"
+ "\xfe\xca"
+ "\xcf"
+ "\xee\xff\xc0\x00"
+ "\xef\xcd\xab\x89\x67\x45\x23\x01"
+};
#define EXPAND_ENDIAN_TEST(endian) \
do { \
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro
index 3c93fd5e1f..eee2c0e30d 100644
--- a/tests/auto/corelib/io/io.pro
+++ b/tests/auto/corelib/io/io.pro
@@ -65,6 +65,9 @@ win32:!qtConfig(private_tests): SUBDIRS -= \
qprocess \
qprocess-noapplication
+!qtConfig(settings): SUBDIRS -= \
+ qsettings
+
winrt: SUBDIRS -= \
qstorageinfo
diff --git a/tests/auto/corelib/io/qdir/Info.plist b/tests/auto/corelib/io/qdir/Info.plist
new file mode 100644
index 0000000000..7dc5622bde
--- /dev/null
+++ b/tests/auto/corelib/io/qdir/Info.plist
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Qt/QMake</string>
+ <key>CFBundleIconFile</key>
+ <string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${QMAKE_SHORT_VERSION}</string>
+ <key>CFBundleSignature</key>
+ <string>${QMAKE_PKGINFO_TYPEINFO}</string>
+ <key>CFBundleVersion</key>
+ <string>${QMAKE_FULL_VERSION}</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>MinimumOSVersion</key>
+ <string>${IPHONEOS_DEPLOYMENT_TARGET}</string>
+ <key>UILaunchStoryboardName</key>
+ <string>LaunchScreen</string>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>NSPhotoLibraryUsageDescription</key>
+ <string>Enables use of assets file engine</string>
+</dict>
+</plist>
diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro
index 2252e71cd8..a8b106e250 100644
--- a/tests/auto/corelib/io/qdir/qdir.pro
+++ b/tests/auto/corelib/io/qdir/qdir.pro
@@ -3,6 +3,7 @@ TARGET = tst_qdir
QT = core core-private testlib
SOURCES = tst_qdir.cpp
RESOURCES += qdir.qrc
+ios: QMAKE_INFO_PLIST = Info.plist
TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 30f0e447ad..2aebc67dcf 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -62,12 +62,7 @@
#endif
#ifdef QT_BUILD_INTERNAL
-
-QT_BEGIN_NAMESPACE
-extern Q_AUTOTEST_EXPORT QString
- qt_normalizePathSegments(const QString &path, bool allowUncPaths, bool *ok = nullptr);
-QT_END_NAMESPACE
-
+#include "private/qdir_p.h"
#endif
static QByteArray msgDoesNotExist(const QString &name)
@@ -354,21 +349,21 @@ void tst_QDir::mkdirRmdir_data()
QTest::addColumn<QString>("path");
QTest::addColumn<bool>("recurse");
- QStringList dirs;
- dirs << "testdir/one"
- << "testdir/two/three/four"
- << "testdir/../testdir/three";
- QTest::newRow("plain") << QDir::currentPath() + "/" + dirs.at(0) << false;
- QTest::newRow("recursive") << QDir::currentPath() + "/" + dirs.at(1) << true;
- QTest::newRow("with-..") << QDir::currentPath() + "/" + dirs.at(2) << false;
-
- QTest::newRow("relative-plain") << dirs.at(0) << false;
- QTest::newRow("relative-recursive") << dirs.at(1) << true;
- QTest::newRow("relative-with-..") << dirs.at(2) << false;
-
- // Ensure that none of these directories already exist
- for (int i = 0; i < dirs.count(); ++i)
- QVERIFY(!QFile::exists(dirs.at(i)));
+ const struct {
+ const char *name; // shall have a prefix added
+ const char *path; // relative
+ bool recurse;
+ } cases[] = {
+ { "plain", "testdir/one", false },
+ { "recursive", "testdir/two/three/four", true },
+ { "with-..", "testdir/../testdir/three", false },
+ };
+
+ for (const auto &it : cases) {
+ QVERIFY(!QFile::exists(it.path));
+ QTest::addRow("absolute-%s", it.name) << (QDir::currentPath() + "/") + it.path << it.recurse;
+ QTest::addRow("relative-%s", it.name) << QString::fromLatin1(it.path) << it.recurse;
+ }
}
void tst_QDir::mkdirRmdir()
@@ -1376,7 +1371,7 @@ void tst_QDir::normalizePathSegments()
QFETCH(QString, path);
QFETCH(UncHandling, uncHandling);
QFETCH(QString, expected);
- QString cleaned = qt_normalizePathSegments(path, uncHandling == HandleUnc);
+ QString cleaned = qt_normalizePathSegments(path, uncHandling == HandleUnc ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization);
QCOMPARE(cleaned, expected);
if (path == expected)
QVERIFY2(path.isSharedWith(cleaned), "Strings are same but data is not shared");
@@ -1528,6 +1523,11 @@ void tst_QDir::filePath_data()
QTest::newRow("rel-rel") << "relative" << "path" << "relative/path";
QTest::newRow("empty-empty") << "" << "" << ".";
QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar";
+#ifdef Q_OS_IOS
+ QTest::newRow("assets-rel") << "assets-library:/" << "foo/bar.baz" << "assets-library:/foo/bar.baz";
+ QTest::newRow("assets-abs") << "assets-library:/" << "/foo/bar.baz" << "/foo/bar.baz";
+ QTest::newRow("abs-assets") << "/some/path" << "assets-library:/foo/bar.baz" << "assets-library:/foo/bar.baz";
+#endif
#ifdef Q_OS_WIN
QTest::newRow("abs-LTUNC") << "Q:/path" << "\\/leaning\\tooth/pick" << "\\/leaning\\tooth/pick";
QTest::newRow("LTUNC-slash") << "\\/leaning\\tooth/pick" << "/path" << "//leaning/tooth/path";
@@ -2045,7 +2045,7 @@ void tst_QDir::detachingOperations()
QCOMPARE(dir2.nameFilters(), nameFilters);
QCOMPARE(dir2.sorting(), sorting);
- dir2 = path1;
+ dir2.setPath(path1);
QCOMPARE(dir2.path(), path1);
QCOMPARE(dir2.filter(), filter);
QCOMPARE(dir2.nameFilters(), nameFilters);
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 3e29475636..714c96b5e5 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -2022,7 +2022,7 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr
QVERIFY(!info.isRoot());
QCOMPARE(info.isNativePath(), !filename.isEmpty());
- QCOMPARE(info.readLink(), QString());
+ QCOMPARE(info.symLinkTarget(), QString());
QCOMPARE(info.ownerId(), uint(-2));
QCOMPARE(info.groupId(), uint(-2));
QCOMPARE(info.owner(), QString());
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/qlockfile/qlockfiletesthelper/qlockfile_test_helper.pro b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.pro
index 3ac3be9c9b..97135d279e 100644
--- a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.pro
+++ b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.pro
@@ -1,7 +1,6 @@
TARGET = qlockfile_test_helper
SOURCES += qlockfile_test_helper.cpp
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
QT = core
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index 11a9b3f189..08635d34c5 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -369,11 +369,9 @@ private slots:
}
Q_LOGGING_CATEGORY(TST_MACRO_1, "tst.macro.1")
-#ifdef Q_COMPILER_VARIADIC_MACROS
Q_LOGGING_CATEGORY(TST_MACRO_2, "tst.macro.2", QtDebugMsg)
Q_LOGGING_CATEGORY(TST_MACRO_3, "tst.macro.3", QtFatalMsg)
Q_LOGGING_CATEGORY(TST_MACRO_4, "tst.macro.4", QtInfoMsg)
-#endif
void QLoggingCategoryMacro()
{
@@ -384,7 +382,6 @@ private slots:
QCOMPARE(cat1.isWarningEnabled(), true);
QCOMPARE(cat1.isCriticalEnabled(), true);
-#ifdef Q_COMPILER_VARIADIC_MACROS
const QLoggingCategory &cat2 = TST_MACRO_2();
QCOMPARE(cat2.categoryName(), "tst.macro.2");
QCOMPARE(cat2.isDebugEnabled(), true);
@@ -405,7 +402,6 @@ private slots:
QCOMPARE(cat4.isInfoEnabled(), true);
QCOMPARE(cat4.isWarningEnabled(), true);
QCOMPARE(cat4.isCriticalEnabled(), true);
-#endif
}
void qCDebugMacros()
diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
index 17c51eaaf4..569c610e24 100644
--- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
+++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
@@ -53,6 +53,7 @@ void tst_QNoDebug::noDebugOutput() const
// should do nothing
qDebug() << "foo";
qCDebug(cat) << "foo";
+ qCDebug(cat, "foo");
// qWarning still works, though
QTest::ignoreMessage(QtWarningMsg, "bar");
diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro b/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro
index 947dc916f2..2744491151 100644
--- a/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro
+++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/fileWriterProcess.pro
@@ -1,5 +1,4 @@
SOURCES = main.cpp
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
QT = core
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro b/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro
index 8d1fcba624..3d80b668df 100644
--- a/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro
+++ b/tests/auto/corelib/io/qprocess/testDetached/testDetached.pro
@@ -1,6 +1,5 @@
SOURCES = main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
INSTALLS =
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro b/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro
index b08371804f..5eaf8dc881 100644
--- a/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro
+++ b/tests/auto/corelib/io/qprocess/testExitCodes/testExitCodes.pro
@@ -1,5 +1,5 @@
SOURCES += main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro b/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro
index 45b498c32a..4d91e0cf36 100644
--- a/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro
+++ b/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro
@@ -1,5 +1,4 @@
SOURCES = main.cpp
-CONFIG -= app_bundle
-CONFIG += console
+CONFIG += cmdline
DESTDIR = ./
QT = core
diff --git a/tests/auto/corelib/io/qprocess/testForwardingHelper/testForwardingHelper.pro b/tests/auto/corelib/io/qprocess/testForwardingHelper/testForwardingHelper.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testForwardingHelper/testForwardingHelper.pro
+++ b/tests/auto/corelib/io/qprocess/testForwardingHelper/testForwardingHelper.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro b/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro
index 8778da7ffe..ef438d6399 100644
--- a/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro
+++ b/tests/auto/corelib/io/qprocess/testGuiProcess/testGuiProcess.pro
@@ -1,5 +1,4 @@
SOURCES += main.cpp
QT += widgets
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro b/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro
index 7ccc976efc..640ce4cd09 100644
--- a/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessCrash/testProcessCrash.pro
@@ -1,5 +1,5 @@
SOURCES = main.cpp
-CONFIG += console
-CONFIG -= qt app_bundle
+CONFIG += cmdline
+CONFIG -= qt
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro
index fbb3411d47..c7be60a82d 100644
--- a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/testProcessDeadWhileReading.pro
@@ -1,5 +1,5 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro b/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro
index 98fe78c8b9..ab1394a5c9 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessEOF/testProcessEOF.pro
@@ -1,6 +1,6 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
win32:!mingw:!equals(TEMPLATE_PREFIX, "vc"):QMAKE_CXXFLAGS += /GS-
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro b/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessEcho/testProcessEcho.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro b/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro b/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessEcho3/testProcessEcho3.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro b/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro
index a07ae00605..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessEnvironment/testProcessEnvironment.pro
@@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
-CONFIG += console
+CONFIG += cmdline
DESTDIR = ./
-
-mac {
- CONFIG -= app_bundle
-}
diff --git a/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro b/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessHang/testProcessHang.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro b/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro
index c6db9d1bac..7e1119c117 100644
--- a/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessNormal/testProcessNormal.pro
@@ -1,6 +1,6 @@
SOURCES = main.cpp
-CONFIG += console
-CONFIG -= qt app_bundle
+CONFIG += cmdline
+CONFIG -= qt
DESTDIR = ./
QT = core
diff --git a/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro b/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro
index 95191098bd..0bbb6b3c0e 100644
--- a/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessOutput/testProcessOutput.pro
@@ -1,5 +1,5 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
QT = core
diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro
index dd7e8e4a85..7954a2f74b 100644
--- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/nospace.pro
@@ -1,6 +1,6 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
OBJECTS_DIR = $${OBJECTS_DIR}-nospace
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro
index d18a683e1c..44a365c9a5 100644
--- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/onespace.pro
@@ -1,6 +1,6 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
OBJECTS_DIR = $${OBJECTS_DIR}-onespace
diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro
index 8b16f65e34..bd2db9fb6d 100644
--- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro
+++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/twospaces.pro
@@ -1,6 +1,6 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
OBJECTS_DIR = $${OBJECTS_DIR}-twospaces
diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro
index e236e05c7d..6a23e52d95 100644
--- a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro
+++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro
@@ -1,4 +1,4 @@
SOURCES = main.cpp
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
diff --git a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro
index 21a115b536..4d91e0cf36 100644
--- a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro
+++ b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/testSetWorkingDirectory.pro
@@ -1,5 +1,4 @@
SOURCES = main.cpp
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
QT = core
diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
index 80e8bcad98..2cfcb4794e 100644
--- a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
+++ b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
@@ -6,7 +6,7 @@ unix {
SOURCES = main_unix.cpp
}
-CONFIG -= qt app_bundle
-CONFIG += console
+CONFIG -= qt
+CONFIG += cmdline
DESTDIR = ./
QT = core
diff --git a/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro b/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro
index afa4f32a85..48f28c4c8b 100644
--- a/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro
+++ b/tests/auto/corelib/io/qprocess/testSpaceInName/testSpaceInName.pro
@@ -1,9 +1,5 @@
SOURCES = main.cpp
CONFIG -= qt
-CONFIG += console
+CONFIG += cmdline
DESTDIR = "../test Space In Name"
-
-mac {
- CONFIG -= app_bundle
-}
QT = core
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index e0aa577154..c51994c1c1 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -185,12 +185,12 @@ void tst_QProcess::getSetCheck()
{
QProcess obj1;
// ProcessChannelMode QProcess::readChannelMode()
- // void QProcess::setReadChannelMode(ProcessChannelMode)
- obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels));
+ // void QProcess::setProcessChannelMode(ProcessChannelMode)
+ obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.readChannelMode());
- obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels));
+ obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.readChannelMode());
- obj1.setReadChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels));
+ obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels));
QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.readChannelMode());
// ProcessChannel QProcess::readChannel()
@@ -913,7 +913,7 @@ public:
switch (n) {
case 0:
- setReadChannelMode(QProcess::MergedChannels);
+ setProcessChannelMode(QProcess::MergedChannels);
connect(this, &QIODevice::readyRead, this, &SoftExitProcess::terminateSlot);
break;
case 1:
@@ -929,7 +929,7 @@ public:
this, &SoftExitProcess::terminateSlot);
break;
case 4:
- setReadChannelMode(QProcess::MergedChannels);
+ setProcessChannelMode(QProcess::MergedChannels);
connect(this, SIGNAL(channelReadyRead(int)), this, SLOT(terminateSlot()));
break;
default:
@@ -1025,7 +1025,7 @@ void tst_QProcess::softExitInSlots()
void tst_QProcess::mergedChannels()
{
QProcess process;
- process.setReadChannelMode(QProcess::MergedChannels);
+ process.setProcessChannelMode(QProcess::MergedChannels);
QCOMPARE(process.readChannelMode(), QProcess::MergedChannels);
process.start("testProcessEcho2/testProcessEcho2");
@@ -1951,7 +1951,7 @@ void tst_QProcess::setStandardOutputFile()
// run the process
QProcess process;
- process.setReadChannelMode(channelMode);
+ process.setProcessChannelMode(channelMode);
if (channelToTest == QProcess::StandardOutput)
process.setStandardOutputFile(file.fileName(), mode);
else
@@ -2037,7 +2037,7 @@ void tst_QProcess::setStandardOutputProcess()
QFETCH(bool, merged);
QFETCH(bool, waitForBytesWritten);
- source.setReadChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels);
+ source.setProcessChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels);
source.setStandardOutputProcess(&sink);
source.start("testProcessEcho2/testProcessEcho2");
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/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 ab49dea6d8..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.
@@ -104,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");
@@ -134,7 +135,7 @@ void tst_QResourceEngine::checkStructure_data()
QTest::newRow("root dir") << QString(":/")
- << QString()
+ << QByteArray()
<< (QStringList()
#if defined(BUILTIN_TESTDATA)
<< "parentdir.txt"
@@ -146,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()
@@ -157,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()
@@ -231,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")
@@ -329,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")
@@ -341,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);
@@ -401,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());
}
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.qrc b/tests/auto/corelib/io/qsettings/qsettings.qrc
index c664a6f68c..db1d8c663f 100644
--- a/tests/auto/corelib/io/qsettings/qsettings.qrc
+++ b/tests/auto/corelib/io/qsettings/qsettings.qrc
@@ -7,5 +7,6 @@
<file>resourcefile5.ini</file>
<file>resourcefile6.plist</file>
<file>bom.ini</file>
+ <file>withcomments.ini</file>
</qresource>
</RCC>
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 5357194406..8b69518ef7 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -187,6 +187,7 @@ private slots:
void bom();
void embeddedZeroByte_data();
void embeddedZeroByte();
+ void spaceAfterComment();
void testXdg();
private:
@@ -764,6 +765,34 @@ void tst_QSettings::embeddedZeroByte()
}
}
+void tst_QSettings::spaceAfterComment()
+{
+ QSettings settings(QFINDTESTDATA("withcomments.ini"), QSettings::IniFormat);
+ QCOMPARE(settings.status(), QSettings::NoError);
+
+ QStringList groups = settings.childGroups();
+ QVERIFY(groups.contains("Regular"));
+ QVERIFY(groups.contains("WithSpaces"));
+ QVERIFY(groups.contains("WithTab"));
+ QVERIFY(groups.contains("SpacedGroup"));
+
+ settings.beginGroup("Regular");
+ QCOMPARE(settings.value("bar"), QVariant(2));
+ settings.endGroup();
+
+ settings.beginGroup("WithSpaces");
+ QCOMPARE(settings.value("bar"), QVariant(4));
+ settings.endGroup();
+
+ settings.beginGroup("WithTab");
+ QCOMPARE(settings.value("bar"), QVariant(6));
+ settings.endGroup();
+
+ settings.beginGroup("SpacedGroup");
+ QCOMPARE(settings.value("bar"), QVariant(7));
+ settings.endGroup();
+}
+
void tst_QSettings::testErrorHandling_data()
{
QTest::addColumn<int>("filePerms"); // -1 means file should not exist
diff --git a/tests/auto/corelib/io/qsettings/withcomments.ini b/tests/auto/corelib/io/qsettings/withcomments.ini
new file mode 100644
index 0000000000..d2de3a356b
--- /dev/null
+++ b/tests/auto/corelib/io/qsettings/withcomments.ini
@@ -0,0 +1,19 @@
+; -*- conf -*-
+; If you edit this file, make sure, that "WithSpaces" has spaces and that
+; "WithTab" has one tab
+
+[Regular]
+;bar = 1
+bar = 2
+
+[WithSpaces]
+;bar = 3
+ bar = 4
+
+[WithTab]
+;bar = 5
+ bar = 6
+
+; [SpacedGroup]
+ [SpacedGroup]
+ bar = 7
diff --git a/tests/auto/corelib/io/qstandardpaths/BLACKLIST b/tests/auto/corelib/io/qstandardpaths/BLACKLIST
deleted file mode 100644
index d5ee9650cd..0000000000
--- a/tests/auto/corelib/io/qstandardpaths/BLACKLIST
+++ /dev/null
@@ -1,3 +0,0 @@
-[testFindExecutable]
-# QTBUG-64404
-b2qt 64bit
diff --git a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
index 9fd7047405..44b1ce8dd8 100644
--- a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
+++ b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
@@ -5,3 +5,6 @@ INCLUDEPATH += ../../../../shared/
HEADERS += ../../../../shared/emulationdetector.h
SOURCES = tst_qstandardpaths.cpp
TESTDATA += tst_qstandardpaths.cpp qstandardpaths.pro
+
+# QTBUG-64404
+boot2qt: DEFINES+=SKIP_FINDEXECUTABLE
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 5cb130f631..1379c788d1 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -371,6 +371,12 @@ static inline QFileInfo findSh()
void tst_qstandardpaths::testFindExecutable_data()
{
+#ifdef SKIP_FINDEXECUTABLE
+ // Test needs to be skipped or Q_ASSERT below will cancel the test
+ // and report FAIL regardless of BLACKLIST contents
+ QSKIP("QTBUG-64404");
+#endif
+
QTest::addColumn<QString>("directory");
QTest::addColumn<QString>("needle");
QTest::addColumn<QString>("expected");
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index dbc3d68e93..67d8c55b04 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -215,7 +215,7 @@ void tst_QTemporaryFile::fileTemplate()
if (!fileTemplate.isEmpty())
file.setFileTemplate(fileTemplate);
- QCOMPARE(file.open(), true);
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QString fileName = QFileInfo(file).fileName();
if (prefix.length())
@@ -376,7 +376,7 @@ void tst_QTemporaryFile::io()
before.setSecsSinceEpoch(before.toSecsSinceEpoch());
QVERIFY(file.open());
- QVERIFY(file.readLink().isEmpty()); // it's not a link!
+ QVERIFY(file.symLinkTarget().isEmpty()); // it's not a link!
QFile::Permissions perm = file.permissions();
QVERIFY(perm & QFile::ReadOwner);
QVERIFY(file.setPermissions(perm));
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 84af1c255a..9c106c7f58 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -47,6 +47,7 @@ class tst_QUrl : public QObject
private slots:
void initTestCase();
+ void cleanupTestCase();
void effectiveTLDs_data();
void effectiveTLDs();
void getSetCheck();
@@ -182,10 +183,13 @@ private slots:
void matches();
void ipv6_zoneId_data();
void ipv6_zoneId();
+ void normalizeRemotePaths_data();
+ void normalizeRemotePaths();
private:
void testThreadingHelper();
+ const QString m_currentPath = QDir::currentPath();
QTemporaryDir m_tempDir;
};
@@ -194,6 +198,12 @@ void tst_QUrl::initTestCase()
QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString()));
}
+void tst_QUrl::cleanupTestCase()
+{
+ // Restore working directory changed in fromUserInputWithCwd()
+ QDir::setCurrent(m_currentPath);
+}
+
// Testing get/set functions
void tst_QUrl::getSetCheck()
{
@@ -323,7 +333,7 @@ void tst_QUrl::comparison()
QUrl url3bis = QUrl::fromEncoded("example://a/b/c/%7Bfoo%7D/");
QUrl url3bisNoSlash = QUrl::fromEncoded("example://a/b/c/%7Bfoo%7D");
- QUrl url4bis = QUrl::fromEncoded("example://a/.//b/../b/c//%7Bfoo%7D/");
+ QUrl url4bis = QUrl::fromEncoded("example://a/./b/../b/c/%7Bfoo%7D/");
QCOMPARE(url4bis.adjusted(QUrl::NormalizePathSegments), url3bis);
QCOMPARE(url4bis.adjusted(QUrl::NormalizePathSegments | QUrl::StripTrailingSlash), url3bisNoSlash);
QVERIFY(url3bis.matches(url4bis, QUrl::NormalizePathSegments));
@@ -335,7 +345,7 @@ void tst_QUrl::comparison()
QCOMPARE(url4EncodedDots.path(QUrl::FullyDecoded), QString("/.//b/..//b/c/"));
QCOMPARE(QString::fromLatin1(url4EncodedDots.toEncoded()), QString::fromLatin1("example://a/.//b/..%2F/b/c/"));
QCOMPARE(url4EncodedDots.toString(), QString("example://a/.//b/..%2F/b/c/"));
- QCOMPARE(url4EncodedDots.adjusted(QUrl::NormalizePathSegments).toString(), QString("example://a/b/..%2F/b/c/"));
+ QCOMPARE(url4EncodedDots.adjusted(QUrl::NormalizePathSegments).toString(), QString("example://a//b/..%2F/b/c/"));
// 6.2.2.1 Make sure hexdecimal characters in percent encoding are
// treated case-insensitively
@@ -3400,6 +3410,21 @@ void tst_QUrl::effectiveTLDs_data()
QTest::newRow("yes16") << QUrl::fromEncoded("http://anything.pagespeedmobilizer.com") << ".pagespeedmobilizer.com";
QTest::newRow("yes17") << QUrl::fromEncoded("http://anything.eu-central-1.compute.amazonaws.com") << ".eu-central-1.compute.amazonaws.com";
QTest::newRow("yes18") << QUrl::fromEncoded("http://anything.ltd.hk") << ".ltd.hk";
+ QTest::newRow("trentino.it")
+ << QUrl::fromEncoded("http://any.thing.trentino.it") << ".trentino.it";
+ QTest::newRow("net.ni") << QUrl::fromEncoded("http://test.net.ni") << ".net.ni";
+ QTest::newRow("dyn.cosidns.de")
+ << QUrl::fromEncoded("http://test.dyn.cosidns.de") << ".dyn.cosidns.de";
+ QTest::newRow("freeddns.org")
+ << QUrl::fromEncoded("http://test.freeddns.org") << ".freeddns.org";
+ QTest::newRow("app.os.stg.fedoraproject.org")
+ << QUrl::fromEncoded("http://test.app.os.stg.fedoraproject.org")
+ << ".app.os.stg.fedoraproject.org";
+ QTest::newRow("development.run") << QUrl::fromEncoded("http://test.development.run") << ".development.run";
+ QTest::newRow("crafting.xyz") << QUrl::fromEncoded("http://test.crafting.xyz") << ".crafting.xyz";
+ QTest::newRow("nym.ie") << QUrl::fromEncoded("http://shamus.nym.ie") << ".nym.ie";
+ QTest::newRow("vapor.cloud") << QUrl::fromEncoded("http://test.vapor.cloud") << ".vapor.cloud";
+ QTest::newRow("official.academy") << QUrl::fromEncoded("http://acredited.official.academy") << ".official.academy";
}
void tst_QUrl::effectiveTLDs()
@@ -4201,6 +4226,36 @@ void tst_QUrl::ipv6_zoneId()
QCOMPARE(url.toString(QUrl::FullyEncoded), "x://[" + encodedHost + "]");
}
+void tst_QUrl::normalizeRemotePaths_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("dotdot-slashslash") << QUrl("http://qt-project.org/some/long/..//path") << "http://qt-project.org/some//path";
+ QTest::newRow("slashslash-dotdot") << QUrl("http://qt-project.org/some//../path") << "http://qt-project.org/some/path";
+ QTest::newRow("slashslash-dotdot2") << QUrl("http://qt-project.org/some//path/../") << "http://qt-project.org/some//";
+ QTest::newRow("dot-slash") << QUrl("http://qt-project.org/some/./path") << "http://qt-project.org/some/path";
+ QTest::newRow("slashslash-dot-slashslash") << QUrl("http://qt-project.org/some//.//path") << "http://qt-project.org/some///path";
+ QTest::newRow("dot-slashslash") << QUrl("http://qt-project.org/some/.//path") << "http://qt-project.org/some//path";
+ QTest::newRow("multiple-slashes") << QUrl("http://qt-project.org/some//path") << "http://qt-project.org/some//path";
+ QTest::newRow("multiple-slashes4") << QUrl("http://qt-project.org/some////path") << "http://qt-project.org/some////path";
+ QTest::newRow("slashes-at-end") << QUrl("http://qt-project.org/some//") << "http://qt-project.org/some//";
+ QTest::newRow("dot-dotdot") << QUrl("http://qt-project.org/path/./../") << "http://qt-project.org/";
+ QTest::newRow("slash-dot-slash-dot-slash") << QUrl("http://qt-project.org/path//.//.//") << "http://qt-project.org/path////";
+ QTest::newRow("dotdot") << QUrl("http://qt-project.org/../") << "http://qt-project.org/";
+ QTest::newRow("dotdot-dotdot") << QUrl("http://qt-project.org/path/../../") << "http://qt-project.org/";
+ QTest::newRow("dot-dotdot-tail") << QUrl("http://qt-project.org/stem/path/./../tail") << "http://qt-project.org/stem/tail";
+ QTest::newRow("slash-dotdot-slash-tail") << QUrl("http://qt-project.org/stem/path//..//tail") << "http://qt-project.org/stem/path//tail";
+}
+
+void tst_QUrl::normalizeRemotePaths()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, expected);
+
+ QCOMPARE(url.adjusted(QUrl::NormalizePathSegments).toString(), expected);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"
diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
index d839141091..25d392b37e 100644
--- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
+++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
@@ -233,6 +233,14 @@ void tst_QUrlQuery::constructing()
query += qMakePair(QString("prosent"), QString("%"));
copy.setQueryItems(query);
QVERIFY(!copy.isEmpty());
+
+ QUrlQuery fromList = {
+ {QString("type"), QString("login")},
+ {QString("name"), QString::fromUtf8("åge nissemannsen")},
+ {QString("ole&du"), QString::fromUtf8("anne+jørgen=sant")},
+ {QString("prosent"), QString("%")}
+ };
+ QCOMPARE(fromList, copy);
}
void tst_QUrlQuery::addRemove()
diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro
index 0346341be6..ffbda6ec40 100644
--- a/tests/auto/corelib/itemmodels/itemmodels.pro
+++ b/tests/auto/corelib/itemmodels/itemmodels.pro
@@ -1,14 +1,15 @@
TEMPLATE=subdirs
-SUBDIRS = qabstractitemmodel \
- qstringlistmodel \
+SUBDIRS = qstringlistmodel
qtHaveModule(gui): SUBDIRS += \
+ qabstractitemmodel \
qabstractproxymodel \
qconcatenatetablesproxymodel \
qidentityproxymodel \
qitemselectionmodel \
qsortfilterproxymodel_recursive \
+ qtransposeproxymodel \
qtHaveModule(widgets) {
SUBDIRS += \
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index 262c6dd9c8..c76052a38b 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -32,10 +32,13 @@
#include <QStandardItemModel>
#include <QStringListModel>
#include <QTest>
+#include <QLoggingCategory>
#include "dynamictreemodel.h"
#include "qidentityproxymodel.h"
+Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels")
+
class DataChangedModel : public QAbstractListModel
{
public:
@@ -390,7 +393,7 @@ void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex
for (auto row = 0; row < model->rowCount(parent); ++row)
{
auto idx = model->index(row, 0, parent);
- qDebug() << (indent + idx.data().toString());
+ qCDebug(lcItemModels) << (indent + idx.data().toString());
dump(model, indent + "- ", idx);
}
}
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
index 6ea7a38137..dbc7173028 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
@@ -251,7 +251,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
QString val = xval + QString::number(y) + QString::number(i);
QModelIndex index = model->index(x, y, parent);
model->setData(index, val);
- model->setData(index, blue, Qt::TextColorRole);
+ model->setData(index, blue, Qt::ForegroundRole);
}
}
*/
@@ -276,7 +276,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
QString val = xval + QString::number(y) + QString::number(i);
QModelIndex index = realModel->index(x, y, parent);
realModel->setData(index, val);
- realModel->setData(index, blue, Qt::TextColorRole);
+ realModel->setData(index, blue, Qt::ForegroundRole);
}
}
*/
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 7cd220e684..b9deb7b6a9 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -125,6 +125,7 @@ private:
tst_QItemModel::tst_QItemModel()
{
qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
+ qRegisterMetaType<QList<QPersistentModelIndex>>();
}
void tst_QItemModel::init()
@@ -181,7 +182,7 @@ void tst_QItemModel::nonDestructiveBasicTest()
currentModel->hasChildren(QModelIndex());
currentModel->hasIndex(0, 0);
currentModel->headerData(0, Qt::Horizontal);
- currentModel->index(0,0), QModelIndex();
+ currentModel->index(0,0);
currentModel->itemData(QModelIndex());
QVariant cache;
currentModel->match(QModelIndex(), -1, cache);
@@ -576,12 +577,12 @@ void tst_QItemModel::data()
alignment == Qt::AlignJustify);
}
- QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundColorRole);
+ QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundRole);
if (colorVariant.isValid()) {
QVERIFY(colorVariant.canConvert<QColor>());
}
- colorVariant = currentModel->data(currentModel->index(0,0), Qt::TextColorRole);
+ colorVariant = currentModel->data(currentModel->index(0,0), Qt::ForegroundRole);
if (colorVariant.isValid()) {
QVERIFY(colorVariant.canConvert<QColor>());
}
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
index 82cd26971b..ccce5a44e5 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
@@ -38,6 +38,8 @@
#include <qdebug.h>
+Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels")
+
// Testing get/set functions
void tst_QSortFilterProxyModel::getSetCheck()
{
@@ -2361,6 +2363,45 @@ void tst_QSortFilterProxyModel::match()
QCOMPARE(indexes.at(i).row(), expectedProxyItems.at(i));
}
+QList<QStandardItem *> createStandardItemList(const QString &prefix, int n)
+{
+ QList<QStandardItem *> result;
+ for (int i = 0; i < n; ++i)
+ result.append(new QStandardItem(prefix + QString::number(i)));
+ return result;
+}
+
+// QTBUG-73864, recursive search in a tree model.
+
+void tst_QSortFilterProxyModel::matchTree()
+{
+ QStandardItemModel model(0, 2);
+ // Header00 Header01
+ // Header10 Header11
+ // Item00 Item01
+ // Item10 Item11
+ model.appendRow(createStandardItemList(QLatin1String("Header0"), 2));
+ auto headerRow = createStandardItemList(QLatin1String("Header1"), 2);
+ model.appendRow(headerRow);
+ headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item0"), 2));
+ headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item1"), 2));
+
+ auto item11 = model.match(model.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20,
+ Qt::MatchRecursive).value(0);
+ QVERIFY(item11.isValid());
+ QCOMPARE(item11.data().toString(), QLatin1String("Item11"));
+
+ // Repeat in proxy model
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ auto proxyItem11 = proxy.match(proxy.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20,
+ Qt::MatchRecursive).value(0);
+ QVERIFY(proxyItem11.isValid());
+ QCOMPARE(proxyItem11.data().toString(), QLatin1String("Item11"));
+
+ QCOMPARE(proxy.mapToSource(proxyItem11).internalId(), item11.internalId());
+}
+
void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
{
QStandardItemModel model;
@@ -4277,7 +4318,7 @@ public:
QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override
{
// QTBUG-44962: Would we always expect the parent to belong to the model
- qDebug() << parent.model() << this;
+ qCDebug(lcItemModels) << parent.model() << this;
Q_ASSERT(!parent.isValid() || parent.model() == this);
quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
@@ -4363,7 +4404,7 @@ void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes()
// The use of qDebug here makes sufficient use of the heap to
// cause corruption at runtime with normal use on linux (before
// the fix). valgrind confirms the fix.
- qDebug() << persistentIndex.parent();
+ qCDebug(lcItemModels) << persistentIndex.parent();
QVERIFY(persistentIndex.parent().isValid());
}
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
index 82d4b7344e..8ae97165b8 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
@@ -109,6 +109,7 @@ private slots:
void selectionFilteredOut();
void match_data();
void match();
+ void matchTree();
void insertIntoChildrenlessItem();
void invalidateMappedChildren();
void insertRowIntoFilteredParent();
@@ -186,4 +187,6 @@ private:
Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint)
+Q_DECLARE_LOGGING_CATEGORY(lcItemModels)
+
#endif // TST_QSORTFILTERPROXYMODEL_H
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index 16e5170a47..3919472b96 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -81,6 +81,8 @@ private slots:
void setData_emits_both_roles_data();
void setData_emits_both_roles();
+ void setData_emits_on_change_only();
+
void supportedDragDropActions();
void moveRows_data();
@@ -331,7 +333,7 @@ template <class C>
C sorted(C c)
{
std::sort(c.begin(), c.end());
- return qMove(c);
+ return std::move(c);
}
void tst_QStringListModel::setData_emits_both_roles()
@@ -422,6 +424,24 @@ void tst_QStringListModel::setItemData()
QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles);
}
+void tst_QStringListModel::setData_emits_on_change_only()
+{
+ QStringListModel model(QStringList{QStringLiteral("one"), QStringLiteral("two")});
+ QSignalSpy dataChangedSpy(&model, &QAbstractItemModel::dataChanged);
+ QVERIFY(dataChangedSpy.isValid());
+ const QModelIndex modelIdx = model.index(0, 0);
+ const QString newStringData = QStringLiteral("test");
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QCOMPARE(dataChangedSpy.count(), 1);
+ const QList<QVariant> spyList = dataChangedSpy.takeFirst();
+ QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
+ QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
+ const QVector<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
+ QCOMPARE(spyList.at(2).value<QVector<int> >(), expectedRoles);
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QVERIFY(dataChangedSpy.isEmpty());
+}
+
void tst_QStringListModel::supportedDragDropActions()
{
QStringListModel model;
diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro b/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro
new file mode 100644
index 0000000000..3834add115
--- /dev/null
+++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qtransposeproxymodel
+QT = core gui testlib
+
+SOURCES = tst_qtransposeproxymodel.cpp
+
diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp
new file mode 100644
index 0000000000..a30ac46571
--- /dev/null
+++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp
@@ -0,0 +1,915 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTest>
+#include <QSignalSpy>
+#include <QStandardItemModel>
+#include <QStringListModel>
+#include <QAbstractItemModelTester>
+#include <random>
+
+#include <qtransposeproxymodel.h>
+
+class tst_QTransposeProxyModel : public QObject
+{
+ Q_OBJECT
+private Q_SLOTS:
+ void initTestCase();
+ void index();
+ void data();
+ void setData_data();
+ void setData();
+ void parent();
+ void mapToSource();
+ void mapFromSource();
+ void basicTest_data();
+ void basicTest();
+ void sort();
+ void insertRowBase_data();
+ void insertRowBase();
+ void insertColumnBase_data();
+ void insertColumnBase();
+ void insertColumnProxy_data();
+ void insertColumnProxy();
+ void insertRowProxy_data();
+ void insertRowProxy();
+ void removeRowBase_data();
+ void removeRowBase();
+ void removeColumnBase_data();
+ void removeColumnBase();
+ void removeColumnProxy_data();
+ void removeColumnProxy();
+ void removeRowProxy_data();
+ void removeRowProxy();
+ void headerData();
+ void setHeaderData();
+ void span();
+ void itemData();
+ void setItemData();
+ void moveRowsBase();
+ void moveColumnsProxy();
+private:
+ void testTransposed(
+ const QAbstractItemModel *const baseModel,
+ const QAbstractItemModel *const transposed,
+ const QModelIndex &baseParent = QModelIndex(),
+ const QModelIndex &transposedParent = QModelIndex()
+ );
+ QAbstractItemModel *createListModel(QObject *parent);
+ QAbstractItemModel *createTableModel(QObject *parent);
+ QAbstractItemModel *createTreeModel(QObject *parent);
+};
+
+QAbstractItemModel *tst_QTransposeProxyModel::createListModel(QObject *parent)
+{
+ QStringList sequence;
+ sequence.reserve(10);
+ for (int i = 0; i < 10; ++i)
+ sequence.append(QString::number(i));
+ return new QStringListModel(sequence, parent);
+}
+
+QAbstractItemModel *tst_QTransposeProxyModel::createTableModel(QObject *parent)
+{
+ QAbstractItemModel *model = new QStandardItemModel(parent);
+ model->insertRows(0, 5);
+ model->insertColumns(0, 4);
+ for (int i = 0; i < model->rowCount(); ++i) {
+ for (int j = 0; j < model->columnCount(); ++j) {
+ model->setData(model->index(i, j), QStringLiteral("%1,%2").arg(i).arg(j), Qt::EditRole);
+ model->setData(model->index(i, j), i, Qt::UserRole);
+ model->setData(model->index(i, j), j, Qt::UserRole + 1);
+ }
+ }
+ return model;
+}
+
+QAbstractItemModel *tst_QTransposeProxyModel::createTreeModel(QObject *parent)
+{
+ QAbstractItemModel *model = new QStandardItemModel(parent);
+ model->insertRows(0, 5);
+ model->insertColumns(0, 4);
+ for (int i = 0; i < model->rowCount(); ++i) {
+ for (int j = 0; j < model->columnCount(); ++j) {
+ const QModelIndex parIdx = model->index(i, j);
+ model->setData(parIdx, QStringLiteral("%1,%2").arg(i).arg(j), Qt::EditRole);
+ model->setData(parIdx, i, Qt::UserRole);
+ model->setData(parIdx, j, Qt::UserRole + 1);
+ model->insertRows(0, 3, parIdx);
+ model->insertColumns(0, 2, parIdx);
+ for (int h = 0; h < model->rowCount(parIdx); ++h) {
+ for (int k = 0; k < model->columnCount(parIdx); ++k) {
+ const QModelIndex childIdx = model->index(h, k, parIdx);
+ model->setData(childIdx, QStringLiteral("%1,%2,%3,%4").arg(i).arg(j).arg(h).arg(k), Qt::EditRole);
+ model->setData(childIdx, i, Qt::UserRole);
+ model->setData(childIdx, j, Qt::UserRole + 1);
+ model->setData(childIdx, h, Qt::UserRole + 2);
+ model->setData(childIdx, k, Qt::UserRole + 3);
+ }
+ }
+ }
+ }
+ return model;
+}
+
+void tst_QTransposeProxyModel::testTransposed(
+ const QAbstractItemModel *const baseModel,
+ const QAbstractItemModel *const transposed,
+ const QModelIndex &baseParent,
+ const QModelIndex &transposedParent
+)
+{
+ QCOMPARE(transposed->hasChildren(transposedParent), baseModel->hasChildren(baseParent));
+ QCOMPARE(transposed->columnCount(transposedParent), baseModel->rowCount(baseParent));
+ QCOMPARE(transposed->rowCount(transposedParent), baseModel->columnCount(baseParent));
+ for (int i = 0, maxRow = baseModel->rowCount(baseParent); i < maxRow; ++i) {
+ for (int j = 0, maxCol = baseModel->columnCount(baseParent); j < maxCol; ++j) {
+ const QModelIndex baseIdx = baseModel->index(i, j, baseParent);
+ const QModelIndex transIdx = transposed->index(j, i, transposedParent);
+ QCOMPARE(transIdx.data(), baseIdx.data());
+ QCOMPARE(transIdx.data(Qt::UserRole), baseIdx.data(Qt::UserRole));
+ QCOMPARE(transIdx.data(Qt::UserRole + 1), baseIdx.data(Qt::UserRole + 1));
+ QCOMPARE(transIdx.data(Qt::UserRole + 2), baseIdx.data(Qt::UserRole + 2));
+ QCOMPARE(transIdx.data(Qt::UserRole + 3), baseIdx.data(Qt::UserRole + 3));
+ if (baseModel->hasChildren(baseIdx)) {
+ testTransposed(baseModel, transposed, baseIdx, transIdx);
+ }
+ }
+ }
+}
+
+void tst_QTransposeProxyModel::initTestCase()
+{
+ qRegisterMetaType<QList<QPersistentModelIndex> >();
+ qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
+}
+
+void tst_QTransposeProxyModel::index()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QVERIFY(!proxy.index(0, -1).isValid());
+ QVERIFY(!proxy.index(0, -1).isValid());
+ QVERIFY(!proxy.index(-1, -1).isValid());
+ QVERIFY(!proxy.index(0, proxy.columnCount()).isValid());
+ QVERIFY(!proxy.index(proxy.rowCount(), 0).isValid());
+ QVERIFY(!proxy.index(proxy.rowCount(), proxy.columnCount()).isValid());
+ QModelIndex tempIdx = proxy.index(0, 1);
+ QVERIFY(tempIdx.isValid());
+ QCOMPARE(tempIdx.row(), 0);
+ QCOMPARE(tempIdx.column(), 1);
+ tempIdx = proxy.index(0, 1, tempIdx);
+ QVERIFY(tempIdx.isValid());
+ QCOMPARE(tempIdx.row(), 0);
+ QCOMPARE(tempIdx.column(), 1);
+ delete model;
+}
+
+void tst_QTransposeProxyModel::data()
+{
+ QStringListModel model{QStringList{"A", "B"}};
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(&model);
+ QCOMPARE(proxy.index(0, 1).data().toString(), QStringLiteral("B"));
+}
+
+void tst_QTransposeProxyModel::parent()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ const QModelIndex parentIdx = proxy.index(0, 0);
+ const QModelIndex childIdx = proxy.index(0, 0, parentIdx);
+ QVERIFY(parentIdx.isValid());
+ QVERIFY(childIdx.isValid());
+ QCOMPARE(childIdx.parent(), parentIdx);
+ delete model;
+}
+
+void tst_QTransposeProxyModel::mapToSource()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QVERIFY(!proxy.mapToSource(QModelIndex()).isValid());
+ QCOMPARE(proxy.mapToSource(proxy.index(0, 0)), model->index(0, 0));
+ QCOMPARE(proxy.mapToSource(proxy.index(1, 0)), model->index(0, 1));
+ QCOMPARE(proxy.mapToSource(proxy.index(0, 1)), model->index(1, 0));
+ const QModelIndex proxyParent = proxy.index(1, 0);
+ const QModelIndex sourceParent = model->index(0, 1);
+ QCOMPARE(proxy.mapToSource(proxy.index(0, 0, proxyParent)), model->index(0, 0, sourceParent));
+ QCOMPARE(proxy.mapToSource(proxy.index(1, 0, proxyParent)), model->index(0, 1, sourceParent));
+ QCOMPARE(proxy.mapToSource(proxy.index(0, 1, proxyParent)), model->index(1, 0, sourceParent));
+ delete model;
+}
+
+void tst_QTransposeProxyModel::mapFromSource()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QVERIFY(!proxy.mapFromSource(QModelIndex()).isValid());
+ QCOMPARE(proxy.mapFromSource(model->index(0, 0)), proxy.index(0, 0));
+ QCOMPARE(proxy.mapFromSource(model->index(0, 1)), proxy.index(1, 0));
+ QCOMPARE(proxy.mapFromSource(model->index(1, 0)), proxy.index(0, 1));
+ const QModelIndex proxyParent = proxy.index(1, 0);
+ const QModelIndex sourceParent = model->index(0, 1);
+ QCOMPARE(proxy.mapToSource(proxy.index(0, 0, proxyParent)), model->index(0, 0, sourceParent));
+ QCOMPARE(proxy.mapFromSource(model->index(1, 0, sourceParent)), proxy.index(0, 1, proxyParent));
+ QCOMPARE(proxy.mapFromSource(model->index(0, 1, sourceParent)), proxy.index(1, 0, proxyParent));
+ delete model;
+}
+
+void tst_QTransposeProxyModel::basicTest_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::newRow("List") << createListModel(this);
+ QTest::newRow("Table") << createTableModel(this);
+ QTest::newRow("Tree") << createTreeModel(this);
+}
+
+void tst_QTransposeProxyModel::basicTest()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ testTransposed(model, &proxy);
+ delete model;
+}
+
+void tst_QTransposeProxyModel::sort()
+{
+ QStringList sequence;
+ sequence.reserve(100);
+ for (int i = 0; i < 100; ++i)
+ sequence.append(QStringLiteral("%1").arg(i, 3, 10, QLatin1Char('0')));
+ std::shuffle(sequence.begin(), sequence.end(), std::mt19937(88));
+ const QString firstItemBeforeSort = sequence.first();
+ QStringListModel baseModel(sequence);
+ QTransposeProxyModel proxyModel;
+ new QAbstractItemModelTester(&proxyModel, &proxyModel);
+ proxyModel.setSourceModel(&baseModel);
+ QSignalSpy layoutChangedSpy(&proxyModel, &QAbstractItemModel::layoutChanged);
+ QVERIFY(layoutChangedSpy.isValid());
+ QSignalSpy layoutAboutToBeChangedSpy(&proxyModel, &QAbstractItemModel::layoutAboutToBeChanged);
+ QVERIFY(layoutAboutToBeChangedSpy.isValid());
+ QPersistentModelIndex firstIndexBeforeSort = proxyModel.index(0, 0);
+ baseModel.sort(0, Qt::AscendingOrder);
+ QCOMPARE(layoutChangedSpy.count(), 1);
+ QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
+ QCOMPARE(layoutChangedSpy.takeFirst().at(1).toInt(), int(QAbstractItemModel::HorizontalSortHint));
+ QCOMPARE(firstIndexBeforeSort.data().toString(), firstItemBeforeSort);
+ for (int i = 0; i < 100; ++i)
+ QCOMPARE(proxyModel.index(0, i).data().toInt(), i);
+}
+
+void tst_QTransposeProxyModel::removeColumnBase_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<QModelIndex>("parent");
+ QTest::newRow("Table") << createTableModel(this) << QModelIndex();
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex();
+ QAbstractItemModel *model = createTreeModel(this);
+ QTest::newRow("Tree_Child_Item") << model << model->index(0, 0);
+}
+
+void tst_QTransposeProxyModel::removeColumnBase()
+{
+ QFETCH(QAbstractItemModel * const, model);
+ QFETCH(const QModelIndex, parent);
+ QTransposeProxyModel proxy;
+ QSignalSpy rowRemoveSpy(&proxy, &QAbstractItemModel::rowsRemoved);
+ QVERIFY(rowRemoveSpy.isValid());
+ QSignalSpy rowAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::rowsAboutToBeRemoved);
+ QVERIFY(rowAboutToBeRemoveSpy.isValid());
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ const int oldRowCount = proxy.rowCount(proxy.mapFromSource(parent));
+ const QVariant expectedNewVal = model->index(0, 2, parent).data();
+ QVERIFY(model->removeColumn(1, parent));
+ QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount - 1);
+ QCOMPARE(proxy.index(1, 0, proxy.mapFromSource(parent)).data(), expectedNewVal);
+ QCOMPARE(rowRemoveSpy.count(), 1);
+ QCOMPARE(rowAboutToBeRemoveSpy.count(), 1);
+ for (const auto &spyArgs : {rowRemoveSpy.takeFirst(),
+ rowAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::insertColumnBase_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<QModelIndex>("parent");
+ QTest::newRow("Table") << createTableModel(this) << QModelIndex();
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex();
+ QAbstractItemModel *model = createTreeModel(this);
+ QTest::newRow("Tree_Child_Item") << model << model->index(0, 0);
+}
+
+void tst_QTransposeProxyModel::insertColumnBase()
+{
+ QFETCH(QAbstractItemModel * const, model);
+ QFETCH(const QModelIndex, parent);
+ QTransposeProxyModel proxy;
+ QSignalSpy rowInsertSpy(&proxy, &QAbstractItemModel::rowsInserted);
+ QVERIFY(rowInsertSpy.isValid());
+ QSignalSpy rowAboutToBeInsertSpy(&proxy, &QAbstractItemModel::rowsAboutToBeInserted);
+ QVERIFY(rowAboutToBeInsertSpy.isValid());
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ const int oldRowCount = proxy.rowCount(proxy.mapFromSource(parent));
+ QVERIFY(model->insertColumn(1, parent));
+ QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount + 1);
+ QVERIFY(!proxy.index(1, 0, proxy.mapFromSource(parent)).data().isValid());
+ QCOMPARE(rowInsertSpy.count(), 1);
+ QCOMPARE(rowAboutToBeInsertSpy.count(), 1);
+ for (const auto &spyArgs : {rowInsertSpy.takeFirst(),
+ rowAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::removeRowBase_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<QModelIndex>("parent");
+ QTest::newRow("List") << createListModel(this) << QModelIndex();
+ QTest::newRow("Table") << createTableModel(this) << QModelIndex();
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex();
+ QAbstractItemModel *model = createTreeModel(this);
+ QTest::newRow("Tree_Child_Item") << model << model->index(0, 0);
+}
+
+void tst_QTransposeProxyModel::removeRowBase()
+{
+ QFETCH(QAbstractItemModel * const, model);
+ QFETCH(const QModelIndex, parent);
+ QTransposeProxyModel proxy;
+ QSignalSpy columnsRemoveSpy(&proxy, &QAbstractItemModel::columnsRemoved);
+ QVERIFY(columnsRemoveSpy.isValid());
+ QSignalSpy columnsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeRemoved);
+ QVERIFY(columnsAboutToBeRemoveSpy.isValid());
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ const int oldColCount = proxy.columnCount(proxy.mapFromSource(parent));
+ const QVariant expectedNewVal = model->index(2, 0, parent).data();
+ QVERIFY(model->removeRow(1, parent));
+ QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount - 1);
+ QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parent)).data(), expectedNewVal);
+ QCOMPARE(columnsRemoveSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
+ for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
+ columnsAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::insertRowBase_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<QModelIndex>("parent");
+ QTest::newRow("List") << createListModel(this) << QModelIndex();
+ QTest::newRow("Table") << createTableModel(this) << QModelIndex();
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex();
+ QAbstractItemModel *model = createTreeModel(this);
+ QTest::newRow("Tree_Child_Item") << model << model->index(0, 0);
+}
+
+void tst_QTransposeProxyModel::insertRowBase()
+{
+ QFETCH(QAbstractItemModel * const, model);
+ QFETCH(const QModelIndex, parent);
+ QTransposeProxyModel proxy;
+ QSignalSpy columnsInsertSpy(&proxy, &QAbstractItemModel::columnsInserted);
+ QVERIFY(columnsInsertSpy.isValid());
+ QSignalSpy columnsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::columnsAboutToBeInserted);
+ QVERIFY(columnsAboutToBeInsertSpy.isValid());
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ const int oldColCount = proxy.columnCount(proxy.mapFromSource(parent));
+ QVERIFY(model->insertRow(1, parent));
+ QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount + 1);
+ QVERIFY(proxy.index(0, 1, proxy.mapFromSource(parent)).data().isNull());
+ QCOMPARE(columnsInsertSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
+ for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
+ columnsAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent));
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::removeColumnProxy_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<bool>("rootItem");
+ QTest::newRow("List") << createListModel(this) << true;
+ QTest::newRow("Table") << createTableModel(this) << true;
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true;
+ QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false;
+}
+
+void tst_QTransposeProxyModel::removeColumnProxy()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QFETCH(bool, rootItem);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ QSignalSpy columnsRemoveSpy(&proxy, &QAbstractItemModel::columnsRemoved);
+ QVERIFY(columnsRemoveSpy.isValid());
+ QSignalSpy columnsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeRemoved);
+ QVERIFY(columnsAboutToBeRemoveSpy.isValid());
+ QSignalSpy rowsRemoveSpy(model, &QAbstractItemModel::rowsRemoved);
+ QVERIFY(rowsRemoveSpy.isValid());
+ QSignalSpy rowsAboutToBeRemoveSpy(model, &QAbstractItemModel::rowsAboutToBeRemoved);
+ QVERIFY(rowsAboutToBeRemoveSpy.isValid());
+ proxy.setSourceModel(model);
+ const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1);
+ const QModelIndex sourceParent = proxy.mapToSource(proxyParent);
+ const int oldColCount = proxy.columnCount(proxyParent);
+ const int oldRowCount = model->rowCount(sourceParent);
+ const QVariant expectedNewVal = proxy.index(0, 2, proxyParent).data();
+ QVERIFY(proxy.removeColumn(1, proxyParent));
+ QCOMPARE(proxy.columnCount(proxyParent), oldColCount - 1);
+ QCOMPARE(model->rowCount(sourceParent), oldRowCount - 1);
+ QCOMPARE(proxy.index(0, 1, proxyParent).data(), expectedNewVal);
+ QCOMPARE(model->index(1, 0, sourceParent).data(), expectedNewVal);
+ QCOMPARE(columnsRemoveSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(rowsRemoveSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1);
+ for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
+ columnsAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ for (const auto &spyArgs : {rowsRemoveSpy.takeFirst(),
+ rowsAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::insertColumnProxy_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<bool>("rootItem");
+ QTest::newRow("List") << createListModel(this) << true;
+ QTest::newRow("Table") << createTableModel(this) << true;
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true;
+ QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false;
+}
+
+void tst_QTransposeProxyModel::insertColumnProxy()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QFETCH(bool, rootItem);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ QSignalSpy columnsInsertSpy(&proxy, &QAbstractItemModel::columnsInserted);
+ QVERIFY(columnsInsertSpy.isValid());
+ QSignalSpy columnsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::columnsAboutToBeInserted);
+ QVERIFY(columnsAboutToBeInsertSpy.isValid());
+ QSignalSpy rowsInsertSpy(model, &QAbstractItemModel::rowsInserted);
+ QVERIFY(rowsInsertSpy.isValid());
+ QSignalSpy rowsAboutToBeInsertSpy(model, &QAbstractItemModel::rowsAboutToBeInserted);
+ QVERIFY(rowsAboutToBeInsertSpy.isValid());
+ proxy.setSourceModel(model);
+ const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1);
+ const QModelIndex sourceParent = proxy.mapToSource(proxyParent);
+ const int oldColCount = proxy.columnCount(proxyParent);
+ const int oldRowCount = model->rowCount(sourceParent);
+ QVERIFY(proxy.insertColumn(1, proxyParent));
+ QCOMPARE(proxy.columnCount(proxyParent), oldColCount + 1);
+ QCOMPARE(model->rowCount(sourceParent), oldRowCount + 1);
+ QVERIFY(proxy.index(0, 1, proxyParent).data().isNull());
+ QVERIFY(model->index(1, 0, sourceParent).data().isNull());
+ QCOMPARE(columnsInsertSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(rowsInsertSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeInsertSpy.count(), 1);
+ for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
+ columnsAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ for (const auto &spyArgs : {rowsInsertSpy.takeFirst(),
+ rowsAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::removeRowProxy_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<bool>("rootItem");
+ QTest::newRow("Table") << createTableModel(this) << true;
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true;
+ QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false;
+}
+
+void tst_QTransposeProxyModel::removeRowProxy()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QFETCH(bool, rootItem);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ QSignalSpy rowsRemoveSpy(&proxy, &QAbstractItemModel::rowsRemoved);
+ QVERIFY(rowsRemoveSpy.isValid());
+ QSignalSpy rowsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::rowsAboutToBeRemoved);
+ QVERIFY(rowsAboutToBeRemoveSpy.isValid());
+ QSignalSpy columnsRemoveSpy(model, &QAbstractItemModel::columnsRemoved);
+ QVERIFY(columnsRemoveSpy.isValid());
+ QSignalSpy columnsAboutToBeRemoveSpy(model, &QAbstractItemModel::columnsAboutToBeRemoved);
+ QVERIFY(columnsAboutToBeRemoveSpy.isValid());
+ proxy.setSourceModel(model);
+ const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1);
+ const QModelIndex sourceParent = proxy.mapToSource(proxyParent);
+ const int oldRowCount = proxy.rowCount(proxyParent);
+ const int oldColCount = model->columnCount(sourceParent);
+ const QVariant expectedNewVal = proxy.index(2, 0, proxyParent).data();
+ QVERIFY(proxy.removeRow(1, proxyParent));
+ QCOMPARE(proxy.rowCount(proxyParent), oldRowCount - 1);
+ QCOMPARE(model->columnCount(sourceParent), oldColCount - 1);
+ QCOMPARE(proxy.index(1, 0, proxyParent).data(), expectedNewVal);
+ QCOMPARE(model->index(0, 1, sourceParent).data(), expectedNewVal);
+ QCOMPARE(columnsRemoveSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1);
+ QCOMPARE(rowsRemoveSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1);
+ for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(),
+ columnsAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ for (const auto &spyArgs : {rowsRemoveSpy.takeFirst(),
+ rowsAboutToBeRemoveSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::insertRowProxy_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<bool>("rootItem");
+ QTest::newRow("Table") << createTableModel(this) << true;
+ QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true;
+ QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false;
+}
+
+void tst_QTransposeProxyModel::insertRowProxy()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QFETCH(bool, rootItem);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ QSignalSpy rowsInsertSpy(&proxy, &QAbstractItemModel::rowsInserted);
+ QVERIFY(rowsInsertSpy.isValid());
+ QSignalSpy rowsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::rowsAboutToBeInserted);
+ QVERIFY(rowsAboutToBeInsertSpy.isValid());
+ QSignalSpy columnsInsertSpy(model, &QAbstractItemModel::columnsInserted);
+ QVERIFY(columnsInsertSpy.isValid());
+ QSignalSpy columnsAboutToBeInsertSpy(model, &QAbstractItemModel::columnsAboutToBeInserted);
+ QVERIFY(columnsAboutToBeInsertSpy.isValid());
+ proxy.setSourceModel(model);
+ const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1);
+ const QModelIndex sourceParent = proxy.mapToSource(proxyParent);
+ const int oldRowCount = proxy.rowCount(proxyParent);
+ const int oldColCount = model->columnCount(sourceParent);
+ QVERIFY(proxy.insertRow(1, proxyParent));
+ QCOMPARE(proxy.rowCount(proxyParent), oldRowCount + 1);
+ QCOMPARE(model->columnCount(sourceParent), oldColCount + 1);
+ QVERIFY(proxy.index(1, 0, proxyParent).data().isNull());
+ QVERIFY(model->index(0, 1, sourceParent).data().isNull());
+ QCOMPARE(columnsInsertSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeInsertSpy.count(), 1);
+ QCOMPARE(rowsInsertSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeInsertSpy.count(), 1);
+ for (const auto &spyArgs : {columnsInsertSpy.takeFirst(),
+ columnsAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ for (const auto &spyArgs : {rowsInsertSpy.takeFirst(),
+ rowsAboutToBeInsertSpy.takeFirst()}) {
+ QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent);
+ QCOMPARE(spyArgs.at(1).toInt(), 1);
+ QCOMPARE(spyArgs.at(2).toInt(), 1);
+ }
+ delete model;
+}
+
+void tst_QTransposeProxyModel::headerData()
+{
+ QStandardItemModel model;
+ model.insertRows(0, 3);
+ model.insertColumns(0, 5);
+ for (int i = 0; i < model.rowCount(); ++i)
+ model.setHeaderData(i, Qt::Horizontal, QChar('A' + i));
+ for (int i = 1; i <= model.columnCount(); ++i)
+ model.setHeaderData(i, Qt::Vertical, i);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(&model);
+ for (int i = 0; i < model.rowCount(); ++i)
+ QCOMPARE(model.headerData(i, Qt::Horizontal), proxy.headerData(i, Qt::Vertical));
+ for (int i = 0; i < model.columnCount(); ++i)
+ QCOMPARE(model.headerData(i, Qt::Vertical), proxy.headerData(i, Qt::Horizontal));
+}
+
+void tst_QTransposeProxyModel::setHeaderData()
+{
+ QStandardItemModel model;
+ model.insertRows(0, 3);
+ model.insertColumns(0, 5);
+ for (int i = 0; i < model.rowCount(); ++i)
+ model.setHeaderData(i, Qt::Horizontal, QChar('A' + i));
+ for (int i = 1; i <= model.columnCount(); ++i)
+ model.setHeaderData(i, Qt::Vertical, i);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(&model);
+ QVERIFY(proxy.setHeaderData(1, Qt::Horizontal, 99));
+ QCOMPARE(model.headerData(1, Qt::Vertical).toInt(), 99);
+ QVERIFY(proxy.setHeaderData(1, Qt::Vertical, QChar('Z')));
+ QCOMPARE(model.headerData(1, Qt::Horizontal).toChar(), QChar('Z'));
+}
+
+void tst_QTransposeProxyModel::span()
+{
+ class SpanModel : public QStandardItemModel
+ {
+ Q_DISABLE_COPY(SpanModel)
+ public:
+ SpanModel(int rows, int columns, QObject *parent = nullptr)
+ : QStandardItemModel(rows, columns, parent)
+ {}
+ QSize span(const QModelIndex &index) const override
+ {
+ Q_UNUSED(index)
+ return QSize(2, 1);
+ }
+ };
+ SpanModel model(3, 5);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(&model);
+ QCOMPARE(proxy.span(proxy.index(0, 0)), QSize(1, 2));
+}
+
+void tst_QTransposeProxyModel::itemData()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QMap<int, QVariant> itmData = proxy.itemData(proxy.index(0, 1));
+ QCOMPARE(itmData.value(Qt::DisplayRole).toString(), QStringLiteral("1,0"));
+ QCOMPARE(itmData.value(Qt::UserRole).toInt(), 1);
+ QCOMPARE(itmData.value(Qt::UserRole + 1).toInt(), 0);
+ itmData = proxy.itemData(proxy.index(1, 2, proxy.index(0, 1)));
+ QCOMPARE(itmData.value(Qt::DisplayRole).toString(), QStringLiteral("1,0,2,1"));
+ QCOMPARE(itmData.value(Qt::UserRole).toInt(), 1);
+ QCOMPARE(itmData.value(Qt::UserRole + 1).toInt(), 0);
+ QCOMPARE(itmData.value(Qt::UserRole + 2).toInt(), 2);
+ QCOMPARE(itmData.value(Qt::UserRole + 3).toInt(), 1);
+ QVERIFY(proxy.itemData(QModelIndex()).isEmpty());
+ delete model;
+}
+
+void tst_QTransposeProxyModel::setItemData()
+{
+ QAbstractItemModel *model = createTreeModel(this);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QSignalSpy sourceDataChangeSpy(model, &QAbstractItemModel::dataChanged);
+ QVERIFY(sourceDataChangeSpy.isValid());
+ QSignalSpy proxyDataChangeSpy(&proxy, &QAbstractItemModel::dataChanged);
+ QVERIFY(proxyDataChangeSpy.isValid());
+ const QMap<int, QVariant> itmData = {
+ std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("Test")),
+ std::make_pair<int, QVariant>(Qt::UserRole, 88),
+ std::make_pair<int, QVariant>(Qt::UserRole + 1, 99),
+ };
+ QModelIndex idx = proxy.index(0, 1);
+ QVERIFY(proxy.setItemData(idx, itmData));
+ QCOMPARE(idx.data(Qt::DisplayRole).toString(), QStringLiteral("Test"));
+ QCOMPARE(idx.data(Qt::UserRole).toInt(), 88);
+ QCOMPARE(idx.data(Qt::UserRole + 1).toInt(), 99);
+ QCOMPARE(sourceDataChangeSpy.size(), 1);
+ QCOMPARE(proxyDataChangeSpy.size(), 1);
+ auto signalData = proxyDataChangeSpy.takeFirst();
+ QCOMPARE(signalData.at(0).value<QModelIndex>(), idx);
+ QCOMPARE(signalData.at(1).value<QModelIndex>(), idx);
+ const QVector<int> expectedRoles{Qt::DisplayRole, Qt::UserRole, Qt::EditRole, Qt::UserRole + 1};
+ QVector<int> receivedRoles = signalData.at(2).value<QVector<int> >();
+ QCOMPARE(receivedRoles.size(), expectedRoles.size());
+ for (int role : expectedRoles)
+ QVERIFY(receivedRoles.contains(role));
+ signalData = sourceDataChangeSpy.takeFirst();
+ QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx));
+ QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx));
+ receivedRoles = signalData.at(2).value<QVector<int> >();
+ QCOMPARE(receivedRoles.size(), expectedRoles.size());
+ for (int role : expectedRoles)
+ QVERIFY(receivedRoles.contains(role));
+ idx = proxy.index(1, 2, proxy.index(0, 1));
+ QVERIFY(proxy.setItemData(idx, itmData));
+ QCOMPARE(idx.data(Qt::DisplayRole).toString(), QStringLiteral("Test"));
+ QCOMPARE(idx.data(Qt::UserRole).toInt(), 88);
+ QCOMPARE(idx.data(Qt::UserRole + 1).toInt(), 99);
+ QCOMPARE(idx.data(Qt::UserRole + 2).toInt(), 2);
+ QCOMPARE(idx.data(Qt::UserRole + 3).toInt(), 1);
+ QCOMPARE(sourceDataChangeSpy.size(), 1);
+ QCOMPARE(proxyDataChangeSpy.size(), 1);
+ signalData = proxyDataChangeSpy.takeFirst();
+ QCOMPARE(signalData.at(0).value<QModelIndex>(), idx);
+ QCOMPARE(signalData.at(1).value<QModelIndex>(), idx);
+ receivedRoles = signalData.at(2).value<QVector<int> >();
+ QCOMPARE(receivedRoles.size(), expectedRoles.size());
+ for (int role : expectedRoles)
+ QVERIFY(receivedRoles.contains(role));
+ signalData = sourceDataChangeSpy.takeFirst();
+ QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx));
+ QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx));
+ receivedRoles = signalData.at(2).value<QVector<int> >();
+ QCOMPARE(receivedRoles.size(), expectedRoles.size());
+ for (int role : expectedRoles)
+ QVERIFY(receivedRoles.contains(role));
+ QVERIFY(!proxy.setItemData(QModelIndex(), itmData));
+ delete model;
+}
+
+void tst_QTransposeProxyModel::moveRowsBase()
+{
+ QStringListModel model{QStringList{"A", "B", "C", "D"}};
+ QTransposeProxyModel proxy;
+ QSignalSpy columnsMoveSpy(&proxy, &QAbstractItemModel::columnsMoved);
+ QVERIFY(columnsMoveSpy.isValid());
+ QSignalSpy columnsAboutToBeMoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeMoved);
+ QVERIFY(columnsAboutToBeMoveSpy.isValid());
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(&model);
+ const QStringList expectedNewVal = {"B", "A", "C", "D"};
+ QVERIFY(model.moveRows(QModelIndex(), 0, 1, QModelIndex(), 2));
+ for (int i = 0; i < expectedNewVal.size(); ++i)
+ QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i));
+ QCOMPARE(columnsMoveSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeMoveSpy.count(), 1);
+ for (const auto &spyArgs : {columnsMoveSpy.takeFirst(),
+ columnsAboutToBeMoveSpy.takeFirst()}) {
+ QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid());
+ QCOMPARE(spyArgs.at(1).toInt(), 0);
+ QCOMPARE(spyArgs.at(2).toInt(), 0);
+ QVERIFY(!spyArgs.at(3).value<QModelIndex>().isValid());
+ QCOMPARE(spyArgs.at(4).toInt(), 2);
+ }
+}
+
+void tst_QTransposeProxyModel::moveColumnsProxy()
+{
+ QStringListModel model{QStringList{"A", "B", "C", "D"}};
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ QSignalSpy columnsMoveSpy(&proxy, &QAbstractItemModel::columnsMoved);
+ QVERIFY(columnsMoveSpy.isValid());
+ QSignalSpy columnsAboutToBeMoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeMoved);
+ QVERIFY(columnsAboutToBeMoveSpy.isValid());
+ QSignalSpy rowsMoveSpy(&model, &QAbstractItemModel::rowsMoved);
+ QVERIFY(rowsMoveSpy.isValid());
+ QSignalSpy rowsAboutToBeMoveSpy(&model, &QAbstractItemModel::rowsAboutToBeMoved);
+ QVERIFY(rowsAboutToBeMoveSpy.isValid());
+ proxy.setSourceModel(&model);
+ const QStringList expectedNewVal = {"B", "A", "C", "D"};
+ QVERIFY(proxy.moveColumns(QModelIndex(), 0, 1, QModelIndex(), 2));
+ for (int i = 0; i < expectedNewVal.size(); ++i)
+ QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i));
+ for (int i = 0; i < expectedNewVal.size(); ++i)
+ QCOMPARE(model.index(i, 0).data(), expectedNewVal.at(i));
+ QCOMPARE(columnsMoveSpy.count(), 1);
+ QCOMPARE(columnsAboutToBeMoveSpy.count(), 1);
+ QCOMPARE(rowsMoveSpy.count(), 1);
+ QCOMPARE(rowsAboutToBeMoveSpy.count(), 1);
+ for (const auto &spyArgs : {columnsMoveSpy.takeFirst(),
+ columnsAboutToBeMoveSpy.takeFirst(),
+ rowsMoveSpy.takeFirst(),rowsAboutToBeMoveSpy.takeFirst()}) {
+ QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid());
+ QCOMPARE(spyArgs.at(1).toInt(), 0);
+ QCOMPARE(spyArgs.at(2).toInt(), 0);
+ QVERIFY(!spyArgs.at(3).value<QModelIndex>().isValid());
+ }
+}
+
+void tst_QTransposeProxyModel::setData_data()
+{
+ QTest::addColumn<QAbstractItemModel *>("model");
+ QTest::addColumn<bool>("rootItem");
+ QTest::addColumn<bool>("viaProxy");
+ QTest::newRow("List_via_Base") << createListModel(this) << true << false;
+ QTest::newRow("Table_via_Base") << createTableModel(this) << true << false;
+ QTest::newRow("Tree_via_Base_Root_Item") << createTreeModel(this) << true << false;
+ QTest::newRow("Tree_via_Base_Child_Item") << createTreeModel(this) << false << false;
+ QTest::newRow("List_via_Proxy") << createListModel(this) << true << true;
+ QTest::newRow("Table_via_Proxy") << createTableModel(this) << true << true;
+ QTest::newRow("Tree_via_Proxy_Root_Item") << createTreeModel(this) << true << true;
+ QTest::newRow("Tree_via_Proxy_Child_Item") << createTreeModel(this) << false << true;
+}
+
+void tst_QTransposeProxyModel::setData()
+{
+ QFETCH(QAbstractItemModel *, model);
+ QFETCH(bool, rootItem);
+ QFETCH(bool, viaProxy);
+ QTransposeProxyModel proxy;
+ new QAbstractItemModelTester(&proxy, &proxy);
+ proxy.setSourceModel(model);
+ QSignalSpy sourceDataChangeSpy(model, &QAbstractItemModel::dataChanged);
+ QVERIFY(sourceDataChangeSpy.isValid());
+ QSignalSpy proxyDataChangeSpy(&proxy, &QAbstractItemModel::dataChanged);
+ QVERIFY(proxyDataChangeSpy.isValid());
+ const QString testData = QStringLiteral("TestingSetData");
+ if (viaProxy) {
+ const QModelIndex parIdx = rootItem ? QModelIndex() : proxy.index(0, 1);
+ QVERIFY(proxy.setData(proxy.index(0, 1, parIdx), testData));
+ QCOMPARE(model->index(1, 0, proxy.mapToSource(parIdx)).data().toString(), testData);
+ } else {
+ const QModelIndex parIdx = rootItem ? QModelIndex() : model->index(1, 0);
+ QVERIFY(model->setData(model->index(1, 0, parIdx), testData));
+ QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parIdx)).data().toString(), testData);
+ }
+ QCOMPARE(sourceDataChangeSpy.size(), 1);
+ QCOMPARE(proxyDataChangeSpy.size(), 1);
+ delete model;
+}
+
+QTEST_GUILESS_MAIN(tst_QTransposeProxyModel)
+
+#include "tst_qtransposeproxymodel.moc"
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index a53501b9dd..6adb393ddd 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -928,6 +928,12 @@ void tst_QCoreApplication::threadedEventDelivery()
thread.start();
QVERIFY(thread.wait(1000));
QCOMPARE(receiver.recordedEvents.contains(QEvent::User + 1), eventsReceived);
+
+}
+
+void tst_QCoreApplication::testTrWithPercantegeAtTheEnd()
+{
+ QCoreApplication::translate("testcontext", "this will crash%", "testdisamb", 3);
}
#if QT_CONFIG(library)
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
index 105cca5174..2a23cf0751 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
@@ -59,6 +59,7 @@ private slots:
void applicationEventFilters_auxThread();
void threadedEventDelivery_data();
void threadedEventDelivery();
+ void testTrWithPercantegeAtTheEnd();
#if QT_CONFIG(library)
void addRemoveLibPaths();
#endif
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
index fb7e025b7c..06588188d4 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
+++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST
@@ -1,7 +1,6 @@
[sendPostedEvents]
windows
-osx
[registerTimer]
windows
-osx
winrt
+osx
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 5784f0728c..49c10c6a24 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -28,6 +28,7 @@
#ifdef QT_GUI_LIB
# include <QtGui/QGuiApplication>
+# define tst_QEventDispatcher tst_QGuiEventDispatcher
#else
# include <QtCore/QCoreApplication>
#endif
@@ -92,77 +93,151 @@ void tst_QEventDispatcher::initTestCase()
}
}
+class TimerManager {
+ Q_DISABLE_COPY(TimerManager)
+
+public:
+ TimerManager(QAbstractEventDispatcher *eventDispatcher, QObject *parent)
+ : m_eventDispatcher(eventDispatcher), m_parent(parent)
+ {
+ }
+
+ ~TimerManager()
+ {
+ if (!registeredTimers().isEmpty())
+ m_eventDispatcher->unregisterTimers(m_parent);
+ }
+
+ TimerManager(TimerManager &&) = delete;
+ TimerManager &operator=(TimerManager &&) = delete;
+
+ int preciseTimerId() const { return m_preciseTimerId; }
+ int coarseTimerId() const { return m_coarseTimerId; }
+ int veryCoarseTimerId() const { return m_veryCoarseTimerId; }
+
+ bool foundPrecise() const { return m_preciseTimerId > 0; }
+ bool foundCoarse() const { return m_coarseTimerId > 0; }
+ bool foundVeryCoarse() const { return m_veryCoarseTimerId > 0; }
+
+ QList<QAbstractEventDispatcher::TimerInfo> registeredTimers() const
+ {
+ return m_eventDispatcher->registeredTimers(m_parent);
+ }
+
+ void registerAll()
+ {
+ // start 3 timers, each with the different timer types and different intervals
+ m_preciseTimerId = m_eventDispatcher->registerTimer(
+ PreciseTimerInterval, Qt::PreciseTimer, m_parent);
+ m_coarseTimerId = m_eventDispatcher->registerTimer(
+ CoarseTimerInterval, Qt::CoarseTimer, m_parent);
+ m_veryCoarseTimerId = m_eventDispatcher->registerTimer(
+ VeryCoarseTimerInterval, Qt::VeryCoarseTimer, m_parent);
+ QVERIFY(m_preciseTimerId > 0);
+ QVERIFY(m_coarseTimerId > 0);
+ QVERIFY(m_veryCoarseTimerId > 0);
+ findTimers();
+ }
+
+ void unregister(int timerId)
+ {
+ m_eventDispatcher->unregisterTimer(timerId);
+ findTimers();
+ }
+
+ void unregisterAll()
+ {
+ m_eventDispatcher->unregisterTimers(m_parent);
+ findTimers();
+ }
+
+private:
+ void findTimers()
+ {
+ bool foundPrecise = false;
+ bool foundCoarse = false;
+ bool foundVeryCoarse = false;
+ const QList<QAbstractEventDispatcher::TimerInfo> timers = registeredTimers();
+ for (int i = 0; i < timers.count(); ++i) {
+ const QAbstractEventDispatcher::TimerInfo &timerInfo = timers.at(i);
+ if (timerInfo.timerId == m_preciseTimerId) {
+ QCOMPARE(timerInfo.interval, int(PreciseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::PreciseTimer);
+ foundPrecise = true;
+ } else if (timerInfo.timerId == m_coarseTimerId) {
+ QCOMPARE(timerInfo.interval, int(CoarseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::CoarseTimer);
+ foundCoarse = true;
+ } else if (timerInfo.timerId == m_veryCoarseTimerId) {
+ QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval));
+ QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer);
+ foundVeryCoarse = true;
+ }
+ }
+ if (!foundPrecise)
+ m_preciseTimerId = -1;
+ if (!foundCoarse)
+ m_coarseTimerId = -1;
+ if (!foundVeryCoarse)
+ m_veryCoarseTimerId = -1;
+ }
+
+ QAbstractEventDispatcher *m_eventDispatcher = nullptr;
+
+ int m_preciseTimerId = -1;
+ int m_coarseTimerId = -1;
+ int m_veryCoarseTimerId = -1;
+
+ QObject *m_parent = nullptr;
+};
+
// test that the eventDispatcher's timer implementation is complete and working
void tst_QEventDispatcher::registerTimer()
{
-#define FIND_TIMERS() \
- do { \
- foundPrecise = false; \
- foundCoarse = false; \
- foundVeryCoarse = false; \
- for (int i = 0; i < registeredTimers.count(); ++i) { \
- const QAbstractEventDispatcher::TimerInfo &timerInfo = registeredTimers.at(i); \
- if (timerInfo.timerId == preciseTimerId) { \
- QCOMPARE(timerInfo.interval, int(PreciseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::PreciseTimer); \
- foundPrecise = true; \
- } else if (timerInfo.timerId == coarseTimerId) { \
- QCOMPARE(timerInfo.interval, int(CoarseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::CoarseTimer); \
- foundCoarse = true; \
- } else if (timerInfo.timerId == veryCoarseTimerId) { \
- QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval)); \
- QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer); \
- foundVeryCoarse = true; \
- } \
- } \
- } while (0)
-
- // start 3 timers, each with the different timer types and different intervals
- int preciseTimerId = eventDispatcher->registerTimer(PreciseTimerInterval, Qt::PreciseTimer, this);
- int coarseTimerId = eventDispatcher->registerTimer(CoarseTimerInterval, Qt::CoarseTimer, this);
- int veryCoarseTimerId = eventDispatcher->registerTimer(VeryCoarseTimerInterval, Qt::VeryCoarseTimer, this);
- QVERIFY(preciseTimerId > 0);
- QVERIFY(coarseTimerId > 0);
- QVERIFY(veryCoarseTimerId > 0);
+ TimerManager timers(eventDispatcher, this);
+ timers.registerAll();
+ if (QTest::currentTestFailed())
+ return;
// check that all 3 are present in the eventDispatcher's registeredTimer() list
- QList<QAbstractEventDispatcher::TimerInfo> registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 3);
- bool foundPrecise, foundCoarse, foundVeryCoarse;
- FIND_TIMERS();
- QVERIFY(foundPrecise && foundCoarse && foundVeryCoarse);
+ QCOMPARE(timers.registeredTimers().count(), 3);
+ QVERIFY(timers.foundPrecise());
+ QVERIFY(timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// process events, waiting for the next event... this should only fire the precise timer
receivedEventType = -1;
timerIdFromEvent = -1;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2);
- QCOMPARE(timerIdFromEvent, preciseTimerId);
+ QCOMPARE(timerIdFromEvent, timers.preciseTimerId());
// now unregister it and make sure it's gone
- eventDispatcher->unregisterTimer(preciseTimerId);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 2);
- FIND_TIMERS();
- QVERIFY(!foundPrecise && foundCoarse && foundVeryCoarse);
+ timers.unregister(timers.preciseTimerId());
+ if (QTest::currentTestFailed())
+ return;
+ QCOMPARE(timers.registeredTimers().count(), 2);
+ QVERIFY(!timers.foundPrecise());
+ QVERIFY(timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// do the same again for the coarse timer
receivedEventType = -1;
timerIdFromEvent = -1;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2);
- QCOMPARE(timerIdFromEvent, coarseTimerId);
+ QCOMPARE(timerIdFromEvent, timers.coarseTimerId());
// now unregister it and make sure it's gone
- eventDispatcher->unregisterTimer(coarseTimerId);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QCOMPARE(registeredTimers.count(), 1);
- FIND_TIMERS();
- QVERIFY(!foundPrecise && !foundCoarse && foundVeryCoarse);
+ timers.unregister(timers.coarseTimerId());
+ if (QTest::currentTestFailed())
+ return;
+ QCOMPARE(timers.registeredTimers().count(), 1);
+ QVERIFY(!timers.foundPrecise());
+ QVERIFY(!timers.foundCoarse());
+ QVERIFY(timers.foundVeryCoarse());
// not going to wait for the VeryCoarseTimer, would take too long, just unregister it
- eventDispatcher->unregisterTimers(this);
- registeredTimers = eventDispatcher->registeredTimers(this);
- QVERIFY(registeredTimers.isEmpty());
-
-#undef FIND_TIMERS
+ timers.unregisterAll();
+ if (QTest::currentTestFailed())
+ return;
+ QVERIFY(timers.registeredTimers().isEmpty());
}
void tst_QEventDispatcher::sendPostedEvents_data()
diff --git a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
index bb111a9137..6ed0a6caa9 100644
--- a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
+++ b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
@@ -46,6 +46,7 @@ private slots:
void fromType();
void valuesToKeys_data();
void valuesToKeys();
+ void defaultConstructed();
};
void tst_QMetaEnum::fromType()
@@ -99,6 +100,15 @@ void tst_QMetaEnum::valuesToKeys()
QCOMPARE(me.valueToKeys(windowFlags), expected);
}
+void tst_QMetaEnum::defaultConstructed()
+{
+ QMetaEnum e;
+ QVERIFY(!e.isValid());
+ QVERIFY(!e.isScoped());
+ QVERIFY(!e.isFlag());
+ QCOMPARE(e.name(), QByteArray());
+}
+
Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<tst_QMetaEnum::SuperEnum>::Value);
Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<Qt::WindowFlags>::Value);
Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<Qt::Orientation>::Value);
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 9855bec520..350ed24c28 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -40,6 +40,13 @@ struct MyStruct
int i;
};
+class MyGadget
+{
+ Q_GADGET
+public:
+ Q_INVOKABLE MyGadget() {}
+};
+
namespace MyNamespace {
// Used in tst_QMetaObject::checkScope
class MyClass : public QObject
@@ -324,6 +331,7 @@ private slots:
void signal();
void signalIndex_data();
void signalIndex();
+ void enumDebugStream_data();
void enumDebugStream();
void inherits_data();
@@ -1207,6 +1215,12 @@ void tst_QMetaObject::invokeMetaConstructor()
QCOMPARE(obj2->parent(), (QObject*)&obj);
QVERIFY(qobject_cast<NamespaceWithConstructibleClass::ConstructibleClass*>(obj2) != 0);
}
+ // gadget shouldn't return a valid pointer
+ {
+ QCOMPARE(MyGadget::staticMetaObject.constructorCount(), 1);
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::newInstance: type MyGadget does not inherit QObject");
+ QVERIFY(!MyGadget::staticMetaObject.newInstance());
+ }
}
void tst_QMetaObject::invokeTypedefTypes()
@@ -1741,37 +1755,104 @@ void tst_QMetaObject::signalIndex()
SignalTestHelper::signalIndex(mm));
}
+void tst_QMetaObject::enumDebugStream_data()
+{
+ QTest::addColumn<int>("verbosity");
+ QTest::addColumn<QString>("normalEnumMsg");
+ QTest::addColumn<QString>("scopedEnumMsg");
+ QTest::addColumn<QString>("globalEnumMsg");
+ QTest::addColumn<QString>("normalFlagMsg");
+ QTest::addColumn<QString>("normalFlagsMsg");
+ QTest::addColumn<QString>("scopedFlagMsg");
+ QTest::addColumn<QString>("scopedFlagsMsg");
+ QTest::addColumn<QString>("flagAsEnumMsg");
+
+ QTest::newRow("verbosity=0") << 0
+ << "hello MyEnum2 world"
+ << "hello MyScopedEnum::Enum3 scoped world"
+ << "WindowTitleHint Window Desktop WindowSystemMenuHint"
+ << "hello MyFlag1 world"
+ << "MyFlag1 MyFlag2|MyFlag3"
+ << "MyScopedFlag(MyFlag2)"
+ << "MyScopedFlag(MyFlag2|MyFlag3)"
+ << "MyFlag1";
+
+ QTest::newRow("verbosity=1") << 1
+ << "hello MyEnum::MyEnum2 world"
+ << "hello MyScopedEnum::Enum3 scoped world"
+ << "WindowType::WindowTitleHint WindowType::Window WindowType::Desktop WindowType::WindowSystemMenuHint"
+ << "hello MyFlag(MyFlag1) world"
+ << "MyFlag(MyFlag1) MyFlag(MyFlag2|MyFlag3)"
+ << "MyScopedFlag(MyFlag2)"
+ << "MyScopedFlag(MyFlag2|MyFlag3)"
+ << "MyFlag::MyFlag1";
+
+ QTest::newRow("verbosity=2") << 2
+ << "hello MyNamespace::MyClass::MyEnum2 world"
+ << "hello MyNamespace::MyClass::MyScopedEnum::Enum3 scoped world"
+ << "Qt::WindowTitleHint Qt::Window Qt::Desktop Qt::WindowSystemMenuHint"
+ << "hello QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) world"
+ << "QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) QFlags<MyNamespace::MyClass::MyFlag>(MyFlag2|MyFlag3)"
+ << "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2)"
+ << "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2|MyFlag3)"
+ << "MyNamespace::MyClass::MyFlag1";
+
+ QTest::newRow("verbosity=3") << 3
+ << "hello MyNamespace::MyClass::MyEnum::MyEnum2 world"
+ << "hello MyNamespace::MyClass::MyScopedEnum::Enum3 scoped world"
+ << "Qt::WindowType::WindowTitleHint Qt::WindowType::Window Qt::WindowType::Desktop Qt::WindowType::WindowSystemMenuHint"
+ << "hello QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) world"
+ << "QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) QFlags<MyNamespace::MyClass::MyFlag>(MyFlag2|MyFlag3)"
+ << "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2)"
+ << "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2|MyFlag3)"
+ << "MyNamespace::MyClass::MyFlag::MyFlag1";
+}
+
void tst_QMetaObject::enumDebugStream()
{
- QTest::ignoreMessage(QtDebugMsg, "hello MyNamespace::MyClass::MyEnum2 world ");
- qDebug() << "hello" << MyNamespace::MyClass::MyEnum2 << "world";
+ QFETCH(int, verbosity);
+
+ QFETCH(QString, normalEnumMsg);
+ QFETCH(QString, scopedEnumMsg);
+ QFETCH(QString, globalEnumMsg);
+
+ QFETCH(QString, normalFlagMsg);
+ QFETCH(QString, normalFlagsMsg);
+ QFETCH(QString, scopedFlagMsg);
+ QFETCH(QString, scopedFlagsMsg);
+ QFETCH(QString, flagAsEnumMsg);
+
+ // Enums
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(normalEnumMsg));
+ qDebug().verbosity(verbosity) << "hello" << MyNamespace::MyClass::MyEnum2 << "world";
- QTest::ignoreMessage(QtDebugMsg, "hello MyNamespace::MyClass::MyScopedEnum::Enum3 scoped world ");
- qDebug() << "hello" << MyNamespace::MyClass::MyScopedEnum::Enum3 << "scoped world";
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(scopedEnumMsg));
+ qDebug().verbosity(verbosity) << "hello" << MyNamespace::MyClass::MyScopedEnum::Enum3 << "scoped world";
- QTest::ignoreMessage(QtDebugMsg, "Qt::WindowTitleHint Qt::Window Qt::Desktop Qt::WindowSystemMenuHint");
- qDebug() << Qt::WindowTitleHint << Qt::Window << Qt::Desktop << Qt::WindowSystemMenuHint;
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(globalEnumMsg));
+ qDebug().verbosity(verbosity) << Qt::WindowTitleHint << Qt::Window << Qt::Desktop << Qt::WindowSystemMenuHint;
- QTest::ignoreMessage(QtDebugMsg, "hello QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) world");
+ // Flags
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(normalFlagMsg));
MyNamespace::MyClass::MyFlags f1 = MyNamespace::MyClass::MyFlag1;
- qDebug() << "hello" << f1 << "world";
+ qDebug().verbosity(verbosity) << "hello" << f1 << "world";
MyNamespace::MyClass::MyFlags f2 = MyNamespace::MyClass::MyFlag2 | MyNamespace::MyClass::MyFlag3;
- QTest::ignoreMessage(QtDebugMsg, "QFlags<MyNamespace::MyClass::MyFlag>(MyFlag1) QFlags<MyNamespace::MyClass::MyFlag>(MyFlag2|MyFlag3)");
- qDebug() << f1 << f2;
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(normalFlagsMsg));
+ qDebug().verbosity(verbosity) << f1 << f2;
- QTest::ignoreMessage(QtDebugMsg, "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2)");
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(scopedFlagMsg));
MyNamespace::MyClass::MyScopedFlags f3 = MyNamespace::MyClass::MyScopedFlag::MyFlag2;
- qDebug() << f3;
+ qDebug().verbosity(verbosity) << f3;
- QTest::ignoreMessage(QtDebugMsg, "QFlags<MyNamespace::MyClass::MyScopedFlag>(MyFlag2|MyFlag3)");
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(scopedFlagsMsg));
f3 |= MyNamespace::MyClass::MyScopedFlag::MyFlag3;
- qDebug() << f3;
+ qDebug().verbosity(verbosity) << f3;
// Single flag recognized as enum:
- QTest::ignoreMessage(QtDebugMsg, "MyNamespace::MyClass::MyFlag1");
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(flagAsEnumMsg));
MyNamespace::MyClass::MyFlag f4 = MyNamespace::MyClass::MyFlag1;
- qDebug() << f4;
+ qDebug().verbosity(verbosity) << f4;
}
void tst_QMetaObject::inherits_data()
diff --git a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
index d70befecfd..56b8c071c3 100644
--- a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
+++ b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
@@ -10,7 +10,7 @@ msvc|winrt {
# Prevents "fatal error C1128: number of sections exceeded object file format limit".
QMAKE_CXXFLAGS += /bigobj
# Reduce compile time
- win32-msvc2012|winrt {
+ winrt {
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE -= -O2
}
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 0c328dff58..28458c43c7 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -124,6 +124,7 @@ private slots:
void compareCustomType();
void compareCustomEqualOnlyType();
void customDebugStream();
+ void unknownType();
};
struct BaseGenericType
@@ -342,6 +343,7 @@ struct Bar
++failureCount;
}
}
+ ~Bar() {}
public:
static int failureCount;
@@ -458,7 +460,7 @@ void tst_QMetaType::threadSafety()
namespace TestSpace
{
- struct Foo { double d; };
+ struct Foo { double d; public: ~Foo() {} };
struct QungTfu {};
}
Q_DECLARE_METATYPE(TestSpace::Foo)
@@ -515,11 +517,17 @@ void tst_QMetaType::properties()
}
template <typename T>
-struct Whity { T t; };
+struct Whity { T t; Whity() {} };
Q_DECLARE_METATYPE( Whity < int > )
Q_DECLARE_METATYPE(Whity<double>)
+#if !defined(Q_CC_CLANG) && defined(Q_CC_GNU) && Q_CC_GNU < 501
+QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(Whity<double>, Q_MOVABLE_TYPE);
+QT_END_NAMESPACE
+#endif
+
void tst_QMetaType::normalizedTypes()
{
int WhityIntId = ::qMetaTypeId<Whity<int> >();
@@ -818,10 +826,13 @@ void tst_QMetaType::sizeOfStaticLess()
QCOMPARE(size_t(QMetaType(type).sizeOf()), size);
}
-struct CustomMovable {};
+struct CustomMovable { CustomMovable() {} };
+#if !defined(Q_CC_CLANG) && defined(Q_CC_GNU) && Q_CC_GNU < 501
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(CustomMovable, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
+#endif
+
Q_DECLARE_METATYPE(CustomMovable);
class CustomObject : public QObject
@@ -850,13 +861,15 @@ public:
};
Q_DECLARE_METATYPE(CustomMultiInheritanceObject*);
-class C { char _[4]; };
-class M { char _[4]; };
+class C { char _[4]; public: C() = default; C(const C&) {} };
+class M { char _[4]; public: M() {} };
class P { char _[4]; };
QT_BEGIN_NAMESPACE
+#if defined(Q_CC_GNU) && Q_CC_GNU < 501
Q_DECLARE_TYPEINFO(M, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(P, Q_PRIMITIVE_TYPE);
+#endif
QT_END_NAMESPACE
// avoid the comma:
@@ -902,7 +915,7 @@ QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(ADD_METATYPE_TEST_ROW)
QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW)
#undef ADD_METATYPE_TEST_ROW
QTest::newRow("TestSpace::Foo") << ::qMetaTypeId<TestSpace::Foo>() << false << true << false << false;
- QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << false << true << false << false;
+ QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << true << true << false << false;
QTest::newRow("CustomMovable") << ::qMetaTypeId<CustomMovable>() << true << true << false << false;
QTest::newRow("CustomObject*") << ::qMetaTypeId<CustomObject*>() << true << false << true << false;
QTest::newRow("CustomMultiInheritanceObject*") << ::qMetaTypeId<CustomMultiInheritanceObject*>() << true << false << true << false;
@@ -1486,7 +1499,7 @@ public:
typedef MyObject* MyObjectPtr;
Q_DECLARE_METATYPE(MyObjectPtr)
-#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER)
+#if !defined(TST_QMETATYPE_BROKEN_COMPILER)
static QByteArray createTypeName(const char *begin, const char *va)
{
QByteArray tn(begin);
@@ -1684,7 +1697,7 @@ void tst_QMetaType::automaticTemplateRegistration()
QVERIFY(qRegisterMetaType<UnregisteredTypeList>("UnregisteredTypeList") > 0);
}
-#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER)
+#if !defined(TST_QMETATYPE_BROKEN_COMPILER)
#define FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \
F(bool) \
@@ -1763,7 +1776,7 @@ void tst_QMetaType::automaticTemplateRegistration()
CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*)
CREATE_AND_VERIFY_CONTAINER(QHash, const void*, const void*)
-#endif // Q_COMPILER_VARIADIC_MACROS
+#endif // !defined(TST_QMETATYPE_BROKEN_COMPILER)
#define TEST_OWNING_SMARTPOINTER(SMARTPOINTER, ELEMENT_TYPE, FLAG_TEST, FROMVARIANTFUNCTION) \
{ \
@@ -2529,6 +2542,16 @@ void tst_QMetaType::customDebugStream()
qDebug() << v1;
}
+void tst_QMetaType::unknownType()
+{
+ QMetaType invalid(QMetaType::UnknownType);
+ QVERIFY(!invalid.create());
+ QVERIFY(!invalid.sizeOf());
+ QVERIFY(!invalid.metaObject());
+ int buffer = 0xBAD;
+ invalid.construct(&buffer);
+ QCOMPARE(buffer, 0xBAD);
+}
// Compile-time test, it should be possible to register function pointer types
class Undefined;
@@ -2542,9 +2565,7 @@ Q_DECLARE_METATYPE(UndefinedFunction0);
Q_DECLARE_METATYPE(UndefinedFunction1);
Q_DECLARE_METATYPE(UndefinedFunction2);
Q_DECLARE_METATYPE(UndefinedFunction3);
-#ifdef Q_COMPILER_VARIADIC_TEMPLATES
Q_DECLARE_METATYPE(UndefinedFunction4);
-#endif
QTEST_MAIN(tst_QMetaType)
#include "tst_qmetatype.moc"
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 9f4419affc..e0394a5d25 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -41,6 +41,7 @@
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
+#include <QScopedPointer>
#if QT_CONFIG(process)
# include <QProcess>
#endif
@@ -103,6 +104,7 @@ private slots:
void deleteQObjectWhenDeletingEvent();
void overloads();
void isSignalConnected();
+ void isSignalConnectedAfterDisconnection();
void qMetaObjectConnect();
void qMetaObjectDisconnectOne();
void sameName();
@@ -152,6 +154,8 @@ private slots:
void mutableFunctor();
void checkArgumentsForNarrowing();
void nullReceiver();
+ void functorReferencesConnection();
+ void disconnectDisconnects();
};
struct QObjectCreatedOnShutdown
@@ -499,14 +503,13 @@ void tst_QObject::connectSlotsByName()
void tst_QObject::qobject_castTemplate()
{
- QObject *o = 0;
- QVERIFY( !::qobject_cast<QObject*>(o) );
+ QScopedPointer<QObject> o;
+ QVERIFY(!::qobject_cast<QObject*>(o.data()));
- o = new SenderObject;
- QVERIFY( ::qobject_cast<SenderObject*>(o) );
- QVERIFY( ::qobject_cast<QObject*>(o) );
- QVERIFY( !::qobject_cast<ReceiverObject*>(o) );
- delete o;
+ o.reset(new SenderObject);
+ QVERIFY(::qobject_cast<SenderObject*>(o.data()));
+ QVERIFY(::qobject_cast<QObject*>(o.data()));
+ QVERIFY(!::qobject_cast<ReceiverObject*>(o.data()));
}
void tst_QObject::findChildren()
@@ -3408,12 +3411,11 @@ void tst_QObject::disconnectSelfInSlotAndDeleteAfterEmit()
void tst_QObject::dumpObjectInfo()
{
QObject a, b;
- QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater()));
- a.disconnect(&b);
+ QObject::connect(&a, &QObject::destroyed, &b, &QObject::deleteLater);
QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT");
QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)");
- QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>");
+ QTest::ignoreMessage(QtDebugMsg, " <functor or function pointer>");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN");
QTest::ignoreMessage(QtDebugMsg, " <None>");
a.dumpObjectInfo(); // should not crash
@@ -3837,6 +3839,58 @@ void tst_QObject::isSignalConnected()
QVERIFY(!o.isSignalConnected(QMetaMethod()));
}
+void tst_QObject::isSignalConnectedAfterDisconnection()
+{
+ ManySignals o;
+ const QMetaObject *meta = o.metaObject();
+
+ const QMetaMethod sig00 = meta->method(meta->indexOfSignal("sig00()"));
+ QVERIFY(!o.isSignalConnected(sig00));
+ QObject::connect(&o, &ManySignals::sig00, qt_noop);
+ QVERIFY(o.isSignalConnected(sig00));
+ QVERIFY(QObject::disconnect(&o, &ManySignals::sig00, 0, 0));
+ QVERIFY(!o.isSignalConnected(sig00));
+
+ const QMetaMethod sig69 = meta->method(meta->indexOfSignal("sig69()"));
+ QVERIFY(!o.isSignalConnected(sig69));
+ QObject::connect(&o, &ManySignals::sig69, qt_noop);
+ QVERIFY(o.isSignalConnected(sig69));
+ QVERIFY(QObject::disconnect(&o, &ManySignals::sig69, 0, 0));
+ QVERIFY(!o.isSignalConnected(sig69));
+
+ {
+ ManySignals o2;
+ QObject::connect(&o, &ManySignals::sig00, &o2, &ManySignals::sig00);
+ QVERIFY(o.isSignalConnected(sig00));
+ // o2 is destructed
+ }
+ QVERIFY(!o.isSignalConnected(sig00));
+
+ const QMetaMethod sig01 = meta->method(meta->indexOfSignal("sig01()"));
+ QObject::connect(&o, &ManySignals::sig00, qt_noop);
+ QObject::connect(&o, &ManySignals::sig01, qt_noop);
+ QObject::connect(&o, &ManySignals::sig69, qt_noop);
+ QVERIFY(o.isSignalConnected(sig00));
+ QVERIFY(o.isSignalConnected(sig01));
+ QVERIFY(o.isSignalConnected(sig69));
+ QVERIFY(QObject::disconnect(&o, &ManySignals::sig69, 0, 0));
+ QVERIFY(o.isSignalConnected(sig00));
+ QVERIFY(o.isSignalConnected(sig01));
+ QVERIFY(!o.isSignalConnected(sig69));
+ QVERIFY(QObject::disconnect(&o, &ManySignals::sig00, 0, 0));
+ QVERIFY(!o.isSignalConnected(sig00));
+ QVERIFY(o.isSignalConnected(sig01));
+ QVERIFY(!o.isSignalConnected(sig69));
+ QObject::connect(&o, &ManySignals::sig69, qt_noop);
+ QVERIFY(!o.isSignalConnected(sig00));
+ QVERIFY(o.isSignalConnected(sig01));
+ QVERIFY(o.isSignalConnected(sig69));
+ QVERIFY(QObject::disconnect(&o, &ManySignals::sig01, 0, 0));
+ QVERIFY(!o.isSignalConnected(sig00));
+ QVERIFY(!o.isSignalConnected(sig01));
+ QVERIFY(o.isSignalConnected(sig69));
+}
+
void tst_QObject::qMetaObjectConnect()
{
ReceiverObject r1;
@@ -4740,13 +4794,13 @@ class LotsOfSignalsAndSlots: public QObject
public slots:
void slot_v() {}
- void slot_v_noexcept() Q_DECL_NOTHROW {}
+ void slot_v_noexcept() noexcept {}
void slot_vi(int) {}
- void slot_vi_noexcept() Q_DECL_NOTHROW {}
+ void slot_vi_noexcept() noexcept {}
void slot_vii(int, int) {}
void slot_viii(int, int, int) {}
int slot_i() { return 0; }
- int slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
+ int slot_i_noexcept() noexcept { return 0; }
int slot_ii(int) { return 0; }
int slot_iii(int, int) { return 0; }
int slot_iiii(int, int, int) { return 0; }
@@ -4760,18 +4814,18 @@ class LotsOfSignalsAndSlots: public QObject
void slot_vPFvvE(fptr) {}
void const_slot_v() const {};
- void const_slot_v_noexcept() const Q_DECL_NOTHROW {}
+ void const_slot_v_noexcept() const noexcept {}
void const_slot_vi(int) const {};
- void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {}
+ void const_slot_vi_noexcept(int) const noexcept {}
static void static_slot_v() {}
- static void static_slot_v_noexcept() Q_DECL_NOTHROW {}
+ static void static_slot_v_noexcept() noexcept {}
static void static_slot_vi(int) {}
- static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {}
+ static void static_slot_vi_noexcept(int) noexcept {}
static void static_slot_vii(int, int) {}
static void static_slot_viii(int, int, int) {}
static int static_slot_i() { return 0; }
- static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
+ static int static_slot_i_noexcept() noexcept { return 0; }
static int static_slot_ii(int) { return 0; }
static int static_slot_iii(int, int) { return 0; }
static int static_slot_iiii(int, int, int) { return 0; }
@@ -4934,11 +4988,11 @@ void tst_QObject::connectCxx0xTypeMatching()
}
-void receiverFunction_noexcept() Q_DECL_NOTHROW {}
-struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} };
+void receiverFunction_noexcept() noexcept {}
+struct Functor_noexcept { void operator()() noexcept {} };
void tst_QObject::connectCxx17Noexcept()
{
- // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier
+ // this is about connecting signals to slots with the noexcept qualifier
// as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
typedef LotsOfSignalsAndSlots Foo;
Foo obj;
@@ -5975,7 +6029,6 @@ void tst_QObject::connectFunctorArgDifference()
QStringListModel model;
connect(&model, &QStringListModel::rowsInserted, SlotFunctor());
-#if defined(Q_COMPILER_LAMBDA)
connect(&timer, &QTimer::timeout, [=](){});
connect(&timer, &QTimer::objectNameChanged, [=](const QString &){});
connect(qApp, &QCoreApplication::aboutToQuit, [=](){});
@@ -5983,7 +6036,6 @@ void tst_QObject::connectFunctorArgDifference()
connect(&timer, &QTimer::objectNameChanged, [=](){});
connect(&model, &QStringListModel::rowsInserted, [=](){});
connect(&model, &QStringListModel::rowsInserted, [=](const QModelIndex &){});
-#endif
QVERIFY(true);
}
@@ -6021,7 +6073,6 @@ void tst_QObject::connectFunctorQueued()
e.exec();
QCOMPARE(status, 2);
-#if defined(Q_COMPILER_LAMBDA)
status = 1;
connect(&obj, &SenderObject::signal1, this, [&status] { status = 2; }, Qt::QueuedConnection);
@@ -6029,7 +6080,6 @@ void tst_QObject::connectFunctorQueued()
QCOMPARE(status, 1);
e.exec();
QCOMPARE(status, 2);
-#endif
}
void tst_QObject::connectFunctorWithContext()
@@ -6063,7 +6113,6 @@ void tst_QObject::connectFunctorWithContext()
e.exec();
QCOMPARE(status, 2);
-#if defined(Q_COMPILER_LAMBDA)
status = 1;
connect(&obj, &SenderObject::signal1, this, [this, &status, &obj] { status = 2; QCOMPARE(sender(), &obj); }, Qt::QueuedConnection);
@@ -6071,7 +6120,6 @@ void tst_QObject::connectFunctorWithContext()
QCOMPARE(status, 1);
e.exec();
QCOMPARE(status, 2);
-#endif
// Free
context->deleteLater();
@@ -6381,7 +6429,7 @@ void connectFunctorOverload_impl(Signal signal, int expOverload, QList<QVariant>
void tst_QObject::connectFunctorOverloads()
{
-#if defined (Q_COMPILER_DECLTYPE) && defined (Q_COMPILER_VARIADIC_TEMPLATES)
+#if defined (Q_COMPILER_VARIADIC_TEMPLATES)
connectFunctorOverload_impl<ComplexFunctor>(&FunctorArgDifferenceObject::signal_ii, 1,
(QList<QVariant>() << 1 << 2));
connectFunctorOverload_impl<ComplexFunctor>(&FunctorArgDifferenceObject::signal_iiS, 1,
@@ -6555,7 +6603,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor()
}
QCOMPARE(countedStructObjectsCount, 0);
{
-#if defined(Q_COMPILER_LAMBDA)
CountedStruct s;
QCOMPARE(countedStructObjectsCount, 1);
QTimer timer;
@@ -6565,7 +6612,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor()
QCOMPARE(countedStructObjectsCount, 2);
QVERIFY(QObject::disconnect(c));
QCOMPARE(countedStructObjectsCount, 1);
-#endif // Q_COMPILER_LAMBDA
}
QCOMPARE(countedStructObjectsCount, 0);
}
@@ -6613,7 +6659,6 @@ void tst_QObject::contextDoesNotLeakFunctor()
}
QCOMPARE(countedStructObjectsCount, 0);
{
-#if defined(Q_COMPILER_LAMBDA)
CountedStruct s;
QEventLoop e;
ContextObject *context = new ContextObject;
@@ -6626,7 +6671,6 @@ void tst_QObject::contextDoesNotLeakFunctor()
context->deleteLater();
e.exec();
QCOMPARE(countedStructObjectsCount, 1);
-#endif // Q_COMPILER_LAMBDA
}
QCOMPARE(countedStructObjectsCount, 0);
}
@@ -6674,16 +6718,16 @@ void tst_QObject::connectWarnings()
r1.reset();
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid null parameter");
- connect(nullptr, &SubSender::signal1, &r1, &ReceiverObject::slot1);
+ connect(static_cast<const SenderObject *>(nullptr), &SubSender::signal1, &r1, &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SubSender, Unknown): invalid null parameter");
- connect(&sub, &SubSender::signal1, nullptr, &ReceiverObject::slot1);
+ connect(&sub, &SubSender::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, ReceiverObject): invalid null parameter");
- connect(nullptr, &SenderObject::signal1, &r1, &ReceiverObject::slot1);
+ connect(static_cast<const SenderObject *>(nullptr), &SenderObject::signal1, &r1, &ReceiverObject::slot1);
QTest::ignoreMessage(QtWarningMsg, "QObject::connect(SenderObject, Unknown): invalid null parameter");
- connect(&obj, &SenderObject::signal1, nullptr, &ReceiverObject::slot1);
+ connect(&obj, &SenderObject::signal1, static_cast<ReceiverObject *>(nullptr), &ReceiverObject::slot1);
}
struct QmlReceiver : public QtPrivate::QSlotObjectBase
@@ -7434,6 +7478,167 @@ void tst_QObject::nullReceiver()
QVERIFY(!connect(&o, SIGNAL(destroyed()), nullObj, SLOT(deleteLater())));
}
+void tst_QObject::functorReferencesConnection()
+{
+ countedStructObjectsCount = 0;
+ QMetaObject::Connection globalCon;
+ {
+ GetSenderObject obj;
+ CountedStruct counted(&obj);
+ QCOMPARE(countedStructObjectsCount, 1);
+ auto c = QSharedPointer<QMetaObject::Connection>::create();
+ int slotCalled = 0;
+ *c = connect(&obj, &GetSenderObject::aSignal, &obj, [&slotCalled, c, counted] {
+ QObject::disconnect(*c);
+ slotCalled++;
+ });
+ globalCon = *c; // keep a handle to the connection somewhere;
+ QVERIFY(globalCon);
+ QCOMPARE(countedStructObjectsCount, 2);
+ obj.triggerSignal();
+ QCOMPARE(slotCalled, 1);
+ QCOMPARE(countedStructObjectsCount, 1);
+ QVERIFY(!globalCon);
+ obj.triggerSignal();
+ QCOMPARE(slotCalled, 1);
+ QCOMPARE(countedStructObjectsCount, 1);
+ }
+ QCOMPARE(countedStructObjectsCount, 0);
+
+ {
+ GetSenderObject obj;
+ CountedStruct counted(&obj);
+ QCOMPARE(countedStructObjectsCount, 1);
+ auto *rec = new QObject;
+ int slotCalled = 0;
+ globalCon = connect(&obj, &GetSenderObject::aSignal, rec, [&slotCalled, rec, counted] {
+ delete rec;
+ slotCalled++;
+ });
+ QCOMPARE(countedStructObjectsCount, 2);
+ obj.triggerSignal();
+ QCOMPARE(slotCalled, 1);
+ QCOMPARE(countedStructObjectsCount, 1);
+ QVERIFY(!globalCon);
+ obj.triggerSignal();
+ QCOMPARE(slotCalled, 1);
+ QCOMPARE(countedStructObjectsCount, 1);
+ }
+ QCOMPARE(countedStructObjectsCount, 0);
+ {
+ int slotCalled = 0;
+ QEventLoop eventLoop;
+ {
+ // Sender will be destroyed when the labda goes out of scope lambda, so it will exit the event loop
+ auto sender = QSharedPointer<GetSenderObject>::create();
+ connect(sender.data(), &QObject::destroyed, &eventLoop, &QEventLoop::quit, Qt::QueuedConnection);
+ globalCon = connect(sender.data(), &GetSenderObject::aSignal, this, [&slotCalled, sender, &globalCon, this] {
+ ++slotCalled;
+ // This signal will be connected, but should never be called as the sender will be destroyed before
+ auto c2 = connect(sender.data(), &GetSenderObject::aSignal, [] { QFAIL("Should not be called"); });
+ QVERIFY(c2);
+ QVERIFY(QObject::disconnect(sender.data(), nullptr, this, nullptr));
+ QVERIFY(!globalCon); // this connection has been disconnected
+ QVERIFY(c2); // sender should not have been deleted yet, only after the emission is done
+ });
+ QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection);
+ }
+ eventLoop.exec();
+ QCOMPARE(slotCalled, 1);
+ }
+
+ {
+ GetSenderObject obj;
+ CountedStruct counted(&obj);
+ QCOMPARE(countedStructObjectsCount, 1);
+ auto c1 = QSharedPointer<QMetaObject::Connection>::create();
+ auto c2 = QSharedPointer<QMetaObject::Connection>::create();
+ int slot1Called = 0;
+ int slot3Called = 0;
+ *c1 = connect(&obj, &GetSenderObject::aSignal, &obj, [&slot1Called, &slot3Called, &obj, c1, c2, counted] {
+ auto c3 = connect(&obj, &GetSenderObject::aSignal, [counted, &slot3Called] {
+ slot3Called++;
+ });
+ // top-level + the one in the 3 others lambdas
+ QCOMPARE(countedStructObjectsCount, 4);
+ QObject::disconnect(*c2);
+ slot1Called++;
+ });
+ connect(&obj, &GetSenderObject::aSignal, [] {}); // just a dummy signal to fill the connection list
+ *c2 = connect(&obj, &GetSenderObject::aSignal, [counted, c2] { QFAIL("should not be called"); });
+ QVERIFY(c1 && c2);
+ QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c2
+ obj.triggerSignal();
+ QCOMPARE(slot1Called, 1);
+ QCOMPARE(slot3Called, 0);
+ QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c3
+ QObject::disconnect(*c1);
+ QCOMPARE(countedStructObjectsCount, 2); // top-level + c3
+ obj.triggerSignal();
+ QCOMPARE(slot1Called, 1);
+ QCOMPARE(slot3Called, 1);
+ }
+ {
+ struct DestroyEmit {
+ Q_DISABLE_COPY(DestroyEmit);
+ explicit DestroyEmit(SenderObject *obj) : obj(obj) {}
+ SenderObject *obj;
+ ~DestroyEmit() {
+ obj->emitSignal1();
+ }
+ };
+ SenderObject obj;
+ int slot1Called = 0;
+ int slot2Called = 0;
+ int slot3Called = 0;
+ auto c1 = QSharedPointer<QMetaObject::Connection>::create();
+ auto de = QSharedPointer<DestroyEmit>::create(&obj);
+ *c1 = connect(&obj, &SenderObject::signal1, [&slot1Called, &slot3Called, de, c1, &obj] {
+ connect(&obj, &SenderObject::signal1, [&slot3Called] { slot3Called++; });
+ slot1Called++;
+ QObject::disconnect(*c1);
+ });
+ de.clear();
+ connect(&obj, &SenderObject::signal1, [&slot2Called] { slot2Called++; });
+ obj.emitSignal1();
+ QCOMPARE(slot1Called, 1);
+ QCOMPARE(slot2Called, 2); // because also called from ~DestroyEmit
+ QCOMPARE(slot3Called, 1);
+ }
+}
+
+void tst_QObject::disconnectDisconnects()
+{
+ // Test what happens if the destructor of an functor slot also disconnects more slot;
+
+ SenderObject s1;
+ QScopedPointer<QObject> receiver(new QObject);
+
+ auto s2 = QSharedPointer<SenderObject>::create();
+ QPointer<QObject> s2_tracker = s2.data();
+ int count = 0;
+ connect(&s1, &SenderObject::signal1, [&count] { count++; }); // α
+ connect(&s1, &SenderObject::signal1, receiver.data(), [s2] { QFAIL("!!"); }); // β
+ connect(s2.data(), &SenderObject::signal1, receiver.data(), [] { QFAIL("!!"); });
+ connect(&s1, &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); });
+ connect(s2.data(), &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); });
+ connect(&s1, &SenderObject::signal1, [&count] { count++; }); // γ
+ connect(&s1, &SenderObject::signal2, [&count] { count++; }); // δ
+ s2.clear();
+
+ QVERIFY(s2_tracker);
+ receiver
+ .reset(); // this will delete the receiver which must also delete s2 as β is disconnected
+ QVERIFY(!s2_tracker);
+ // test that the data structures are still in order
+ s1.emitSignal1();
+ QCOMPARE(count, 2); // α + γ
+ s1.emitSignal2();
+ QCOMPARE(count, 3); // + δ
+}
+
// Test for QtPrivate::HasQ_OBJECT_Macro
Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST
index b355bc22c2..16cbab4587 100644
--- a/tests/auto/corelib/kernel/qtimer/BLACKLIST
+++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST
@@ -2,4 +2,4 @@
windows
osx
[basic_chrono]
-osx ci
+osx
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 8d194dafc1..b7c87418c7 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -51,6 +51,8 @@ private slots:
void singleShotTimeout();
void timeout();
void remainingTime();
+ void remainingTimeInitial_data();
+ void remainingTimeInitial();
void remainingTimeDuringActivation_data();
void remainingTimeDuringActivation();
void basic_chrono();
@@ -71,7 +73,12 @@ private slots:
void recurseOnTimeoutAndStopTimer();
void singleShotToFunctors();
void singleShot_chrono();
+ void singleShot_static();
void crossThreadSingleShotToFunctor();
+ void timerOrder();
+ void timerOrder_data();
+ void timerOrderBackgroundThread();
+ void timerOrderBackgroundThread_data() { timerOrder_data(); }
void dontBlockEvents();
void postedEventsShouldNotStarveTimers();
@@ -133,14 +140,41 @@ void tst_QTimer::remainingTime()
QCOMPARE(timeoutSpy.count(), 0);
int remainingTime = timer.remainingTime();
- QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime)));
+ QVERIFY2(remainingTime >= 50 && remainingTime <= 200, qPrintable(QString::number(remainingTime)));
QVERIFY(timeoutSpy.wait());
QCOMPARE(timeoutSpy.count(), 1);
// the timer is still active, so it should have a non-zero remaining time
remainingTime = timer.remainingTime();
- QVERIFY2(remainingTime > 150, qPrintable(QString::number(remainingTime)));
+ QVERIFY2(remainingTime >= 50, qPrintable(QString::number(remainingTime)));
+}
+
+void tst_QTimer::remainingTimeInitial_data()
+{
+ QTest::addColumn<int>("startTimeMs");
+ QTest::addColumn<Qt::TimerType>("timerType");
+
+ QTest::addRow("precise time 0ms") << 0 << Qt::PreciseTimer;
+ QTest::addRow("precise time 1ms") << 1 << Qt::PreciseTimer;
+ QTest::addRow("precise time 10ms") << 10 << Qt::PreciseTimer;
+
+ QTest::addRow("coarse time 0ms") << 0 << Qt::CoarseTimer;
+ QTest::addRow("coarse time 1ms") << 1 << Qt::CoarseTimer;
+ QTest::addRow("coarse time 10ms") << 10 << Qt::CoarseTimer;
+}
+
+void tst_QTimer::remainingTimeInitial()
+{
+ QFETCH(int, startTimeMs);
+ QFETCH(Qt::TimerType, timerType);
+
+ QTimer timer;
+ timer.setTimerType(timerType);
+ timer.start(startTimeMs);
+
+ const int rt = timer.remainingTime();
+ QVERIFY2(rt >= 0 && rt <= startTimeMs, qPrintable(QString::number(rt)));
}
void tst_QTimer::remainingTimeDuringActivation_data()
@@ -228,7 +262,7 @@ void tst_QTimer::basic_chrono()
QCOMPARE(timeoutSpy.count(), 0);
milliseconds rt = timer.remainingTimeAsDuration();
- QVERIFY2(qAbs(rt.count() - 150) < 50, qPrintable(QString::number(rt.count())));
+ QVERIFY2(rt.count() >= 50 && rt.count() <= 200, qPrintable(QString::number(rt.count())));
timeoutSpy.clear();
timer.setSingleShot(true);
@@ -739,7 +773,7 @@ public:
quitEventLoop_noexcept();
}
- static void quitEventLoop_noexcept() Q_DECL_NOTHROW
+ static void quitEventLoop_noexcept() noexcept
{
QVERIFY(!_e.isNull());
_e->quit();
@@ -1004,5 +1038,121 @@ void tst_QTimer::callOnTimeout()
QVERIFY(!connection);
}
-QTEST_MAIN(tst_QTimer)
+class OrderHelper : public QObject
+{
+ Q_OBJECT
+public:
+ enum CallType
+ {
+ String,
+ PMF,
+ Functor,
+ FunctorNoCtx
+ };
+ Q_ENUM(CallType)
+ QVector<CallType> calls;
+
+ void triggerCall(CallType callType)
+ {
+ switch (callType)
+ {
+ case String:
+ QTimer::singleShot(0, this, SLOT(stringSlot()));
+ break;
+ case PMF:
+ QTimer::singleShot(0, this, &OrderHelper::pmfSlot);
+ break;
+ case Functor:
+ QTimer::singleShot(0, this, [this]() { functorSlot(); });
+ break;
+ case FunctorNoCtx:
+ QTimer::singleShot(0, [this]() { functorNoCtxSlot(); });
+ break;
+ }
+ }
+
+public slots:
+ void stringSlot() { calls << String; }
+ void pmfSlot() { calls << PMF; }
+ void functorSlot() { calls << Functor; }
+ void functorNoCtxSlot() { calls << FunctorNoCtx; }
+};
+
+Q_DECLARE_METATYPE(OrderHelper::CallType)
+
+void tst_QTimer::timerOrder()
+{
+ QFETCH(QVector<OrderHelper::CallType>, calls);
+
+ OrderHelper helper;
+
+ for (const auto call : calls)
+ helper.triggerCall(call);
+
+ QTRY_COMPARE(helper.calls, calls);
+}
+
+void tst_QTimer::timerOrder_data()
+{
+ QTest::addColumn<QVector<OrderHelper::CallType>>("calls");
+
+ QVector<OrderHelper::CallType> calls = {
+ OrderHelper::String, OrderHelper::PMF,
+ OrderHelper::Functor, OrderHelper::FunctorNoCtx
+ };
+ std::sort(calls.begin(), calls.end());
+
+ int permutation = 0;
+ do {
+ QTest::addRow("permutation=%d", permutation) << calls;
+ ++permutation;
+ } while (std::next_permutation(calls.begin(), calls.end()));
+}
+
+void tst_QTimer::timerOrderBackgroundThread()
+{
+#if !QT_CONFIG(cxx11_future)
+ QSKIP("This test requires QThread::create");
+#else
+ auto *thread = QThread::create([this]() { timerOrder(); });
+ thread->start();
+ QVERIFY(thread->wait());
+ delete thread;
+#endif
+}
+
+struct StaticSingleShotUser
+{
+ StaticSingleShotUser()
+ {
+ for (auto call : calls())
+ helper.triggerCall(call);
+ }
+ OrderHelper helper;
+
+ static QVector<OrderHelper::CallType> calls()
+ {
+ return {OrderHelper::String, OrderHelper::PMF,
+ OrderHelper::Functor, OrderHelper::FunctorNoCtx};
+ }
+};
+
+static StaticSingleShotUser *s_staticSingleShotUser = nullptr;
+
+void tst_QTimer::singleShot_static()
+{
+ QCoreApplication::processEvents();
+ QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls());
+}
+
+// NOTE: to prevent any static initialization order fiasco, we handle QTEST_MAIN
+// ourselves, but instantiate the staticSingleShotUser before qApp
+
+int main(int argc, char *argv[])
+{
+ StaticSingleShotUser staticSingleShotUser;
+ s_staticSingleShotUser = &staticSingleShotUser;
+ QTEST_MAIN_IMPL(tst_QTimer)
+}
+
#include "tst_qtimer.moc"
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 0780fb9172..6ae8fd0010 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -59,12 +59,6 @@
class CustomNonQObject;
-#if defined(Q_COMPILER_CLASS_ENUM)
-#define ENUM_SIZE(X) : X
-#else
-#define ENUM_SIZE(X)
-#endif
-
class tst_QVariant : public QObject
{
Q_OBJECT
@@ -82,15 +76,15 @@ public:
enum MetaEnumTest_Enum1 : qint64 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
Q_ENUM(MetaEnumTest_Enum1)
- enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 };
+ enum MetaEnumTest_Enum3 : qint64 { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 };
Q_ENUM(MetaEnumTest_Enum3)
- enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 };
+ enum MetaEnumTest_Enum4 : quint64 { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 };
Q_ENUM(MetaEnumTest_Enum4)
- enum MetaEnumTest_Enum5 ENUM_SIZE(uint) { MetaEnumTest_Enum5_value = 47 };
+ enum MetaEnumTest_Enum5 : uint { MetaEnumTest_Enum5_value = 47 };
Q_ENUM(MetaEnumTest_Enum5)
- enum MetaEnumTest_Enum6 ENUM_SIZE(uchar) { MetaEnumTest_Enum6_value = 47 };
+ enum MetaEnumTest_Enum6 : uchar { MetaEnumTest_Enum6_value = 47 };
Q_ENUM(MetaEnumTest_Enum6)
- enum MetaEnumTest_Enum8 ENUM_SIZE(short) { MetaEnumTest_Enum8_value = 47 };
+ enum MetaEnumTest_Enum8 : short { MetaEnumTest_Enum8_value = 47 };
Q_ENUM(MetaEnumTest_Enum8)
private slots:
@@ -525,6 +519,12 @@ void tst_QVariant::canConvert_data()
var = QVariant::fromValue<signed char>(-1);
QTest::newRow("SChar")
<< var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
+ var = QVariant((short)-3);
+ QTest::newRow("Short")
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
+ var = QVariant((ushort)7);
+ QTest::newRow("UShort")
+ << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
var = QVariant::fromValue<QJsonValue>(QJsonValue(QStringLiteral("hello")));
QTest::newRow("JsonValue")
<< var << N << N << Y << N << N << N << N << N << N << Y << N << N << Y << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
@@ -563,6 +563,8 @@ void tst_QVariant::toInt_data()
QTest::newRow( "char" ) << QVariant::fromValue('a') << int('a') << true;
signed char signedChar = -13;
QTest::newRow( "signed char" ) << QVariant::fromValue(signedChar) << -13 << true;
+ QTest::newRow( "short" ) << QVariant::fromValue(short(-7)) << int(-7) << true;
+ QTest::newRow( "ushort" ) << QVariant::fromValue(ushort(30000)) << 30000 << true;
QTest::newRow( "double" ) << QVariant( 3.1415927 ) << 3 << true;
QTest::newRow( "float" ) << QVariant( 3.1415927f ) << 3 << true;
QTest::newRow( "uint" ) << QVariant( 123u ) << 123 << true;
@@ -2753,6 +2755,14 @@ void tst_QVariant::qvariant_cast_QObject_derived()
QCOMPARE(data.value<CustomQObjectDerived *>(), object);
QCOMPARE(data.value<CustomQObject *>(), object);
}
+ {
+ QObject *object = new CustomQObjectDerivedNoMetaType(this);
+ QVariant data = QVariant::fromValue(object);
+ QVERIFY(data.canConvert<CustomQObjectDerivedNoMetaType*>());
+ QVERIFY(data.convert(qMetaTypeId<CustomQObjectDerivedNoMetaType*>()));
+ QCOMPARE(data.value<CustomQObjectDerivedNoMetaType*>(), object);
+ QCOMPARE(data.isNull(), false);
+ }
}
struct QObjectWrapper
@@ -4684,7 +4694,6 @@ Q_DECLARE_METATYPE(EnumTest_Enum0)
enum EnumTest_Enum1 : qint64 { EnumTest_Enum1_value = 42, EnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
Q_DECLARE_METATYPE(EnumTest_Enum1)
-#if defined(Q_COMPILER_CLASS_ENUM)
enum EnumTest_Enum3 : qint64 { EnumTest_Enum3_value = -47, EnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 };
Q_DECLARE_METATYPE(EnumTest_Enum3)
enum EnumTest_Enum4 : quint64 { EnumTest_Enum4_value = 47, EnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 };
@@ -4697,7 +4706,6 @@ enum class EnumTest_Enum7 { EnumTest_Enum7_value = 47, ensureSignedEnum7 = -1 };
Q_DECLARE_METATYPE(EnumTest_Enum7)
enum EnumTest_Enum8 : short { EnumTest_Enum8_value = 47 };
Q_DECLARE_METATYPE(EnumTest_Enum8)
-#endif
template<typename Enum> void testVariant(Enum value, bool *ok)
{
@@ -4756,7 +4764,6 @@ void tst_QVariant::enums()
QVERIFY(ok);
testVariant(EnumTest_Enum1_bigValue, &ok);
QVERIFY(ok);
-#if defined(Q_COMPILER_CLASS_ENUM)
testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok);
QVERIFY(ok);
testVariant(EnumTest_Enum3::EnumTest_Enum3_bigValue, &ok);
@@ -4775,7 +4782,6 @@ void tst_QVariant::enums()
QVERIFY(ok);
testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok);
QVERIFY(ok);
-#endif
}
template<typename Enum> void testVariantMeta(Enum value, bool *ok, const char *string)
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 597d51e7e0..fd3cc18af5 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -73,12 +73,12 @@ static inline QString testSuiteWarning()
str << "\nCannot find the shared-mime-info test suite\nstarting from: "
<< QDir::toNativeSeparators(QDir::currentPath()) << "\n"
"cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
- "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-8.zip\n"
- "unzip Release-1-8.zip\n";
+ "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+ "unzip Release-1-10.zip\n";
#ifdef Q_OS_WIN
- str << "mkdir testfiles\nxcopy /s Release-1-8 s-m-i\n";
+ str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
#else
- str << "ln -s Release-1-8 s-m-i\n";
+ str << "ln -s Release-1-10 s-m-i\n";
#endif
return result;
}
@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
QVERIFY(!lst.isEmpty());
// Hardcoding this is the only way to check both providers find the same number of mimetypes.
- QCOMPARE(lst.count(), 749);
+ QCOMPARE(lst.count(), 779);
foreach (const QMimeType &mime, lst) {
const QString name = mime.name();
@@ -640,7 +640,7 @@ void tst_QMimeDatabase::suffixes_data()
QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
QTest::newRow("mimetype with uncommon pattern") << "text/x-readme" << "README*" << QString();
QTest::newRow("mimetype with no patterns") << "application/x-ole-storage" << QString() << QString();
- QTest::newRow("default_mimetype") << "application/octet-stream" << "*.bin" << QString();
+ QTest::newRow("default_mimetype") << "application/octet-stream" << QString() << QString();
}
void tst_QMimeDatabase::suffixes()
@@ -992,6 +992,20 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
const QString fooTestFile2 = QLatin1String(RESOURCE_PREFIX "magic-and-hierarchy2.foo");
QCOMPARE(db.mimeTypeForFile(fooTestFile2).name(), QString::fromLatin1("application/vnd.qnx.bar-descriptor"));
+ // Test if we can use the default comment
+ {
+ struct RestoreLocale
+ {
+ ~RestoreLocale() { QLocale::setDefault(QLocale::c()); }
+ } restoreLocale;
+
+ QLocale::setDefault(QLocale("zh_CN"));
+ QMimeType suseymp = db.mimeTypeForName("text/x-suse-ymp");
+ QVERIFY(suseymp.isValid());
+ QCOMPARE(suseymp.comment(),
+ QString::fromLatin1("YaST Meta Package"));
+ }
+
// Now test removing the mimetype definitions again
for (int i = 0; i < m_additionalMimeFileNames.size(); ++i)
QFile::remove(destDir + m_additionalMimeFileNames.at(i));
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
index 3e15861021..c44cd46597 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
@@ -6,7 +6,7 @@ TARGET = mylib
DESTDIR = ../
QT = core
-win32-msvc: DEFINES += WIN32_MSVC
+msvc: DEFINES += WIN32_MSVC
# This project is testdata for tst_qlibrary
target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
index bd73227b3d..bfda0e0194 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
@@ -7,7 +7,7 @@ DESTDIR = ../
VERSION = 2
QT = core
-win32-msvc: DEFINES += WIN32_MSVC
+msvc: DEFINES += WIN32_MSVC
# Force a copy of the library to have an extension that is non-standard.
# We want to test if we can load a shared library with *any* filename...
diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro
index 44b71e6e99..9fc76a4201 100644
--- a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro
@@ -7,7 +7,7 @@ DESTDIR = ../bin
winrt:include(../winrt.pri)
QT = core
-win32-msvc: DEFINES += WIN32_MSVC
+msvc: DEFINES += WIN32_MSVC
# This is testdata for the tst_qpluginloader test.
target.path = $$[QT_INSTALL_TESTS]/tst_qpluginloader/bin
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri
new file mode 100644
index 0000000000..ca4a0a07e9
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri
@@ -0,0 +1,13 @@
+TEMPLATE = aux
+
+# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
+load(qt)
+
+goodlib.target = good.$${QMAKE_APPLE_DEVICE_ARCHS}.dylib
+goodlib.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
+goodlib.depends += $$PWD/../fakeplugin.cpp
+
+all.depends += goodlib
+
+QMAKE_EXTRA_TARGETS += goodlib all
+QMAKE_CLEAN += $$goodlib.target
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
index 7f7caa7f76..795dd89895 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
@@ -1,64 +1,15 @@
-TEMPLATE = aux
-OTHER_FILES += \
- ppcconverter.pl \
- generate-bad.pl
+TEMPLATE = subdirs
-# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
-load(qt)
-
-i386_d.target = good.i386.dylib
-i386_d.depends = EXPORT_VALID_ARCHS=i386
-i386.target = good.i386.dylib
-i386.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
-i386.depends += $$PWD/../fakeplugin.cpp
-
-x86_64_d.target = good.x86_64.dylib
-x86_64_d.depends = EXPORT_VALID_ARCHS=x86_64
-x86_64.target = good.x86_64.dylib
-x86_64.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
-x86_64.depends += $$PWD/../fakeplugin.cpp
-
-# Current Mac OS X toolchains have no compiler for PPC anymore
-# So we fake it by converting an x86-64 binary to (little-endian!) PPC64
-ppc64.target = good.ppc64.dylib
-ppc64.commands = $$PWD/ppcconverter.pl $< $@
-ppc64.depends = x86_64 $$PWD/ppcconverter.pl
-
-# Generate a fat binary with three architectures
-fat_all.target = good.fat.all.dylib
-fat_all.commands = lipo -create -output $@ \
- -arch ppc64 $$ppc64.target \
- -arch i386 $$i386.target \
- -arch x86_64 $$x86_64.target
-fat_all.depends += i386 x86_64 ppc64
-
-fat_no_i386.target = good.fat.no-i386.dylib
-fat_no_i386.commands = lipo -create -output $@ -arch x86_64 $$x86_64.target -arch ppc64 $$ppc64.target
-fat_no_i386.depends += x86_64 ppc64
-
-fat_no_x86_64.target = good.fat.no-x86_64.dylib
-fat_no_x86_64.commands = lipo -create -output $@ -arch i386 $$i386.target -arch ppc64 $$ppc64.target
-fat_no_x86_64.depends += i386 ppc64
-
-fat_stub_i386.target = good.fat.stub-i386.dylib
-fat_stub_i386.commands = lipo -create -output $@ -arch ppc64 $$ppc64.target -arch_blank i386
-fat_stub_i386.depends += x86_64 ppc64
-
-fat_stub_x86_64.target = good.fat.stub-x86_64.dylib
-fat_stub_x86_64.commands = lipo -create -output $@ -arch ppc64 $$ppc64.target -arch_blank x86_64
-fat_stub_x86_64.depends += i386 ppc64
-
-bad.commands = $$PWD/generate-bad.pl
-bad.depends += $$PWD/generate-bad.pl
-
-MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
- fat_stub_i386 fat_stub_x86_64 bad
-all.depends += $$MYTARGETS
-QMAKE_EXTRA_TARGETS += i386_d x86_64_d $$MYTARGETS all
-
-QMAKE_CLEAN += $$i386.target $$x86_64.target $$ppc64.target $$fat_all.target \
- $$fat_no_i386.target $$fat_no_x86_64.target \
- $$fat_stub_i386.target $$fat_stub_x86_64.target \
- "bad*.dylib"
+SUBDIRS = \
+ machtest_i386.pro \
+ machtest_x86_64.pro \
+ machtest_ppc64.pro \
+ machtest_fat.pro
+machtest_fat-pro.depends = \
+ machtest_i386.pro \
+ machtest_x86_64.pro \
+ machtest_ppc64.pro
+machtest_ppc64-pro.depends = \
+ machtest_x86_64.pro
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro
new file mode 100644
index 0000000000..8daa343e2b
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro
@@ -0,0 +1,41 @@
+TEMPLATE = aux
+OTHER_FILES += generate-bad.pl
+
+# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
+load(qt)
+
+# Generate a fat binary with three architectures
+fat_all.target = good.fat.all.dylib
+fat_all.commands = lipo -create -output $@ \
+ -arch ppc64 good.ppc64.dylib \
+ -arch i386 good.i386.dylib \
+ -arch x86_64 good.x86_64.dylib
+fat_all.depends += good.i386.dylib good.x86_64.dylib good.ppc64.dylib
+
+fat_no_i386.target = good.fat.no-i386.dylib
+fat_no_i386.commands = lipo -create -output $@ -arch x86_64 good.x86_64.dylib -arch ppc64 good.ppc64.dylib
+fat_no_i386.depends += good.x86_64.dylib good.ppc64.dylib
+
+fat_no_x86_64.target = good.fat.no-x86_64.dylib
+fat_no_x86_64.commands = lipo -create -output $@ -arch i386 good.i386.dylib -arch ppc64 good.ppc64.dylib
+fat_no_x86_64.depends += good.i386.dylib good.ppc64.dylib
+
+fat_stub_i386.target = good.fat.stub-i386.dylib
+fat_stub_i386.commands = lipo -create -output $@ -arch ppc64 good.ppc64.dylib -arch_blank i386
+fat_stub_i386.depends += good.x86_64.dylib good.ppc64.dylib
+
+fat_stub_x86_64.target = good.fat.stub-x86_64.dylib
+fat_stub_x86_64.commands = lipo -create -output $@ -arch ppc64 good.ppc64.dylib -arch_blank x86_64
+fat_stub_x86_64.depends += good.i386.dylib good.ppc64.dylib
+
+bad.commands = $$PWD/generate-bad.pl
+bad.depends += $$PWD/generate-bad.pl
+
+MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
+ fat_stub_i386 fat_stub_x86_64 bad
+all.depends += $$MYTARGETS
+QMAKE_EXTRA_TARGETS += $$MYTARGETS all
+
+QMAKE_CLEAN += $$fat_all.target $$fat_no_i386.target $$fat_no_x86_64.target \
+ $$fat_stub_i386.target $$fat_stub_x86_64.target \
+ "bad*.dylib"
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro
new file mode 100644
index 0000000000..bfb2e0930c
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro
@@ -0,0 +1,3 @@
+QMAKE_APPLE_DEVICE_ARCHS = i386
+include(machtest.pri)
+
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro
new file mode 100644
index 0000000000..a73f97ccc6
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro
@@ -0,0 +1,9 @@
+QMAKE_APPLE_DEVICE_ARCHS = ppc64
+include(machtest.pri)
+
+OTHER_FILES += ppcconverter.pl
+
+# Current macOS toolchains have no compiler for PPC anymore
+# So we fake it by converting an x86-64 binary to (little-endian!) PPC64
+goodlib.commands = $$PWD/ppcconverter.pl $< $@
+goodlib.depends = good.x86_64.dylib $$PWD/ppcconverter.pl
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro
new file mode 100644
index 0000000000..9dbae5c4ee
--- /dev/null
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro
@@ -0,0 +1,2 @@
+QMAKE_APPLE_DEVICE_ARCHS = x86_64
+include(machtest.pri)
diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
index 5efe68f4af..18c9c8d198 100644
--- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
@@ -10,7 +10,7 @@ SUBDIRS = lib \
tst.depends += almostplugin
SUBDIRS += almostplugin
}
-macos:qtConfig(private_tests) {
+macos:qtConfig(private_tests):qtHaveModule(gui) {
tst.depends += machtest
SUBDIRS += machtest
}
diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
index 24d9c7409e..3dd4b5114c 100644
--- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
@@ -269,7 +269,7 @@ void tst_QCborStreamReader::integers()
quint64 absolute = (isNegative ? expectedRaw + 1 : expectedRaw);
QBuffer buffer(&data);
- QCborStreamReader reader(data);
+ QCborStreamReader reader(useDevice ? QByteArray() : data);
if (useDevice) {
buffer.open(QIODevice::ReadOnly);
reader.setDevice(&buffer);
@@ -605,7 +605,7 @@ void tst_QCborStreamReader::fixed()
removeIndicators(expected);
QBuffer buffer(&data);
- QCborStreamReader reader(data);
+ QCborStreamReader reader(useDevice ? QByteArray() : data);
if (useDevice) {
buffer.open(QIODevice::ReadOnly);
reader.setDevice(&buffer);
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 1b818ad152..f69ce4120d 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -334,7 +334,7 @@ void tst_QCborValue::copyCompare()
QCOMPARE(v, other);
QVERIFY(!(v != other));
QVERIFY(!(v < other));
-#if QT_HAS_INCLUDE(<compare>)
+#if 0 && QT_HAS_INCLUDE(<compare>)
QVERIFY(v <= other);
QVERIFY(v >= other);
QVERIFY(!(v > other));
@@ -384,11 +384,17 @@ void tst_QCborValue::arrayDefaultInitialization()
QVERIFY(v.isArray());
QVERIFY(!v.isMap());
QVERIFY(!v.isTag());
- QVERIFY(v[0].isUndefined());
QCborArray a2 = v.toArray();
QVERIFY(a2.isEmpty());
QCOMPARE(a2, a);
+ auto front = v[0];
+ QVERIFY(front.isUndefined());
+ front = 1;
+ QCOMPARE(v[0], 1);
+ QVERIFY(a2.isEmpty());
+ a2 = v.toArray();
+ QCOMPARE(a2.size(), 1);
}
void tst_QCborValue::mapDefaultInitialization()
@@ -425,7 +431,7 @@ void tst_QCborValue::mapDefaultInitialization()
QVERIFY(m == QCborMap{});
QVERIFY(QCborMap{} == m);
- QCborValue v(m);
+ const QCborValue v(m);
QVERIFY(v.isMap());
QVERIFY(!v.isArray());
QVERIFY(!v.isTag());
@@ -727,6 +733,31 @@ void tst_QCborValue::arrayMutation()
QCOMPARE(a.at(1), QCborValue(-1));
QCOMPARE(a2.at(1), QCborValue(nullptr));
QCOMPARE(++it, end);
+
+ // Array accessed via value:
+ QCborValue val(a);
+ val[2] = QCborArray{2, 3, 5, 7};
+ QCOMPARE(a.size(), 2); // Unchanged
+ QVERIFY(val.isArray());
+ QCOMPARE(val.toArray().size(), 3);
+ val[2][4] = 17;
+ QVERIFY(val.isArray());
+ QVERIFY(val[2].isArray());
+ QCOMPARE(val[2].toArray().size(), 5);
+ QCOMPARE(val[2][4], 17);
+ QCOMPARE(val.toArray().size(), 3);
+ val[3] = 42;
+ QVERIFY(val.isArray());
+ QCOMPARE(val.toArray().size(), 4);
+ QCOMPARE(val[3], 42);
+
+ // Coerce to map on string key:
+ const QLatin1String any("any");
+ val[any] = any;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 5);
+ QVERIFY(val[2].isArray());
+ QCOMPARE(val[2].toArray().size(), 5);
}
void tst_QCborValue::mapMutation()
@@ -782,6 +813,30 @@ void tst_QCborValue::mapMutation()
QCOMPARE((m.end() - 1)->toInteger(), -1);
QVERIFY((m2.end() - 1)->isNull());
QCOMPARE(++it, end);
+
+ // Map accessed via value:
+ QCborValue val(m);
+ val[7] = QCborMap({{0, 2}, {1, 3}, {2, 5}});
+ QCOMPARE(m.size(), 2); // Unchanged
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 3);
+ val[7][3] = 11;
+ QVERIFY(val.isMap());
+ QVERIFY(val[7].isMap());
+ QCOMPARE(val[7].toMap().size(), 4);
+ val[14] = 42;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 4);
+
+ const QLatin1String any("any");
+ const QString hello(QStringLiteral("Hello World"));
+ val[any][3][hello] = any;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 5);
+ QVERIFY(val[any].isMap());
+ QCOMPARE(val[any].toMap().size(), 1);
+ QVERIFY(val[any][3].isMap());
+ QCOMPARE(val[any][3].toMap().size(), 1);
}
void tst_QCborValue::arrayPrepend()
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 085a638eb7..19cdd42a74 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -181,6 +181,8 @@ private slots:
void streamRealDataTypes();
+ void enumTest();
+
void floatingPointPrecision();
void compatibility_Qt3();
@@ -2352,25 +2354,22 @@ void tst_QDataStream::setVersion()
}
}
-class SequentialBuffer : public QBuffer
+class SequentialBuffer : public QIODevice
{
public:
- SequentialBuffer(QByteArray *data) : QBuffer(data) { offset = 0; }
+ SequentialBuffer(QByteArray *data) : QIODevice() { buf.setBuffer(data); }
- bool isSequential() const { return true; }
- bool seek(qint64 pos) { offset = pos; return QBuffer::seek(pos); }
- qint64 pos() const { return qint64(offset); }
+ bool isSequential() const override { return true; }
+ bool open(OpenMode mode) override { return buf.open(mode) && QIODevice::open(mode | QIODevice::Unbuffered); }
+ void close() override { buf.close(); QIODevice::close(); }
+ qint64 bytesAvailable() const override { return QIODevice::bytesAvailable() + buf.bytesAvailable(); }
protected:
- qint64 readData(char *data, qint64 maxSize)
- {
- qint64 ret = QBuffer::readData(data, maxSize);
- offset += ret;
- return ret;
- }
+ qint64 readData(char *data, qint64 maxSize) override { return buf.read(data, maxSize); }
+ qint64 writeData(const char *data, qint64 maxSize) override { return buf.write(data, maxSize); }
private:
- int offset;
+ QBuffer buf;
};
void tst_QDataStream::skipRawData_data()
@@ -3412,6 +3411,90 @@ void tst_QDataStream::floatingPointNaN()
}
}
+void tst_QDataStream::enumTest()
+{
+ QByteArray ba;
+
+ enum class E1 : qint8
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E1::A;
+ QCOMPARE(ba.size(), int(sizeof(E1)));
+ }
+ {
+ QDataStream stream(ba);
+ E1 e;
+ stream >> e;
+ QCOMPARE(e, E1::A);
+ }
+ ba.clear();
+
+ enum class E2 : qint16
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E2::B;
+ QCOMPARE(ba.size(), int(sizeof(E2)));
+ }
+ {
+ QDataStream stream(ba);
+ E2 e;
+ stream >> e;
+ QCOMPARE(e, E2::B);
+ }
+ ba.clear();
+
+ enum class E4 : qint32
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E4::C;
+ QCOMPARE(ba.size(), int(sizeof(E4)));
+ }
+ {
+ QDataStream stream(ba);
+ E4 e;
+ stream >> e;
+ QCOMPARE(e, E4::C);
+ }
+ ba.clear();
+
+
+ enum E
+ {
+ A,
+ B,
+ C,
+ D
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E::D;
+ QCOMPARE(ba.size(), 4);
+ }
+ {
+ QDataStream stream(ba);
+ E e;
+ stream >> e;
+ QCOMPARE(e, E::D);
+ }
+ ba.clear();
+
+}
+
void tst_QDataStream::floatingPointPrecision()
{
QByteArray ba;
@@ -3470,15 +3553,21 @@ void tst_QDataStream::transaction_data()
QTest::addColumn<bool>("bData");
QTest::addColumn<float>("fData");
QTest::addColumn<double>("dData");
+ QTest::addColumn<QImage>("imgData");
QTest::addColumn<QByteArray>("strData");
QTest::addColumn<QByteArray>("rawData");
+ QImage img1(open_xpm);
+ QImage img2;
+ QImage img3(50, 50, QImage::Format_ARGB32);
+ img3.fill(qRgba(12, 34, 56, 78));
+
QTest::newRow("1") << qint8(1) << qint16(2) << qint32(3) << qint64(4) << true << 5.0f
- << double(6.0) << QByteArray("Hello world!") << QByteArray("Qt rocks!");
+ << double(6.0) << img1 << QByteArray("Hello world!") << QByteArray("Qt rocks!");
QTest::newRow("2") << qint8(1 << 6) << qint16(1 << 14) << qint32(1 << 30) << qint64Data(3) << false << 123.0f
- << double(234.0) << stringData(5).toUtf8() << stringData(6).toUtf8();
+ << double(234.0) << img2 << stringData(5).toUtf8() << stringData(6).toUtf8();
QTest::newRow("3") << qint8(-1) << qint16(-2) << qint32(-3) << qint64(-4) << true << -123.0f
- << double(-234.0) << stringData(3).toUtf8() << stringData(4).toUtf8();
+ << double(-234.0) << img3 << stringData(3).toUtf8() << stringData(4).toUtf8();
}
void tst_QDataStream::transaction()
@@ -3492,6 +3581,7 @@ void tst_QDataStream::transaction()
QFETCH(bool, bData);
QFETCH(float, fData);
QFETCH(double, dData);
+ QFETCH(QImage, imgData);
QFETCH(QByteArray, strData);
QFETCH(QByteArray, rawData);
@@ -3499,12 +3589,13 @@ void tst_QDataStream::transaction()
QDataStream stream(&testBuffer, QIODevice::WriteOnly);
stream << i8Data << i16Data << i32Data << i64Data
- << bData << fData << dData << strData.constData();
+ << bData << fData << dData << imgData << strData.constData();
stream.writeRawData(rawData.constData(), rawData.size());
}
for (int splitPos = 0; splitPos <= testBuffer.size(); ++splitPos) {
QByteArray readBuffer(testBuffer.left(splitPos));
+
SequentialBuffer dev(&readBuffer);
dev.open(QIODevice::ReadOnly);
QDataStream stream(&dev);
@@ -3516,12 +3607,13 @@ void tst_QDataStream::transaction()
bool b;
float f;
double d;
+ QImage img;
char *str;
QByteArray raw(rawData.size(), 0);
forever {
stream.startTransaction();
- stream >> i8 >> i16 >> i32 >> i64 >> b >> f >> d >> str;
+ stream >> i8 >> i16 >> i32 >> i64 >> b >> f >> d >> img >> str;
stream.readRawData(raw.data(), raw.size());
if (stream.commitTransaction())
@@ -3543,6 +3635,7 @@ void tst_QDataStream::transaction()
QCOMPARE(b, bData);
QCOMPARE(f, fData);
QCOMPARE(d, dData);
+ QCOMPARE(img, imgData);
QVERIFY(strData == str);
delete [] str;
QCOMPARE(raw, rawData);
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
new file mode 100644
index 0000000000..7e003304af
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qdatastream_core_pixmap
+QT += testlib
+SOURCES = tst_qdatastream_core_pixmap.cpp
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
new file mode 100644
index 0000000000..c931016a61
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGui/QBitmap>
+#include <QtGui/QPalette>
+#include <QtGui/QPixmap>
+#include <QtGui/QPicture>
+#include <QtGui/QTextLength>
+#include <QtGui/QPainter>
+#include <QtGui/QPen>
+
+class tst_QDataStream : public QObject
+{
+Q_OBJECT
+
+private slots:
+ void stream_with_pixmap();
+
+};
+
+void tst_QDataStream::stream_with_pixmap()
+{
+ // This is a QVariantMap with a 3x3 red QPixmap and two strings inside
+ const QByteArray ba = QByteArray::fromBase64("AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5HDQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBhAAAACgAAAAAKAGgAZQBsAGwAbw==");
+ QImage dummy; // Needed to make sure qtGui is loaded
+
+ QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
+
+ QVariantMap map;
+ QDataStream d(ba);
+ d.setVersion(QDataStream::Qt_5_12);
+ d >> map;
+
+ QCOMPARE(map["a"].toString(), QString("hello"));
+ QCOMPARE(map["p"].value<QPixmap>(), QPixmap()); // the pixmap is null because this is not a QGuiApplication
+ QCOMPARE(map["z"].toString(), QString("there"));
+}
+
+QTEST_GUILESS_MAIN(tst_QDataStream)
+
+#include "tst_qdatastream_core_pixmap.moc"
+
diff --git a/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/test/test.pro b/tests/auto/corelib/serialization/qtextstream/test/test.pro
index 3dcfa0b414..0f289a5ce1 100644
--- a/tests/auto/corelib/serialization/qtextstream/test/test.pro
+++ b/tests/auto/corelib/serialization/qtextstream/test/test.pro
@@ -3,6 +3,8 @@ TARGET = ../tst_qtextstream
QT = core network testlib
SOURCES = ../tst_qtextstream.cpp
RESOURCES += ../qtextstream.qrc
+INCLUDEPATH += ../../../../../shared/
+HEADERS += ../../../../../shared/emulationdetector.h
win32 {
CONFIG(debug, debug|release) {
diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
index 1c1631760b..af97d4a003 100644
--- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
@@ -44,7 +44,7 @@
# include <QProcess>
#endif
#include "../../../network-settings.h"
-
+#include "emulationdetector.h"
QT_BEGIN_NAMESPACE
template<> struct QMetaTypeId<QIODevice::OpenModeFlag>
@@ -1102,7 +1102,7 @@ void tst_QTextStream::hexTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << hex << number;
+ stream << Qt::showbase << Qt::hex << number;
stream.flush();
QCOMPARE(array, data);
}
@@ -1132,7 +1132,7 @@ void tst_QTextStream::binTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << bin << number;
+ stream << Qt::showbase << Qt::bin << number;
stream.flush();
QCOMPARE(array.constData(), data.constData());
}
@@ -1155,7 +1155,7 @@ void tst_QTextStream::octTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << oct << number;
+ stream << Qt::showbase << Qt::oct << number;
stream.flush();
QCOMPARE(array, data);
}
@@ -1196,7 +1196,7 @@ void tst_QTextStream::ws_manipulator()
QTextStream stream(&string);
char a, b, c, d;
- stream >> a >> ws >> b >> ws >> c >> ws >> d;
+ stream >> a >> Qt::ws >> b >> Qt::ws >> c >> Qt::ws >> d;
QCOMPARE(a, 'a');
QCOMPARE(b, 'b');
QCOMPARE(c, 'c');
@@ -1460,6 +1460,9 @@ void tst_QTextStream::pos2()
// ------------------------------------------------------------------------------
void tst_QTextStream::pos3LargeFile()
{
+ if (EmulationDetector::isRunningArmOnX86())
+ QSKIP("Running QTextStream::pos() in tight loop is too slow on emulator");
+
{
QFile file(testFileName);
file.open(QIODevice::WriteOnly | QIODevice::Text);
@@ -1620,18 +1623,18 @@ void tst_QTextStream::forcePoint()
{
QString str;
QTextStream stream(&str);
- stream << fixed << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
+ stream << Qt::fixed << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.000000 1 0 -1.000000 -1"));
str.clear();
stream.seek(0);
- stream << scientific << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
+ stream << Qt::scientific << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.000000e+00 1 0 -1.000000e+00 -1"));
str.clear();
stream.seek(0);
stream.setRealNumberNotation(QTextStream::SmartNotation);
- stream << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
+ stream << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.00000 1 0 -1.00000 -1"));
}
@@ -1641,7 +1644,7 @@ void tst_QTextStream::forceSign()
{
QString str;
QTextStream stream(&str);
- stream << forcesign << 1.2 << ' ' << -1.2 << ' ' << 0;
+ stream << Qt::forcesign << 1.2 << ' ' << -1.2 << ' ' << 0;
QCOMPARE(str, QString("+1.2 -1.2 +0"));
}
@@ -1660,19 +1663,22 @@ void tst_QTextStream::read0d0d0a()
Q_DECLARE_METATYPE(QTextStreamFunction);
+// Also tests that we can have namespaces that conflict with our QTextStream constants.
+namespace ws {
QTextStream &noop(QTextStream &s) { return s; }
+}
void tst_QTextStream::numeralCase_data()
{
- QTextStreamFunction noop_ = noop;
- QTextStreamFunction bin_ = bin;
- QTextStreamFunction oct_ = oct;
- QTextStreamFunction hex_ = hex;
- QTextStreamFunction base = showbase;
- QTextStreamFunction ucb = uppercasebase;
- QTextStreamFunction lcb = lowercasebase;
- QTextStreamFunction ucd = uppercasedigits;
- QTextStreamFunction lcd = lowercasedigits;
+ QTextStreamFunction noop_ = ws::noop;
+ QTextStreamFunction bin = Qt::bin;
+ QTextStreamFunction oct = Qt::oct;
+ QTextStreamFunction hex = Qt::hex;
+ QTextStreamFunction base = Qt::showbase;
+ QTextStreamFunction ucb = Qt::uppercasebase;
+ QTextStreamFunction lcb = Qt::lowercasebase;
+ QTextStreamFunction ucd = Qt::uppercasedigits;
+ QTextStreamFunction lcd = Qt::lowercasedigits;
QTest::addColumn<QTextStreamFunction>("func1");
QTest::addColumn<QTextStreamFunction>("func2");
@@ -1683,30 +1689,30 @@ void tst_QTextStream::numeralCase_data()
QTest::newRow("dec 1") << noop_ << noop_ << noop_ << noop_ << 31 << "31";
QTest::newRow("dec 2") << noop_ << base << noop_ << noop_ << 31 << "31";
- QTest::newRow("hex 1") << hex_ << noop_ << noop_ << noop_ << 31 << "1f";
- QTest::newRow("hex 2") << hex_ << noop_ << noop_ << lcd << 31 << "1f";
- QTest::newRow("hex 3") << hex_ << noop_ << ucb << noop_ << 31 << "1f";
- QTest::newRow("hex 4") << hex_ << noop_ << noop_ << ucd << 31 << "1F";
- QTest::newRow("hex 5") << hex_ << noop_ << lcb << ucd << 31 << "1F";
- QTest::newRow("hex 6") << hex_ << noop_ << ucb << ucd << 31 << "1F";
- QTest::newRow("hex 7") << hex_ << base << noop_ << noop_ << 31 << "0x1f";
- QTest::newRow("hex 8") << hex_ << base << lcb << lcd << 31 << "0x1f";
- QTest::newRow("hex 9") << hex_ << base << ucb << noop_ << 31 << "0X1f";
- QTest::newRow("hex 10") << hex_ << base << ucb << lcd << 31 << "0X1f";
- QTest::newRow("hex 11") << hex_ << base << noop_ << ucd << 31 << "0x1F";
- QTest::newRow("hex 12") << hex_ << base << lcb << ucd << 31 << "0x1F";
- QTest::newRow("hex 13") << hex_ << base << ucb << ucd << 31 << "0X1F";
-
- QTest::newRow("bin 1") << bin_ << noop_ << noop_ << noop_ << 31 << "11111";
- QTest::newRow("bin 2") << bin_ << base << noop_ << noop_ << 31 << "0b11111";
- QTest::newRow("bin 3") << bin_ << base << lcb << noop_ << 31 << "0b11111";
- QTest::newRow("bin 4") << bin_ << base << ucb << noop_ << 31 << "0B11111";
- QTest::newRow("bin 5") << bin_ << base << noop_ << ucd << 31 << "0b11111";
- QTest::newRow("bin 6") << bin_ << base << lcb << ucd << 31 << "0b11111";
- QTest::newRow("bin 7") << bin_ << base << ucb << ucd << 31 << "0B11111";
-
- QTest::newRow("oct 1") << oct_ << noop_ << noop_ << noop_ << 31 << "37";
- QTest::newRow("oct 2") << oct_ << base << noop_ << noop_ << 31 << "037";
+ QTest::newRow("hex 1") << hex << noop_ << noop_ << noop_ << 31 << "1f";
+ QTest::newRow("hex 2") << hex << noop_ << noop_ << lcd << 31 << "1f";
+ QTest::newRow("hex 3") << hex << noop_ << ucb << noop_ << 31 << "1f";
+ QTest::newRow("hex 4") << hex << noop_ << noop_ << ucd << 31 << "1F";
+ QTest::newRow("hex 5") << hex << noop_ << lcb << ucd << 31 << "1F";
+ QTest::newRow("hex 6") << hex << noop_ << ucb << ucd << 31 << "1F";
+ QTest::newRow("hex 7") << hex << base << noop_ << noop_ << 31 << "0x1f";
+ QTest::newRow("hex 8") << hex << base << lcb << lcd << 31 << "0x1f";
+ QTest::newRow("hex 9") << hex << base << ucb << noop_ << 31 << "0X1f";
+ QTest::newRow("hex 10") << hex << base << ucb << lcd << 31 << "0X1f";
+ QTest::newRow("hex 11") << hex << base << noop_ << ucd << 31 << "0x1F";
+ QTest::newRow("hex 12") << hex << base << lcb << ucd << 31 << "0x1F";
+ QTest::newRow("hex 13") << hex << base << ucb << ucd << 31 << "0X1F";
+
+ QTest::newRow("bin 1") << bin << noop_ << noop_ << noop_ << 31 << "11111";
+ QTest::newRow("bin 2") << bin << base << noop_ << noop_ << 31 << "0b11111";
+ QTest::newRow("bin 3") << bin << base << lcb << noop_ << 31 << "0b11111";
+ QTest::newRow("bin 4") << bin << base << ucb << noop_ << 31 << "0B11111";
+ QTest::newRow("bin 5") << bin << base << noop_ << ucd << 31 << "0b11111";
+ QTest::newRow("bin 6") << bin << base << lcb << ucd << 31 << "0b11111";
+ QTest::newRow("bin 7") << bin << base << ucb << ucd << 31 << "0B11111";
+
+ QTest::newRow("oct 1") << oct << noop_ << noop_ << noop_ << 31 << "37";
+ QTest::newRow("oct 2") << oct << base << noop_ << noop_ << 31 << "037";
}
void tst_QTextStream::numeralCase()
@@ -1779,9 +1785,9 @@ void tst_QTextStream::nanInf()
QString s;
QTextStream out(&s);
out << qInf() << ' ' << -qInf() << ' ' << qQNaN()
- << uppercasedigits << ' '
+ << Qt::uppercasedigits << ' '
<< qInf() << ' ' << -qInf() << ' ' << qQNaN()
- << flush;
+ << Qt::flush;
QCOMPARE(s, QString("inf -inf nan INF -INF NAN"));
}
@@ -1856,9 +1862,9 @@ void tst_QTextStream::writeSeekWriteNoBOM()
int number = 0;
QString sizeStr = QLatin1String("Size=")
+ QString::number(number).rightJustified(10, QLatin1Char('0'));
- stream << sizeStr << endl;
- stream << "Version=" << QString::number(14) << endl;
- stream << "blah blah blah" << endl;
+ stream << sizeStr << Qt::endl;
+ stream << "Version=" << QString::number(14) << Qt::endl;
+ stream << "blah blah blah" << Qt::endl;
stream.flush();
QCOMPARE(out.buffer().constData(), "Size=0000000000\nVersion=14\nblah blah blah\n");
@@ -1868,7 +1874,7 @@ void tst_QTextStream::writeSeekWriteNoBOM()
stream.seek(0);
sizeStr = QLatin1String("Size=")
+ QString::number(number).rightJustified(10, QLatin1Char('0'));
- stream << sizeStr << endl;
+ stream << sizeStr << Qt::endl;
stream.flush();
// Check buffer is still OK
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 8fdf91b090..e4d50607b7 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -253,7 +253,7 @@ public:
qFatal("%s: aId must not be an empty string", Q_FUNC_INFO);
}
- void swap(MissedBaseline &other) Q_DECL_NOTHROW
+ void swap(MissedBaseline &other) noexcept
{
qSwap(id, other.id);
qSwap(expected, other.expected);
diff --git a/tests/auto/corelib/serialization/serialization.pro b/tests/auto/corelib/serialization/serialization.pro
index 9187de1bc5..9638178cdc 100644
--- a/tests/auto/corelib/serialization/serialization.pro
+++ b/tests/auto/corelib/serialization/serialization.pro
@@ -6,6 +6,7 @@ SUBDIRS = \
qcborvalue \
qcborvalue_json \
qdatastream \
+ qdatastream_core_pixmap \
qtextstream \
qxmlstream
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index 810698fb4e..55a672aae1 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -6680,13 +6680,13 @@ void tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning()
} emitter;
initialState.addTransition(&emitter, &Emitter::signalWithNoArg, &finalState);
- QTimer::singleShot(0, [&]() {
- metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg");
- metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg");
- });
machine.addState(&initialState);
machine.addState(&finalState);
machine.setInitialState(&initialState);
+ connect(&machine, &QStateMachine::started, &emitter, [&]() {
+ metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg");
+ metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg");
+ });
connect(&machine, &QStateMachine::finished, &emitter.thread, &QThread::quit);
machine.start();
QSignalSpy emittedSpy(&emitter, &SignalEmitter::signalWithNoArg);
diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
index 32e5b8ee56..3a98732f9d 100644
--- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
+++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
@@ -291,10 +291,10 @@ void tst_QAtomicIntegerXX::copy()
QCOMPARE(copy2.load(), atomic.load());
// move
- QAtomicInteger<T> copy3(qMove(copy));
+ QAtomicInteger<T> copy3(std::move(copy));
QCOMPARE(copy3.load(), atomic.load());
- QAtomicInteger<T> copy4 = qMove(copy2);
+ QAtomicInteger<T> copy4 = std::move(copy2);
QCOMPARE(copy4.load(), atomic.load());
}
@@ -317,11 +317,11 @@ void tst_QAtomicIntegerXX::assign()
// move
QAtomicInteger<T> copy3;
- copy3 = qMove(copy);
+ copy3 = std::move(copy);
QCOMPARE(copy3.load(), atomic.load());
QAtomicInteger<T> copy4;
- copy4 = qMove(copy2);
+ copy4 = std::move(copy2);
QCOMPARE(copy4.load(), atomic.load());
}
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index d73dcc1b6d..f72b662c94 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -1330,6 +1330,8 @@ void tst_QThread::quitLock()
QCOMPARE(job->thread(), &thread);
loop.exec();
QVERIFY(exitThreadCalled);
+
+ delete job;
}
void tst_QThread::create()
diff --git a/tests/auto/corelib/thread/qthreadpool/BLACKLIST b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
index 1c392ce96c..fc49731687 100644
--- a/tests/auto/corelib/thread/qthreadpool/BLACKLIST
+++ b/tests/auto/corelib/thread/qthreadpool/BLACKLIST
@@ -1,2 +1,3 @@
[expiryTimeoutRace]
osx
+linux
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 838431cd5a..27b49602fc 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -1322,6 +1322,7 @@ void tst_QThreadPool::waitForDoneAfterTake()
QRunnable *runnable = createTask(emptyFunct);
manager.start(runnable);
QVERIFY(manager.tryTake(runnable));
+ delete runnable;
}
// Add another runnable that will not be removed
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
index d5c09ebc84..57bd78bcee 100644
--- a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
+++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
@@ -9,8 +9,7 @@ debug_and_release {
TARGET = ../crashOnExit_helper
}
QT = core
-CONFIG -= app_bundle
-CONFIG += console
+CONFIG += cmdline
# This app is testdata for tst_qthreadstorage
target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index b40b1f0624..104de4d783 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -2425,7 +2425,7 @@ void testContainer()
c1 = newInstance<Container>();
QVERIFY(c1.size() == 4);
QVERIFY(c1 == newInstance<Container>());
- Container c2 = qMove(c1);
+ Container c2 = std::move(c1);
QVERIFY(c2.size() == 4);
QVERIFY(c2 == newInstance<Container>());
}
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index a00c962510..2d1ae07b35 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -78,9 +78,7 @@ private slots:
void fromRawData_data();
void fromRawData();
void literals();
-#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA)
void variadicLiterals();
-#endif
#ifdef Q_COMPILER_RVALUE_REFS
void rValueReferences();
#endif
@@ -1618,9 +1616,7 @@ void tst_QArrayData::literals()
QCOMPARE(v.size(), size_t(11));
// v.capacity() is unspecified, for now
-#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA)
QVERIFY(v.isStatic());
-#endif
#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v.isSharable());
@@ -1633,7 +1629,6 @@ void tst_QArrayData::literals()
}
}
-#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA)
// Variadic Q_ARRAY_LITERAL need to be available in the current configuration.
void tst_QArrayData::variadicLiterals()
{
@@ -1682,7 +1677,6 @@ void tst_QArrayData::variadicLiterals()
QCOMPARE(const_(v)[i], i);
}
}
-#endif
#ifdef Q_COMPILER_RVALUE_REFS
// std::remove_reference is in C++11, but requires library support
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 1ed41793dc..987b3058e3 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -138,9 +138,7 @@ private slots:
void reserveExtended();
void movablity_data();
void movablity();
-#if defined(Q_COMPILER_LAMBDA)
void literals();
-#endif
void toUpperLower_data();
void toUpperLower();
void isUpper();
@@ -1361,6 +1359,9 @@ void tst_QByteArray::toDouble_data()
QTest::newRow("trailing spaces") << QByteArray("1.2345 \n\r\t") << 1.2345 << true;
QTest::newRow("leading junk") << QByteArray("x1.2345") << 0.0 << false;
QTest::newRow("trailing junk") << QByteArray("1.2345x") << 0.0 << false;
+
+ QTest::newRow("raw, null plus junk") << QByteArray::fromRawData("1.2\0 junk", 9) << 0.0 << false;
+ QTest::newRow("raw, null-terminator not included") << QByteArray::fromRawData("2.3", 3) << 2.3 << true;
}
void tst_QByteArray::toDouble()
@@ -2189,7 +2190,6 @@ void tst_QByteArray::movablity()
QVERIFY(true);
}
-#if defined(Q_COMPILER_LAMBDA)
// Only tested on c++0x compliant compiler or gcc
void tst_QByteArray::literals()
{
@@ -2210,7 +2210,6 @@ void tst_QByteArray::literals()
QVERIFY(str2.constData() == s);
QVERIFY(str2.data() != s);
}
-#endif
void tst_QByteArray::toUpperLower_data()
{
@@ -2242,28 +2241,28 @@ void tst_QByteArray::toUpperLower()
QCOMPARE(input.toLower(), lower);
QByteArray copy = input;
- QCOMPARE(qMove(copy).toUpper(), upper);
+ QCOMPARE(std::move(copy).toUpper(), upper);
copy = input;
copy.detach();
- QCOMPARE(qMove(copy).toUpper(), upper);
+ QCOMPARE(std::move(copy).toUpper(), upper);
copy = input;
- QCOMPARE(qMove(copy).toLower(), lower);
+ QCOMPARE(std::move(copy).toLower(), lower);
copy = input;
copy.detach();
- QCOMPARE(qMove(copy).toLower(), lower);
+ QCOMPARE(std::move(copy).toLower(), lower);
copy = lower;
- QCOMPARE(qMove(copy).toLower(), lower);
+ QCOMPARE(std::move(copy).toLower(), lower);
copy = lower;
copy.detach();
- QCOMPARE(qMove(copy).toLower(), lower);
+ QCOMPARE(std::move(copy).toLower(), lower);
copy = upper;
- QCOMPARE(qMove(copy).toUpper(), upper);
+ QCOMPARE(std::move(copy).toUpper(), upper);
copy = upper;
copy.detach();
- QCOMPARE(qMove(copy).toUpper(), upper);
+ QCOMPARE(std::move(copy).toUpper(), upper);
}
void tst_QByteArray::isUpper()
diff --git a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp
index 85b4c4bfb7..a28bbc12c8 100644
--- a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp
+++ b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp
@@ -49,6 +49,9 @@ private slots:
void operator_plus() const;
void operator_plus_data() const;
+ void indexOf_data() const;
+ void indexOf() const;
+
void initializerList() const;
};
@@ -191,22 +194,22 @@ void tst_QByteArrayList::operator_plus() const
{
QByteArrayList bal1 = lhs;
const QByteArrayList bal2 = rhs;
- QCOMPARE(qMove(bal1) + bal2, expectedResult);
+ QCOMPARE(std::move(bal1) + bal2, expectedResult);
}
{
QList<QByteArray> lba1 = lhs;
const QByteArrayList bal2 = rhs;
- QCOMPARE(qMove(lba1) + bal2, expectedResult);
+ QCOMPARE(std::move(lba1) + bal2, expectedResult);
}
{
QByteArrayList bal1 = lhs;
const QList<QByteArray> lba2 = rhs;
- QCOMPARE(qMove(bal1) + lba2, expectedResult);
+ QCOMPARE(std::move(bal1) + lba2, expectedResult);
}
{
QList<QByteArray> lba1 = lhs;
const QList<QByteArray> lba2 = rhs;
- QCOMPARE(qMove(lba1) + lba2, QList<QByteArray>(expectedResult)); // check we don't mess with old code
+ QCOMPARE(std::move(lba1) + lba2, QList<QByteArray>(expectedResult)); // check we don't mess with old code
}
// operator += for const lvalues
@@ -229,7 +232,7 @@ void tst_QByteArrayList::operator_plus() const
QByteArrayList t1 = lhs;
QByteArrayList t2 = rhs;
- QCOMPARE(qMove(t1) + t2, expectedResult);
+ QCOMPARE(std::move(t1) + t2, expectedResult);
}
void tst_QByteArrayList::operator_plus_data() const
@@ -259,6 +262,29 @@ void tst_QByteArrayList::operator_plus_data() const
<< ( QByteArrayList() << "a" << "" << "c" );
}
+void tst_QByteArrayList::indexOf_data() const
+{
+ QTest::addColumn<QByteArrayList>("list");
+ QTest::addColumn<QByteArray>("item");
+ QTest::addColumn<int>("expectedResult");
+
+ QTest::newRow("empty") << QByteArrayList() << QByteArray("a") << -1;
+ QTest::newRow("found_1") << ( QByteArrayList() << "a" ) << QByteArray("a") << 0;
+ QTest::newRow("not_found_1") << ( QByteArrayList() << "a" ) << QByteArray("b") << -1;
+ QTest::newRow("found_2") << ( QByteArrayList() << "hello" << "world" ) << QByteArray("world") << 1;
+ QTest::newRow("returns_first") << ( QByteArrayList() << "hello" << "world" << "hello" << "again" ) << QByteArray("hello") << 0;
+}
+
+void tst_QByteArrayList::indexOf() const
+{
+ QFETCH(QByteArrayList, list);
+ QFETCH(QByteArray, item);
+ QFETCH(int, expectedResult);
+
+ QCOMPARE(list.indexOf(item), expectedResult);
+ QCOMPARE(list.indexOf(item.constData()), expectedResult);
+}
+
void tst_QByteArrayList::initializerList() const
{
#ifdef Q_COMPILER_INITIALIZER_LISTS
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
index 00b22dab6c..72f88a235d 100644
--- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -93,12 +93,7 @@ void tst_QCollator::compare_data()
QTest::addColumn<int>("caseInsensitiveResult");
QTest::addColumn<bool>("numericMode");
QTest::addColumn<bool>("ignorePunctuation");
- QTest::addColumn<int>("punctuationResult");
-
- /*
- A few tests below are commented out on the mac. It's unclear why they fail,
- as it looks like the collator for the locale is created correctly.
- */
+ QTest::addColumn<int>("punctuationResult"); // Test ignores punctuation *and case*
/*
It's hard to test English, because it's treated differently
@@ -164,7 +159,7 @@ void tst_QCollator::compare_data()
QTest::newRow("german13") << QString("de_DE") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
/*
- French sorting of e and e with accent
+ French sorting of e and e with acute accent
*/
QTest::newRow("french1") << QString("fr_FR") << QString::fromLatin1("\xe9") << QString::fromLatin1("e") << 1 << 1 << false << false << 1;
QTest::newRow("french2") << QString("fr_FR") << QString::fromLatin1("\xe9t") << QString::fromLatin1("et") << 1 << 1 << false << false << 1;
@@ -174,8 +169,12 @@ void tst_QCollator::compare_data()
QTest::newRow("french6") << QString("fr_FR") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("french7") << QString("fr_FR") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("french8") << QString("fr_FR") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
-}
+ // C locale: case sensitive [A-Z] < [a-z] but case insensitive [Aa] < [Bb] <...< [Zz]
+ const QString C = QStringLiteral("C");
+ QTest::newRow("C:ABBA:AaaA") << C << QStringLiteral("ABBA") << QStringLiteral("AaaA") << -1 << 1 << false << false << 1;
+ QTest::newRow("C:AZa:aAZ") << C << QStringLiteral("AZa") << QStringLiteral("aAZ") << -1 << 1 << false << false << 1;
+}
void tst_QCollator::compare()
{
@@ -189,6 +188,10 @@ void tst_QCollator::compare()
QFETCH(int, punctuationResult);
QCollator collator(locale);
+ // Need to canonicalize sign to -1, 0 or 1, as .compare() can produce any -ve for <, any +ve for >.
+ auto asSign = [](int compared) {
+ return compared < 0 ? -1 : compared > 0 ? 1 : 0;
+ };
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
if (collator.locale() != QLocale())
@@ -198,12 +201,12 @@ void tst_QCollator::compare()
if (numericMode)
collator.setNumericMode(true);
- QCOMPARE(collator.compare(s1, s2), result);
+ QCOMPARE(asSign(collator.compare(s1, s2)), result);
collator.setCaseSensitivity(Qt::CaseInsensitive);
- QCOMPARE(collator.compare(s1, s2), caseInsensitiveResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), caseInsensitiveResult);
#if !QT_CONFIG(iconv)
collator.setIgnorePunctuation(ignorePunctuation);
- QCOMPARE(collator.compare(s1, s2), punctuationResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), punctuationResult);
#endif
}
diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.pro b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.pro
index dce1ac0d37..5020658835 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.pro
+++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.pro
@@ -1,5 +1,4 @@
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
QT = core
DESTDIR = ./
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 62c29229e1..811e9a0010 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -44,6 +44,7 @@ private slots:
// In-process tests
void testInvalidOptions();
+ void testDuplicateOption();
void testPositionalArguments();
void testBooleanOption_data();
void testBooleanOption();
@@ -74,6 +75,7 @@ private slots:
void testHelpOption_data();
void testHelpOption();
void testQuoteEscaping();
+ void testUnknownOption();
};
static char *empty_argv[] = { 0 };
@@ -103,6 +105,15 @@ void tst_QCommandLineParser::testInvalidOptions()
QVERIFY(!parser.addOption(QCommandLineOption(QStringLiteral("-v"), QStringLiteral("Displays version information."))));
}
+void tst_QCommandLineParser::testDuplicateOption()
+{
+ QCoreApplication app(empty_argc, empty_argv);
+ QCommandLineParser parser;
+ QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("h"), QStringLiteral("Hostname."), QStringLiteral("hostname"))));
+ QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: already having an option named \"h\"");
+ parser.addHelpOption();
+}
+
void tst_QCommandLineParser::testPositionalArguments()
{
QCoreApplication app(empty_argc, empty_argv);
@@ -648,6 +659,27 @@ void tst_QCommandLineParser::testQuoteEscaping()
#endif // QT_CONFIG(process)
}
+void tst_QCommandLineParser::testUnknownOption()
+{
+#if !QT_CONFIG(process)
+ QSKIP("This test requires QProcess support");
+#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+ QSKIP("Deploying executable applications to file system on Android not supported.");
+#else
+ QCoreApplication app(empty_argc, empty_argv);
+ QProcess process;
+ process.start("testhelper/qcommandlineparser_test_helper", QStringList() <<
+ QString::number(QCommandLineParser::ParseAsLongOptions) <<
+ "-unknown-option");
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ process.setReadChannel(QProcess::StandardError);
+ QString output = process.readAll();
+ QVERIFY2(output.contains("qcommandlineparser_test_helper"), qPrintable(output)); // separate in case of .exe extension
+ QVERIFY2(output.contains(": Unknown option 'unknown-option'"), qPrintable(output));
+#endif // QT_CONFIG(process)
+}
+
QTEST_APPLESS_MAIN(tst_QCommandLineParser)
#include "tst_qcommandlineparser.moc"
diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
index 31a5f93822..9b45e17a28 100644
--- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
+++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
@@ -68,7 +68,7 @@ void tst_QContiguousCache::assignment()
// copy:
cc1 = cc2;
// move:
- cc1 = qMove(cc2);
+ cc1 = std::move(cc2);
}
void tst_QContiguousCache::empty()
diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
index ce1e5730dd..c17af8741b 100644
--- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
@@ -83,6 +83,7 @@ private slots:
void negativeYear() const;
void printNegativeYear() const;
void roundtripGermanLocale() const;
+#if QT_CONFIG(textdate)
void shortDayName() const;
void standaloneShortDayName() const;
void longDayName() const;
@@ -91,6 +92,7 @@ private slots:
void standaloneShortMonthName() const;
void longMonthName() const;
void standaloneLongMonthName() const;
+#endif // textdate
void roundtrip() const;
void qdebug() const;
private:
@@ -1038,18 +1040,18 @@ void tst_QDate::fromStringFormat_data()
// Undo this (inline the C-locale versions) for ### Qt 6
// Get localized names:
- QString january = QDate::longMonthName(1);
- QString february = QDate::longMonthName(2);
- QString march = QDate::longMonthName(3);
- QString august = QDate::longMonthName(8);
- QString mon = QDate::shortDayName(1);
- QString monday = QDate::longDayName(1);
- QString tuesday = QDate::longDayName(2);
- QString wednesday = QDate::longDayName(3);
- QString thursday = QDate::longDayName(4);
- QString friday = QDate::longDayName(5);
- QString saturday = QDate::longDayName(6);
- QString sunday = QDate::longDayName(7);
+ QString january = QLocale::system().monthName(1, QLocale::LongFormat);
+ QString february = QLocale::system().monthName(2, QLocale::LongFormat);
+ QString march = QLocale::system().monthName(3, QLocale::LongFormat);
+ QString august = QLocale::system().monthName(8, QLocale::LongFormat);
+ QString mon = QLocale::system().dayName(1, QLocale::ShortFormat);
+ QString monday = QLocale::system().dayName(1, QLocale::LongFormat);
+ QString tuesday = QLocale::system().dayName(2, QLocale::LongFormat);
+ QString wednesday = QLocale::system().dayName(3, QLocale::LongFormat);
+ QString thursday = QLocale::system().dayName(4, QLocale::LongFormat);
+ QString friday = QLocale::system().dayName(5, QLocale::LongFormat);
+ QString saturday = QLocale::system().dayName(6, QLocale::LongFormat);
+ QString sunday = QLocale::system().dayName(7, QLocale::LongFormat);
QTest::newRow("data0") << QString("") << QString("") << defDate();
QTest::newRow("data1") << QString(" ") << QString("") << invalidDate();
@@ -1305,6 +1307,10 @@ void tst_QDate::roundtripGermanLocale() const
theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate);
}
+#if QT_CONFIG(textdate)
+QT_WARNING_PUSH // the methods tested here are all deprecated
+QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
+
void tst_QDate::shortDayName() const
{
QCOMPARE(QDate::shortDayName(0), QString());
@@ -1432,6 +1438,8 @@ void tst_QDate::standaloneLongMonthName() const
QCOMPARE(QDate::longMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::LongFormat));
}
}
+QT_WARNING_POP
+#endif // textdate
void tst_QDate::roundtrip() const
{
diff --git a/tests/auto/corelib/tools/qdatetime/qdatetime.pro b/tests/auto/corelib/tools/qdatetime/qdatetime.pro
index ba36621cf1..742eb47075 100644
--- a/tests/auto/corelib/tools/qdatetime/qdatetime.pro
+++ b/tests/auto/corelib/tools/qdatetime/qdatetime.pro
@@ -5,7 +5,7 @@ SOURCES = tst_qdatetime.cpp
# For some reason using optimization here triggers a compiler issue, which causes an exception
# However, the code is correct
-win32-msvc|win32-msvc9x {
+msvc {
!build_pass:message ( "Compiler issue, removing -O1 flag" )
QMAKE_CFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O1
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 56792f38fb..6ad3357f40 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -2396,6 +2396,19 @@ void tst_QDateTime::fromStringStringFormat_data()
QTest::newRow("late") << QString("9999-12-31T23:59:59.999Z")
<< QString("yyyy-MM-ddThh:mm:ss.zZ")
<< QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
+ // Separators match /([^aAdhHMmstyz]*)/
+ QTest::newRow("oddly-separated") // To show broken-separator's format is valid.
+ << QStringLiteral("2018 wilful long working block relief 12-19T21:09 cruel blurb encore flux")
+ << QStringLiteral("yyyy wilful long working block relief MM-ddThh:mm cruel blurb encore flux")
+ << QDateTime(QDate(2018, 12, 19), QTime(21, 9));
+ QTest::newRow("broken-separator")
+ << QStringLiteral("2018 wilful")
+ << QStringLiteral("yyyy wilful long working block relief MM-ddThh:mm cruel blurb encore flux")
+ << invalidDateTime();
+ QTest::newRow("broken-terminator")
+ << QStringLiteral("2018 wilful long working block relief 12-19T21:09 cruel")
+ << QStringLiteral("yyyy wilful long working block relief MM-ddThh:mm cruel blurb encore flux")
+ << invalidDateTime();
}
void tst_QDateTime::fromStringStringFormat()
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index 0196dd2d23..c21d0afacb 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -55,6 +55,8 @@ private slots:
void testCbrtFloat();
void cpp11();
void quadraticEquation();
+ void streamInOut_data();
+ void streamInOut();
};
void tst_QEasingCurve::type()
@@ -879,5 +881,36 @@ void tst_QEasingCurve::quadraticEquation() {
}
}
+void tst_QEasingCurve::streamInOut_data()
+{
+ QTest::addColumn<int>("version");
+ QTest::addColumn<bool>("equality");
+
+ QTest::newRow("5.11") << int(QDataStream::Qt_5_11) << false;
+ QTest::newRow("5.13") << int(QDataStream::Qt_5_13) << true;
+}
+
+void tst_QEasingCurve::streamInOut()
+{
+ QFETCH(int, version);
+ QFETCH(bool, equality);
+
+ QEasingCurve orig;
+ orig.addCubicBezierSegment(QPointF(0.43, 0.0025), QPointF(0.38, 0.51), QPointF(0.57, 0.99));
+
+ QEasingCurve copy;
+
+ QByteArray data;
+ QDataStream dsw(&data,QIODevice::WriteOnly);
+ QDataStream dsr(&data,QIODevice::ReadOnly);
+
+ dsw.setVersion(version);
+ dsr.setVersion(version);
+ dsw << orig;
+ dsr >> copy;
+
+ QCOMPARE(copy == orig, equality);
+}
+
QTEST_MAIN(tst_QEasingCurve)
#include "tst_qeasingcurve.moc"
diff --git a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro
index b61f51d53a..3e283c05a4 100644
--- a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro
+++ b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro
@@ -1,8 +1,7 @@
SOURCES += syslocaleapp.cpp
DESTDIR = ./
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
QT = core
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index ff36beadcb..0b41af3371 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -84,6 +84,8 @@ private slots:
void matchingLocales();
void stringToDouble_data();
void stringToDouble();
+ void stringToFloat_data();
+ void stringToFloat();
void doubleToString_data();
void doubleToString();
void strtod_data();
@@ -160,6 +162,17 @@ private:
QString m_sysapp;
QStringList cleanEnv;
bool europeanTimeZone;
+ void toReal_data();
+
+ class TransientLocale
+ {
+ const int m_category;
+ const char *const m_prior;
+ public:
+ TransientLocale(int category, const char *locale)
+ : m_category(category), m_prior(setlocale(category, locale)) {}
+ ~TransientLocale() { setlocale(m_category, m_prior); }
+ };
};
tst_QLocale::tst_QLocale()
@@ -741,7 +754,7 @@ void tst_QLocale::unixLocaleName()
QCOMPARE(locale.name(), expect);
}
-void tst_QLocale::stringToDouble_data()
+void tst_QLocale::toReal_data()
{
QTest::addColumn<QString>("locale_name");
QTest::addColumn<QString>("num_str");
@@ -754,6 +767,8 @@ void tst_QLocale::stringToDouble_data()
QTest::newRow("C 1.234e-10") << QString("C") << QString("1.234e-10") << true << 1.234e-10;
QTest::newRow("C 1.234E10") << QString("C") << QString("1.234E10") << true << 1.234e10;
QTest::newRow("C 1e10") << QString("C") << QString("1e10") << true << 1.0e10;
+ QTest::newRow("C 1e310") << QString("C") << QString("1e310") << false << std::numeric_limits<double>::infinity();
+ QTest::newRow("C 1E310") << QString("C") << QString("1E310") << false << std::numeric_limits<double>::infinity();
QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0;
QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0;
QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0;
@@ -863,9 +878,35 @@ void tst_QLocale::stringToDouble_data()
QTest::newRow("de_DE 9.876543,0e--2") << QString("de_DE") << QString("9.876543,0e")+QChar(8722)+QString("2") << false << 0.0;
}
+void tst_QLocale::stringToDouble_data()
+{
+ toReal_data();
+ if (std::numeric_limits<double>::has_infinity) {
+ double huge = std::numeric_limits<double>::infinity();
+ QTest::newRow("C inf") << QString("C") << QString("inf") << true << huge;
+ QTest::newRow("C +inf") << QString("C") << QString("+inf") << true << +huge;
+ QTest::newRow("C -inf") << QString("C") << QString("-inf") << true << -huge;
+ // Overflow:
+ QTest::newRow("C huge") << QString("C") << QString("2e308") << false << huge;
+ QTest::newRow("C -huge") << QString("C") << QString("-2e308") << false << -huge;
+ }
+ if (std::numeric_limits<double>::has_quiet_NaN)
+ QTest::newRow("C qnan") << QString("C") << QString("NaN") << true << std::numeric_limits<double>::quiet_NaN();
+
+ // In range (but outside float's range):
+ QTest::newRow("C big") << QString("C") << QString("3.5e38") << true << 3.5e38;
+ QTest::newRow("C -big") << QString("C") << QString("-3.5e38") << true << -3.5e38;
+ QTest::newRow("C small") << QString("C") << QString("1e-45") << true << 1e-45;
+ QTest::newRow("C -small") << QString("C") << QString("-1e-45") << true << -1e-45;
+
+ // Underflow:
+ QTest::newRow("C tiny") << QString("C") << QString("2e-324") << false << 0.;
+ QTest::newRow("C -tiny") << QString("C") << QString("-2e-324") << false << 0.;
+}
+
void tst_QLocale::stringToDouble()
{
-#define MY_DOUBLE_EPSILON (2.22045e-16)
+#define MY_DOUBLE_EPSILON (2.22045e-16) // 1/2^{52}; double has a 53-bit mantissa
QFETCH(QString, locale_name);
QFETCH(QString, num_str);
@@ -880,27 +921,120 @@ void tst_QLocale::stringToDouble()
double d = locale.toDouble(num_str, &ok);
QCOMPARE(ok, good);
- char *currentLocale = setlocale(LC_ALL, "de_DE");
- QCOMPARE(locale.toDouble(num_str, &ok), d); // make sure result is independent of locale
- QCOMPARE(ok, good);
- setlocale(LC_ALL, currentLocale);
+ {
+ // Make sure result is independent of locale:
+ TransientLocale ignoreme(LC_ALL, "ar_SA");
+ QCOMPARE(locale.toDouble(num_str, &ok), d);
+ QCOMPARE(ok, good);
+ }
- if (ok) {
- double diff = d - num;
- if (diff < 0)
- diff = -diff;
- QVERIFY(diff <= MY_DOUBLE_EPSILON);
+ if (ok || std::isinf(num)) {
+ // First use fuzzy-compare, then a more precise check:
+ QCOMPARE(d, num);
+ if (std::isfinite(num)) {
+ double diff = d > num ? d - num : num - d;
+ QVERIFY(diff <= MY_DOUBLE_EPSILON);
+ }
}
d = locale.toDouble(num_strRef, &ok);
QCOMPARE(ok, good);
- if (ok) {
- double diff = d - num;
- if (diff < 0)
- diff = -diff;
- QVERIFY(diff <= MY_DOUBLE_EPSILON);
+ if (ok || std::isinf(num)) {
+ QCOMPARE(d, num);
+ if (std::isfinite(num)) {
+ double diff = d > num ? d - num : num - d;
+ QVERIFY(diff <= MY_DOUBLE_EPSILON);
+ }
+ }
+#undef MY_DOUBLE_EPSILON
+}
+
+void tst_QLocale::stringToFloat_data()
+{
+ using Bounds = std::numeric_limits<float>;
+ toReal_data();
+ const QString C(QStringLiteral("C"));
+ if (Bounds::has_infinity) {
+ double huge = Bounds::infinity();
+ QTest::newRow("C inf") << C << QString("inf") << true << huge;
+ QTest::newRow("C +inf") << C << QString("+inf") << true << +huge;
+ QTest::newRow("C -inf") << C << QString("-inf") << true << -huge;
+ // Overflow float, but not double:
+ QTest::newRow("C big") << C << QString("3.5e38") << false << huge;
+ QTest::newRow("C -big") << C << QString("-3.5e38") << false << -huge;
+ // Overflow double, too:
+ QTest::newRow("C huge") << C << QString("2e308") << false << huge;
+ QTest::newRow("C -huge") << C << QString("-2e308") << false << -huge;
+ }
+ if (Bounds::has_quiet_NaN)
+ QTest::newRow("C qnan") << C << QString("NaN") << true << double(Bounds::quiet_NaN());
+
+ // Minimal float: shouldn't underflow
+ QTest::newRow("C float min")
+ << C << QLocale::c().toString(Bounds::denorm_min()) << true << double(Bounds::denorm_min());
+ QTest::newRow("C float -min")
+ << C << QLocale::c().toString(-Bounds::denorm_min()) << true << -double(Bounds::denorm_min());
+
+ // Underflow float, but not double:
+ QTest::newRow("C small") << C << QString("7e-46") << false << 0.;
+ QTest::newRow("C -small") << C << QString("-7e-46") << false << 0.;
+ using Double = std::numeric_limits<double>;
+ QTest::newRow("C double min")
+ << C << QLocale::c().toString(Double::denorm_min()) << false << 0.0;
+ QTest::newRow("C double -min")
+ << C << QLocale::c().toString(-Double::denorm_min()) << false << 0.0;
+
+ // Underflow double, too:
+ QTest::newRow("C tiny") << C << QString("2e-324") << false << 0.;
+ QTest::newRow("C -tiny") << C << QString("-2e-324") << false << 0.;
+}
+
+void tst_QLocale::stringToFloat()
+{
+#define MY_FLOAT_EPSILON (2.384e-7) // 1/2^{22}; float has a 23-bit mantissa
+
+ QFETCH(QString, locale_name);
+ QFETCH(QString, num_str);
+ QFETCH(bool, good);
+ QFETCH(double, num);
+ QStringRef num_strRef = num_str.leftRef(-1);
+ float fnum = num;
+
+ QLocale locale(locale_name);
+ QCOMPARE(locale.name(), locale_name);
+
+ bool ok;
+ float f = locale.toFloat(num_str, &ok);
+ QCOMPARE(ok, good);
+
+ {
+ // Make sure result is independent of locale:
+ TransientLocale ignoreme(LC_ALL, "ar_SA");
+ QCOMPARE(locale.toFloat(num_str, &ok), f);
+ QCOMPARE(ok, good);
+ }
+
+ if (ok || std::isinf(fnum)) {
+ // First use fuzzy-compare, then a more precise check:
+ QCOMPARE(f, fnum);
+ if (std::isfinite(fnum)) {
+ float diff = f > fnum ? f - fnum : fnum - f;
+ QVERIFY(diff <= MY_FLOAT_EPSILON);
+ }
+ }
+
+ f = locale.toFloat(num_strRef, &ok);
+ QCOMPARE(ok, good);
+
+ if (ok || std::isinf(fnum)) {
+ QCOMPARE(f, fnum);
+ if (std::isfinite(fnum)) {
+ float diff = f > fnum ? f - fnum : fnum - f;
+ QVERIFY(diff <= MY_FLOAT_EPSILON);
+ }
}
+#undef MY_FLOAT_EPSILON
}
void tst_QLocale::doubleToString_data()
@@ -1013,9 +1147,8 @@ void tst_QLocale::doubleToString()
const QLocale locale(locale_name);
QCOMPARE(locale.toString(num, mode, precision), num_str);
- char *currentLocale = setlocale(LC_ALL, "de_DE");
+ TransientLocale ignoreme(LC_ALL, "de_DE");
QCOMPARE(locale.toString(num, mode, precision), num_str);
- setlocale(LC_ALL, currentLocale);
}
void tst_QLocale::strtod_data()
diff --git a/tests/auto/corelib/tools/qpair/qpair.pro b/tests/auto/corelib/tools/qpair/qpair.pro
index 659be887d3..d684a24a57 100644
--- a/tests/auto/corelib/tools/qpair/qpair.pro
+++ b/tests/auto/corelib/tools/qpair/qpair.pro
@@ -2,3 +2,6 @@ CONFIG += testcase
TARGET = tst_qpair
QT = core testlib
SOURCES = tst_qpair.cpp
+
+# Force C++17 if available (needed due to Q_COMPILER_DEDUCTION_GUIDES)
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
index 1d5f7536c8..3c972329bc 100644
--- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp
+++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
@@ -39,10 +39,11 @@ private Q_SLOTS:
void testConstexpr();
void testConversions();
void taskQTBUG_48780_pairContainingCArray();
+ void testDeducationRules();
};
-class C { char _[4]; };
-class M { char _[4]; };
+class C { C() {} char _[4]; };
+class M { M() {} char _[4]; };
class P { char _[4]; };
QT_BEGIN_NAMESPACE
@@ -202,5 +203,30 @@ void tst_QPair::taskQTBUG_48780_pairContainingCArray()
Q_UNUSED(pair);
}
+void tst_QPair::testDeducationRules()
+{
+#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606
+ QPair p1{1, 2};
+ static_assert(std::is_same<decltype(p1)::first_type, decltype(1)>::value);
+ static_assert(std::is_same<decltype(p1)::second_type, decltype(2)>::value);
+ QCOMPARE(p1.first, 1);
+ QCOMPARE(p1.second, 2);
+
+ QPair p2{QString("string"), 2};
+ static_assert(std::is_same<decltype(p2)::first_type, QString>::value);
+ static_assert(std::is_same<decltype(p2)::second_type, decltype(2)>::value);
+ QCOMPARE(p2.first, "string");
+ QCOMPARE(p2.second, 2);
+
+ QPair p3(p2);
+ static_assert(std::is_same<decltype(p3)::first_type, decltype(p2)::first_type>::value);
+ static_assert(std::is_same<decltype(p3)::second_type, decltype(p2)::second_type>::value);
+ QCOMPARE(p3.first, "string");
+ QCOMPARE(p3.second, 2);
+#else
+ QSKIP("Unsupported");
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_QPair)
#include "tst_qpair.moc"
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index f520e9742a..c02756d76a 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -2108,12 +2108,16 @@ void tst_QRegularExpression::threadSafety_data()
QTest::addRow("pattern%d", ++i) << "ab.*cd" << subject;
}
+ // pcre2 does not support JIT for winrt. As this test row takes a long time without JIT we skip
+ // it for winrt as it might time out in COIN.
+#ifndef Q_OS_WINRT
{
QString subject = "ab";
subject.append(QString(512*1024, QLatin1Char('x')));
subject.append("c");
QTest::addRow("pattern%d", ++i) << "ab.*cd" << subject;
}
+#endif // Q_OS_WINRT
{
QString subject = "ab";
@@ -2131,11 +2135,12 @@ void tst_QRegularExpression::threadSafety()
QFETCH(QString, pattern);
QFETCH(QString, subject);
+ QElapsedTimer time;
+ time.start();
static const int THREAD_SAFETY_ITERATIONS = 50;
-
const int threadCount = qMax(QThread::idealThreadCount(), 4);
- for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS; ++threadSafetyIteration) {
+ for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS && time.elapsed() < 2000; ++threadSafetyIteration) {
QRegularExpression re(pattern);
QVector<MatcherThread *> threads;
@@ -2164,47 +2169,47 @@ void tst_QRegularExpression::wildcard_data()
addRow("*.html", "test.html", 0);
addRow("*.html", "test.htm", -1);
- addRow("bar*", "foobarbaz", 3);
+ addRow("*bar*", "foobarbaz", 0);
addRow("*", "Qt Rocks!", 0);
- addRow(".html", "test.html", 4);
- addRow(".h", "test.cpp", -1);
- addRow(".???l", "test.html", 4);
- addRow("?", "test.html", 0);
- addRow("?m", "test.html", 6);
- addRow("[*]", "test.html", -1);
- addRow("[?]","test.html", -1);
- addRow("[?]","test.h?ml", 6);
- addRow("[[]","test.h[ml", 6);
- addRow("[]]","test.h]ml", 6);
- addRow(".h[a-z]ml", "test.html", 4);
- addRow(".h[A-Z]ml", "test.html", -1);
- addRow(".h[A-Z]ml", "test.hTml", 4);
- addRow(".h[!A-Z]ml", "test.hTml", -1);
- addRow(".h[!A-Z]ml", "test.html", 4);
- addRow(".h[!T]ml", "test.hTml", -1);
- addRow(".h[!T]ml", "test.html", 4);
- addRow(".h[!T]m[!L]", "test.htmL", -1);
- addRow(".h[!T]m[!L]", "test.html", 4);
- addRow(".h[][!]", "test.h]ml", 4);
- addRow(".h[][!]", "test.h[ml", 4);
- addRow(".h[][!]", "test.h!ml", 4);
-
- addRow("foo/*/bar", "Qt/foo/baz/bar", 3);
- addRow("foo/(*)/bar", "Qt/foo/baz/bar", -1);
- addRow("foo/(*)/bar", "Qt/foo/(baz)/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Q/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Qt/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/Q/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/(Q)/bar", 3);
+ addRow("*.html", "test.html", 0);
+ addRow("*.h", "test.cpp", -1);
+ addRow("*.???l", "test.html", 0);
+ addRow("*?", "test.html", 0);
+ addRow("*?ml", "test.html", 0);
+ addRow("*[*]", "test.html", -1);
+ addRow("*[?]","test.html", -1);
+ addRow("*[?]ml","test.h?ml", 0);
+ addRow("*[[]ml","test.h[ml", 0);
+ addRow("*[]]ml","test.h]ml", 0);
+ addRow("*.h[a-z]ml", "test.html", 0);
+ addRow("*.h[A-Z]ml", "test.html", -1);
+ addRow("*.h[A-Z]ml", "test.hTml", 0);
+ addRow("*.h[!A-Z]ml", "test.hTml", -1);
+ addRow("*.h[!A-Z]ml", "test.html", 0);
+ addRow("*.h[!T]ml", "test.hTml", -1);
+ addRow("*.h[!T]ml", "test.html", 0);
+ addRow("*.h[!T]m[!L]", "test.htmL", -1);
+ addRow("*.h[!T]m[!L]", "test.html", 0);
+ addRow("*.h[][!]ml", "test.h]ml", 0);
+ addRow("*.h[][!]ml", "test.h[ml", 0);
+ addRow("*.h[][!]ml", "test.h!ml", 0);
+
+ addRow("foo/*/bar", "foo/baz/bar", 0);
+ addRow("foo/(*)/bar", "foo/baz/bar", -1);
+ addRow("foo/(*)/bar", "foo/(baz)/bar", 0);
+ addRow("foo/?/bar", "foo/Q/bar", 0);
+ addRow("foo/?/bar", "foo/Qt/bar", -1);
+ addRow("foo/(?)/bar", "foo/Q/bar", -1);
+ addRow("foo/(?)/bar", "foo/(Q)/bar", 0);
#ifdef Q_OS_WIN
- addRow("foo\\*\\bar", "Qt\\foo\\baz\\bar", 3);
- addRow("foo\\(*)\\bar", "Qt\\foo\\baz\\bar", -1);
- addRow("foo\\(*)\\bar", "Qt\\foo\\(baz)\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Q\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Qt\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\Q\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\(Q)\\bar", 3);
+ addRow("foo\\*\\bar", "foo\\baz\\bar", 0);
+ addRow("foo\\(*)\\bar", "foo\\baz\\bar", -1);
+ addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Q\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Qt\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\Q\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", 0);
#endif
}
diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
index 656dd6a6e3..9b607db608 100644
--- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
+++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp
@@ -46,6 +46,7 @@ private Q_SLOTS:
void rollbackToPreviousCommit();
void exceptions();
void earlyExitScope();
+ void moveOnly();
private:
void earlyExitScope_helper(int exitpoint, int &member);
};
@@ -190,5 +191,17 @@ void tst_QScopedValueRollback::earlyExitScope_helper(int exitpoint, int& member)
r.commit();
}
+void tst_QScopedValueRollback::moveOnly()
+{
+ std::unique_ptr<int> uniquePtr;
+ std::unique_ptr<int> newVal(new int(5));
+ QVERIFY(!uniquePtr);
+ {
+ QScopedValueRollback<std::unique_ptr<int>> r(uniquePtr, std::move(newVal));
+ QVERIFY(uniquePtr);
+ }
+ QVERIFY(!uniquePtr);
+}
+
QTEST_MAIN(tst_QScopedValueRollback)
#include "tst_qscopedvaluerollback.moc"
diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
index 4dc620e6ab..d1bb89f549 100644
--- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
@@ -470,9 +470,8 @@ namespace QTest {
"TEMPLATE = app\n"
"\n"
"TARGET = externaltest\n"
- "CONFIG -= app_bundle\n" // for the Mac
"CONFIG -= debug_and_release\n"
- "CONFIG += console\n"
+ "CONFIG += cmdline\n"
"DESTDIR = .\n"
"OBJECTS_DIR = .\n"
"UI_DIR = .\n"
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index ade9c5e754..19b2aa02f3 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -89,9 +89,7 @@ private slots:
#endif
void constCorrectness();
void customDeleter();
-#ifdef Q_COMPILER_LAMBDA
void lambdaCustomDeleter();
-#endif
void creating();
void creatingCvQualified();
void creatingVariadic();
@@ -573,10 +571,10 @@ void tst_QSharedPointer::useOfForwardDeclared()
// move assignment:
QSharedPointer<ForwardDeclared> sp4;
- sp4 = qMove(sp);
+ sp4 = std::move(sp);
// and move constuction:
- QSharedPointer<ForwardDeclared> sp5 = qMove(sp2);
+ QSharedPointer<ForwardDeclared> sp5 = std::move(sp2);
// swapping:
sp4.swap(sp3);
@@ -1670,7 +1668,6 @@ void tst_QSharedPointer::customDeleter()
safetyCheck();
}
-#ifdef Q_COMPILER_LAMBDA
// The compiler needs to be in C++11 mode and to support lambdas
void tst_QSharedPointer::lambdaCustomDeleter()
{
@@ -1698,7 +1695,6 @@ void tst_QSharedPointer::lambdaCustomDeleter()
}
safetyCheck();
}
-#endif
void customQObjectDeleterFn(QObject *obj)
{
@@ -2233,11 +2229,9 @@ void tst_QSharedPointer::invalidConstructs_data()
<< &QTest::QExternalTest::tryCompileFail
<< "struct IncompatibleCustomDeleter { void operator()(int *); };\n"
"QSharedPointer<Data> ptr(new Data, IncompatibleCustomDeleter());\n";
-#ifdef Q_COMPILER_LAMBDA
QTest::newRow("incompatible-custom-lambda-deleter")
<< &QTest::QExternalTest::tryCompileFail
<< "QSharedPointer<Data> ptr(new Data, [](int *) {});\n";
-#endif
}
void tst_QSharedPointer::invalidConstructs()
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index f429bda804..79f5a8c46d 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -319,10 +319,18 @@ class tst_QString : public QObject
template <typename ArgType>
void insert_impl() const { insert_impl<ArgType, QString &(QString::*)(int, const ArgType&)>(); }
void insert_data(bool emptyIsNoop = false);
+
+ class TransientDefaultLocale
+ {
+ const QLocale prior; // Records what *was* the default before we set it.
+ public:
+ TransientDefaultLocale(const QLocale &transient) { revise(transient); }
+ void revise(const QLocale &transient) { QLocale::setDefault(transient); }
+ ~TransientDefaultLocale() { QLocale::setDefault(prior); }
+ };
+
public:
tst_QString();
-public slots:
- void cleanup();
private slots:
void fromStdString();
void toStdString();
@@ -474,8 +482,8 @@ private slots:
void indexOf2();
void indexOf3_data();
// void indexOf3();
- void sprintf();
- void sprintfS();
+ void asprintf();
+ void asprintfS();
void fill();
void truncate();
void chop_data();
@@ -570,7 +578,7 @@ private slots:
#ifdef QT_USE_ICU
void toUpperLower_icu();
#endif
-#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA)
+#if !defined(QT_NO_UNICODE_LITERAL)
void literals();
#endif
void eightBitLiterals_data();
@@ -604,7 +612,7 @@ QString verifyZeroTermination(const QString &str)
int strSize = str.size();
QChar strTerminator = str.constData()[strSize];
if (QChar('\0') != strTerminator)
- return QString::fromAscii(
+ return QString::fromLatin1(
"*** Result ('%1') not null-terminated: 0x%2 ***").arg(str)
.arg(strTerminator.unicode(), 4, 16, QChar('0'));
@@ -617,11 +625,11 @@ QString verifyZeroTermination(const QString &str)
const_cast<QChar *>(strData)[strSize] = QChar('x');
if (QChar('x') != str.constData()[strSize]) {
- return QString::fromAscii("*** Failed to replace null-terminator in "
+ return QString::fromLatin1("*** Failed to replace null-terminator in "
"result ('%1') ***").arg(str);
}
if (str != strCopy) {
- return QString::fromAscii( "*** Result ('%1') differs from its copy "
+ return QString::fromLatin1( "*** Result ('%1') differs from its copy "
"after null-terminator was replaced ***").arg(str);
}
const_cast<QChar *>(strData)[strSize] = QChar('\0'); // Restore sanity
@@ -654,11 +662,6 @@ tst_QString::tst_QString()
QTextCodec::setCodecForLocale(QTextCodec::codecForName("ISO 8859-1"));
}
-void tst_QString::cleanup()
-{
- QLocale::setDefault(QString("C"));
-}
-
void tst_QString::remove_uint_uint_data()
{
replace_uint_uint_data();
@@ -1072,9 +1075,8 @@ void tst_QString::isNull()
QString a;
QVERIFY(a.isNull());
- const char *zero = 0;
- a.sprintf( zero );
- QVERIFY(!a.isNull());
+ const char *zero = nullptr;
+ QVERIFY(!QString::asprintf(zero).isNull());
}
QT_WARNING_POP
@@ -1260,75 +1262,66 @@ static inline const void *ptrValue(quintptr v)
return reinterpret_cast<const void *>(v);
}
-void tst_QString::sprintf()
+void tst_QString::asprintf()
{
QString a;
- a.sprintf("COMPARE");
- QCOMPARE(a, QLatin1String("COMPARE"));
- a.sprintf("%%%d",1);
- QCOMPARE(a, QLatin1String("%1"));
- QCOMPARE(a.sprintf("X%dY",2), QLatin1String("X2Y"));
- QCOMPARE(a.sprintf("X%9iY", 50000 ), QLatin1String("X 50000Y"));
- QCOMPARE(a.sprintf("X%-9sY","hello"), QLatin1String("Xhello Y"));
- QCOMPARE(a.sprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y"));
- QCOMPARE(a.sprintf("%lf", 1.23), QLatin1String("1.230000"));
- QCOMPARE(a.sprintf("%lf", 1.23456789), QLatin1String("1.234568"));
- QCOMPARE(a.sprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350"));
- QCOMPARE(a.sprintf("%p", ptrValue(0)), QLatin1String("0x0"));
+ QCOMPARE(QString::asprintf("COMPARE"), QLatin1String("COMPARE"));
+ QCOMPARE(QString::asprintf("%%%d", 1), QLatin1String("%1"));
+ QCOMPARE(QString::asprintf("X%dY",2), QLatin1String("X2Y"));
+ QCOMPARE(QString::asprintf("X%9iY", 50000 ), QLatin1String("X 50000Y"));
+ QCOMPARE(QString::asprintf("X%-9sY","hello"), QLatin1String("Xhello Y"));
+ QCOMPARE(QString::asprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y"));
+ QCOMPARE(QString::asprintf("%lf", 1.23), QLatin1String("1.230000"));
+ QCOMPARE(QString::asprintf("%lf", 1.23456789), QLatin1String("1.234568"));
+ QCOMPARE(QString::asprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350"));
+ QCOMPARE(QString::asprintf("%p", ptrValue(0)), QLatin1String("0x0"));
int i = 6;
long l = -2;
float f = 4.023f;
- QString S1;
- S1.sprintf("%d %ld %f",i,l,f);
- QCOMPARE(S1, QLatin1String("6 -2 4.023000"));
+ QCOMPARE(QString::asprintf("%d %ld %f", i, l, f), QLatin1String("6 -2 4.023000"));
double d = -514.25683;
- S1.sprintf("%f",d);
- QCOMPARE(S1, QLatin1String("-514.256830"));
+ QCOMPARE(QString::asprintf("%f", d), QLatin1String("-514.256830"));
}
-void tst_QString::sprintfS()
+void tst_QString::asprintfS()
{
- QString a;
- QCOMPARE(a.sprintf("%.3s", "Hello" ), QLatin1String("Hel"));
- QCOMPARE(a.sprintf("%10.3s", "Hello" ), QLatin1String(" Hel"));
- QCOMPARE(a.sprintf("%.10s", "Hello" ), QLatin1String("Hello"));
- QCOMPARE(a.sprintf("%10.10s", "Hello" ), QLatin1String(" Hello"));
- QCOMPARE(a.sprintf("%-10.10s", "Hello" ), QLatin1String("Hello "));
- QCOMPARE(a.sprintf("%-10.3s", "Hello" ), QLatin1String("Hel "));
- QCOMPARE(a.sprintf("%-5.5s", "Hello" ), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%.3s", "Hello" ), QLatin1String("Hel"));
+ QCOMPARE(QString::asprintf("%10.3s", "Hello" ), QLatin1String(" Hel"));
+ QCOMPARE(QString::asprintf("%.10s", "Hello" ), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%10.10s", "Hello" ), QLatin1String(" Hello"));
+ QCOMPARE(QString::asprintf("%-10.10s", "Hello" ), QLatin1String("Hello "));
+ QCOMPARE(QString::asprintf("%-10.3s", "Hello" ), QLatin1String("Hel "));
+ QCOMPARE(QString::asprintf("%-5.5s", "Hello" ), QLatin1String("Hello"));
// Check utf8 conversion for %s
- QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));
+ QCOMPARE(QString::asprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));
int n1;
- a.sprintf("%s%n%s", "hello", &n1, "goodbye");
+ QCOMPARE(QString::asprintf("%s%n%s", "hello", &n1, "goodbye"), QString("hellogoodbye"));
QCOMPARE(n1, 5);
- QCOMPARE(a, QString("hellogoodbye"));
qlonglong n2;
- a.sprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz");
+ QCOMPARE(QString::asprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"), QString("foobarwhiz"));
QCOMPARE((int)n2, 6);
- QCOMPARE(a, QString("foobarwhiz"));
{ // %ls
- QCOMPARE(a.sprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel"));
- QCOMPARE(a.sprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel"));
- QCOMPARE(a.sprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello"));
- QCOMPARE(a.sprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello"));
- QCOMPARE(a.sprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello "));
- QCOMPARE(a.sprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel "));
- QCOMPARE(a.sprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel"));
+ QCOMPARE(QString::asprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel"));
+ QCOMPARE(QString::asprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello"));
+ QCOMPARE(QString::asprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello"));
+ QCOMPARE(QString::asprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello "));
+ QCOMPARE(QString::asprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel "));
+ QCOMPARE(QString::asprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello"));
// Check utf16 is preserved for %ls
- QCOMPARE(a.sprintf("%ls",
+ QCOMPARE(QString::asprintf("%ls",
qUtf16Printable("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")),
QLatin1String("\366\344\374\326\304\334\370\346\345\330\306\305"));
int n;
- a.sprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye");
+ QCOMPARE(QString::asprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye"), QLatin1String("hellogoodbye"));
QCOMPARE(n, 5);
- QCOMPARE(a, QLatin1String("hellogoodbye"));
}
}
@@ -2209,12 +2202,12 @@ void tst_QString::toUpper()
// call rvalue-ref while shared (the original mustn't change)
QString copy = s;
- QCOMPARE(qMove(copy).toUpper(), QString("GROSSSTRASSE"));
+ QCOMPARE(std::move(copy).toUpper(), QString("GROSSSTRASSE"));
QCOMPARE(s, QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e"));
// call rvalue-ref version on detached case
copy.clear();
- QCOMPARE(qMove(s).toUpper(), QString("GROSSSTRASSE"));
+ QCOMPARE(std::move(s).toUpper(), QString("GROSSSTRASSE"));
}
QString lower, upper;
@@ -2424,11 +2417,11 @@ void tst_QString::trimmed()
QCOMPARE(a.trimmed(), QLatin1String("a"));
a="Text";
- QCOMPARE(qMove(a).trimmed(), QLatin1String("Text"));
+ QCOMPARE(std::move(a).trimmed(), QLatin1String("Text"));
a=" ";
- QCOMPARE(qMove(a).trimmed(), QLatin1String(""));
+ QCOMPARE(std::move(a).trimmed(), QLatin1String(""));
a=" a ";
- QCOMPARE(qMove(a).trimmed(), QLatin1String("a"));
+ QCOMPARE(std::move(a).trimmed(), QLatin1String("a"));
}
void tst_QString::simplified_data()
@@ -2483,13 +2476,13 @@ void tst_QString::simplified()
// without detaching:
QString copy1 = full;
- QCOMPARE(qMove(full).simplified(), simple);
+ QCOMPARE(std::move(full).simplified(), simple);
QCOMPARE(full, orig_full);
// force a detach
if (!full.isEmpty())
full[0] = full[0];
- QCOMPARE(qMove(full).simplified(), simple);
+ QCOMPARE(std::move(full).simplified(), simple);
}
void tst_QString::insert_data(bool emptyIsNoop)
@@ -3786,7 +3779,7 @@ void tst_QString::startsWith()
QVERIFY( !a.startsWith("C") );
QVERIFY( !a.startsWith("ABCDEF") );
QVERIFY( a.startsWith("") );
- QVERIFY( a.startsWith(QString::null) );
+ QVERIFY( a.startsWith(QString()) );
QVERIFY( a.startsWith('A') );
QVERIFY( a.startsWith(QLatin1Char('A')) );
QVERIFY( a.startsWith(QChar('A')) );
@@ -3813,7 +3806,7 @@ void tst_QString::startsWith()
QVERIFY( !a.startsWith("c", Qt::CaseInsensitive) );
QVERIFY( !a.startsWith("abcdef", Qt::CaseInsensitive) );
QVERIFY( a.startsWith("", Qt::CaseInsensitive) );
- QVERIFY( a.startsWith(QString::null, Qt::CaseInsensitive) );
+ QVERIFY( a.startsWith(QString(), Qt::CaseInsensitive) );
QVERIFY( a.startsWith('a', Qt::CaseInsensitive) );
QVERIFY( a.startsWith('A', Qt::CaseInsensitive) );
QVERIFY( a.startsWith(QLatin1Char('a'), Qt::CaseInsensitive) );
@@ -3852,7 +3845,7 @@ void tst_QString::startsWith()
a = "";
QVERIFY( a.startsWith("") );
- QVERIFY( a.startsWith(QString::null) );
+ QVERIFY( a.startsWith(QString()) );
QVERIFY( !a.startsWith("ABC") );
QVERIFY( a.startsWith(QLatin1String("")) );
@@ -3865,7 +3858,7 @@ void tst_QString::startsWith()
a = QString();
QVERIFY( !a.startsWith("") );
- QVERIFY( a.startsWith(QString::null) );
+ QVERIFY( a.startsWith(QString()) );
QVERIFY( !a.startsWith("ABC") );
QVERIFY( !a.startsWith(QLatin1String("")) );
@@ -3894,7 +3887,7 @@ void tst_QString::endsWith()
QVERIFY( !a.endsWith("C") );
QVERIFY( !a.endsWith("ABCDEF") );
QVERIFY( a.endsWith("") );
- QVERIFY( a.endsWith(QString::null) );
+ QVERIFY( a.endsWith(QString()) );
QVERIFY( a.endsWith('B') );
QVERIFY( a.endsWith(QLatin1Char('B')) );
QVERIFY( a.endsWith(QChar('B')) );
@@ -3921,7 +3914,7 @@ void tst_QString::endsWith()
QVERIFY( !a.endsWith("c", Qt::CaseInsensitive) );
QVERIFY( !a.endsWith("abcdef", Qt::CaseInsensitive) );
QVERIFY( a.endsWith("", Qt::CaseInsensitive) );
- QVERIFY( a.endsWith(QString::null, Qt::CaseInsensitive) );
+ QVERIFY( a.endsWith(QString(), Qt::CaseInsensitive) );
QVERIFY( a.endsWith('b', Qt::CaseInsensitive) );
QVERIFY( a.endsWith('B', Qt::CaseInsensitive) );
QVERIFY( a.endsWith(QLatin1Char('b'), Qt::CaseInsensitive) );
@@ -3963,7 +3956,7 @@ void tst_QString::endsWith()
a = "";
QVERIFY( a.endsWith("") );
- QVERIFY( a.endsWith(QString::null) );
+ QVERIFY( a.endsWith(QString()) );
QVERIFY( !a.endsWith("ABC") );
QVERIFY( !a.endsWith(QLatin1Char(0)) );
QVERIFY( !a.endsWith(QLatin1Char('x')) );
@@ -3975,7 +3968,7 @@ void tst_QString::endsWith()
a = QString();
QVERIFY( !a.endsWith("") );
- QVERIFY( a.endsWith(QString::null) );
+ QVERIFY( a.endsWith(QString()) );
QVERIFY( !a.endsWith("ABC") );
QVERIFY( !a.endsWith(QLatin1String("")) );
@@ -4531,7 +4524,7 @@ void tst_QString::toLatin1Roundtrip()
// try the rvalue version of toLatin1()
QString s = unicodesrc;
- QCOMPARE(qMove(s).toLatin1(), latin1);
+ QCOMPARE(std::move(s).toLatin1(), latin1);
// and verify that the moved-from object can still be used
s = "foo";
@@ -4750,7 +4743,7 @@ void tst_QString::arg()
is all messed up, because Qt Test itself uses QString::arg().
*/
- QLocale::setDefault(QString("de_DE"));
+ TransientDefaultLocale transient(QString("de_DE"));
QString s4( "[%0]" );
QString s5( "[%1]" );
@@ -4835,7 +4828,7 @@ void tst_QString::arg()
QCOMPARE( QString("%1").arg("hello", 10), QLatin1String(" hello") );
QCOMPARE( QString("%1%1").arg("hello"), QLatin1String("hellohello") );
QCOMPARE( QString("%2%1").arg("hello"), QLatin1String("%2hello") );
- QCOMPARE( QString("%1%1").arg(QString::null), QLatin1String("") );
+ QCOMPARE( QString("%1%1").arg(QString()), QLatin1String("") );
QCOMPARE( QString("%2%1").arg(""), QLatin1String("%2") );
QCOMPARE( QString("%2 %L1").arg(12345.6789).arg(12345.6789),
@@ -4898,13 +4891,11 @@ void tst_QString::arg()
QCOMPARE(QString("%1").arg(-1., 3, 'g', -1, QChar('x')), QLatin1String("x-1"));
QCOMPARE(QString("%1").arg(-100., 3, 'g', -1, QChar('x')), QLatin1String("-100"));
- QLocale::setDefault(QString("ar"));
+ transient.revise(QString("ar"));
QCOMPARE( QString("%L1").arg(12345.6789, 10, 'g', 7, QLatin1Char('0')),
QString::fromUtf8("\xd9\xa0\xd9\xa1\xd9\xa2\xd9\xac\xd9\xa3\xd9\xa4\xd9\xa5\xd9\xab\xd9\xa6\xd9\xa8") ); // "٠١٢٬٣٤٥٫٦٨"
QCOMPARE( QString("%L1").arg(123456789, 13, 10, QLatin1Char('0')),
QString("\xd9\xa0\xd9\xa0\xd9\xa1\xd9\xa2\xd9\xa3\xd9\xac\xd9\xa4\xd9\xa5\xd9\xa6\xd9\xac\xd9\xa7\xd9\xa8\xd9\xa9") ); // ٠٠١٢٣٬٤٥٦٬٧٨٩
-
- QLocale::setDefault(QLocale::system());
}
void tst_QString::number()
@@ -4933,9 +4924,7 @@ void tst_QString::doubleOut()
QCOMPARE(QString::number(micro), expect);
QCOMPARE(QString("%1").arg(micro), expect);
{
- QString text;
- text.sprintf("%g", micro);
- QCOMPARE(text, expect);
+ QCOMPARE(QString::asprintf("%g", micro), expect);
}
{
QString text;
@@ -5479,8 +5468,6 @@ void tst_QString::tortureSprintfDouble()
{
const SprintfDoubleData *data = g_sprintf_double_data;
- QString s;
-
for (; data->fmt != 0; ++data) {
double d;
char *buff = (char *)&d;
@@ -5495,7 +5482,7 @@ void tst_QString::tortureSprintfDouble()
for (uint i = 0; i < 8; ++i)
buff[7 - i] = data->bytes[i];
# endif
- s.sprintf(data->fmt, d);
+ const QString s = QString::asprintf(data->fmt, d);
#ifdef QT_NO_FPU // reduced precision when running with hardfloats in qemu
if (d - 0.1 < 1e12)
QSKIP("clib sprintf doesn't fill with 0's on this platform");
@@ -5521,35 +5508,35 @@ void tst_QString::localeAwareCompare_data()
// console.log("\u1111\u1171\u11B6".localeCompare("\ud4db")
// example from Unicode 5.0, section 3.7, definition D70
- QTest::newRow("normalize1") << QString() << QString::fromUtf8("o\xCC\x88") << QString::fromUtf8("\xC3\xB6") << 0;
+ QTest::newRow("normalize1") << QString("en_US") << QString::fromUtf8("o\xCC\x88") << QString::fromUtf8("\xC3\xB6") << 0;
// examples from Unicode 5.0, chapter 3.11
- QTest::newRow("normalize2") << QString() << QString::fromUtf8("\xC3\xA4\xCC\xA3") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
- QTest::newRow("normalize3") << QString() << QString::fromUtf8("a\xCC\x88\xCC\xA3") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
- QTest::newRow("normalize4") << QString() << QString::fromUtf8("\xE1\xBA\xA1\xCC\x88") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
- QTest::newRow("normalize5") << QString() << QString::fromUtf8("\xC3\xA4\xCC\x86") << QString::fromUtf8("a\xCC\x88\xCC\x86") << 0;
- QTest::newRow("normalize6") << QString() << QString::fromUtf8("\xC4\x83\xCC\x88") << QString::fromUtf8("a\xCC\x86\xCC\x88") << 0;
+ QTest::newRow("normalize2") << QString("en_US") << QString::fromUtf8("\xC3\xA4\xCC\xA3") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
+ QTest::newRow("normalize3") << QString("en_US") << QString::fromUtf8("a\xCC\x88\xCC\xA3") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
+ QTest::newRow("normalize4") << QString("en_US") << QString::fromUtf8("\xE1\xBA\xA1\xCC\x88") << QString::fromUtf8("a\xCC\xA3\xCC\x88") << 0;
+ QTest::newRow("normalize5") << QString("en_US") << QString::fromUtf8("\xC3\xA4\xCC\x86") << QString::fromUtf8("a\xCC\x88\xCC\x86") << 0;
+ QTest::newRow("normalize6") << QString("en_US") << QString::fromUtf8("\xC4\x83\xCC\x88") << QString::fromUtf8("a\xCC\x86\xCC\x88") << 0;
// example from Unicode 5.0, chapter 3.12
- QTest::newRow("normalize7") << QString() << QString::fromUtf8("\xE1\x84\x91\xE1\x85\xB1\xE1\x86\xB6") << QString::fromUtf8("\xED\x93\x9B") << 0;
+ QTest::newRow("normalize7") << QString("en_US") << QString::fromUtf8("\xE1\x84\x91\xE1\x85\xB1\xE1\x86\xB6") << QString::fromUtf8("\xED\x93\x9B") << 0;
// examples from UTS 10, Unicode Collation Algorithm
- QTest::newRow("normalize8") << QString() << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("\xC3\x85") << 0;
- QTest::newRow("normalize9") << QString() << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("A\xCC\x8A") << 0;
- QTest::newRow("normalize10") << QString() << QString::fromUtf8("x\xCC\x9B\xCC\xA3") << QString::fromUtf8("x\xCC\xA3\xCC\x9B") << 0;
- QTest::newRow("normalize11") << QString() << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("\xE1\xBB\xA5\xCC\x9B") << 0;
- QTest::newRow("normalize12") << QString() << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("u\xCC\x9B\xCC\xA3") << 0;
- QTest::newRow("normalize13") << QString() << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("\xC6\xB0\xCC\xA3") << 0;
- QTest::newRow("normalize14") << QString() << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("u\xCC\xA3\xCC\x9B") << 0;
+ QTest::newRow("normalize8") << QString("en_US") << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("\xC3\x85") << 0;
+ QTest::newRow("normalize9") << QString("en_US") << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("A\xCC\x8A") << 0;
+ QTest::newRow("normalize10") << QString("en_US") << QString::fromUtf8("x\xCC\x9B\xCC\xA3") << QString::fromUtf8("x\xCC\xA3\xCC\x9B") << 0;
+ QTest::newRow("normalize11") << QString("en_US") << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("\xE1\xBB\xA5\xCC\x9B") << 0;
+ QTest::newRow("normalize12") << QString("en_US") << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("u\xCC\x9B\xCC\xA3") << 0;
+ QTest::newRow("normalize13") << QString("en_US") << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("\xC6\xB0\xCC\xA3") << 0;
+ QTest::newRow("normalize14") << QString("en_US") << QString::fromUtf8("\xE1\xBB\xB1") << QString::fromUtf8("u\xCC\xA3\xCC\x9B") << 0;
// examples from UAX 15, Unicode Normalization Forms
- QTest::newRow("normalize15") << QString() << QString::fromUtf8("\xC3\x87") << QString::fromUtf8("C\xCC\xA7") << 0;
- QTest::newRow("normalize16") << QString() << QString::fromUtf8("q\xCC\x87\xCC\xA3") << QString::fromUtf8("q\xCC\xA3\xCC\x87") << 0;
- QTest::newRow("normalize17") << QString() << QString::fromUtf8("\xEA\xB0\x80") << QString::fromUtf8("\xE1\x84\x80\xE1\x85\xA1") << 0;
- QTest::newRow("normalize18") << QString() << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("A\xCC\x8A") << 0;
- QTest::newRow("normalize19") << QString() << QString::fromUtf8("\xE2\x84\xA6") << QString::fromUtf8("\xCE\xA9") << 0;
- QTest::newRow("normalize20") << QString() << QString::fromUtf8("\xC3\x85") << QString::fromUtf8("A\xCC\x8A") << 0;
- QTest::newRow("normalize21") << QString() << QString::fromUtf8("\xC3\xB4") << QString::fromUtf8("o\xCC\x82") << 0;
- QTest::newRow("normalize22") << QString() << QString::fromUtf8("\xE1\xB9\xA9") << QString::fromUtf8("s\xCC\xA3\xCC\x87") << 0;
- QTest::newRow("normalize23") << QString() << QString::fromUtf8("\xE1\xB8\x8B\xCC\xA3") << QString::fromUtf8("d\xCC\xA3\xCC\x87") << 0;
- QTest::newRow("normalize24") << QString() << QString::fromUtf8("\xE1\xB8\x8B\xCC\xA3") << QString::fromUtf8("\xE1\xB8\x8D\xCC\x87") << 0;
- QTest::newRow("normalize25") << QString() << QString::fromUtf8("q\xCC\x87\xCC\xA3") << QString::fromUtf8("q\xCC\xA3\xCC\x87") << 0;
+ QTest::newRow("normalize15") << QString("en_US") << QString::fromUtf8("\xC3\x87") << QString::fromUtf8("C\xCC\xA7") << 0;
+ QTest::newRow("normalize16") << QString("en_US") << QString::fromUtf8("q\xCC\x87\xCC\xA3") << QString::fromUtf8("q\xCC\xA3\xCC\x87") << 0;
+ QTest::newRow("normalize17") << QString("en_US") << QString::fromUtf8("\xEA\xB0\x80") << QString::fromUtf8("\xE1\x84\x80\xE1\x85\xA1") << 0;
+ QTest::newRow("normalize18") << QString("en_US") << QString::fromUtf8("\xE2\x84\xAB") << QString::fromUtf8("A\xCC\x8A") << 0;
+ QTest::newRow("normalize19") << QString("en_US") << QString::fromUtf8("\xE2\x84\xA6") << QString::fromUtf8("\xCE\xA9") << 0;
+ QTest::newRow("normalize20") << QString("en_US") << QString::fromUtf8("\xC3\x85") << QString::fromUtf8("A\xCC\x8A") << 0;
+ QTest::newRow("normalize21") << QString("en_US") << QString::fromUtf8("\xC3\xB4") << QString::fromUtf8("o\xCC\x82") << 0;
+ QTest::newRow("normalize22") << QString("en_US") << QString::fromUtf8("\xE1\xB9\xA9") << QString::fromUtf8("s\xCC\xA3\xCC\x87") << 0;
+ QTest::newRow("normalize23") << QString("en_US") << QString::fromUtf8("\xE1\xB8\x8B\xCC\xA3") << QString::fromUtf8("d\xCC\xA3\xCC\x87") << 0;
+ QTest::newRow("normalize24") << QString("en_US") << QString::fromUtf8("\xE1\xB8\x8B\xCC\xA3") << QString::fromUtf8("\xE1\xB8\x8D\xCC\x87") << 0;
+ QTest::newRow("normalize25") << QString("en_US") << QString::fromUtf8("q\xCC\x87\xCC\xA3") << QString::fromUtf8("q\xCC\xA3\xCC\x87") << 0;
}
@@ -6449,32 +6436,24 @@ void tst_QString::QCharRefDetaching() const
void tst_QString::sprintfZU() const
{
{
- QString string;
size_t s = 6;
- string.sprintf("%zu", s);
- QCOMPARE(string, QString::fromLatin1("6"));
+ QCOMPARE(QString::asprintf("%zu", s), QString::fromLatin1("6"));
}
{
- QString string;
- string.sprintf("%s\n", "foo");
- QCOMPARE(string, QString::fromLatin1("foo\n"));
+ QCOMPARE(QString::asprintf("%s\n", "foo"), QString::fromLatin1("foo\n"));
}
{
/* This code crashed. I don't know how to reduce it further. In other words,
* both %zu and %s needs to be present. */
size_t s = 6;
- QString string;
- string.sprintf("%zu%s", s, "foo");
- QCOMPARE(string, QString::fromLatin1("6foo"));
+ QCOMPARE(QString::asprintf("%zu%s", s, "foo"), QString::fromLatin1("6foo"));
}
{
size_t s = 6;
- QString string;
- string.sprintf("%zu %s\n", s, "foo");
- QCOMPARE(string, QString::fromLatin1("6 foo\n"));
+ QCOMPARE(QString::asprintf("%zu %s\n", s, "foo"), QString::fromLatin1("6 foo\n"));
}
}
@@ -6594,14 +6573,14 @@ void tst_QString::arg_locale()
QLocale l(QLocale::English, QLocale::UnitedKingdom);
QString str("*%L1*%L2*");
- QLocale::setDefault(l);
+ TransientDefaultLocale transient(l);
QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123,456*1,234.56*"));
l.setNumberOptions(QLocale::OmitGroupSeparator);
- QLocale::setDefault(l);
+ transient.revise(l);
QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*"));
- QLocale::setDefault(QLocale::C);
+ transient.revise(QLocale::C);
QCOMPARE(str.arg(123456).arg(1234.56), QString::fromLatin1("*123456*1234.56*"));
}
@@ -6615,7 +6594,7 @@ void tst_QString::toUpperLower_icu()
QCOMPARE(s.toUpper(), QString::fromLatin1("I"));
QCOMPARE(s.toLower(), QString::fromLatin1("i"));
- QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey));
+ TransientDefaultLocale transient(QLocale(QLocale::Turkish, QLocale::Turkey));
QCOMPARE(s.toUpper(), QString::fromLatin1("I"));
QCOMPARE(s.toLower(), QString::fromLatin1("i"));
@@ -6639,12 +6618,10 @@ void tst_QString::toUpperLower_icu()
// nothing should happen here
QCOMPARE(l.toLower(sup), sup);
QCOMPARE(l.toLower(QString::fromLatin1("i")), QString::fromLatin1("i"));
-
- // the cleanup function will restore the default locale
}
#endif
-#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA)
+#if !defined(QT_NO_UNICODE_LITERAL)
// Only tested on c++0x compliant compiler or gcc
void tst_QString::literals()
{
diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
index a3aec4c299..42bdf62a93 100644
--- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
@@ -43,7 +43,9 @@ private slots:
void removeDuplicates();
void removeDuplicates_data();
void contains();
+ void indexOf_data();
void indexOf();
+ void lastIndexOf_data();
void lastIndexOf();
void indexOf_regExp();
@@ -141,20 +143,52 @@ void tst_QStringList::lastIndexOf_regExp()
}
+void tst_QStringList::indexOf_data()
+{
+ QTest::addColumn<QString>("search");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("expectedResult");
+
+ QTest::newRow("harald") << "harald" << 0 << 0;
+ QTest::newRow("trond") << "trond" << 0 << 1;
+ QTest::newRow("vohi") << "vohi" << 0 << 2;
+ QTest::newRow("harald-1") << "harald" << 1 << 3;
+
+ QTest::newRow("hans") << "hans" << 0 << -1;
+ QTest::newRow("trond-1") << "trond" << 2 << -1;
+ QTest::newRow("harald-2") << "harald" << -1 << 3;
+ QTest::newRow("vohi-1") << "vohi" << -3 << 2;
+}
+
void tst_QStringList::indexOf()
{
QStringList list;
list << "harald" << "trond" << "vohi" << "harald";
- QCOMPARE(list.indexOf("harald"), 0);
- QCOMPARE(list.indexOf("trond"), 1);
- QCOMPARE(list.indexOf("vohi"), 2);
- QCOMPARE(list.indexOf("harald", 1), 3);
+ QFETCH(QString, search);
+ QFETCH(int, from);
+ QFETCH(int, expectedResult);
- QCOMPARE(list.indexOf("hans"), -1);
- QCOMPARE(list.indexOf("trond", 2), -1);
- QCOMPARE(list.indexOf("harald", -1), 3);
- QCOMPARE(list.indexOf("vohi", -3), 2);
+ QCOMPARE(list.indexOf(search, from), expectedResult);
+ QCOMPARE(list.indexOf(QStringView(search), from), expectedResult);
+ QCOMPARE(list.indexOf(QLatin1String(search.toLatin1()), from), expectedResult);
+}
+
+void tst_QStringList::lastIndexOf_data()
+{
+ QTest::addColumn<QString>("search");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("expectedResult");
+
+ QTest::newRow("harald") << "harald" << -1 << 3;
+ QTest::newRow("trond") << "trond" << -1 << 1;
+ QTest::newRow("vohi") << "vohi" << -1 << 2;
+ QTest::newRow("harald-1") << "harald" << 2 << 0;
+
+ QTest::newRow("hans") << "hans" << -1 << -1;
+ QTest::newRow("vohi-1") << "vohi" << 1 << -1;
+ QTest::newRow("vohi-2") << "vohi" << -1 << 2;
+ QTest::newRow("vohi-3") << "vohi" << -3 << -1;
}
void tst_QStringList::lastIndexOf()
@@ -162,15 +196,13 @@ void tst_QStringList::lastIndexOf()
QStringList list;
list << "harald" << "trond" << "vohi" << "harald";
- QCOMPARE(list.lastIndexOf("harald"), 3);
- QCOMPARE(list.lastIndexOf("trond"), 1);
- QCOMPARE(list.lastIndexOf("vohi"), 2);
- QCOMPARE(list.lastIndexOf("harald", 2), 0);
+ QFETCH(QString, search);
+ QFETCH(int, from);
+ QFETCH(int, expectedResult);
- QCOMPARE(list.lastIndexOf("hans"), -1);
- QCOMPARE(list.lastIndexOf("vohi", 1), -1);
- QCOMPARE(list.lastIndexOf("vohi", -1), 2);
- QCOMPARE(list.lastIndexOf("vohi", -3), -1);
+ QCOMPARE(list.lastIndexOf(search, from), expectedResult);
+ QCOMPARE(list.lastIndexOf(QStringView(search), from), expectedResult);
+ QCOMPARE(list.lastIndexOf(QLatin1String(search.toLatin1()), from), expectedResult);
}
void tst_QStringList::filter()
diff --git a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp
index 8a55f54449..2d577bb0ab 100644
--- a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp
+++ b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp
@@ -100,6 +100,11 @@ void tst_QStringMatcher::indexIn()
matcher.setPattern(needle);
QCOMPARE(matcher.indexIn(haystack, from), indexIn);
+
+ const auto needleSV = QStringView(needle);
+ QStringMatcher matcherSV(needleSV);
+
+ QCOMPARE(matcherSV.indexIn(QStringView(haystack), from), indexIn);
}
void tst_QStringMatcher::setCaseSensitivity_data()
@@ -128,6 +133,7 @@ void tst_QStringMatcher::setCaseSensitivity()
matcher.setCaseSensitivity(static_cast<Qt::CaseSensitivity> (cs));
QCOMPARE(matcher.indexIn(haystack, from), indexIn);
+ QCOMPARE(matcher.indexIn(QStringView(haystack), from), indexIn);
}
void tst_QStringMatcher::assignOperator()
diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
index 3e5724213e..3403c5bf7f 100644
--- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp
+++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
@@ -95,8 +95,9 @@ void tst_QTime::addSecs_data()
QTest::newRow("Data0") << QTime(0,0,0) << 200 << QTime(0,3,20);
QTest::newRow("Data1") << QTime(0,0,0) << 20 << QTime(0,0,20);
- QTest::newRow("overflow") << QTime(0,0,0) << (INT_MAX / 1000 + 1)
- << QTime(0,0,0).addSecs((INT_MAX / 1000 + 1) % 86400);
+ QTest::newRow("overflow")
+ << QTime(0,0,0) << (INT_MAX / 1000 + 1)
+ << QTime::fromMSecsSinceStartOfDay(((INT_MAX / 1000 + 1) % 86400) * 1000);
}
void tst_QTime::addSecs()
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index d335dae7bc..4160a00f71 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -480,11 +480,10 @@ void tst_QTimeZone::transitionEachZone_data()
{ 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia
};
- QString name;
const auto zones = QTimeZone::availableTimeZoneIds();
for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) {
for (const QByteArray &zone : zones) {
- name.sprintf("%s@%d", zone.constData(), table[k].year);
+ const QString name = QString::asprintf("%s@%d", zone.constData(), table[k].year);
QTest::newRow(name.toUtf8().constData())
<< zone
<< table[k].baseSecs
@@ -508,8 +507,7 @@ void tst_QTimeZone::transitionEachZone()
#ifdef USING_WIN_TZ
// See QTBUG-64985: MS's TZ APIs' misdescription of Europe/Samara leads
// to mis-disambiguation of its fall-back here.
- if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7
- && zone == "Europe/Samara" && i == -3) {
+ if (zone == "Europe/Samara" && i == -3) {
continue;
}
#endif
@@ -540,6 +538,13 @@ void tst_QTimeZone::checkOffset_data()
int year, month, day, hour, min, sec;
int std, dst;
} table[] = {
+ // Zone with no transitions (QTBUG-74614, QTBUG-74666, when TZ backend uses minimal data)
+ { "Etc/UTC", "epoch", 1970, 1, 1, 0, 0, 0, 0, 0 },
+ { "Etc/UTC", "pre_int32", 1901, 12, 13, 20, 45, 51, 0, 0 },
+ { "Etc/UTC", "post_int32", 2038, 1, 19, 3, 14, 9, 0, 0 },
+ { "Etc/UTC", "post_uint32", 2106, 2, 7, 6, 28, 17, 0, 0 },
+ { "Etc/UTC", "initial", -292275056, 5, 16, 16, 47, 5, 0, 0 },
+ { "Etc/UTC", "final", 292278994, 8, 17, 7, 12, 55, 0, 0 },
// Kiev: regression test for QTBUG-64122 (on MS):
{ "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
{ "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
@@ -552,6 +557,8 @@ void tst_QTimeZone::checkOffset_data()
<< QDateTime(QDate(entry.year, entry.month, entry.day),
QTime(entry.hour, entry.min, entry.sec), zone)
<< entry.dst + entry.std << entry.std << entry.dst;
+ } else {
+ qWarning("Skipping %s@%s test as zone is invalid", entry.zone, entry.nick);
}
}
}
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index a7faeb5ca5..2278e0ba13 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -206,6 +206,9 @@ private slots:
void assignmentInt() const;
void assignmentMovable() const;
void assignmentCustom() const;
+ void assignFromInitializerListInt() const;
+ void assignFromInitializerListMovable() const;
+ void assignFromInitializerListCustom() const;
void addInt() const;
void addMovable() const;
void addCustom() const;
@@ -330,6 +333,7 @@ private:
template<typename T> void copyConstructor() const;
template<typename T> void add() const;
template<typename T> void append() const;
+ template<typename T> void assignFromInitializerList() const;
template<typename T> void capacity() const;
template<typename T> void clear() const;
template<typename T> void count() const;
@@ -543,6 +547,44 @@ void tst_QVector::assignmentCustom() const
}
template<typename T>
+void tst_QVector::assignFromInitializerList() const
+{
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ T val1(SimpleValue<T>::at(1));
+ T val2(SimpleValue<T>::at(2));
+ T val3(SimpleValue<T>::at(3));
+
+ QVector<T> v1 = {val1, val2, val3};
+ QCOMPARE(v1, QVector<T>() << val1 << val2 << val3);
+ QCOMPARE(v1, (QVector<T> {val1, val2, val3}));
+
+ v1 = {};
+ QCOMPARE(v1.size(), 0);
+#else
+ QSKIP("This test requires support for C++11 initializer lists.");
+#endif
+}
+
+void tst_QVector::assignFromInitializerListInt() const
+{
+ assignFromInitializerList<int>();
+}
+
+void tst_QVector::assignFromInitializerListMovable() const
+{
+ const int instancesCount = Movable::counter.loadAcquire();
+ assignFromInitializerList<Movable>();
+ QCOMPARE(instancesCount, Movable::counter.loadAcquire());
+}
+
+void tst_QVector::assignFromInitializerListCustom() const
+{
+ const int instancesCount = Custom::counter.loadAcquire();
+ assignFromInitializerList<Custom>();
+ QCOMPARE(instancesCount, Custom::counter.loadAcquire());
+}
+
+template<typename T>
void tst_QVector::add() const
{
{
diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
index 05579dce6e..aaf40a9c2e 100644
--- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
+++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
@@ -436,7 +436,7 @@ void tst_QVersionNumber::normalized()
QFETCH(QVersionNumber, expected);
QCOMPARE(version.normalized(), expected);
- QCOMPARE(qMove(version).normalized(), expected);
+ QCOMPARE(std::move(version).normalized(), expected);
}
void tst_QVersionNumber::isNormalized_data()
@@ -590,21 +590,21 @@ void tst_QVersionNumber::moveSemantics()
// QVersionNumber(QVersionNumber &&)
{
QVersionNumber v1(1, 2, 3);
- QVersionNumber v2 = qMove(v1);
+ QVersionNumber v2 = std::move(v1);
QCOMPARE(v2, QVersionNumber(1, 2, 3));
}
// QVersionNumber &operator=(QVersionNumber &&)
{
QVersionNumber v1(1, 2, 3);
QVersionNumber v2;
- v2 = qMove(v1);
+ v2 = std::move(v1);
QCOMPARE(v2, QVersionNumber(1, 2, 3));
}
// QVersionNumber(QVector<int> &&)
{
QVector<int> segments = QVector<int>() << 1 << 2 << 3;
QVersionNumber v1(segments);
- QVersionNumber v2(qMove(segments));
+ QVersionNumber v2(std::move(segments));
QVERIFY(!v1.isNull());
QVERIFY(!v2.isNull());
QCOMPARE(v1, v2);
@@ -620,7 +620,7 @@ void tst_QVersionNumber::moveSemantics()
QVERIFY(!v.isNull());
QVERIFY(!nv.isNull());
QVERIFY(nv.isNormalized());
- nv = qMove(v).normalized();
+ nv = std::move(v).normalized();
QVERIFY(!nv.isNull());
QVERIFY(nv.isNormalized());
}
@@ -632,7 +632,7 @@ void tst_QVersionNumber::moveSemantics()
segments = v.segments();
QVERIFY(!v.isNull());
QVERIFY(!segments.empty());
- segments = qMove(v).segments();
+ segments = std::move(v).segments();
QVERIFY(!segments.empty());
}
#endif
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index 2a975e67d1..c6da33cce0 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -46,6 +46,7 @@ SUBDIRS=\
qringbuffer \
qscopedpointer \
qscopedvaluerollback \
+ qscopeguard \
qset \
qsharedpointer \
qsize \