summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp4
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/qtextcodec.pro4
-rw-r--r--tests/auto/corelib/corelib.pro2
-rw-r--r--tests/auto/corelib/global/qtendian/qtendian.pro4
-rw-r--r--tests/auto/corelib/io/io.pro2
-rw-r--r--tests/auto/corelib/io/largefile/largefile.pro2
-rw-r--r--tests/auto/corelib/io/largefile/tst_largefile.cpp16
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp45
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp61
-rw-r--r--tests/auto/corelib/io/qdiriterator/qdiriterator.pro2
-rw-r--r--tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp27
-rw-r--r--tests/auto/corelib/io/qfile/qfile.pro7
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro1
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp93
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp97
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp11
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp6
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp8
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/qprocess.pri3
-rw-r--r--tests/auto/corelib/io/qprocess/qprocess.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp5
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp4
-rw-r--r--tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp11
-rw-r--r--tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp151
-rw-r--r--tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp14
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp26
-rw-r--r--tests/auto/corelib/io/qstorageinfo/BLACKLIST2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp4
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp11
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp22
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp24
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp40
-rw-r--r--tests/auto/corelib/kernel/kernel.pro3
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp2
-rw-r--r--tests/auto/corelib/kernel/qelapsedtimer/qelapsedtimer.pro (renamed from tests/auto/corelib/tools/qelapsedtimer/qelapsedtimer.pro)0
-rw-r--r--tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp (renamed from tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp)0
-rw-r--r--tests/auto/corelib/kernel/qeventloop/qeventloop.pro2
-rw-r--r--tests/auto/corelib/kernel/qmetatype/qmetatype.pro4
-rw-r--r--tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro3
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp27
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp7
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp101
-rw-r--r--tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.binbin40 -> 40 bytes
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib/lib.pro1
-rw-r--r--tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro1
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp17
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp5
-rw-r--r--tests/auto/corelib/thread/qmutex/qmutex.pro1
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp1065
-rw-r--r--tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp6
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp20
-rw-r--r--tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp2
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp10
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp14
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp3
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp6
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp17
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp166
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp68
-rw-r--r--tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp30
-rw-r--r--tests/auto/corelib/tools/qline/tst_qline.cpp77
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp22
-rw-r--r--tests/auto/corelib/tools/qregexp/tst_qregexp.cpp20
-rw-r--r--tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp26
-rw-r--r--tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp4
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/externaltests.cpp4
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp143
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp57
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/.gitignore1
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/qstringapisymmetry.pro5
-rw-r--r--tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp262
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp14
-rw-r--r--tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp13
-rw-r--r--tests/auto/corelib/tools/qstringref/tst_qstringref.cpp43
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp4
-rw-r--r--tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp13
-rw-r--r--tests/auto/corelib/tools/tools.pro2
81 files changed, 1891 insertions, 1121 deletions
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 320e0095d3..a8d64f1cd9 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -62,8 +62,8 @@ private slots:
void tst_QParallelAnimationGroup::initTestCase()
{
qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
- // give the mac/wince app start event queue time to clear
+#if defined(Q_OS_DARWIN)
+ // give the Darwin app start event queue time to clear
QTest::qWait(1000);
#endif
}
diff --git a/tests/auto/corelib/codecs/qtextcodec/qtextcodec.pro b/tests/auto/corelib/codecs/qtextcodec/qtextcodec.pro
index 9f2e4f9c92..302d887fc7 100644
--- a/tests/auto/corelib/codecs/qtextcodec/qtextcodec.pro
+++ b/tests/auto/corelib/codecs/qtextcodec/qtextcodec.pro
@@ -1,4 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = test
-
-!wince: SUBDIRS += echo
+SUBDIRS = test echo
diff --git a/tests/auto/corelib/corelib.pro b/tests/auto/corelib/corelib.pro
index 4d88b04828..169579bd6b 100644
--- a/tests/auto/corelib/corelib.pro
+++ b/tests/auto/corelib/corelib.pro
@@ -3,7 +3,7 @@ TEMPLATE=subdirs
SUBDIRS = \
kernel
-!ios: SUBDIRS += \
+!uikit: SUBDIRS += \
animation \
codecs \
global \
diff --git a/tests/auto/corelib/global/qtendian/qtendian.pro b/tests/auto/corelib/global/qtendian/qtendian.pro
index 2b0af4fa4c..214c706ca5 100644
--- a/tests/auto/corelib/global/qtendian/qtendian.pro
+++ b/tests/auto/corelib/global/qtendian/qtendian.pro
@@ -2,7 +2,3 @@ CONFIG += testcase
TARGET = tst_qtendian
QT = core testlib
SOURCES = tst_qtendian.cpp
-wince* { # QTBUG-37194 , internal compiler errors with MSVC2008 for Windows CE
- QMAKE_CFLAGS_RELEASE -= -O2
- QMAKE_CXXFLAGS_RELEASE -= -O2
-}
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro
index 29717b3a1c..24c762ed84 100644
--- a/tests/auto/corelib/io/io.pro
+++ b/tests/auto/corelib/io/io.pro
@@ -35,7 +35,7 @@ SUBDIRS=\
qurlquery \
qwinoverlappedionotifier \
-!win32|wince* {
+!win32 {
SUBDIRS -=\
qwinoverlappedionotifier
}
diff --git a/tests/auto/corelib/io/largefile/largefile.pro b/tests/auto/corelib/io/largefile/largefile.pro
index caef116684..6c1bb8d7ea 100644
--- a/tests/auto/corelib/io/largefile/largefile.pro
+++ b/tests/auto/corelib/io/largefile/largefile.pro
@@ -2,5 +2,3 @@ CONFIG += testcase
TARGET = tst_largefile
QT = core testlib
SOURCES = tst_largefile.cpp
-
-wince: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp
diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp
index e448093062..a19a5ce58d 100644
--- a/tests/auto/corelib/io/largefile/tst_largefile.cpp
+++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp
@@ -39,18 +39,12 @@
#include <cstdio>
#ifdef Q_OS_WIN
-
-#include <windows.h>
-
-#ifndef Q_OS_WINCE
-#include <io.h>
-#endif
-
-#ifndef FSCTL_SET_SPARSE
+# include <qt_windows.h>
+# include <io.h>
+# ifndef FSCTL_SET_SPARSE
// MinGW doesn't define this.
-#define FSCTL_SET_SPARSE (0x900C4)
-#endif
-
+# define FSCTL_SET_SPARSE (0x900C4)
+# endif
#endif // Q_OS_WIN
class tst_LargeFile
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index 447cf2845e..5b03b35780 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -35,8 +35,6 @@
#include <QtGui/QPainter>
#include <QtGui/QPen>
-#include "../../../qtest-config.h"
-
class tst_QDataStream : public QObject
{
Q_OBJECT
@@ -65,7 +63,7 @@ private slots:
void stream_QByteArray_data();
void stream_QByteArray();
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void stream_QCursor_data();
void stream_QCursor();
#endif
@@ -88,10 +86,8 @@ private slots:
void stream_QPen_data();
void stream_QPen();
-#ifndef Q_OS_WINCE
void stream_QPixmap_data();
void stream_QPixmap();
-#endif
void stream_QPoint_data();
void stream_QPoint();
@@ -123,10 +119,8 @@ private slots:
void stream_qint64_data();
void stream_qint64();
-#ifndef Q_OS_WINCE
void stream_QIcon_data();
void stream_QIcon();
-#endif
void stream_QEasingCurve_data();
void stream_QEasingCurve();
@@ -193,7 +187,7 @@ private:
void writeQBrush(QDataStream *s);
void writeQColor(QDataStream *s);
void writeQByteArray(QDataStream *s);
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void writeQCursor(QDataStream *s);
#endif
void writeQWaitCursor(QDataStream *s);
@@ -222,7 +216,7 @@ private:
void readQBrush(QDataStream *s);
void readQColor(QDataStream *s);
void readQByteArray(QDataStream *s);
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void readQCursor(QDataStream *s);
#endif
void readQDate(QDataStream *s);
@@ -1023,7 +1017,7 @@ void tst_QDataStream::readQByteArray(QDataStream *s)
}
// ************************************
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
static QCursor qCursorData(int index)
{
switch (index) {
@@ -1042,21 +1036,21 @@ static QCursor qCursorData(int index)
}
#endif
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QDataStream::stream_QCursor_data()
{
stream_data(9);
}
#endif
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QDataStream::stream_QCursor()
{
STREAM_IMPL(QCursor);
}
#endif
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QDataStream::writeQCursor(QDataStream *s)
{
QCursor d5(qCursorData(dataIndex(QTest::currentDataTag())));
@@ -1064,7 +1058,7 @@ void tst_QDataStream::writeQCursor(QDataStream *s)
}
#endif
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QDataStream::readQCursor(QDataStream *s)
{
QCursor test(qCursorData(dataIndex(QTest::currentDataTag())));
@@ -1543,24 +1537,16 @@ void tst_QDataStream::readQPen(QDataStream *s)
// pixmap testing is currently limited to one pixmap only.
//
-#ifndef Q_OS_WINCE
-// Test depends on more memory than available on Qt/CE
void tst_QDataStream::stream_QPixmap_data()
{
stream_data(1);
}
-#endif
-#ifndef Q_OS_WINCE
-// Test depends on more memory than available on Qt/CE
void tst_QDataStream::stream_QPixmap()
{
STREAM_IMPL(QPixmap);
}
-#endif
-#ifndef Q_OS_WINCE
-// Test depends on more memory than available on Qt/CE
void tst_QDataStream::stream_QIcon_data()
{
stream_data(1);
@@ -1570,7 +1556,6 @@ void tst_QDataStream::stream_QIcon()
{
STREAM_IMPL(QIcon);
}
-#endif
void tst_QDataStream::writeQPixmap(QDataStream *s)
{
@@ -1845,7 +1830,7 @@ static QRegion qRegionData(int index)
case 4: return QRegion(100, -100, 2048, 4096, QRegion::Rectangle);
case 5: return QRegion(-100, 100, 4096, 2048, QRegion::Rectangle);
case 6: return QRegion(0, 0, 0, 0, QRegion::Ellipse);
-#if (!defined(Q_OS_UNIX) && !defined(Q_OS_WINCE)) // all our Unix platforms use X regions.
+#if !defined(Q_OS_UNIX) // all our Unix platforms use X regions.
case 7: return QRegion(1, 2, 300, 400, QRegion::Ellipse);
case 8: return QRegion(100, 100, 1024, 768, QRegion::Ellipse);
case 9: return QRegion(-100, -100, 1024, 1024, QRegion::Ellipse);
@@ -2497,12 +2482,10 @@ void tst_QDataStream::status_charptr_QByteArray_data()
QTest::addColumn<int>("expectedStatus");
QTest::addColumn<QByteArray>("expectedString");
-#if !defined(Q_OS_WINCE)
QByteArray oneMbMinus1(1024 * 1024 - 1, '\0');
for (int i = 0; i < oneMbMinus1.size(); ++i)
oneMbMinus1[i] = 0x1 | (8 * ((uchar)i / 9));
QByteArray threeMbMinus1 = oneMbMinus1 + 'j' + oneMbMinus1 + 'k' + oneMbMinus1;
-#endif
// ok
QTest::newRow("size 0") << QByteArray("\x00\x00\x00\x00", 4) << (int) QDataStream::Ok << QByteArray();
@@ -2511,14 +2494,12 @@ void tst_QDataStream::status_charptr_QByteArray_data()
QTest::newRow("size 3") << QByteArray("\x00\x00\x00\x03jkl", 7) << (int) QDataStream::Ok << QByteArray("jkl");
QTest::newRow("size 4") << QByteArray("\x00\x00\x00\x04jklm", 8) << (int) QDataStream::Ok << QByteArray("jklm");
QTest::newRow("size 4j") << QByteArray("\x00\x00\x00\x04jklmj", 8) << (int) QDataStream::Ok << QByteArray("jklm");
-#if !defined(Q_OS_WINCE)
QTest::newRow("size 1MB-1") << QByteArray("\x00\x0f\xff\xff", 4) + oneMbMinus1 + QByteArray("j") << (int) QDataStream::Ok << oneMbMinus1;
QTest::newRow("size 1MB") << QByteArray("\x00\x10\x00\x00", 4) + oneMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << oneMbMinus1 + "j";
QTest::newRow("size 1MB+1") << QByteArray("\x00\x10\x00\x01", 4) + oneMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << oneMbMinus1 + "jk";
QTest::newRow("size 3MB-1") << QByteArray("\x00\x2f\xff\xff", 4) + threeMbMinus1 + QByteArray("j") << (int) QDataStream::Ok << threeMbMinus1;
QTest::newRow("size 3MB") << QByteArray("\x00\x30\x00\x00", 4) + threeMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << threeMbMinus1 + "j";
QTest::newRow("size 3MB+1") << QByteArray("\x00\x30\x00\x01", 4) + threeMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << threeMbMinus1 + "jk";
-#endif
// past end
QTest::newRow("empty") << QByteArray() << (int) QDataStream::ReadPastEnd << QByteArray();
@@ -2531,12 +2512,10 @@ void tst_QDataStream::status_charptr_QByteArray_data()
QTest::newRow("badsize 2") << QByteArray("\x00\x00\x00\x02j", 5) << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("badsize 3") << QByteArray("\x00\x00\x00\x03jk", 6) << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("badsize 4") << QByteArray("\x00\x00\x00\x04jkl", 7) << (int) QDataStream::ReadPastEnd << QByteArray();
-#if !defined(Q_OS_WINCE)
QTest::newRow("badsize 1MB") << QByteArray("\x00\x10\x00\x00", 4) + oneMbMinus1 << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("badsize 1MB+1") << QByteArray("\x00\x10\x00\x01", 4) + oneMbMinus1 + QByteArray("j") << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("badsize 3MB") << QByteArray("\x00\x30\x00\x00", 4) + threeMbMinus1 << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("badsize 3MB+1") << QByteArray("\x00\x30\x00\x01", 4) + threeMbMinus1 + QByteArray("j") << (int) QDataStream::ReadPastEnd << QByteArray();
-#endif
QTest::newRow("size -1") << QByteArray("\xff\xff\xff\xff", 4) << (int) QDataStream::ReadPastEnd << QByteArray();
QTest::newRow("size -2") << QByteArray("\xff\xff\xff\xfe", 4) << (int) QDataStream::ReadPastEnd << QByteArray();
}
@@ -2601,7 +2580,6 @@ void tst_QDataStream::status_QString_data()
QTest::addColumn<int>("expectedStatus");
QTest::addColumn<QString>("expectedString");
-#if !defined(Q_OS_WINCE)
QString oneMbMinus1;
oneMbMinus1.resize(1024 * 1024 - 1);
for (int i = 0; i < oneMbMinus1.size(); ++i)
@@ -2610,7 +2588,6 @@ void tst_QDataStream::status_QString_data()
QByteArray threeMbMinus1Data = qstring2qbytearray(threeMbMinus1);
QByteArray oneMbMinus1Data = qstring2qbytearray(oneMbMinus1);
-#endif
// ok
QTest::newRow("size 0") << QByteArray("\x00\x00\x00\x00", 4) << (int) QDataStream::Ok << QString();
@@ -2619,14 +2596,12 @@ void tst_QDataStream::status_QString_data()
QTest::newRow("size 3") << QByteArray("\x00\x00\x00\x06\x00j\x00k\x00l", 10) << (int) QDataStream::Ok << QString("jkl");
QTest::newRow("size 4") << QByteArray("\x00\x00\x00\x08\x00j\x00k\x00l\x00m", 12) << (int) QDataStream::Ok << QString("jklm");
QTest::newRow("size 4j") << QByteArray("\x00\x00\x00\x08\x00j\x00k\x00l\x00mjj", 14) << (int) QDataStream::Ok << QString("jklm");
-#if !defined(Q_OS_WINCE)
QTest::newRow("size 1MB-1") << QByteArray("\x00\x1f\xff\xfe", 4) + oneMbMinus1Data + QByteArray("jj") << (int) QDataStream::Ok << oneMbMinus1;
QTest::newRow("size 1MB") << QByteArray("\x00\x20\x00\x00", 4) + oneMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << oneMbMinus1 + "j";
QTest::newRow("size 1MB+1") << QByteArray("\x00\x20\x00\x02", 4) + oneMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << oneMbMinus1 + "jk";
QTest::newRow("size 3MB-1") << QByteArray("\x00\x5f\xff\xfe", 4) + threeMbMinus1Data + QByteArray("jj") << (int) QDataStream::Ok << threeMbMinus1;
QTest::newRow("size 3MB") << QByteArray("\x00\x60\x00\x00", 4) + threeMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << threeMbMinus1 + "j";
QTest::newRow("size 3MB+1") << QByteArray("\x00\x60\x00\x02", 4) + threeMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << threeMbMinus1 + "jk";
-#endif
// past end
QTest::newRow("empty") << QByteArray() << (int) QDataStream::ReadPastEnd << QString();
@@ -2639,14 +2614,12 @@ void tst_QDataStream::status_QString_data()
QTest::newRow("badsize 2") << QByteArray("\x00\x00\x00\x04jj", 6) << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("badsize 3") << QByteArray("\x00\x00\x00\x06jjkk", 8) << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("badsize 4") << QByteArray("\x00\x00\x00\x08jjkkll", 10) << (int) QDataStream::ReadPastEnd << QString();
-#if !defined(Q_OS_WINCE)
QTest::newRow("badsize 1MB") << QByteArray("\x00\x20\x00\x00", 4) + oneMbMinus1Data << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("badsize 1MB+1") << QByteArray("\x00\x20\x00\x02", 4) + oneMbMinus1Data + QByteArray("j") << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("badsize 3MB") << QByteArray("\x00\x60\x00\x00", 4) + threeMbMinus1Data << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("badsize 3MB+1") << QByteArray("\x00\x60\x00\x02", 4) + threeMbMinus1Data + QByteArray("j") << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("size -2") << QByteArray("\xff\xff\xff\xfe", 4) << (int) QDataStream::ReadPastEnd << QString();
QTest::newRow("size MAX") << QByteArray("\x7f\xff\xff\xfe", 4) << (int) QDataStream::ReadPastEnd << QString();
-#endif
// corrupt data
QTest::newRow("corrupt1") << QByteArray("yyyy") << (int) QDataStream::ReadCorruptData << QString();
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 48b8db949f..294a53645e 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -35,7 +35,7 @@
#include <qregexp.h>
#include <qstringlist.h>
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
#include <QtCore/private/qfsfileengine_p.h>
#include "../../../network-settings.h"
#endif
@@ -163,9 +163,8 @@ private slots:
void operator_eq();
-#ifndef Q_OS_WINCE
void dotAndDotDot();
-#endif
+
void homePath();
void tempPath();
void rootPath();
@@ -317,7 +316,7 @@ void tst_QDir::setPath_data()
QTest::addColumn<QString>("dir2");
QTest::newRow("data0") << QString(".") << QString("..");
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
QTest::newRow("data1") << QString("c:/") << QDir::currentPath();
#endif
}
@@ -544,7 +543,7 @@ void tst_QDir::exists_data()
QTest::newRow("simple dir") << (m_dataPath + "/resources") << true;
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@@ -556,7 +555,7 @@ void tst_QDir::exists_data()
QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
#endif
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINRT))
QTest::newRow("This drive should exist") << "C:/" << true;
// find a non-existing drive and check if it does not exist
#ifdef QT_BUILD_INTERNAL
@@ -597,7 +596,7 @@ void tst_QDir::isRelativePath_data()
QTest::addColumn<bool>("relative");
QTest::newRow("data0") << "../somedir" << true;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
QTest::newRow("data1") << "C:/sOmedir" << false;
#endif
QTest::newRow("data2") << "somedir" << true;
@@ -803,12 +802,6 @@ void tst_QDir::entryList()
QFile::remove(entrylistPath + "brokenlink.lnk");
QFile::remove(entrylistPath + "brokenlink");
- // WinCE does not have . and .. in the directory listing
-#if defined(Q_OS_WINCE)
- expected.removeAll(".");
- expected.removeAll("..");
-#endif
-
#ifndef Q_NO_SYMLINKS
#if defined(Q_OS_WIN)
// ### Sadly, this is a platform difference right now.
@@ -901,15 +894,10 @@ void tst_QDir::entryListSimple_data()
QTest::addColumn<int>("countMin");
QTest::newRow("data2") << "do_not_expect_this_path_to_exist/" << 0;
-#if defined(Q_OS_WINCE)
- QTest::newRow("simple dir") << (m_dataPath + "/resources") << 0;
- QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 0;
-#else
QTest::newRow("simple dir") << (m_dataPath + "/resources") << 2;
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2;
-#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << 2;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2;
@@ -1000,15 +988,7 @@ void tst_QDir::canonicalPath_data()
QTest::newRow("nonexistant") << "testd" << QString();
QTest::newRow("rootPath") << QDir::rootPath() << QDir::rootPath();
-
-#ifdef Q_OS_MAC
- // On Mac OS X 10.5 and earlier, canonicalPath depends on cleanPath which
- // is itself very broken and fundamentally wrong on "/./" which, this would
- // exercise
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
-#endif
- QTest::newRow("rootPath + ./") << QDir::rootPath().append("./") << QDir::rootPath();
-
+ QTest::newRow("rootPath + ./") << QDir::rootPath().append("./") << QDir::rootPath();
QTest::newRow("rootPath + ../.. ") << QDir::rootPath().append("../..") << QDir::rootPath();
#if defined(Q_OS_WIN)
QTest::newRow("drive:\\") << QDir::toNativeSeparators(QDir::rootPath()) << QDir::rootPath();
@@ -1171,7 +1151,6 @@ tst_QDir::cleanPath_data()
QTest::newRow("data2") << "/" << "/";
QTest::newRow("data3") << QDir::cleanPath("../.") << "..";
QTest::newRow("data4") << QDir::cleanPath("../..") << "../..";
-#if !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN)
QTest::newRow("data5") << "d:\\a\\bc\\def\\.." << "d:/a/bc";
QTest::newRow("data6") << "d:\\a\\bc\\def\\../../.." << "d:/";
@@ -1179,17 +1158,14 @@ tst_QDir::cleanPath_data()
QTest::newRow("data5") << "d:\\a\\bc\\def\\.." << "d:\\a\\bc\\def\\..";
QTest::newRow("data6") << "d:\\a\\bc\\def\\../../.." << "..";
#endif
-#endif
QTest::newRow("data7") << ".//file1.txt" << "file1.txt";
QTest::newRow("data8") << "/foo/bar/..//file1.txt" << "/foo/file1.txt";
QTest::newRow("data9") << "//" << "/";
-#if !defined(Q_OS_WINCE)
#if defined Q_OS_WIN
QTest::newRow("data10") << "c:\\" << "c:/";
#else
QTest::newRow("data10") << "/:/" << "/:";
#endif
-#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QTest::newRow("data11") << "//foo//bar" << "//foo/bar";
#endif
@@ -1351,7 +1327,7 @@ void tst_QDir::absolutePath_data()
QTest::addColumn<QString>("expectedPath");
QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1";
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINRT))
QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1";
QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1";
QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1";
@@ -1400,7 +1376,7 @@ void tst_QDir::relativeFilePath_data()
QTest::newRow("same path 1") << "/tmp" << "/tmp" << ".";
QTest::newRow("same path 2") << "//tmp" << "/tmp/" << ".";
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
QTest::newRow("12") << "C:/foo/bar" << "ding" << "ding";
QTest::newRow("13") << "C:/foo/bar" << "C:/ding/dong" << "../../ding/dong";
QTest::newRow("14") << "C:/foo/bar" << "/ding/dong" << "../../ding/dong";
@@ -1576,7 +1552,6 @@ void tst_QDir::operator_eq()
dir1.setPath("..");
}
-#ifndef Q_OS_WINCE
// WinCE does not have . nor ..
void tst_QDir::dotAndDotDot()
{
@@ -1586,7 +1561,6 @@ void tst_QDir::dotAndDotDot()
entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
QCOMPARE(entryList, QStringList() << QString("dir") << QString("spaces"));
}
-#endif
void tst_QDir::homePath()
{
@@ -1830,16 +1804,9 @@ void tst_QDir::updateFileLists()
QDir dir(fs.absoluteFilePath(dirName));
-#if defined(Q_OS_WINCE)
- //no . and .. on these OS.
- QCOMPARE(dir.count(), uint(4));
- QCOMPARE(dir.entryList().size(), 4);
- QCOMPARE(dir.entryInfoList().size(), 4);
-#else
QCOMPARE(dir.count(), uint(6));
QCOMPARE(dir.entryList().size(), 6);
QCOMPARE(dir.entryInfoList().size(), 6);
-#endif
dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
@@ -2020,13 +1987,7 @@ void tst_QDir::isRoot_data()
QTest::newRow(QString("./ appended " + test).toLatin1()) << test << false;
test = QDir(QDir::rootPath().append("./")).canonicalPath();
-#ifdef Q_OS_MAC
- // On Mac OS X 10.5 and earlier, canonicalPath depends on cleanPath which
- // is itself very broken and fundamentally wrong on "/./", which this would
- // exercise
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
-#endif
- QTest::newRow(QString("canonicalPath " + test).toLatin1()) << test << true;
+ QTest::newRow(QString("canonicalPath " + test).toLatin1()) << test << true;
#if defined(Q_OS_WIN)
test = QDir::rootPath().left(2);
diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
index 5404e9058f..7c1f026bdb 100644
--- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
+++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro
@@ -6,5 +6,3 @@ RESOURCES += qdiriterator.qrc
TESTDATA += entrylist
contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA
-
-wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1
diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
index 0fbce74055..6450e9af7b 100644
--- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
+++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp
@@ -41,7 +41,7 @@
#define Q_NO_SYMLINKS
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
# include "../../../network-settings.h"
#endif
@@ -103,7 +103,7 @@ private slots:
void longPath();
void dirorder();
void relativePaths();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
void uncPaths_data();
void uncPaths();
#endif
@@ -196,7 +196,7 @@ void tst_QDirIterator::initTestCase()
# endif
#endif
-#if !defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
createDirectory("hiddenDirs_hiddenFiles");
createFile("hiddenDirs_hiddenFiles/normalFile");
createFile("hiddenDirs_hiddenFiles/.hiddenFile");
@@ -239,10 +239,8 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
<< QString("entrylist") << QDirIterator::IteratorFlags(0)
<< QDir::Filters(QDir::NoFilter) << QStringList("*")
<< QString(
-#if !defined(Q_OS_WINCE)
"entrylist/.,"
"entrylist/..,"
-#endif
"entrylist/file,"
#ifndef Q_NO_SYMLINKS
"entrylist/linktofile.lnk,"
@@ -257,9 +255,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
<< QString("entrylist") << QDirIterator::IteratorFlags(0)
<< QDir::Filters(QDir::AllEntries | QDir::NoDot) << QStringList("*")
<< QString(
-#if !defined(Q_OS_WINCE)
"entrylist/..,"
-#endif
"entrylist/file,"
#ifndef Q_NO_SYMLINKS
"entrylist/linktofile.lnk,"
@@ -274,9 +270,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
<< QString("entrylist") << QDirIterator::IteratorFlags(0)
<< QDir::Filters(QDir::AllEntries | QDir::NoDotDot) << QStringList("*")
<< QString(
-#if !defined(Q_OS_WINCE)
"entrylist/.,"
-#endif
"entrylist/file,"
#ifndef Q_NO_SYMLINKS
"entrylist/linktofile.lnk,"
@@ -305,12 +299,10 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
<< QString("entrylist") << QDirIterator::IteratorFlags(QDirIterator::Subdirectories | QDirIterator::FollowSymlinks)
<< QDir::Filters(QDir::NoFilter) << QStringList("*")
<< QString(
-#if !defined(Q_OS_WINCE)
"entrylist/.,"
"entrylist/..,"
"entrylist/directory/.,"
"entrylist/directory/..,"
-#endif
"entrylist/file,"
#ifndef Q_NO_SYMLINKS
"entrylist/linktofile.lnk,"
@@ -345,11 +337,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data()
QTest::newRow("empty, default")
<< QString("empty") << QDirIterator::IteratorFlags(0)
<< QDir::Filters(QDir::NoFilter) << QStringList("*")
-#if defined(Q_OS_WINCE)
- << QStringList();
-#else
<< QString("empty/.,empty/..").split(',');
-#endif
QTest::newRow("empty, QDir::NoDotAndDotDot")
<< QString("empty") << QDirIterator::IteratorFlags(0)
@@ -562,13 +550,6 @@ void tst_QDirIterator::longPath()
while (dir.exists(dirName) || dir.mkdir(dirName)) {
++n;
dirName.append('x');
-#if defined(Q_OS_WINCE) && defined(WINCE_BROKEN_ITERATE)
- // Some Windows CE devices/emulators are broken.
- // though one can create directories of length <= 217,
- // FindNextFile only reports entries until ~ 214.
- if (n >= 210)
- break;
-#endif
}
QDirIterator it(dir.absolutePath(), QDir::NoDotAndDotDot|QDir::Dirs, QDirIterator::Subdirectories);
@@ -606,7 +587,7 @@ void tst_QDirIterator::relativePaths()
}
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
void tst_QDirIterator::uncPaths_data()
{
QTest::addColumn<QString>("dirName");
diff --git a/tests/auto/corelib/io/qfile/qfile.pro b/tests/auto/corelib/io/qfile/qfile.pro
index 10c8d918f7..0735daedb3 100644
--- a/tests/auto/corelib/io/qfile/qfile.pro
+++ b/tests/auto/corelib/io/qfile/qfile.pro
@@ -1,7 +1,2 @@
TEMPLATE = subdirs
-wince* {
- SUBDIRS = test
-} else {
- SUBDIRS = test stdinprocess
-}
-
+SUBDIRS = test stdinprocess
diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro
index c9ba96cc1b..c0c4b9d5d2 100644
--- a/tests/auto/corelib/io/qfile/test/test.pro
+++ b/tests/auto/corelib/io/qfile/test/test.pro
@@ -6,7 +6,6 @@ else: DEFINES += QT_NO_NETWORK
TARGET = ../tst_qfile
SOURCES = ../tst_qfile.cpp
-wince: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp
RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 411c73fb90..4c9986d50e 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -47,7 +47,7 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
QT_END_NAMESPACE
#endif
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_NETWORK)
#include <QHostInfo>
#endif
#include <QProcess>
@@ -66,8 +66,6 @@ QT_END_NAMESPACE
# include <sys/mount.h>
#elif defined(Q_OS_IRIX)
# include <sys/statfs.h>
-#elif defined(Q_OS_WINCE)
-# include <qplatformdefs.h>
#elif defined(Q_OS_VXWORKS)
# include <fcntl.h>
#if defined(_WRS_KERNEL)
@@ -85,7 +83,7 @@ QT_END_NAMESPACE
#include <stdio.h>
#include <errno.h>
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
#include "../../../network-settings.h"
#endif
@@ -135,11 +133,9 @@ private slots:
void readAll_data();
void readAll();
void readAllBuffer();
-#if !defined(Q_OS_WINCE)
void readAllStdin();
void readLineStdin();
void readLineStdin_lineByLine();
-#endif
void text();
void missingEndOfLine();
void readBlock();
@@ -169,7 +165,7 @@ private slots:
void writeTextFile_data();
void writeTextFile();
/* void largeFileSupport(); */
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void largeUncFileSupport();
#endif
void flush();
@@ -225,10 +221,8 @@ private slots:
void mapWrittenFile_data();
void mapWrittenFile();
-#ifndef Q_OS_WINCE
void openStandardStreamsFileDescriptors();
void openStandardStreamsBufferedStreams();
-#endif
void resize_data();
void resize();
@@ -491,7 +485,7 @@ void tst_QFile::exists()
file.remove();
QVERIFY(!file.exists());
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncPath = "//" + QtNetworkSettings::winServerName() + "/testshare/readme.txt";
QFile unc(uncPath);
QVERIFY2(unc.exists(), msgFileDoesNotExist(uncPath).constData());
@@ -543,7 +537,7 @@ void tst_QFile::open_data()
<< int(QIODevice::ReadOnly)
<< false
<< QFile::OpenError;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
//opening devices requires administrative privileges (and elevation).
HANDLE hTest = CreateFile(_T("\\\\.\\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hTest != INVALID_HANDLE_VALUE) {
@@ -574,7 +568,7 @@ void tst_QFile::open()
QSKIP("Running this test as root doesn't make sense");
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
QEXPECT_FAIL("noreadfile", "Windows does not currently support non-readable files.", Abort);
#endif
if (filename.isEmpty())
@@ -626,7 +620,7 @@ void tst_QFile::size_data()
QTest::addColumn<qint64>("size");
QTest::newRow( "exist01" ) << m_testFile << (qint64)245;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Only test UNC on Windows./
QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34;
#endif
@@ -637,10 +631,6 @@ void tst_QFile::size()
QFETCH( QString, filename );
QFETCH( qint64, size );
-#ifdef Q_OS_WINCE
- filename = QFileInfo(filename).absoluteFilePath();
-#endif
-
{
QFile f( filename );
QCOMPARE( f.size(), size );
@@ -660,9 +650,6 @@ void tst_QFile::size()
fclose(stream);
}
- // Currently low level file I/O is not well supported on Windows CE, so
- // skip this part of the test.
-#ifndef Q_OS_WINCE
{
QFile f;
@@ -675,7 +662,6 @@ void tst_QFile::size()
f.close();
QT_CLOSE(fd);
}
-#endif
}
void tst_QFile::sizeNoExist()
@@ -920,7 +906,6 @@ private:
};
#endif // !QT_NO_PROCESS
-#if !defined(Q_OS_WINCE)
void tst_QFile::readAllStdin()
{
#ifdef QT_NO_PROCESS
@@ -1011,7 +996,6 @@ void tst_QFile::readLineStdin_lineByLine()
}
#endif
}
-#endif
void tst_QFile::text()
{
@@ -1112,7 +1096,7 @@ void tst_QFile::ungetChar()
QCOMPARE(buf[2], '4');
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QString driveLetters()
{
wchar_t volumeName[MAX_PATH];
@@ -1149,7 +1133,7 @@ void tst_QFile::invalidFile_data()
#if !defined(Q_OS_WIN)
QTest::newRow( "x11" ) << QString( "qwe//" );
#else
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid");
#endif
QTest::newRow( "colon3" ) << QString( ":failinvalid" );
@@ -1211,13 +1195,11 @@ void tst_QFile::permissions_data()
QTest::newRow("data0") << QCoreApplication::instance()->applicationFilePath() << uint(QFile::ExeUser) << true << false;
QTest::newRow("data1") << m_testSourceFile << uint(QFile::ReadUser) << true << false;
QTest::newRow("readonly") << QString::fromLatin1("readonlyfile") << uint(QFile::WriteUser) << false << false;
-#ifndef Q_OS_WINCE
QTest::newRow("longfile") << QString::fromLatin1("longFileNamelongFileNamelongFileNamelongFileName"
"longFileNamelongFileNamelongFileNamelongFileName"
"longFileNamelongFileNamelongFileNamelongFileName"
"longFileNamelongFileNamelongFileNamelongFileName"
"longFileNamelongFileNamelongFileNamelongFileName.txt") << uint(QFile::ReadUser) << true << true;
-#endif
QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ReadUser) << true << false;
QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::WriteUser) << false << false;
QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << uint(QFile::ExeUser) << false << false;
@@ -1369,15 +1351,9 @@ void tst_QFile::copyFallback()
QVERIFY(QFile::exists("file-copy-destination.txt"));
QVERIFY(!file.isOpen());
-#ifdef Q_OS_WINCE
- // Need to reset permissions on Windows to be able to delete
- QVERIFY(QFile::setPermissions("file-copy-destination.txt",
- QFile::WriteOther));
-#else
// Need to reset permissions on Windows to be able to delete
QVERIFY(QFile::setPermissions("file-copy-destination.txt",
QFile::ReadOwner | QFile::WriteOwner));
-#endif
QVERIFY(QFile::remove("file-copy-destination.txt"));
// Fallback copy of open file.
@@ -1398,7 +1374,7 @@ void tst_QFile::copyFallback()
#endif
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
static QString getWorkingDirectoryForLink(const QString &linkFileName)
{
bool neededCoInit = false;
@@ -1457,7 +1433,7 @@ void tst_QFile::link()
QCOMPARE(QFile::symLinkTarget("myLink.lnk"), referenceTarget);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath());
QCOMPARE(QDir::fromNativeSeparators(wd), QDir::cleanPath(info1.absolutePath()));
#endif
@@ -1595,7 +1571,7 @@ void tst_QFile::writeTextFile()
QCOMPARE(file.readAll(), out);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void tst_QFile::largeUncFileSupport()
{
qint64 size = Q_INT64_C(8589934592);
@@ -1674,11 +1650,7 @@ void tst_QFile::bufferedRead()
file.write("abcdef");
file.close();
-#if defined(Q_OS_WINCE)
- FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toLatin1() , "r");
-#else
FILE *stdFile = fopen("stdfile.txt", "r");
-#endif
QVERIFY(stdFile);
char c;
QCOMPARE(int(fread(&c, 1, 1, stdFile)), 1);
@@ -1823,11 +1795,7 @@ void tst_QFile::FILEReadWrite()
f.close();
}
-#ifdef Q_OS_WINCE
- FILE *fp = fopen(qPrintable(QCoreApplication::applicationDirPath() + "\\FILEReadWrite.txt"), "r+b");
-#else
FILE *fp = fopen("FILEReadWrite.txt", "r+b");
-#endif
QVERIFY(fp);
QFile file;
QVERIFY2(file.open(fp, QFile::ReadWrite), msgOpenFailed(file).constData());
@@ -2032,10 +2000,6 @@ void tst_QFile::longFileName()
}
{
QFile file(fileName);
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("244 chars", "Full pathname must be less than 260 chars", Abort);
- QEXPECT_FAIL("244 chars to absolutepath", "Full pathname must be less than 260 chars", Abort);
-#endif
QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts << fileName << endl;
@@ -2303,7 +2267,7 @@ void tst_QFile::writeLargeDataBlock_data()
QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd;
QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && !defined(QT_NO_NETWORK)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(QT_NO_NETWORK)
// Some semi-randomness to avoid collisions.
QTest::newRow("unc file")
<< QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt")
@@ -2318,8 +2282,8 @@ static QByteArray getLargeDataBlock()
if (array.isNull())
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS)
- int resizeSize = 1024 * 1024; // WinCE does not have much space
+#if defined(Q_OS_VXWORKS)
+ int resizeSize = 1024 * 1024; // VxWorks does not have much space
#else
int resizeSize = 64 * 1024 * 1024;
#endif
@@ -2447,9 +2411,7 @@ void tst_QFile::virtualFile()
void tst_QFile::textFile()
{
-#if defined(Q_OS_WINCE)
- FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toLatin1() , "wt");
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
FILE *fs = ::fopen("writeabletextfile", "wt");
#else
FILE *fs = ::fopen("writeabletextfile", "w");
@@ -2662,7 +2624,7 @@ void tst_QFile::appendAndRead()
void tst_QFile::miscWithUncPathAsCurrentDir()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QString current = QDir::currentPath();
const QString path = QLatin1String("//") + QtNetworkSettings::winServerName()
+ QLatin1String("/testshare");
@@ -2686,7 +2648,6 @@ void tst_QFile::standarderror()
void tst_QFile::handle()
{
int fd;
-#if !defined(Q_OS_WINCE)
QFile file(m_testSourceFile);
QVERIFY2(file.open(QIODevice::ReadOnly), msgOpenFailed(file).constData());
fd = int(file.handle());
@@ -2714,7 +2675,6 @@ void tst_QFile::handle()
#endif
QCOMPARE(c, '*');
-#endif
//test round trip of adopted stdio file handle
QFile file2;
@@ -2957,10 +2917,6 @@ void tst_QFile::map()
QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile";
-#ifdef Q_OS_WINCE
- fileName = QFileInfo(fileName).absoluteFilePath();
-#endif
-
if (QFile::exists(fileName)) {
QVERIFY(QFile::setPermissions(fileName,
QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser));
@@ -3002,7 +2958,7 @@ void tst_QFile::map()
QCOMPARE(file.error(), QFile::NoError);
// hpux won't let you map multiple times.
-#if !defined(Q_OS_HPUX) && !defined(Q_USE_DEPRECATED_MAP_API) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_HPUX) && !defined(Q_USE_DEPRECATED_MAP_API)
// exotic test to make sure that multiple maps work
// note: windows ce does not reference count mutliple maps
@@ -3125,10 +3081,6 @@ void tst_QFile::mapOpenMode()
QVERIFY2(file.open(om), msgOpenFailed(om, file).constData());
uchar *memory = file.map(0, fileSize, QFileDevice::MemoryMapFlags(flags));
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("ReadOnly + MapPrivate" , "Windows CE does not support MapPrivateOption.", Abort);
- QEXPECT_FAIL("ReadWrite + MapPrivate", "Windows CE does not support MapPrivateOption.", Abort);
-#endif
QVERIFY(memory);
QVERIFY(memcmp(memory, pattern, fileSize) == 0);
@@ -3161,10 +3113,6 @@ void tst_QFile::mapWrittenFile()
QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile";
-#ifdef Q_OS_WINCE
- fileName = QFileInfo(fileName).absoluteFilePath();
-#endif
-
if (QFile::exists(fileName)) {
QVERIFY(QFile::setPermissions(fileName,
QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser));
@@ -3263,10 +3211,6 @@ protected:
bool MessageHandler::ok = true;
QtMessageHandler MessageHandler::oldMessageHandler = 0;
- //allthough Windows CE (not mobile!) has functions that allow redirecting
- //the standard file descriptors to a file (see SetStdioPathW/GetStdioPathW)
- //it does not have functions to simply open them like below .
-#ifndef Q_OS_WINCE
void tst_QFile::openStandardStreamsFileDescriptors()
{
@@ -3326,7 +3270,6 @@ void tst_QFile::openStandardStreamsBufferedStreams()
QVERIFY(msgHandler.testPassed());
}
-#endif
void tst_QFile::writeNothing()
{
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 8d62a38e6b..b3527f5d27 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -49,13 +49,13 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#include <qlibrary.h>
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
#include <lm.h>
#endif
#endif
#include <qplatformdefs.h>
#include <qdebug.h>
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
#include "../../../network-settings.h"
#endif
#include <private/qfileinfo_p.h>
@@ -141,7 +141,7 @@ inline bool qIsLikelyToBeNfs(int /* handle */)
static QString seedAndTemplate()
{
- qsrand(QDateTime::currentDateTimeUtc().toTime_t());
+ qsrand(QDateTime::currentSecsSinceEpoch());
return QDir::tempPath() + "/tst_qfileinfo-XXXXXX";
}
@@ -256,7 +256,7 @@ private slots:
void refresh();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void ntfsJunctionPointsAndSymlinks_data();
void ntfsJunctionPointsAndSymlinks();
void brokenShortcut();
@@ -273,7 +273,7 @@ private slots:
void detachingOperations();
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
void owner();
#endif
void group();
@@ -354,17 +354,8 @@ void tst_QFileInfo::copy()
file.flush();
QTest::qWait(250);
-#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
- if (QSysInfo::windowsVersion() & QSysInfo::WV_VISTA ||
- QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
- file.close();
-#endif
-#if defined(Q_OS_WINCE)
- // On Windows CE we need to close the file.
- // Otherwise the content will be cached and not
- // flushed to the storage, although we flushed it
- // manually!!! CE has interim cache, we cannot influence.
- QTest::qWait(5000);
+#if defined(Q_OS_WIN)
+ file.close();
#endif
info3.refresh();
privateInfo3 = getPrivate(info3);
@@ -422,12 +413,12 @@ void tst_QFileInfo::isDir_data()
QTest::newRow("broken link") << "brokenlink.lnk" << false;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINRT))
QTest::newRow("drive 1") << "c:" << true;
QTest::newRow("drive 2") << "c:/" << true;
//QTest::newRow("drive 2") << "t:s" << false;
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@@ -464,13 +455,13 @@ void tst_QFileInfo::isRoot_data()
QTest::newRow("simple dir") << m_resourcesDir << false;
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << false;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINRT))
QTest::newRow("drive 1") << "c:" << false;
QTest::newRow("drive 2") << "c:/" << true;
QTest::newRow("drive 3") << "p:/" << false;
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@@ -519,7 +510,7 @@ void tst_QFileInfo::exists_data()
QTest::newRow("simple dir") << m_resourcesDir << true;
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << true;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@@ -554,7 +545,7 @@ void tst_QFileInfo::absolutePath_data()
QTest::addColumn<QString>("filename");
QString drivePrefix;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINRT))
drivePrefix = QDir::currentPath().left(2);
QString nonCurrentDrivePrefix =
drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:");
@@ -573,7 +564,7 @@ void tst_QFileInfo::absolutePath_data()
QTest::newRow("3") << "/usr/local/bin/" << drivePrefix + "/usr/local/bin" << "";
QTest::newRow("/test") << "/test" << drivePrefix + "/" << "test";
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/"
<< "autoexec.bat";
QTest::newRow("c:autoexec.bat") << QDir::currentPath().left(2) + "autoexec.bat" << QDir::currentPath()
@@ -606,7 +597,7 @@ void tst_QFileInfo::absFilePath_data()
QTest::newRow("relativeFile") << "tmp.txt" << QDir::currentPath() + "/tmp.txt";
QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt";
QString drivePrefix;
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
QString curr = QDir::currentPath();
curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo
@@ -774,7 +765,7 @@ void tst_QFileInfo::fileName_data()
QTest::newRow("relativeFile") << "tmp.txt" << "tmp.txt";
QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << "tmp.txt";
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
+#if defined(Q_OS_WIN)
QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "tmp.txt";
QTest::newRow("driveWithNoSlash") << "c:tmp.txt" << "tmp.txt";
#else
@@ -1024,7 +1015,7 @@ void tst_QFileInfo::size()
void tst_QFileInfo::systemFiles()
{
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if !defined(Q_OS_WIN) || defined(Q_OS_WINRT)
QSKIP("This is a Windows only test");
#endif
QFileInfo fi("c:\\pagefile.sys");
@@ -1121,11 +1112,7 @@ void tst_QFileInfo::fileTimes_data()
void tst_QFileInfo::fileTimes()
{
-#if defined(Q_OS_WINCE)
- int sleepTime = 3000;
-#else
int sleepTime = 2000;
-#endif
QFETCH(QString, fileName);
if (QFile::exists(fileName)) {
QVERIFY(QFile::remove(fileName));
@@ -1133,10 +1120,6 @@ void tst_QFileInfo::fileTimes()
QTest::qSleep(sleepTime);
{
QFile file(fileName);
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("longfile", "No long filenames on WinCE", Abort);
- QEXPECT_FAIL("longfile absolutepath", "No long filenames on WinCE", Abort);
-#endif
QVERIFY(file.open(QFile::WriteOnly | QFile::Text));
#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
if (qIsLikelyToBeNfs(file.handle()))
@@ -1162,7 +1145,7 @@ void tst_QFileInfo::fileTimes()
{
QFileInfo fileInfo(fileName);
// On unix created() returns the same as lastModified().
-#if !defined(Q_OS_UNIX) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_UNIX)
QVERIFY(fileInfo.created() < beforeWrite);
#endif
QVERIFY(fileInfo.lastModified() > beforeWrite);
@@ -1174,7 +1157,7 @@ void tst_QFileInfo::fileTimes()
}
QFileInfo fileInfo(fileName);
-#if !defined(Q_OS_UNIX) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_UNIX)
QVERIFY(fileInfo.created() < beforeWrite);
#endif
//In Vista the last-access timestamp is not updated when the file is accessed/touched (by default).
@@ -1193,9 +1176,7 @@ void tst_QFileInfo::fileTimes()
RegCloseKey(key);
}
#endif
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue);
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
QEXPECT_FAIL("", "WinRT does not allow timestamp handling change in the filesystem due to sandboxing", Continue);
#elif defined(Q_OS_QNX)
QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue);
@@ -1211,8 +1192,8 @@ void tst_QFileInfo::fileTimes()
void tst_QFileInfo::fileTimes_oldFile()
{
- // This is not supported on WinCE or WinRT
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+ // This is not supported on WinRT
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// All files are opened in share mode (both read and write).
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
@@ -1310,7 +1291,7 @@ void tst_QFileInfo::isHidden_data()
QTest::newRow(qPrintable("drive." + info.path())) << info.path() << false;
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
QVERIFY(QDir("./hidden-directory").exists() || QDir().mkdir("./hidden-directory"));
QVERIFY(SetFileAttributesW(reinterpret_cast<LPCWSTR>(QString("./hidden-directory").utf16()),FILE_ATTRIBUTE_HIDDEN));
QTest::newRow("C:/path/to/hidden-directory") << QDir::currentPath() + QString::fromLatin1("/hidden-directory") << true;
@@ -1413,7 +1394,7 @@ void tst_QFileInfo::isNativePath()
void tst_QFileInfo::refresh()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
int sleepTime = 3000;
#else
int sleepTime = 2000;
@@ -1436,17 +1417,8 @@ void tst_QFileInfo::refresh()
QCOMPARE(info.lastModified(), lastModified);
QCOMPARE(info.size(), qint64(7));
-#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
- if (QSysInfo::windowsVersion() & QSysInfo::WV_VISTA ||
- QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
- file.close();
-#endif
-#if defined(Q_OS_WINCE)
- // On Windows CE we need to close the file.
- // Otherwise the content will be cached and not
- // flushed to the storage, although we flushed it
- // manually!!! CE has interim cache, we cannot influence.
- QTest::qWait(5000);
+#if defined(Q_OS_WIN)
+ file.close();
#endif
info.refresh();
QCOMPARE(info.size(), qint64(13));
@@ -1459,7 +1431,7 @@ void tst_QFileInfo::refresh()
QCOMPARE(info2.size(), info.size());
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
{
QTest::addColumn<QString>("path");
@@ -1633,11 +1605,7 @@ void tst_QFileInfo::isWritable()
tempfile.remove();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-#ifdef Q_OS_WINCE
- QFileInfo fi("\\Windows\\wince.nls");
-#else
QFileInfo fi("c:\\pagefile.sys");
-#endif
QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QVERIFY(!fi.isWritable());
#endif
@@ -1813,8 +1781,7 @@ void tst_QFileInfo::detachingOperations()
QVERIFY(!info1.caching());
}
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if defined (Q_OS_WIN)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
BOOL IsUserAdmin()
{
BOOL b;
@@ -1835,14 +1802,14 @@ BOOL IsUserAdmin()
return(b);
}
-#endif
-#if defined(Q_OS_WIN)
QT_BEGIN_NAMESPACE
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
QT_END_NAMESPACE
-#endif
+#endif // Q_OS_WIN && !Q_OS_WINRT
+
+#ifndef Q_OS_WINRT
void tst_QFileInfo::owner()
{
QString userName;
@@ -1904,7 +1871,7 @@ void tst_QFileInfo::owner()
qt_ntfs_permission_lookup = 0;
#endif
}
-#endif
+#endif // !Q_OS_WINRT
void tst_QFileInfo::group()
{
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index 187f72d095..fe2a1a562d 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -146,12 +146,7 @@ void tst_QFileSystemWatcher::basicTest()
// resolution of the modification time is system dependent, but it's at most 1 second when using
// the polling engine. I've heard rumors that FAT32 has a 2 second resolution. So, we have to
// wait a bit before we can modify the file (hrmph)...
-#ifndef Q_OS_WINCE
QTest::qWait(2000);
-#else
- // WinCE is always a little bit slower. Give it a little bit more time
- QTest::qWait(5000);
-#endif
testFile.open(QIODevice::WriteOnly | QIODevice::Append);
testFile.write(QByteArray("world"));
@@ -309,9 +304,6 @@ void tst_QFileSystemWatcher::watchDirectory()
QVERIFY(temporaryDir.rmdir(testDirName));
// waiting max 5 seconds for notification for directory removal to trigger
-#ifdef Q_OS_WINCE
- QEXPECT_FAIL("poller", "Directory does not get updated on file removal(See #137910)", Abort);
-#endif
QTRY_COMPARE(changedSpy.count(), 2);
QCOMPARE(changedSpy.at(0).count(), 1);
QCOMPARE(changedSpy.at(1).count(), 1);
@@ -553,9 +545,6 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QEXPECT_FAIL("", "See QTBUG-30943", Continue);
#endif
QCOMPARE(fileChangedSpyCount, 0);
-#ifdef Q_OS_WINCE
- QEXPECT_FAIL("poller", "Directory does not get updated on file removal(See #137910)", Abort);
-#endif
QCOMPARE(dirChangedSpy.count(), 1);
dirChangedSpy.clear();
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 30eaa5aab9..5cb532f76b 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -100,9 +100,6 @@ void tst_QIODevice::getSetCheck()
//----------------------------------------------------------------------------------
void tst_QIODevice::constructing_QTcpSocket()
{
-#if defined(Q_OS_WINCE) && defined(WINCE_EMULATOR_TEST)
- QSKIP("Networking tests in a WinCE emulator are unstable");
-#endif
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
@@ -205,9 +202,6 @@ void tst_QIODevice::read_QByteArray()
//--------------------------------------------------------------------
void tst_QIODevice::unget()
{
-#if defined(Q_OS_WINCE) && defined(WINCE_EMULATOR_TEST)
- QSKIP("Networking tests in a WinCE emulator are unstable");
-#endif
#if defined(Q_OS_MAC)
QSKIP("The unget network test is unstable on Mac. See QTBUG-39983.");
#endif
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index 2e5cfb1053..b21701f341 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -34,7 +34,7 @@
#include <qsysinfo.h>
#if defined(Q_OS_UNIX) && !defined(Q_OS_VXWORKS)
#include <unistd.h>
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#endif
@@ -281,7 +281,7 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid()
{
#if defined(QT_NO_PROCESS)
QSKIP("This test requires QProcess support");
-#elif defined(Q_OS_WINRT) || defined(Q_OS_WINCE) || defined(Q_OS_IOS)
+#elif defined(Q_OS_WINRT) || defined(QT_PLATFORM_UIKIT)
QSKIP("We cannot retrieve information about other processes on this platform.");
#else
const QString fileName = dir.path() + "/staleLockFromCrashedProcessReusedPid";
@@ -455,7 +455,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(ProcessProperties)
static inline ProcessProperties processProperties()
{
ProcessProperties result;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
HANDLE processToken = NULL;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &processToken)) {
DWORD elevation; // struct containing a DWORD, not present in some MinGW headers.
@@ -484,7 +484,7 @@ void tst_QLockFile::noPermissionsWindows()
{
// Windows: Do the permissions test in a system directory in which
// files cannot be created.
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if !defined(Q_OS_WIN) || defined(Q_OS_WINRT)
QSKIP("This test is for desktop Windows only");
#endif
#ifdef Q_OS_WIN
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
index 6eb72343bc..7b83d5dbe8 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
@@ -4,4 +4,4 @@ TARGET = tst_qlockfile
SOURCES += tst_qlockfile.cpp
QT = core testlib concurrent
-win32:!wince:!winrt:LIBS += -ladvapi32
+win32:!winrt:LIBS += -ladvapi32
diff --git a/tests/auto/corelib/io/qprocess/qprocess.pri b/tests/auto/corelib/io/qprocess/qprocess.pri
index a43c823846..d5a7532ee1 100644
--- a/tests/auto/corelib/io/qprocess/qprocess.pri
+++ b/tests/auto/corelib/io/qprocess/qprocess.pri
@@ -10,13 +10,12 @@ SUBPROGRAMS = \
testProcessDeadWhileReading \
testProcessEOF \
testExitCodes \
+ testForwarding \
testGuiProcess \
testDetached \
fileWriterProcess \
testSetWorkingDirectory \
testSoftExit
-!contains(QMAKE_PLATFORM, wince): SUBPROGRAMS += testForwarding
-
!qtHaveModule(widgets): SUBPROGRAMS -= \
testGuiProcess
diff --git a/tests/auto/corelib/io/qprocess/qprocess.pro b/tests/auto/corelib/io/qprocess/qprocess.pro
index 6ba54b1e92..3867ac5741 100644
--- a/tests/auto/corelib/io/qprocess/qprocess.pro
+++ b/tests/auto/corelib/io/qprocess/qprocess.pro
@@ -8,7 +8,7 @@ SUBDIRS += testProcessSpacesArgs/nospace.pro \
testProcessSpacesArgs/twospaces.pro \
testSpaceInName
-win32:!wince* {
+win32 {
SUBDIRS += \
testProcessEchoGui \
testSetNamedPipeHandleState
diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp
index 19f30de552..e18e48e516 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp
@@ -31,9 +31,6 @@
int main()
{
-#if defined(_WIN32_WCE) && defined(_X86_)
- return 0;
-#else
int c;
while ((c = fgetc(stdin)) != -1) {
if (c == '\0')
@@ -42,5 +39,4 @@ int main()
fflush(stdout);
}
return 0;
-#endif
}
diff --git a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp
index 4de359d83f..9f13f5c00f 100644
--- a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp
@@ -31,10 +31,6 @@
int main(int argc, char **argv)
{
-#if defined(_WIN32_WCE)
- // no environment in Windows CE
- return 0;
-#else
if (argc == 1)
return 1;
@@ -44,5 +40,4 @@ int main(int argc, char **argv)
return 0;
}
return 1;
-#endif
}
diff --git a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp b/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp
index 07409166f2..4934708153 100644
--- a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp
@@ -31,11 +31,7 @@
int main()
{
-#if defined(_WIN32_WCE)
- for (int i=0; i<240; i++) {
-#else //fprintf Output is very slow on Windows CE
for (int i=0; i<10240; i++) {
-#endif
fprintf(stdout, "%d -this is a number\n", i);
fflush(stderr);
}
diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp
index 494d8147a7..0d40a9b83c 100644
--- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp
@@ -31,21 +31,10 @@
int main(int argc, char ** argv)
{
-#if defined(WINCE) || defined(_WIN32_WCE)
- // No pipes on this "OS"
- FILE* file = fopen("\\temp\\qprocess_args_test.txt","w+");
- for (int i = 0; i < argc; ++i) {
- if (i)
- fprintf(file, "|");
- fprintf(file, argv[i]);
- }
- fclose(file);
-#else
for (int i = 0; i < argc; ++i) {
if (i)
printf("|");
printf("%s", argv[i]);
}
-#endif
return 0;
}
diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
index d19a631cae..80e8bcad98 100644
--- a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
+++ b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro
@@ -1,6 +1,6 @@
win32 {
SOURCES = main_win.cpp
- !wince: LIBS += -luser32
+ LIBS += -luser32
}
unix {
SOURCES = main_unix.cpp
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 1f0ace0dd3..0bc1e77925 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -64,7 +64,6 @@ private slots:
void startDetached();
void crashTest();
void crashTest2();
-#ifndef Q_OS_WINCE
void echoTest_data();
void echoTest();
void echoTest2();
@@ -110,7 +109,6 @@ private slots:
void discardUnwantedOutput();
void setWorkingDirectory();
void setNonExistentWorkingDirectory();
-#endif // not Q_OS_WINCE
void exitStatus_data();
void exitStatus();
@@ -154,11 +152,9 @@ protected slots:
void readFromProcess();
void exitLoopSlot();
void processApplicationEvents();
-#ifndef Q_OS_WINCE
void restartProcess();
void waitForReadyReadInAReadyReadSlotSlot();
void waitForBytesWrittenInABytesWrittenSlotSlot();
-#endif
private:
qint64 bytesAvailable;
@@ -406,8 +402,6 @@ void tst_QProcess::crashTest2()
QCOMPARE(process.exitStatus(), QProcess::CrashExit);
}
-#ifndef Q_OS_WINCE
-//Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::echoTest_data()
{
QTest::addColumn<QByteArray>("input");
@@ -462,7 +456,6 @@ void tst_QProcess::echoTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
void tst_QProcess::exitLoopSlot()
{
@@ -474,8 +467,6 @@ void tst_QProcess::processApplicationEvents()
QCoreApplication::processEvents();
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::echoTest2()
{
@@ -523,10 +514,8 @@ void tst_QProcess::echoTest2()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-// Reading and writing to a process is not supported on Qt/CE
+#if defined(Q_OS_WIN)
void tst_QProcess::echoTestGui()
{
QProcess process;
@@ -555,10 +544,9 @@ void tst_QProcess::testSetNamedPipeHandleState()
QCOMPARE(process.exitCode(), 0);
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
}
-#endif // !Q_OS_WINCE && Q_OS_WIN
+#endif // Q_OS_WIN
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-// Batch files are not supported on Windows CE
+#if defined(Q_OS_WIN)
void tst_QProcess::batFiles_data()
{
QTest::addColumn<QString>("batFile");
@@ -585,7 +573,7 @@ void tst_QProcess::batFiles()
QVERIFY(proc.readAll().startsWith(output));
}
-#endif // !Q_OS_WINCE && Q_OS_WIN
+#endif // Q_OS_WIN
void tst_QProcess::exitStatus_data()
{
@@ -627,8 +615,6 @@ void tst_QProcess::exitStatus()
}
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::loopBackTest()
{
@@ -649,10 +635,7 @@ void tst_QProcess::loopBackTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::readTimeoutAndThenCrash()
{
@@ -683,7 +666,6 @@ void tst_QProcess::readTimeoutAndThenCrash()
QCOMPARE(spy2.count(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed);
}
-#endif
void tst_QProcess::waitForFinished()
{
@@ -694,9 +676,6 @@ void tst_QProcess::waitForFinished()
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
-#if defined (Q_OS_WINCE)
- QEXPECT_FAIL("", "Reading and writing to a process is not supported on Qt/CE", Continue);
-#endif
QString output = process.readAll();
QCOMPARE(output.count("\n"), 10*1024);
@@ -705,8 +684,6 @@ void tst_QProcess::waitForFinished()
QCOMPARE(process.error(), QProcess::FailedToStart);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::deadWhileReading()
{
QProcess process;
@@ -724,10 +701,7 @@ void tst_QProcess::deadWhileReading()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::restartProcessDeadlock()
{
@@ -757,10 +731,7 @@ void tst_QProcess::restartProcess()
QVERIFY(process);
process->start("testProcessEcho/testProcessEcho");
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::closeWriteChannel()
{
QProcess more;
@@ -786,10 +757,7 @@ void tst_QProcess::closeWriteChannel()
QCOMPARE(more.exitStatus(), QProcess::NormalExit);
QCOMPARE(more.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE"
void tst_QProcess::closeReadChannel()
{
for (int i = 0; i < 10; ++i) {
@@ -819,10 +787,7 @@ void tst_QProcess::closeReadChannel()
QCOMPARE(proc.exitCode(), 0);
}
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::openModes()
{
QProcess proc;
@@ -863,10 +828,7 @@ void tst_QProcess::openModes()
QVERIFY(!proc.isWritable());
QCOMPARE(proc.state(), QProcess::NotRunning);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
{
@@ -900,17 +862,12 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0);
}
-#endif
void tst_QProcess::hardExit()
{
QProcess proc;
-#if defined(Q_OS_WINCE)
- proc.start("testSoftExit/testSoftExit");
-#else
proc.start("testProcessEcho/testProcessEcho");
-#endif
QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString()));
@@ -937,9 +894,7 @@ void tst_QProcess::softExit()
proc.start("testSoftExit/testSoftExit");
QVERIFY(proc.waitForStarted(10000));
-#if !defined(Q_OS_WINCE)
QVERIFY(proc.waitForReadyRead(10000));
-#endif
QVERIFY(proc.processId() > 0);
@@ -950,8 +905,6 @@ void tst_QProcess::softExit()
QCOMPARE(int(proc.error()), int(QProcess::UnknownError));
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
class SoftExitProcess : public QProcess
{
Q_OBJECT
@@ -1073,10 +1026,7 @@ void tst_QProcess::softExitInSlots()
QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000);
QCOMPARE(proc.state(), QProcess::NotRunning);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::mergedChannels()
{
QProcess process;
@@ -1099,10 +1049,6 @@ void tst_QProcess::mergedChannels()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::forwardedChannels_data()
{
@@ -1155,10 +1101,7 @@ void tst_QProcess::forwardedChannels()
QCOMPARE(process.readAllStandardOutput(), outdata);
QCOMPARE(process.readAllStandardError(), errdata);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd()
{
QProcess process;
@@ -1180,7 +1123,6 @@ void tst_QProcess::atEnd()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
class TestThread : public QThread
{
@@ -1202,9 +1144,7 @@ protected:
process.start("testProcessEcho/testProcessEcho");
-#if !defined(Q_OS_WINCE)
QCOMPARE(process.write("abc\0", 4), qint64(4));
-#endif
exitCode = exec();
}
@@ -1253,8 +1193,6 @@ void tst_QProcess::processesInMultipleThreads()
}
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForFinishedWithTimeout()
{
QProcess process;
@@ -1268,10 +1206,7 @@ void tst_QProcess::waitForFinishedWithTimeout()
QVERIFY(process.waitForFinished());
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlot()
{
QProcess process;
@@ -1297,10 +1232,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
QCOMPARE(process.exitCode(), 0);
QVERIFY(process.bytesAvailable() > bytesAvailable);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
{
QProcess *process = qobject_cast<QProcess *>(sender());
@@ -1310,10 +1242,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
QVERIFY(process->waitForReadyRead(5000));
QTestEventLoop::instance().exitLoop();
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
{
QProcess process;
@@ -1336,10 +1265,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
{
QProcess *process = qobject_cast<QProcess *>(sender());
@@ -1348,7 +1274,6 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
QVERIFY(process->waitForBytesWritten(5000));
QTestEventLoop::instance().exitLoop();
}
-#endif
void tst_QProcess::spaceArgsTest_data()
{
@@ -1427,14 +1352,12 @@ void tst_QProcess::spaceArgsTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
-#if !defined(Q_OS_WINCE)
QStringList actual = QString::fromLatin1(process.readAll()).split("|");
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QCOMPARE(actual, args);
-#endif
if (program.contains(QLatin1Char(' ')))
program = QLatin1Char('"') + program + QLatin1Char('"');
@@ -1451,14 +1374,12 @@ void tst_QProcess::spaceArgsTest()
QVERIFY2(started, errorMessage.constData());
QVERIFY(process.waitForFinished(5000));
-#if !defined(Q_OS_WINCE)
actual = QString::fromLatin1(process.readAll()).split("|");
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QCOMPARE(actual, args);
-#endif
}
}
@@ -1479,26 +1400,12 @@ void tst_QProcess::nativeArguments()
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0);
-#if defined(Q_OS_WINCE)
- // WinCE test outputs to a file, so check that
- FILE* file = fopen("\\temp\\qprocess_args_test.txt","r");
- QVERIFY(file);
- char buf[256];
- fgets(buf, 256, file);
- fclose(file);
- QStringList actual = QString::fromLatin1(buf).split(QLatin1Char('|'));
-#else
QStringList actual = QString::fromLatin1(proc.readAll()).split(QLatin1Char('|'));
-#endif
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QStringList expected;
-#if defined(Q_OS_WINCE)
- expected << "hello" << "kitty," << "\"*\"!"; // Weird, weird ...
-#else
expected << "hello" << "kitty," << "*!";
-#endif
QCOMPARE(actual, expected);
}
@@ -1703,8 +1610,6 @@ void tst_QProcess::failToStartEmptyArgs()
QCOMPARE(process.error(), QProcess::FailedToStart);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::removeFileWhileProcessIsRunning()
{
QFile file(m_temporaryDir.path() + QLatin1String("/removeFile.txt"));
@@ -1722,9 +1627,7 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// OS doesn't support environment variables
+
void tst_QProcess::setEnvironment_data()
{
QTest::addColumn<QString>("name");
@@ -1799,9 +1702,7 @@ void tst_QProcess::setEnvironment()
QCOMPARE(process.readAll(), value.toLocal8Bit());
}
}
-#endif
-#ifndef Q_OS_WINCE
-// OS doesn't support environment variables
+
void tst_QProcess::setProcessEnvironment_data()
{
setEnvironment_data();
@@ -1839,25 +1740,16 @@ void tst_QProcess::setProcessEnvironment()
QCOMPARE(process.readAll(), value.toLocal8Bit());
}
}
-#endif
void tst_QProcess::systemEnvironment()
{
-#if defined (Q_OS_WINCE)
- // there is no concept of system variables on Windows CE as there is no console
- QVERIFY(QProcess::systemEnvironment().isEmpty());
- QVERIFY(QProcessEnvironment::systemEnvironment().isEmpty());
-#else
QVERIFY(!QProcess::systemEnvironment().isEmpty());
QVERIFY(!QProcessEnvironment::systemEnvironment().isEmpty());
QVERIFY(QProcessEnvironment::systemEnvironment().contains("PATH"));
QVERIFY(!QProcess::systemEnvironment().filter(QRegExp("^PATH=", Qt::CaseInsensitive)).isEmpty());
-#endif
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::spaceInName()
{
QProcess process;
@@ -1868,7 +1760,6 @@ void tst_QProcess::spaceInName()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
void tst_QProcess::lockupsInStartDetached()
{
@@ -1883,8 +1774,6 @@ void tst_QProcess::lockupsInStartDetached()
QProcess::startDetached("yjhbrty");
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd2()
{
QProcess process;
@@ -1899,7 +1788,6 @@ void tst_QProcess::atEnd2()
}
QCOMPARE(lines.size(), 7);
}
-#endif
void tst_QProcess::waitForReadyReadForNonexistantProcess()
{
@@ -1929,8 +1817,6 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
QCOMPARE(finishedSpy2.count(), 0);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardInputFile()
{
static const char data[] = "A bunch\1of\2data\3\4\5\6\7...";
@@ -1958,10 +1844,7 @@ void tst_QProcess::setStandardInputFile()
all = process2.readAll();
QCOMPARE(all.size(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputFile_data()
{
QTest::addColumn<int>("channelToTest");
@@ -2079,10 +1962,7 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
QCOMPARE(all, QByteArray::fromRawData(testdata, sizeof testdata - 1));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputProcess_data()
{
QTest::addColumn<bool>("merged");
@@ -2123,10 +2003,7 @@ void tst_QProcess::setStandardOutputProcess()
else
QCOMPARE(all, QByteArray("HHeelllloo,, WWoorrlldd"));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::fileWriterProcess()
{
const QByteArray line = QByteArrayLiteral(" -- testing testing 1 2 3\n");
@@ -2160,16 +2037,11 @@ void tst_QProcess::fileWriterProcess()
QCOMPARE(QFile(fileName).size(), qint64(stdinStr.size()));
} while (stopWatch.elapsed() < 3000);
}
-#endif
void tst_QProcess::detachedWorkingDirectoryAndPid()
{
qint64 pid;
-#ifdef Q_OS_WINCE
- QTest::qSleep(1000);
-#endif
-
QFile infoFile(m_temporaryDir.path() + QLatin1String("/detachedinfo.txt"));
if (infoFile.exists())
QVERIFY(infoFile.remove());
@@ -2206,8 +2078,6 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
QCOMPARE(actualPid, pid);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::switchReadChannels()
{
const char data[] = "ABCD";
@@ -2236,10 +2106,7 @@ void tst_QProcess::switchReadChannels()
process.setReadChannel(QProcess::StandardOutput);
QCOMPARE(process.read(1), QByteArray("D"));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::discardUnwantedOutput()
{
QProcess process;
@@ -2257,11 +2124,8 @@ void tst_QProcess::discardUnwantedOutput()
process.setReadChannel(QProcess::StandardError);
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
}
-#endif
-#ifndef Q_OS_WINCE
// Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices
-// Windows CE does not support working directory logic
void tst_QProcess::setWorkingDirectory()
{
QProcess process;
@@ -2297,7 +2161,6 @@ void tst_QProcess::setNonExistentWorkingDirectory()
QVERIFY2(process.errorString().startsWith("chdir:"), process.errorString().toLocal8Bit());
#endif
}
-#endif
void tst_QProcess::startFinishStartFinish()
{
@@ -2307,11 +2170,9 @@ void tst_QProcess::startFinishStartFinish()
QCOMPARE(process.state(), QProcess::NotRunning);
process.start("testProcessOutput/testProcessOutput");
-#if !defined(Q_OS_WINCE)
QVERIFY(process.waitForReadyRead(10000));
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),
QString("0 -this is a number"));
-#endif
if (process.state() != QProcess::NotRunning) {
QVERIFY(process.waitForFinished(10000));
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
index a4a5d5b0c7..af5078a3dc 100644
--- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -44,9 +44,7 @@ private slots:
void caseSensitivity();
void systemEnvironment();
-#ifndef Q_OS_WINCE
void putenv();
-#endif
};
void tst_QProcessEnvironment::operator_eq()
@@ -257,12 +255,6 @@ void tst_QProcessEnvironment::systemEnvironment()
QVERIFY(nonexistant.isNull());
-#ifdef Q_OS_WINCE
- // Windows CE has no environment
- QVERIFY(path.isEmpty());
- QVERIFY(!system.contains("PATH"));
- QVERIFY(system.isEmpty());
-#else
// all other system have environments
if (path.isEmpty())
QFAIL("Could not find the PATH environment variable -- please correct the test environment");
@@ -272,18 +264,15 @@ void tst_QProcessEnvironment::systemEnvironment()
QVERIFY(!system.contains(envname));
-# ifdef Q_OS_WIN
+#ifdef Q_OS_WIN
// check case-insensitive too
QVERIFY(system.contains("path"));
QCOMPARE(system.value("path"), QString::fromLocal8Bit(path));
QVERIFY(!system.contains(QString(envname).toLower()));
-# endif
#endif
}
-#ifndef Q_OS_WINCE
-//Windows CE has no environment
void tst_QProcessEnvironment::putenv()
{
static const char envname[] = "WE_RE_SETTING_THIS_ENVIRONMENT_VARIABLE";
@@ -317,7 +306,6 @@ void tst_QProcessEnvironment::putenv()
QCOMPARE(eAfter.value(lower), QString("Hello, World"));
# endif
}
-#endif
QTEST_MAIN(tst_QProcessEnvironment)
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 87a801c9dd..2f039cbcd8 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -1521,7 +1521,7 @@ void tst_QSettings::sync()
// Now "some other app" will change other.software.org.ini
QString userConfDir = settingsPath("__user__") + QDir::separator();
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
unlink((userConfDir + "other.software.org.ini").toLatin1());
rename((userConfDir + "software.org.ini").toLatin1(),
(userConfDir + "other.software.org.ini").toLatin1());
@@ -2856,27 +2856,19 @@ void tst_QSettings::isWritable()
if (s1.contains("foo")) {
#if defined(Q_OS_MACX)
- if (QSysInfo::macVersion() >= QSysInfo::MV_10_9) {
- QVERIFY(s1.isWritable());
- if (format == QSettings::NativeFormat) {
- QVERIFY(!s2.isWritable());
- QVERIFY(!s3.isWritable());
- } else {
- QVERIFY(s2.isWritable());
- QVERIFY(s3.isWritable());
- }
- } else if (QSysInfo::macVersion() >= QSysInfo::MV_10_7 &&
- format == QSettings::NativeFormat) {
- QVERIFY(!s1.isWritable());
+ QVERIFY(s1.isWritable());
+ if (format == QSettings::NativeFormat) {
QVERIFY(!s2.isWritable());
QVERIFY(!s3.isWritable());
- } else
-#endif
- {
- QVERIFY(s1.isWritable());
+ } else {
QVERIFY(s2.isWritable());
QVERIFY(s3.isWritable());
}
+#else
+ QVERIFY(s1.isWritable());
+ QVERIFY(s2.isWritable());
+ QVERIFY(s3.isWritable());
+#endif
} else {
QVERIFY(!s1.isWritable());
QVERIFY(!s2.isWritable());
diff --git a/tests/auto/corelib/io/qstorageinfo/BLACKLIST b/tests/auto/corelib/io/qstorageinfo/BLACKLIST
new file mode 100644
index 0000000000..ab4f888dd9
--- /dev/null
+++ b/tests/auto/corelib/io/qstorageinfo/BLACKLIST
@@ -0,0 +1,2 @@
+[storageList]
+opensuse-42.1
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 0e73ea7862..487c13be94 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -307,7 +307,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir()
void tst_QTemporaryDir::openOnRootDrives()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
#endif
// If it's possible to create a file in the root directory, it
@@ -321,7 +321,7 @@ void tst_QTemporaryDir::openOnRootDrives()
QVERIFY(dir.isValid());
}
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
SetErrorMode(lastErrorMode);
#endif
}
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 8ebde627df..59cd3a8411 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -415,9 +415,7 @@ void tst_QTemporaryFile::size()
// On CE it takes more time for the filesystem to update
// the information. Usually you have to close it or seek
// to get latest information. flush() does not help either.
-#if !defined(Q_OS_WINCE)
QCOMPARE(file.size(), qint64(6));
-#endif
file.seek(0);
QCOMPARE(file.size(), qint64(6));
}
@@ -436,7 +434,7 @@ void tst_QTemporaryFile::resize()
void tst_QTemporaryFile::openOnRootDrives()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
#endif
// If it's possible to create a file in the root directory, it
@@ -450,19 +448,14 @@ void tst_QTemporaryFile::openOnRootDrives()
QVERIFY(file.open());
}
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
SetErrorMode(lastErrorMode);
#endif
}
void tst_QTemporaryFile::stressTest()
{
-#if defined(Q_OS_WINCE)
- // 200 is still ok, first colision happens after ~30
- const int iterations = 200;
-#else
const int iterations = 1000;
-#endif
QSet<QString> names;
for (int i = 0; i < iterations; ++i) {
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 104873b85e..9533989b9d 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -175,20 +175,16 @@ private slots:
void octTest();
void zeroTermination();
void ws_manipulator();
-#ifndef Q_OS_WINCE
void stillOpenWhenAtEnd();
-#endif
void readNewlines_data();
void readNewlines();
void seek();
void pos();
void pos2();
void pos3LargeFile();
-#if !defined(Q_OS_WINCE)
void readStdin();
void readAllFromStdin();
void readLineFromStdin();
-#endif
void read();
void qbool();
void forcePoint();
@@ -1207,8 +1203,6 @@ void tst_QTextStream::ws_manipulator()
}
// ------------------------------------------------------------------------------
-#ifndef Q_OS_WINCE
-// Qt/CE: Cannot test network on emulator
void tst_QTextStream::stillOpenWhenAtEnd()
{
QFile file(QFINDTESTDATA("tst_qtextstream.cpp"));
@@ -1229,7 +1223,6 @@ void tst_QTextStream::stillOpenWhenAtEnd()
while (!stream2.readLine().isNull()) {}
QVERIFY(socket.isOpen());
}
-#endif
// ------------------------------------------------------------------------------
void tst_QTextStream::readNewlines_data()
@@ -1498,8 +1491,6 @@ void tst_QTextStream::pos3LargeFile()
}
// ------------------------------------------------------------------------------
-// Qt/CE has no stdin/out support for processes
-#if !defined(Q_OS_WINCE)
void tst_QTextStream::readStdin()
{
#ifdef QT_NO_PROCESS
@@ -1527,7 +1518,6 @@ void tst_QTextStream::readStdin()
}
// ------------------------------------------------------------------------------
-// Qt/CE has no stdin/out support for processes
void tst_QTextStream::readAllFromStdin()
{
#ifdef QT_NO_PROCESS
@@ -1549,7 +1539,6 @@ void tst_QTextStream::readAllFromStdin()
}
// ------------------------------------------------------------------------------
-// Qt/CE has no stdin/out support for processes
void tst_QTextStream::readLineFromStdin()
{
#ifdef QT_NO_PROCESS
@@ -1572,7 +1561,6 @@ void tst_QTextStream::readLineFromStdin()
QVERIFY(stdinProcess.waitForFinished(5000));
#endif
}
-#endif
// ------------------------------------------------------------------------------
void tst_QTextStream::read()
@@ -2799,12 +2787,7 @@ void tst_QTextStream::status_real_read()
void tst_QTextStream::status_integer_read()
{
-#ifdef Q_OS_WINCE
- QString text = QLatin1String("123 abc ");
- QTextStream s(&text);
-#else
QTextStream s("123 abc ");
-#endif
int i;
QString w;
s >> i;
@@ -2822,12 +2805,7 @@ void tst_QTextStream::status_integer_read()
void tst_QTextStream::status_word_read()
{
-#ifdef Q_OS_WINCE
- QString text = QLatin1String("abc ");
- QTextStream s(&text);
-#else
QTextStream s("abc ");
-#endif
QString w;
s >> w;
QCOMPARE(s.status(), QTextStream::Ok);
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
index 4b3f76a78e..6ea7a38137 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
@@ -239,18 +239,10 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
// Basic tree StandardItemModel
QModelIndex parent;
QVariant blue = QVariant(QColor(Qt::blue));
-#ifndef Q_OS_WINCE
for (int i = 0; i < 4; ++i) {
-#else
- for (int i = 0; i < 2; ++i) {
-#endif
parent = model->index(0, 0, parent);
model->insertRows(0, 26 + i, parent);
-#ifndef Q_OS_WINCE
- model->insertColumns(0, 26 + i, parent);
-#else
model->insertColumns(0, 4 + i, parent);
-#endif
// Fill in some values to make it easier to debug
/*
for (int x = 0; x < 26 + i; ++x) {
@@ -272,18 +264,10 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
// Basic tree StandardItemModel
QModelIndex parent;
QVariant blue = QVariant(QColor(Qt::blue));
-#ifndef Q_OS_WINCE
for (int i = 0; i < 4; ++i) {
-#else
- for (int i = 0; i < 2; ++i) {
-#endif
parent = realModel->index(0, 0, parent);
realModel->insertRows(0, 26+i, parent);
-#ifndef Q_OS_WINCE
- realModel->insertColumns(0, 26+i, parent);
-#else
realModel->insertColumns(0, 4, parent);
-#endif
// Fill in some values to make it easier to debug
/*
for (int x = 0; x < 26+i; ++x) {
@@ -324,11 +308,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
QSqlQuery q;
q.exec("CREATE TABLE test(id int primary key, name varchar(30))");
q.prepare("INSERT INTO test(id, name) values (?, ?)");
-#ifndef Q_OS_WINCE
for (int i = 0; i < 1024; ++i) {
-#else
- for (int i = 0; i < 512; ++i) {
-#endif
q.addBindValue(i);
q.addBindValue("Mr. Smith" + QString::number(i));
q.exec();
@@ -344,11 +324,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
}
if (QListWidget *listWidget = qobject_cast<QListWidget *>(model->parent())) {
-#ifndef Q_OS_WINCE
- int items = 100;
-#else
int items = 50;
-#endif
while (items--)
listWidget->addItem(QLatin1String("item ") + QString::number(items));
return QModelIndex();
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 5878d56a47..ade0a45200 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -137,6 +137,8 @@ private Q_SLOTS:
void garbageAtEnd();
void removeNonLatinKey();
+ void documentFromVariant();
+
private:
QString testDataDir;
};
@@ -2788,5 +2790,43 @@ void tst_QtJson::removeNonLatinKey()
QVERIFY(restoredObject.contains(nonLatinKeyName));
}
+void tst_QtJson::documentFromVariant()
+{
+ // Test the valid forms of QJsonDocument::fromVariant.
+
+ QString string = QStringLiteral("value");
+
+ QStringList strList;
+ strList.append(string);
+
+ QJsonDocument da1 = QJsonDocument::fromVariant(QVariant(strList));
+ QVERIFY(da1.isArray());
+
+ QVariantList list;
+ list.append(string);
+
+ QJsonDocument da2 = QJsonDocument::fromVariant(list);
+ QVERIFY(da2.isArray());
+
+ // As JSON arrays they should be equal.
+ QCOMPARE(da1.array(), da2.array());
+
+
+ QMap <QString, QVariant> map;
+ map["key"] = string;
+
+ QJsonDocument do1 = QJsonDocument::fromVariant(QVariant(map));
+ QVERIFY(do1.isObject());
+
+ QHash <QString, QVariant> hash;
+ hash["key"] = string;
+
+ QJsonDocument do2 = QJsonDocument::fromVariant(QVariant(hash));
+ QVERIFY(do2.isObject());
+
+ // As JSON objects they should be equal.
+ QCOMPARE(do1.object(), do2.object());
+}
+
QTEST_MAIN(tst_QtJson)
#include "tst_qtjson.moc"
diff --git a/tests/auto/corelib/kernel/kernel.pro b/tests/auto/corelib/kernel/kernel.pro
index f85c39e9e6..431d483339 100644
--- a/tests/auto/corelib/kernel/kernel.pro
+++ b/tests/auto/corelib/kernel/kernel.pro
@@ -1,6 +1,7 @@
TEMPLATE=subdirs
SUBDIRS=\
qcoreapplication \
+ qelapsedtimer \
qeventdispatcher \
qeventloop \
qmath \
@@ -38,4 +39,4 @@ SUBDIRS=\
# This test is only applicable on Windows
!win32*|winrt: SUBDIRS -= qwineventnotifier
-android|ios: SUBDIRS -= qsharedmemory qsystemsemaphore
+android|uikit: SUBDIRS -= qsharedmemory qsystemsemaphore
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index a8de5b7a9a..0691297497 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -155,7 +155,7 @@ void tst_QCoreApplication::qAppName()
void tst_QCoreApplication::argc()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
QSKIP("QCoreApplication::arguments() parses arguments from actual command line on this platform.");
#endif
{
diff --git a/tests/auto/corelib/tools/qelapsedtimer/qelapsedtimer.pro b/tests/auto/corelib/kernel/qelapsedtimer/qelapsedtimer.pro
index 657a63a5d7..657a63a5d7 100644
--- a/tests/auto/corelib/tools/qelapsedtimer/qelapsedtimer.pro
+++ b/tests/auto/corelib/kernel/qelapsedtimer/qelapsedtimer.pro
diff --git a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp
index 9db001c37d..9db001c37d 100644
--- a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp
+++ b/tests/auto/corelib/kernel/qelapsedtimer/tst_qelapsedtimer.cpp
diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro
index 5cd043b584..50072dc612 100644
--- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro
+++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro
@@ -3,6 +3,6 @@ TARGET = tst_qeventloop
QT = core network testlib core-private
SOURCES = $$PWD/tst_qeventloop.cpp
-win32:!wince:!winrt: LIBS += -luser32
+win32:!winrt: LIBS += -luser32
contains(QT_CONFIG, glib): DEFINES += HAVE_GLIB
diff --git a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
index 1d4e647a4b..b5f1d0fe00 100644
--- a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
+++ b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro
@@ -6,11 +6,11 @@ SOURCES = tst_qmetatype.cpp
TESTDATA=./typeFlags.bin
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-win32-msvc*|wince|winrt {
+win32-msvc*|winrt {
# Prevents "fatal error C1128: number of sections exceeded object file format limit".
QMAKE_CXXFLAGS += /bigobj
# Reduce compile time
- win32-msvc2012|wince|winrt {
+ win32-msvc2012|winrt {
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE -= -O2
}
diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro
index 125915047a..cc51b4c661 100644
--- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro
+++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro
@@ -2,9 +2,6 @@ CONFIG -= app_bundle debug_and_release
CONFIG += console
DESTDIR = ./
QT = core
-wince {
- LIBS += coredll.lib
-}
HEADERS += signalbug.h
SOURCES += signalbug.cpp
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index b605b89f34..9ee9c1f331 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -66,6 +66,7 @@ private slots:
void connectDisconnectNotify();
void connectDisconnectNotifyPMF();
void disconnectNotify_receiverDestroyed();
+ void disconnectNotify_metaObjConnection();
void connectNotify_connectSlotsByName();
void connectDisconnectNotify_shadowing();
void emitInDefinedOrder();
@@ -923,8 +924,7 @@ void tst_QObject::connectDisconnectNotifyPMF()
// Test disconnectNotify when disconnecting by QMetaObject::Connection
QVERIFY(QObject::disconnect(conn));
- // disconnectNotify() is not called, but it probably should be.
- QVERIFY(s->disconnectedSignals.isEmpty());
+ QVERIFY(!s->disconnectedSignals.isEmpty());
// Test connectNotify when connecting by function pointer
s->clearNotifications();
@@ -969,6 +969,25 @@ void tst_QObject::disconnectNotify_receiverDestroyed()
delete s;
}
+void tst_QObject::disconnectNotify_metaObjConnection()
+{
+ NotifyObject *s = new NotifyObject;
+ NotifyObject *r = new NotifyObject;
+
+ QMetaObject::Connection c = QObject::connect((SenderObject*)s, SIGNAL(signal1()),
+ (ReceiverObject*)r, SLOT(slot1()));
+ QVERIFY(c);
+ QVERIFY(QObject::disconnect(c));
+
+ QCOMPARE(s->disconnectedSignals.count(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1));
+
+ delete r;
+ QCOMPARE(s->disconnectedSignals.count(), 1);
+
+ delete s;
+}
+
class ConnectByNameNotifySenderObject : public QObject
{
Q_OBJECT
@@ -1575,11 +1594,7 @@ Q_DECLARE_METATYPE(PropertyObject::Priority)
void tst_QObject::threadSignalEmissionCrash()
{
-#if defined(Q_OS_WINCE)
- int loopCount = 100;
-#else
int loopCount = 1000;
-#endif
for (int i = 0; i < loopCount; ++i) {
QTcpSocket socket;
socket.connectToHost("localhost", 80);
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
index b6f6d2a7f3..26caff4301 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp
@@ -90,7 +90,7 @@ private slots:
// extreme cases
void useTooMuchMemory();
-#if !defined(Q_OS_HPUX) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_HPUX)
void attachTooMuch();
#endif
@@ -516,8 +516,7 @@ void tst_QSharedMemory::useTooMuchMemory()
attach before the system runs out of resources.
*/
// HPUX doesn't allow for multiple attaches per process.
-// For WinCE, this test nearly kills the system, so skip it.
-#if !defined(Q_OS_HPUX) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_HPUX)
void tst_QSharedMemory::attachTooMuch()
{
QSKIP("disabled");
@@ -576,9 +575,7 @@ void tst_QSharedMemory::simpleProducerConsumer()
char *get = (char*)consumer.data();
// On Windows CE you always have ReadWrite access. Thus
// ViewMapOfFile returns the same pointer
-#if !defined(Q_OS_WINCE)
QVERIFY(put != get);
-#endif
for (int i = 0; i < size; ++i) {
put[i] = 'Q';
QCOMPARE(get[i], 'Q');
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 6fd192c357..28df01cc16 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -52,6 +52,7 @@ private slots:
void remainingTime();
void remainingTimeDuringActivation_data();
void remainingTimeDuringActivation();
+ void basic_chrono();
void livelock_data();
void livelock();
void timerInfiniteRecursion_data();
@@ -68,6 +69,7 @@ private slots:
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
void singleShotToFunctors();
+ void singleShot_chrono();
void crossThreadSingleShotToFunctor();
void dontBlockEvents();
@@ -214,6 +216,57 @@ void tst_QTimer::remainingTimeDuringActivation()
}
}
+void tst_QTimer::basic_chrono()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires C++11 <chrono> support");
+#else
+ // duplicates zeroTimer, singleShotTimeout, interval and remainingTime
+ using namespace std::chrono;
+ TimerHelper helper;
+ QTimer timer;
+ timer.setInterval(nanoseconds(0));
+ timer.start();
+ QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(0));
+ QCOMPARE(timer.remainingTimeAsDuration().count(), milliseconds::rep(0));
+
+ connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout()));
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(helper.count, 1);
+
+ helper.count = 0;
+ timer.start(milliseconds(100));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 0);
+ int oldCount = helper.count;
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+
+ helper.count = 0;
+ timer.start(microseconds(200000));
+ QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(200));
+ QTest::qWait(50);
+ QCOMPARE(helper.count, 0);
+
+ milliseconds rt = timer.remainingTimeAsDuration();
+ QVERIFY2(qAbs(rt.count() - 150) < 50, qPrintable(QString::number(rt.count())));
+
+ helper.count = 0;
+ timer.setSingleShot(true);
+ timer.start(milliseconds(100));
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+ helper.count = 0;
+#endif
+}
+
void tst_QTimer::livelock_data()
{
QTest::addColumn<int>("interval");
@@ -295,9 +348,6 @@ void tst_QTimer::livelock()
QTRY_COMPARE(tester.timeoutsForFirst, 1);
QCOMPARE(tester.timeoutsForExtra, 0);
QTRY_COMPARE(tester.timeoutsForSecond, 1);
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("non-zero timer", "Windows CE devices often too slow", Continue);
-#endif
QVERIFY(tester.postEventAtRightTime);
}
@@ -790,6 +840,51 @@ void tst_QTimer::singleShotToFunctors()
_t = Q_NULLPTR;
}
+void tst_QTimer::singleShot_chrono()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires C++11 <chrono> support");
+#else
+ // duplicates singleShotStaticFunctionZeroTimeout and singleShotToFunctors
+ using namespace std::chrono;
+ TimerHelper helper;
+
+ QTimer::singleShot(hours(0), &helper, SLOT(timeout()));
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+
+ TimerHelper nhelper;
+
+ QTimer::singleShot(seconds(0), &nhelper, &TimerHelper::timeout);
+ QCoreApplication::processEvents();
+ QCOMPARE(nhelper.count, 1);
+ QCoreApplication::processEvents();
+ QCOMPARE(nhelper.count, 1);
+
+ int count = 0;
+ QTimer::singleShot(microseconds(0), CountedStruct(&count));
+ QCoreApplication::processEvents();
+ QCOMPARE(count, 1);
+
+ _e.reset(new QEventLoop);
+ QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
+ QCOMPARE(_e->exec(), 0);
+
+ QObject c3;
+ QTimer::singleShot(milliseconds(500), &c3, CountedStruct(&count));
+ QTest::qWait(800);
+ QCOMPARE(count, 2);
+
+ QTimer::singleShot(0, [&count] { ++count; });
+ QCoreApplication::processEvents();
+ QCOMPARE(count, 3);
+
+ _e.reset();
+#endif
+}
+
class DontBlockEvents : public QObject
{
Q_OBJECT
diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin
index ee3da63a18..e3a897c37d 100644
--- a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin
+++ b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin
Binary files differ
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 593706ac0d..a7ab221dda 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -116,7 +116,7 @@ Q_CONSTRUCTOR_FUNCTION(initializeLang)
static QString seedAndTemplate()
{
- qsrand(QDateTime::currentDateTimeUtc().toTime_t());
+ qsrand(QDateTime::currentSecsSinceEpoch());
return QDir::tempPath() + "/tst_qmimedatabase-XXXXXX";
}
diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
index 44bd0be14e..3e15861021 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro
@@ -6,7 +6,6 @@ TARGET = mylib
DESTDIR = ../
QT = core
-wince: DEFINES += WIN32_MSVC
win32-msvc: DEFINES += WIN32_MSVC
# This project is testdata for tst_qlibrary
diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
index d55747501c..bd73227b3d 100644
--- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
+++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro
@@ -7,7 +7,6 @@ DESTDIR = ../
VERSION = 2
QT = core
-wince: DEFINES += WIN32_MSVC
win32-msvc: DEFINES += WIN32_MSVC
# Force a copy of the library to have an extension that is non-standard.
diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
index ed41ab51e1..42fed1191b 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp
@@ -189,7 +189,7 @@ void tst_QLibrary::load_data()
QTest::newRow("ok (libmylib ver. 1)") << appDir + "/libmylib" <<true;
#endif
-# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+# if defined(Q_OS_WIN32)
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << true;
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << true;
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << true;
@@ -223,10 +223,6 @@ void tst_QLibrary::unload_data()
QString appDir = QCoreApplication::applicationDirPath();
QTest::newRow( "mylib" ) << appDir + "/mylib" << true;
-#ifdef Q_OS_MAC
- if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3)
- QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue);
-#endif
QTest::newRow( "ok01" ) << appDir + "/nolib" << false;
}
@@ -346,11 +342,7 @@ void tst_QLibrary::errorString_data()
QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*");
QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error");
-#ifdef Q_OS_WINCE
- QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*");
-#else
QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*");
-#endif
QTest::newRow("good resolve") << (int)Resolve << appDir + "/mylib" << true << QString("Unknown error");
#ifdef Q_OS_WIN
@@ -414,7 +406,7 @@ void tst_QLibrary::loadHints_data()
QString appDir = QCoreApplication::applicationDirPath();
lh |= QLibrary::ResolveAllSymbolsHint;
-# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+# if defined(Q_OS_WIN32) || defined(Q_OS_WINRT)
QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << int(lh) << true;
QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << int(lh) << true;
QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true;
@@ -467,13 +459,8 @@ void tst_QLibrary::fileName_data()
QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib"))
<< sys_qualifiedLibraryName(QLatin1String("mylib"));
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-#ifndef Q_OS_WINCE
QTest::newRow( "ok03" ) << "user32"
<< "USER32.dll";
-#else
- QTest::newRow( "ok03" ) << "coredll"
- << "coredll.dll";
-#endif
#endif
}
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index bc853de24e..499d276ef8 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -140,11 +140,6 @@ void tst_QPluginLoader::cleanup()
void tst_QPluginLoader::errorString()
{
-#if defined(Q_OS_WINCE)
- // On WinCE we need an QCoreApplication object for current dir
- int argc = 0;
- QCoreApplication app(argc,0);
-#endif
const QString unknown(QLatin1String("Unknown error"));
{
diff --git a/tests/auto/corelib/thread/qmutex/qmutex.pro b/tests/auto/corelib/thread/qmutex/qmutex.pro
index 229e57eb89..cb9d364b71 100644
--- a/tests/auto/corelib/thread/qmutex/qmutex.pro
+++ b/tests/auto/corelib/thread/qmutex/qmutex.pro
@@ -2,3 +2,4 @@ CONFIG += testcase
TARGET = tst_qmutex
QT = core testlib
SOURCES = tst_qmutex.cpp
+win32:QT += core-private
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index 594bae674c..b24ecfcd43 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -31,16 +31,27 @@
#include <qatomic.h>
#include <qcoreapplication.h>
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <qmutex.h>
#include <qthread.h>
#include <qwaitcondition.h>
+#ifdef Q_OS_WIN
+#include <private/qsystemlibrary_p.h>
+#include <cmath>
+#endif
+
class tst_QMutex : public QObject
{
Q_OBJECT
private slots:
- void tryLock();
+ void initTestCase();
+ void tryLock_non_recursive();
+ void try_lock_for_non_recursive();
+ void try_lock_until_non_recursive();
+ void tryLock_recursive();
+ void try_lock_for_recursive();
+ void try_lock_until_recursive();
void lock_unlock_locked_tryLock();
void stressTest();
void tryLockRace();
@@ -48,6 +59,8 @@ private slots:
void tryLockNegative_data();
void tryLockNegative();
void moreStress();
+private:
+ void initializeSystemTimersResolution();
};
static const int iterations = 100;
@@ -58,257 +71,819 @@ QSemaphore testsTurn;
QSemaphore threadsTurn;
enum { waitTime = 100 };
+uint systemTimersResolution = 1;
+
+#if QT_HAS_INCLUDE(<chrono>)
+static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime);
+#endif
+
+/*
+ Depending on the OS, tryWaits may return early than expected because of the
+ resolution of the underlying timer is too coarse. E.g.: on Windows
+ WaitForSingleObjectEx does *not* use high resolution multimedia timers, and
+ it's actually very coarse, about 16msec by default.
+
+ Try to find out the timer resolution in here, so that the tryLock tests can
+ actually take into account early wakes.
+*/
+void tst_QMutex::initializeSystemTimersResolution()
+{
+#ifdef Q_OS_WIN
+ // according to MSDN, Windows can default up to this
+ systemTimersResolution = 16;
+
+ // private API. There's no way on Windows to otherwise know the
+ // actual resolution of the application's timers (you can only set it)
+ // cf. https://stackoverflow.com/questions/7685762/windows-7-timing-functions-how-to-use-getsystemtimeadjustment-correctly/11743614#11743614
+ typedef NTSTATUS (NTAPI *NtQueryTimerResolutionType)(OUT PULONG MinimumResolution,
+ OUT PULONG MaximumResolution,
+ OUT PULONG ActualResolution);
+
+ const NtQueryTimerResolutionType NtQueryTimerResolutionPtr =
+ reinterpret_cast<NtQueryTimerResolutionType>(QSystemLibrary::resolve(QStringLiteral("ntdll"), "NtQueryTimerResolution"));
+
+ if (!NtQueryTimerResolutionPtr)
+ return;
+
+ ULONG minimumResolution;
+ ULONG maximumResolution;
+ ULONG actualResolution;
+
+ if (!NtQueryTimerResolutionPtr(&minimumResolution, &maximumResolution, &actualResolution)) {
+ // the result is in 100ns units => adjust to msec
+ const double actualResolutionMsec = actualResolution / 10000.0;
+ systemTimersResolution = static_cast<int>(std::ceil(actualResolutionMsec));
+ }
+#endif // Q_OS_WIN
+}
+
+void tst_QMutex::initTestCase()
+{
+ initializeSystemTimersResolution();
+}
-void tst_QMutex::tryLock()
+void tst_QMutex::tryLock_non_recursive()
{
- // test non-recursive mutex
+ class Thread : public QThread
{
- class Thread : public QThread
+ public:
+ void run()
{
- public:
- void run()
- {
- testsTurn.release();
-
- // TEST 1: thread can't acquire lock
- threadsTurn.acquire();
- QVERIFY(!normalMutex.tryLock());
- testsTurn.release();
-
- // TEST 2: thread can acquire lock
- threadsTurn.acquire();
- QVERIFY(normalMutex.tryLock());
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- QVERIFY(!normalMutex.tryLock());
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- testsTurn.release();
-
- // TEST 3: thread can't acquire lock, timeout = waitTime
- threadsTurn.acquire();
- QTime timer;
- timer.start();
- QVERIFY(!normalMutex.tryLock(waitTime));
- QVERIFY(timer.elapsed() >= waitTime);
- testsTurn.release();
-
- // TEST 4: thread can acquire lock, timeout = waitTime
- threadsTurn.acquire();
- timer.start();
- QVERIFY(normalMutex.tryLock(waitTime));
- QVERIFY(timer.elapsed() <= waitTime);
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- timer.start();
- // it's non-recursive, so the following lock needs to fail
- QVERIFY(!normalMutex.tryLock(waitTime));
- QVERIFY(timer.elapsed() >= waitTime);
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- testsTurn.release();
-
- // TEST 5: thread can't acquire lock, timeout = 0
- threadsTurn.acquire();
- QVERIFY(!normalMutex.tryLock(0));
- testsTurn.release();
-
- // TEST 6: thread can acquire lock, timeout = 0
- threadsTurn.acquire();
- timer.start();
- QVERIFY(normalMutex.tryLock(0));
- QVERIFY(timer.elapsed() < waitTime);
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- QVERIFY(!normalMutex.tryLock(0));
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- testsTurn.release();
-
- // TEST 7 overflow: thread can acquire lock, timeout = 3000 (QTBUG-24795)
- threadsTurn.acquire();
- timer.start();
- QVERIFY(normalMutex.tryLock(3000));
- QVERIFY(timer.elapsed() < 3000);
- normalMutex.unlock();
- testsTurn.release();
-
- threadsTurn.acquire();
- }
- };
+ testsTurn.release();
+
+ // TEST 1: thread can't acquire lock
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.tryLock());
+ testsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ threadsTurn.acquire();
+ QVERIFY(normalMutex.tryLock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.tryLock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ QElapsedTimer timer;
+ timer.start();
+ QVERIFY(!normalMutex.tryLock(waitTime));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ testsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.tryLock(waitTime));
+ QVERIFY(timer.elapsed() <= waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ timer.start();
+ // it's non-recursive, so the following lock needs to fail
+ QVERIFY(!normalMutex.tryLock(waitTime));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.tryLock(0));
+ testsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.tryLock(0));
+ QVERIFY(timer.elapsed() < waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.tryLock(0));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 7 overflow: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.tryLock(3000));
+ QVERIFY(timer.elapsed() < 3000 + systemTimersResolution);
+ normalMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
- Thread thread;
- thread.start();
+ Thread thread;
+ thread.start();
+
+ // TEST 1: thread can't acquire lock
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 7: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ testsTurn.acquire();
+ normalMutex.lock();
+ threadsTurn.release();
+ QThread::msleep(100);
+ normalMutex.unlock();
+
+ // wait for thread to finish
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+}
- // TEST 1: thread can't acquire lock
- testsTurn.acquire();
- normalMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- threadsTurn.release();
-
- // TEST 2: thread can acquire lock
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- threadsTurn.release();
-
- // TEST 3: thread can't acquire lock, timeout = waitTime
- testsTurn.acquire();
- normalMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- threadsTurn.release();
-
- // TEST 4: thread can acquire lock, timeout = waitTime
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- threadsTurn.release();
-
- // TEST 5: thread can't acquire lock, timeout = 0
- testsTurn.acquire();
- normalMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- threadsTurn.release();
-
- // TEST 6: thread can acquire lock, timeout = 0
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- normalMutex.unlock();
- threadsTurn.release();
-
- // TEST 7: thread can acquire lock, timeout = 3000 (QTBUG-24795)
- testsTurn.acquire();
- normalMutex.lock();
- threadsTurn.release();
- QThread::msleep(100);
- normalMutex.unlock();
-
- // wait for thread to finish
- testsTurn.acquire();
- threadsTurn.release();
- thread.wait();
- }
+void tst_QMutex::try_lock_for_non_recursive() {
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires <chrono>");
+#else
+ class Thread : public QThread
+ {
+ public:
+ void run()
+ {
+ testsTurn.release();
+
+ // TEST 1: thread can't acquire lock
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.try_lock());
+ testsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ threadsTurn.acquire();
+ QVERIFY(normalMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ QElapsedTimer timer;
+ timer.start();
+ QVERIFY(!normalMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ testsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(timer.elapsed() <= waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ timer.start();
+ // it's non-recursive, so the following lock needs to fail
+ QVERIFY(!normalMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ testsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ QVERIFY(timer.elapsed() < waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 7 overflow: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(normalMutex.try_lock_for(std::chrono::milliseconds(3000)));
+ QVERIFY(timer.elapsed() < 3000 + systemTimersResolution);
+ normalMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
+
+ Thread thread;
+ thread.start();
+
+ // TEST 1: thread can't acquire lock
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 7: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ testsTurn.acquire();
+ normalMutex.lock();
+ threadsTurn.release();
+ QThread::msleep(100);
+ normalMutex.unlock();
+
+ // wait for thread to finish
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+#endif
+}
- // test recursive mutex
+void tst_QMutex::try_lock_until_non_recursive()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires <chrono>");
+#else
+ class Thread : public QThread
{
- class Thread : public QThread
+ public:
+ void run()
{
- public:
- void run()
- {
- testsTurn.release();
-
- threadsTurn.acquire();
- QVERIFY(!recursiveMutex.tryLock());
- testsTurn.release();
-
- threadsTurn.acquire();
- QVERIFY(recursiveMutex.tryLock());
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- QVERIFY(recursiveMutex.tryLock());
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- testsTurn.release();
-
- threadsTurn.acquire();
- QTime timer;
- timer.start();
- QVERIFY(!recursiveMutex.tryLock(waitTime));
- QVERIFY(timer.elapsed() >= waitTime);
- QVERIFY(!recursiveMutex.tryLock(0));
- testsTurn.release();
-
- threadsTurn.acquire();
- timer.start();
- QVERIFY(recursiveMutex.tryLock(waitTime));
- QVERIFY(timer.elapsed() <= waitTime);
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- QVERIFY(recursiveMutex.tryLock(waitTime));
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- testsTurn.release();
-
- threadsTurn.acquire();
- QVERIFY(!recursiveMutex.tryLock(0));
- QVERIFY(!recursiveMutex.tryLock(0));
- testsTurn.release();
-
- threadsTurn.acquire();
- timer.start();
- QVERIFY(recursiveMutex.tryLock(0));
- QVERIFY(timer.elapsed() < waitTime);
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- QVERIFY(recursiveMutex.tryLock(0));
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- testsTurn.release();
-
- threadsTurn.acquire();
- }
- };
+ const std::chrono::milliseconds systemTimersResolutionAsDuration(systemTimersResolution);
+ testsTurn.release();
+
+ // TEST 1: thread can't acquire lock
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.try_lock());
+ testsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ threadsTurn.acquire();
+ QVERIFY(normalMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ auto endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(!normalMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() >= endTimePoint - systemTimersResolutionAsDuration);
+ testsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ threadsTurn.acquire();
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(normalMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() <= endTimePoint + systemTimersResolutionAsDuration);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ // it's non-recursive, so the following lock needs to fail
+ QVERIFY(!normalMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() >= endTimePoint - systemTimersResolutionAsDuration);
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ threadsTurn.acquire();
+ QVERIFY(!normalMutex.try_lock_until(std::chrono::steady_clock::now()));
+ testsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ threadsTurn.acquire();
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(normalMutex.try_lock_until(std::chrono::steady_clock::now()));
+ QVERIFY(std::chrono::steady_clock::now() < endTimePoint + systemTimersResolutionAsDuration);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(!normalMutex.try_lock_until(std::chrono::steady_clock::now()));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ testsTurn.release();
+
+ // TEST 7 overflow: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ threadsTurn.acquire();
+ endTimePoint = std::chrono::steady_clock::now() + std::chrono::milliseconds(3000);
+ QVERIFY(normalMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() < endTimePoint + systemTimersResolutionAsDuration);
+ normalMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
- Thread thread;
- thread.start();
+ Thread thread;
+ thread.start();
+
+ // TEST 1: thread can't acquire lock
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 2: thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 3: thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 4: thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 5: thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ normalMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ threadsTurn.release();
+
+ // TEST 6: thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ normalMutex.unlock();
+ threadsTurn.release();
+
+ // TEST 7: thread can acquire lock, timeout = 3000 (QTBUG-24795)
+ testsTurn.acquire();
+ normalMutex.lock();
+ threadsTurn.release();
+ QThread::msleep(100);
+ normalMutex.unlock();
+
+ // wait for thread to finish
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+#endif
+}
- // thread can't acquire lock
- testsTurn.acquire();
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- threadsTurn.release();
-
- // thread can acquire lock
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- threadsTurn.release();
-
- // thread can't acquire lock, timeout = waitTime
- testsTurn.acquire();
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- threadsTurn.release();
-
- // thread can acquire lock, timeout = waitTime
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- threadsTurn.release();
-
- // thread can't acquire lock, timeout = 0
- testsTurn.acquire();
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(0, 1));
- recursiveMutex.lock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 2));
- threadsTurn.release();
-
- // thread can acquire lock, timeout = 0
- testsTurn.acquire();
- QVERIFY(lockCount.testAndSetRelaxed(2, 1));
- recursiveMutex.unlock();
- QVERIFY(lockCount.testAndSetRelaxed(1, 0));
- recursiveMutex.unlock();
- threadsTurn.release();
-
- // stop thread
- testsTurn.acquire();
- threadsTurn.release();
- thread.wait();
- }
+void tst_QMutex::tryLock_recursive()
+{
+ class Thread : public QThread
+ {
+ public:
+ void run()
+ {
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.tryLock());
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(recursiveMutex.tryLock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.tryLock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QElapsedTimer timer;
+ timer.start();
+ QVERIFY(!recursiveMutex.tryLock(waitTime));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ QVERIFY(!recursiveMutex.tryLock(0));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(recursiveMutex.tryLock(waitTime));
+ QVERIFY(timer.elapsed() <= waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.tryLock(waitTime));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.tryLock(0));
+ QVERIFY(!recursiveMutex.tryLock(0));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(recursiveMutex.tryLock(0));
+ QVERIFY(timer.elapsed() < waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.tryLock(0));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
+
+ Thread thread;
+ thread.start();
+
+ // thread can't acquire lock
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // stop thread
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+}
+
+void tst_QMutex::try_lock_for_recursive()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires <chrono>");
+#else
+ class Thread : public QThread
+ {
+ public:
+ void run()
+ {
+ const std::chrono::milliseconds systemTimersResolutionAsDuration(systemTimersResolution);
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.try_lock());
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(recursiveMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QElapsedTimer timer;
+ timer.start();
+ QVERIFY(!recursiveMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution);
+ QVERIFY(!recursiveMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(recursiveMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(timer.elapsed() <= waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.try_lock_for(waitTimeAsDuration));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ QVERIFY(!recursiveMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ timer.start();
+ QVERIFY(recursiveMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ QVERIFY(timer.elapsed() < waitTime + systemTimersResolution);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.try_lock_for(std::chrono::milliseconds::zero()));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
+
+ Thread thread;
+ thread.start();
+
+ // thread can't acquire lock
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // stop thread
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+#endif
+}
+
+void tst_QMutex::try_lock_until_recursive()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires <chrono>");
+#else
+ class Thread : public QThread
+ {
+ public:
+ void run()
+ {
+ const std::chrono::milliseconds systemTimersResolutionAsDuration(systemTimersResolution);
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.try_lock());
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(recursiveMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.try_lock());
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ auto endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(!recursiveMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() >= endTimePoint - systemTimersResolutionAsDuration);
+ QVERIFY(!recursiveMutex.try_lock());
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(recursiveMutex.try_lock_until(endTimePoint));
+ QVERIFY(std::chrono::steady_clock::now() <= endTimePoint + systemTimersResolutionAsDuration);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(recursiveMutex.try_lock_until(endTimePoint));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ QVERIFY(!recursiveMutex.try_lock_until(std::chrono::steady_clock::now()));
+ QVERIFY(!recursiveMutex.try_lock_until(std::chrono::steady_clock::now()));
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ endTimePoint = std::chrono::steady_clock::now() + waitTimeAsDuration;
+ QVERIFY(recursiveMutex.try_lock_until(std::chrono::steady_clock::now()));
+ QVERIFY(std::chrono::steady_clock::now() <= endTimePoint + systemTimersResolutionAsDuration);
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ QVERIFY(recursiveMutex.try_lock_until(std::chrono::steady_clock::now()));
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ testsTurn.release();
+
+ threadsTurn.acquire();
+ }
+ };
+
+ Thread thread;
+ thread.start();
+
+ // thread can't acquire lock
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = waitTime
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // thread can't acquire lock, timeout = 0
+ testsTurn.acquire();
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(0, 1));
+ recursiveMutex.lock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 2));
+ threadsTurn.release();
+
+ // thread can acquire lock, timeout = 0
+ testsTurn.acquire();
+ QVERIFY(lockCount.testAndSetRelaxed(2, 1));
+ recursiveMutex.unlock();
+ QVERIFY(lockCount.testAndSetRelaxed(1, 0));
+ recursiveMutex.unlock();
+ threadsTurn.release();
+
+ // stop thread
+ testsTurn.acquire();
+ threadsTurn.release();
+ thread.wait();
+#endif
}
class mutex_Thread : public QThread
@@ -439,7 +1014,7 @@ enum { one_minute = 6 * 1000, //not really one minute, but else it is too long.
class StressTestThread : public QThread
{
- QTime t;
+ QElapsedTimer t;
public:
static QBasicAtomicInt lockCount;
static QBasicAtomicInt sentinel;
@@ -491,7 +1066,7 @@ public:
void run()
{
- QTime t;
+ QElapsedTimer t;
t.start();
do {
if (mutex.tryLock())
@@ -619,7 +1194,7 @@ void tst_QMutex::tryLockNegative()
class MoreStressTestThread : public QThread
{
- QTime t;
+ QElapsedTimer t;
public:
static QAtomicInt lockCount;
static QAtomicInt sentinel[threadCount];
diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
index 341bd21e5a..8597bf1a6d 100644
--- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
+++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
@@ -350,15 +350,9 @@ const int AlphabetSize = sizeof(alphabet) - 1;
const int BufferSize = 4096; // GCD of BufferSize and alphabet size must be 1
char buffer[BufferSize];
-#ifndef Q_OS_WINCE
const int ProducerChunkSize = 3;
const int ConsumerChunkSize = 7;
const int Multiplier = 10;
-#else
-const int ProducerChunkSize = 2;
-const int ConsumerChunkSize = 5;
-const int Multiplier = 3;
-#endif
// note: the code depends on the fact that DataSize is a multiple of
// ProducerChunkSize, ConsumerChunkSize, and BufferSize
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index b4d0866d01..06b27f79cd 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -95,9 +95,7 @@ private slots:
void requestTermination();
-#ifndef Q_OS_WINCE
void stressTest();
-#endif
void quitLock();
};
@@ -664,7 +662,7 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data)
#if defined Q_OS_UNIX
const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this);
Q_UNUSED(state);
-#elif defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#elif defined(Q_OS_WINRT)
nativeThreadHandle = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL);
#elif defined Q_OS_WIN
unsigned thrdid = 0;
@@ -684,11 +682,7 @@ void NativeThreadWrapper::join()
#if defined Q_OS_UNIX
pthread_join(nativeThreadHandle, 0);
#elif defined Q_OS_WIN
-#ifndef Q_OS_WINCE
WaitForSingleObjectEx(nativeThreadHandle, INFINITE, FALSE);
-#else
- WaitForSingleObject(nativeThreadHandle, INFINITE);
-#endif
CloseHandle(nativeThreadHandle);
#endif
}
@@ -874,13 +868,8 @@ void tst_QThread::adoptedThreadExecFinished()
void tst_QThread::adoptMultipleThreads()
{
#if defined(Q_OS_WIN)
- // Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already.
-# if defined(Q_OS_WINCE)
- const int numThreads = 20;
-# else
// need to test lots of threads, so that we exceed MAXIMUM_WAIT_OBJECTS in qt_adopted_thread_watcher()
const int numThreads = 200;
-# endif
#else
const int numThreads = 5;
#endif
@@ -911,13 +900,8 @@ void tst_QThread::adoptMultipleThreads()
void tst_QThread::adoptMultipleThreadsOverlap()
{
#if defined(Q_OS_WIN)
- // Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already.
-# if defined(Q_OS_WINCE)
- const int numThreads = 20;
-# else
// need to test lots of threads, so that we exceed MAXIMUM_WAIT_OBJECTS in qt_adopted_thread_watcher()
const int numThreads = 200;
-# endif
#else
const int numThreads = 5;
#endif
@@ -950,7 +934,6 @@ void tst_QThread::adoptMultipleThreadsOverlap()
QCOMPARE(recorder.activationCount.load(), numThreads);
}
-#ifndef Q_OS_WINCE
// Disconnects on WinCE
void tst_QThread::stressTest()
{
@@ -962,7 +945,6 @@ void tst_QThread::stressTest()
t.wait(one_minute);
}
}
-#endif
class Syncronizer : public QObject
{ Q_OBJECT
diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
index ba64bf2963..a9af182ed8 100644
--- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
+++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp
@@ -120,7 +120,7 @@ void tst_QThreadOnce::sameThread()
void tst_QThreadOnce::multipleThreads()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS)
+#if defined(Q_OS_VXWORKS)
const int NumberOfThreads = 20;
#else
const int NumberOfThreads = 100;
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
index f3eba5c823..4e582cc346 100644
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
@@ -40,10 +40,8 @@
#include <pthread.h>
#endif
#ifdef Q_OS_WIN
-#ifndef Q_OS_WINCE
-#include <process.h>
-#endif
-#include <windows.h>
+# include <process.h>
+# include <qt_windows.h>
#endif
class tst_QThreadStorage : public QObject
@@ -221,11 +219,7 @@ void tst_QThreadStorage::adoptedThreads()
pthread_join(thread, 0);
#elif defined Q_OS_WIN && !defined(Q_OS_WINRT)
HANDLE thread;
-#if defined(Q_OS_WINCE)
- thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)testAdoptedThreadStorageWin, &pointers, 0, NULL);
-#else
thread = (HANDLE)_beginthread(testAdoptedThreadStorageWin, 0, &pointers);
-#endif
QVERIFY(thread);
WaitForSingleObject(thread, INFINITE);
#endif
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index a460afcfa2..88c505601a 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -34,9 +34,6 @@
#include <qhash.h>
#include <limits.h>
#include <private/qtools_p.h>
-#if defined(Q_OS_WINCE)
-#include <qcoreapplication.h>
-#endif
class tst_QByteArray : public QObject
{
@@ -246,11 +243,7 @@ void tst_QByteArray::qCompress_data()
{
QTest::addColumn<QByteArray>("ba");
-#ifndef Q_OS_WINCE
const int size1 = 1024*1024;
-#else
- const int size1 = 1024;
-#endif
QByteArray ba1( size1, 0 );
QTest::newRow( "00" ) << QByteArray();
@@ -267,11 +260,6 @@ void tst_QByteArray::qCompress_data()
ba1.fill( 'A' );
QTest::newRow( "03" ) << ba1;
-#if defined(Q_OS_WINCE)
- int tmpArgc = 0;
- char** tmpArgv = 0;
- QCoreApplication app(tmpArgc, tmpArgv);
-#endif
QFile file( QFINDTESTDATA("rfc3252.txt") );
QVERIFY( file.open(QIODevice::ReadOnly) );
QTest::newRow( "04" ) << file.readAll();
@@ -728,7 +716,7 @@ void tst_QByteArray::qvsnprintf()
memset(buf, 42, sizeof(buf));
#ifdef Q_OS_WIN
// VS 2005 uses the Qt implementation of vsnprintf.
-# if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
+# if defined(_MSC_VER)
QCOMPARE(::qsnprintf(buf, 3, "%s", "bubu"), -1);
QCOMPARE(static_cast<const char*>(buf), "bu");
# else
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index e51f5d4694..92585fd471 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -31,9 +31,6 @@
#include <qfile.h>
#include <qstringlist.h>
#include <private/qunicodetables_p.h>
-#if defined(Q_OS_WINCE)
-#include <qcoreapplication.h>
-#endif
class tst_QChar : public QObject
{
diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
index 36bc8621d2..30c7b1bf69 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
@@ -71,8 +71,12 @@ int main(int argc, char *argv[])
// A hidden option
QCommandLineOption hiddenOption(QStringList() << QStringLiteral("hidden"));
hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR"));
- hiddenOption.setHidden(true);
+ hiddenOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(hiddenOption);
+ QCommandLineOption hiddenOption2(QStringList() << QStringLiteral("hidden2"));
+ hiddenOption2.setDescription(QStringLiteral("NEITHER SHOULD THIS"));
+ hiddenOption2.setHidden(true);
+ parser.addOption(hiddenOption2);
// This program supports different options depending on the "command" (first argument).
// Call parse() to find out the positional arguments.
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 9552152136..a54ad3d9c9 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -450,6 +450,13 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes_data()
<< QStringList("abc") << QStringList("val");
QTest::newRow("implicitlylong_with_space") << QCommandLineParser::ParseAsCompactedShortOptions << (QStringList() << "-c" << "val")
<< QStringList("c") << QStringList("val");
+
+ QTest::newRow("forceshort_detached") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I" << "45")
+ << QStringList("I") << QStringList("45");
+ QTest::newRow("forceshort_attached") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I46")
+ << QStringList("I") << QStringList("46");
+ QTest::newRow("forceshort_mixed") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I45" << "-nn")
+ << (QStringList() << "I" << "nn") << QStringList("45");
}
void tst_QCommandLineParser::testSingleDashWordOptionModes()
@@ -468,6 +475,10 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes()
parser.addOption(QCommandLineOption("b", QStringLiteral("b option.")));
parser.addOption(QCommandLineOption(QStringList() << "c" << "abc", QStringLiteral("c option."), QStringLiteral("value")));
parser.addOption(QCommandLineOption("nn", QStringLiteral("nn option.")));
+ QCommandLineOption forceShort(QStringLiteral("I"), QStringLiteral("always short option"),
+ QStringLiteral("path"), QStringLiteral("default"));
+ forceShort.setFlags(QCommandLineOption::ShortOptionStyle);
+ parser.addOption(forceShort);
QVERIFY(parser.parse(commandLine));
QCOMPARE(parser.optionNames(), expectedOptionNames);
for (int i = 0; i < expectedOptionValues.count(); ++i)
@@ -501,9 +512,6 @@ void tst_QCommandLineParser::testVersionOption()
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
-#ifdef Q_OS_WINCE
- QSKIP("Reading and writing to a process is not supported on Qt/CE");
-#endif
#if defined(Q_OS_ANDROID)
QSKIP("Deploying executable applications to file system on Android not supported.");
#endif
@@ -570,9 +578,6 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
-#ifdef Q_OS_WINCE
- QSKIP("Reading and writing to a process is not supported on Qt/CE");
-#endif
#if defined(Q_OS_ANDROID)
QSKIP("Deploying executable applications to file system on Android not supported.");
#endif
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index cfec327319..0404a276ff 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -28,10 +28,7 @@
****************************************************************************/
#include <QtTest/QtTest>
-#ifndef Q_OS_WINCE
#include <time.h>
-#endif
-
#include <qdatetime.h>
#include <private/qdatetime_p.h>
@@ -62,8 +59,8 @@ private slots:
void date();
void time();
void timeSpec();
- void toTime_t_data();
- void toTime_t();
+ void toSecsSinceEpoch_data();
+ void toSecsSinceEpoch();
void daylightSavingsTimeChange_data();
void daylightSavingsTimeChange();
void springForward_data();
@@ -73,7 +70,7 @@ private slots:
void setTime();
void setTimeSpec_data();
void setTimeSpec();
- void setTime_t();
+ void setSecsSinceEpoch();
void setMSecsSinceEpoch_data();
void setMSecsSinceEpoch();
void fromMSecsSinceEpoch_data();
@@ -108,10 +105,8 @@ private slots:
void msecsTo();
void operator_eqeq_data();
void operator_eqeq();
-#ifndef Q_OS_WINCE
void operator_insert_extract_data();
void operator_insert_extract();
-#endif
void currentDateTime();
void currentDateTimeUtc();
void currentDateTimeUtc2();
@@ -180,22 +175,22 @@ tst_QDateTime::tst_QDateTime()
differently, so don't probe them here.
*/
const uint day = 24 * 3600; // in seconds
- zoneIsCET = (QDateTime(QDate(2038, 1, 19), QTime(4, 14, 7)).toTime_t() == 0x7fffffff
+ zoneIsCET = (QDateTime(QDate(2038, 1, 19), QTime(4, 14, 7)).toSecsSinceEpoch() == 0x7fffffff
// Entries a year apart robustly differ by multiples of day.
- && QDateTime(QDate(2015, 7, 1), QTime()).toTime_t() == 1435701600
- && QDateTime(QDate(2015, 1, 1), QTime()).toTime_t() == 1420066800
- && QDateTime(QDate(2013, 7, 1), QTime()).toTime_t() == 1372629600
- && QDateTime(QDate(2013, 1, 1), QTime()).toTime_t() == 1356994800
- && QDateTime(QDate(2012, 7, 1), QTime()).toTime_t() == 1341093600
- && QDateTime(QDate(2012, 1, 1), QTime()).toTime_t() == 1325372400
- && QDateTime(QDate(2008, 7, 1), QTime()).toTime_t() == 1214863200
- && QDateTime(QDate(2004, 1, 1), QTime()).toTime_t() == 1072911600
- && QDateTime(QDate(2000, 1, 1), QTime()).toTime_t() == 946681200
- && QDateTime(QDate(1990, 7, 1), QTime()).toTime_t() == 646783200
- && QDateTime(QDate(1990, 1, 1), QTime()).toTime_t() == 631148400
- && QDateTime(QDate(1979, 1, 1), QTime()).toTime_t() == 283993200
- // .toTime_t() returns -1 for everything before this:
- && QDateTime(QDate(1970, 1, 1), QTime(1, 0, 0)).toTime_t() == 0);
+ && QDateTime(QDate(2015, 7, 1), QTime()).toSecsSinceEpoch() == 1435701600
+ && QDateTime(QDate(2015, 1, 1), QTime()).toSecsSinceEpoch() == 1420066800
+ && QDateTime(QDate(2013, 7, 1), QTime()).toSecsSinceEpoch() == 1372629600
+ && QDateTime(QDate(2013, 1, 1), QTime()).toSecsSinceEpoch() == 1356994800
+ && QDateTime(QDate(2012, 7, 1), QTime()).toSecsSinceEpoch() == 1341093600
+ && QDateTime(QDate(2012, 1, 1), QTime()).toSecsSinceEpoch() == 1325372400
+ && QDateTime(QDate(2008, 7, 1), QTime()).toSecsSinceEpoch() == 1214863200
+ && QDateTime(QDate(2004, 1, 1), QTime()).toSecsSinceEpoch() == 1072911600
+ && QDateTime(QDate(2000, 1, 1), QTime()).toSecsSinceEpoch() == 946681200
+ && QDateTime(QDate(1990, 7, 1), QTime()).toSecsSinceEpoch() == 646783200
+ && QDateTime(QDate(1990, 1, 1), QTime()).toSecsSinceEpoch() == 631148400
+ && QDateTime(QDate(1979, 1, 1), QTime()).toSecsSinceEpoch() == 283993200
+ // .toSecsSinceEpoch() returns -1 for everything before this:
+ && QDateTime(QDate(1970, 1, 1), QTime(1, 0, 0)).toSecsSinceEpoch() == 0);
// Use .toMSecsSinceEpoch() if you really need to test anything earlier.
/*
@@ -207,12 +202,12 @@ tst_QDateTime::tst_QDateTime()
*/
const int sampled = 3;
// UTC starts of months in 2004, 2038 and 1970:
- uint jans[sampled] = { 12418 * day, 24837 * day, 0 };
- uint juls[sampled] = { 12600 * day, 25018 * day, 181 * day };
+ qint64 jans[sampled] = { 12418 * day, 24837 * day, 0 };
+ qint64 juls[sampled] = { 12600 * day, 25018 * day, 181 * day };
localTimeType = LocalTimeIsUtc;
for (int i = sampled; i-- > 0; ) {
- QDateTime jan = QDateTime::fromTime_t(jans[i]);
- QDateTime jul = QDateTime::fromTime_t(juls[i]);
+ QDateTime jan = QDateTime::fromSecsSinceEpoch(jans[i]);
+ QDateTime jul = QDateTime::fromSecsSinceEpoch(juls[i]);
if (jan.date().year() < 1970 || jul.date().month() < 7) {
localTimeType = LocalTimeBehindUtc;
break;
@@ -259,9 +254,7 @@ void tst_QDateTime::initTestCase()
void tst_QDateTime::init()
{
-#if defined(Q_OS_WINCE)
- SetUserDefaultLCID(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
-#elif defined(Q_OS_WIN32)
+#if defined(Q_OS_WIN32)
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
#endif
}
@@ -523,52 +516,52 @@ void tst_QDateTime::setTimeSpec()
QCOMPARE(dateTime.timeSpec(), newTimeSpec);
}
-void tst_QDateTime::setTime_t()
+void tst_QDateTime::setSecsSinceEpoch()
{
QDateTime dt1;
- dt1.setTime_t(0);
+ dt1.setSecsSinceEpoch(0);
QCOMPARE(dt1.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(), Qt::UTC));
QCOMPARE(dt1.timeSpec(), Qt::LocalTime);
dt1.setTimeSpec(Qt::UTC);
- dt1.setTime_t(0);
+ dt1.setSecsSinceEpoch(0);
QCOMPARE(dt1, QDateTime(QDate(1970, 1, 1), QTime(), Qt::UTC));
QCOMPARE(dt1.timeSpec(), Qt::UTC);
- dt1.setTime_t(123456);
+ dt1.setSecsSinceEpoch(123456);
QCOMPARE(dt1, QDateTime(QDate(1970, 1, 2), QTime(10, 17, 36), Qt::UTC));
if (zoneIsCET) {
QDateTime dt2;
- dt2.setTime_t(123456);
+ dt2.setSecsSinceEpoch(123456);
QCOMPARE(dt2, QDateTime(QDate(1970, 1, 2), QTime(11, 17, 36), Qt::LocalTime));
}
- dt1.setTime_t((uint)(quint32)-123456);
+ dt1.setSecsSinceEpoch((uint)(quint32)-123456);
QCOMPARE(dt1, QDateTime(QDate(2106, 2, 5), QTime(20, 10, 40), Qt::UTC));
if (zoneIsCET) {
QDateTime dt2;
- dt2.setTime_t((uint)(quint32)-123456);
+ dt2.setSecsSinceEpoch((uint)(quint32)-123456);
QCOMPARE(dt2, QDateTime(QDate(2106, 2, 5), QTime(21, 10, 40), Qt::LocalTime));
}
- dt1.setTime_t(1214567890);
+ dt1.setSecsSinceEpoch(1214567890);
QCOMPARE(dt1, QDateTime(QDate(2008, 6, 27), QTime(11, 58, 10), Qt::UTC));
if (zoneIsCET) {
QDateTime dt2;
- dt2.setTime_t(1214567890);
+ dt2.setSecsSinceEpoch(1214567890);
QCOMPARE(dt2, QDateTime(QDate(2008, 6, 27), QTime(13, 58, 10), Qt::LocalTime));
}
- dt1.setTime_t(0x7FFFFFFF);
+ dt1.setSecsSinceEpoch(0x7FFFFFFF);
QCOMPARE(dt1, QDateTime(QDate(2038, 1, 19), QTime(3, 14, 7), Qt::UTC));
if (zoneIsCET) {
QDateTime dt2;
- dt2.setTime_t(0x7FFFFFFF);
+ dt2.setSecsSinceEpoch(0x7FFFFFFF);
QCOMPARE(dt2, QDateTime(QDate(2038, 1, 19), QTime(4, 14, 7), Qt::LocalTime));
}
dt1 = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::OffsetFromUTC, 60 * 60);
- dt1.setTime_t(123456);
+ dt1.setSecsSinceEpoch(123456);
QCOMPARE(dt1, QDateTime(QDate(1970, 1, 2), QTime(10, 17, 36), Qt::UTC));
QCOMPARE(dt1.timeSpec(), Qt::OffsetFromUTC);
QCOMPARE(dt1.offsetFromUtc(), 60 * 60);
@@ -672,7 +665,7 @@ void tst_QDateTime::setMSecsSinceEpoch()
QCOMPARE(dt.toMSecsSinceEpoch(), msecs);
if (quint64(msecs / 1000) < 0xFFFFFFFF) {
- QCOMPARE(qint64(dt.toTime_t()), msecs / 1000);
+ QCOMPARE(qint64(dt.toSecsSinceEpoch()), msecs / 1000);
}
QDateTime reference(QDate(1970, 1, 1), QTime(), Qt::UTC);
@@ -723,9 +716,9 @@ void tst_QDateTime::fromMSecsSinceEpoch()
QCOMPARE(dtOffset.toMSecsSinceEpoch(), msecs);
if (quint64(msecs / 1000) < 0xFFFFFFFF) {
- QCOMPARE(qint64(dtLocal.toTime_t()), msecs / 1000);
- QCOMPARE(qint64(dtUtc.toTime_t()), msecs / 1000);
- QCOMPARE(qint64(dtOffset.toTime_t()), msecs / 1000);
+ QCOMPARE(qint64(dtLocal.toSecsSinceEpoch()), msecs / 1000);
+ QCOMPARE(qint64(dtUtc.toSecsSinceEpoch()), msecs / 1000);
+ QCOMPARE(qint64(dtOffset.toSecsSinceEpoch()), msecs / 1000);
}
QDateTime reference(QDate(1970, 1, 1), QTime(), Qt::UTC);
@@ -1429,27 +1422,19 @@ void tst_QDateTime::msecsTo()
void tst_QDateTime::currentDateTime()
{
-#if defined(Q_OS_WINCE)
- __time64_t buf1, buf2;
- ::_time64(&buf1);
-#else
time_t buf1, buf2;
::time(&buf1);
-#endif
QDateTime lowerBound;
- lowerBound.setTime_t(buf1);
+ lowerBound.setSecsSinceEpoch(buf1);
QDateTime dt1 = QDateTime::currentDateTime();
QDateTime dt2 = QDateTime::currentDateTime().toLocalTime();
QDateTime dt3 = QDateTime::currentDateTime().toUTC();
-#if defined(Q_OS_WINCE)
- ::_time64(&buf2);
-#else
::time(&buf2);
-#endif
+
QDateTime upperBound;
- upperBound.setTime_t(buf2);
+ upperBound.setSecsSinceEpoch(buf2);
// Note we must add 2 seconds here because time() may return up to
// 1 second difference from the more accurate method used by QDateTime::currentDateTime()
upperBound = upperBound.addSecs(2);
@@ -1460,11 +1445,11 @@ void tst_QDateTime::currentDateTime()
"dt2: %3\n"
"dt3: %4\n"
"upperBound: %5\n")
- .arg(lowerBound.toTime_t())
- .arg(dt1.toTime_t())
- .arg(dt2.toTime_t())
- .arg(dt3.toTime_t())
- .arg(upperBound.toTime_t());
+ .arg(lowerBound.toSecsSinceEpoch())
+ .arg(dt1.toSecsSinceEpoch())
+ .arg(dt2.toSecsSinceEpoch())
+ .arg(dt3.toSecsSinceEpoch())
+ .arg(upperBound.toSecsSinceEpoch());
QVERIFY2(lowerBound < upperBound, qPrintable(details));
@@ -1482,27 +1467,20 @@ void tst_QDateTime::currentDateTime()
void tst_QDateTime::currentDateTimeUtc()
{
-#if defined(Q_OS_WINCE)
- __time64_t buf1, buf2;
- ::_time64(&buf1);
-#else
time_t buf1, buf2;
::time(&buf1);
-#endif
+
QDateTime lowerBound;
- lowerBound.setTime_t(buf1);
+ lowerBound.setSecsSinceEpoch(buf1);
QDateTime dt1 = QDateTime::currentDateTimeUtc();
QDateTime dt2 = QDateTime::currentDateTimeUtc().toLocalTime();
QDateTime dt3 = QDateTime::currentDateTimeUtc().toUTC();
-#if defined(Q_OS_WINCE)
- ::_time64(&buf2);
-#else
::time(&buf2);
-#endif
+
QDateTime upperBound;
- upperBound.setTime_t(buf2);
+ upperBound.setSecsSinceEpoch(buf2);
// Note we must add 2 seconds here because time() may return up to
// 1 second difference from the more accurate method used by QDateTime::currentDateTime()
upperBound = upperBound.addSecs(2);
@@ -1513,11 +1491,11 @@ void tst_QDateTime::currentDateTimeUtc()
"dt2: %3\n"
"dt3: %4\n"
"upperBound: %5\n")
- .arg(lowerBound.toTime_t())
- .arg(dt1.toTime_t())
- .arg(dt2.toTime_t())
- .arg(dt3.toTime_t())
- .arg(upperBound.toTime_t());
+ .arg(lowerBound.toSecsSinceEpoch())
+ .arg(dt1.toSecsSinceEpoch())
+ .arg(dt2.toSecsSinceEpoch())
+ .arg(dt3.toSecsSinceEpoch())
+ .arg(upperBound.toSecsSinceEpoch());
QVERIFY2(lowerBound < upperBound, qPrintable(details));
@@ -1562,14 +1540,14 @@ void tst_QDateTime::currentDateTimeUtc2()
QCOMPARE(local.toUTC(), utc);
QCOMPARE(utc.toLocalTime(), local);
- // and finally, the time_t should equal our number
- QCOMPARE(qint64(utc.toTime_t()), msec / 1000);
- QCOMPARE(qint64(local.toTime_t()), msec / 1000);
+ // and finally, the SecsSinceEpoch should equal our number
+ QCOMPARE(qint64(utc.toSecsSinceEpoch()), msec / 1000);
+ QCOMPARE(qint64(local.toSecsSinceEpoch()), msec / 1000);
QCOMPARE(utc.toMSecsSinceEpoch(), msec);
QCOMPARE(local.toMSecsSinceEpoch(), msec);
}
-void tst_QDateTime::toTime_t_data()
+void tst_QDateTime::toSecsSinceEpoch_data()
{
QTest::addColumn<QString>("dateTimeStr");
QTest::addColumn<bool>("res");
@@ -1585,11 +1563,12 @@ void tst_QDateTime::toTime_t_data()
<< bool( sizeof(uint) > 32 && sizeof(time_t) > 32 );
}
-void tst_QDateTime::toTime_t()
+void tst_QDateTime::toSecsSinceEpoch()
{
QFETCH( QString, dateTimeStr );
QDateTime datetime = dt( dateTimeStr );
+ qint64 asSecsSinceEpoch = datetime.toSecsSinceEpoch();
uint asTime_t = datetime.toTime_t();
QFETCH( bool, res );
if (res) {
@@ -1597,11 +1576,14 @@ void tst_QDateTime::toTime_t()
} else {
QVERIFY( asTime_t == (uint)-1 );
}
+ QCOMPARE(asSecsSinceEpoch, datetime.toMSecsSinceEpoch() / 1000);
if ( asTime_t != (uint) -1 ) {
QDateTime datetime2 = QDateTime::fromTime_t( asTime_t );
QCOMPARE(datetime, datetime2);
}
+ QDateTime datetime2 = QDateTime::fromSecsSinceEpoch(asSecsSinceEpoch);
+ QCOMPARE(datetime, datetime2);
}
void tst_QDateTime::daylightSavingsTimeChange_data()
@@ -1640,7 +1622,7 @@ void tst_QDateTime::daylightSavingsTimeChange()
// First with simple construction
QDateTime dt = QDateTime(outDST, QTime(0, 0, 0), Qt::LocalTime);
- int outDSTsecs = dt.toTime_t();
+ int outDSTsecs = dt.toSecsSinceEpoch();
dt.setDate(inDST);
dt = dt.addSecs(1);
@@ -1662,8 +1644,8 @@ void tst_QDateTime::daylightSavingsTimeChange()
dt = dt.addMonths(-months).addSecs(1);
QCOMPARE(dt, QDateTime(inDST, QTime(0, 0, 5)));
- // now using fromTime_t
- dt = QDateTime::fromTime_t(outDSTsecs);
+ // now using fromSecsSinceEpoch
+ dt = QDateTime::fromSecsSinceEpoch(outDSTsecs);
QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 0)));
dt.setDate(inDST);
@@ -1717,7 +1699,7 @@ void tst_QDateTime::springForward_data()
QTest::addColumn<int>("adjust"); // minutes ahead of UTC on day stepped from
/*
- Zone tests compare a summer and winter moment's time_t to known values.
+ Zone tests compare a summer and winter moment's SecsSinceEpoch to known values.
This could in principle be flawed (two DST-using zones in the same
hemisphere with the same DST and standard times but different transition
times) but no actual example is known where this is a problem. Please
@@ -1727,8 +1709,8 @@ void tst_QDateTime::springForward_data()
test.
*/
- uint winter = QDateTime(QDate(2015, 1, 1), QTime()).toTime_t();
- uint summer = QDateTime(QDate(2015, 7, 1), QTime()).toTime_t();
+ uint winter = QDateTime(QDate(2015, 1, 1), QTime()).toSecsSinceEpoch();
+ uint summer = QDateTime(QDate(2015, 7, 1), QTime()).toSecsSinceEpoch();
if (winter == 1420066800 && summer == 1435701600) {
QTest::newRow("CET from day before") << QDate(2015, 3, 29) << QTime(2, 30, 0) << 1 << 60;
@@ -1859,7 +1841,6 @@ void tst_QDateTime::operator_eqeq()
}
}
-#ifndef Q_OS_WINCE
Q_DECLARE_METATYPE(QDataStream::Version)
void tst_QDateTime::operator_insert_extract_data()
@@ -1988,7 +1969,6 @@ void tst_QDateTime::operator_insert_extract()
qputenv("TZ", previousTimeZone.constData());
tzset();
}
-#endif
void tst_QDateTime::toString_strformat()
{
@@ -2442,7 +2422,7 @@ void tst_QDateTime::setOffsetFromUtc()
dt1.setMSecsSinceEpoch(123456789);
QCOMPARE(dt1.timeSpec(), Qt::OffsetFromUTC);
QCOMPARE(dt1.offsetFromUtc(), 60 * 60);
- dt1.setTime_t(123456789);
+ dt1.setSecsSinceEpoch(123456789);
QCOMPARE(dt1.timeSpec(), Qt::OffsetFromUTC);
QCOMPARE(dt1.offsetFromUtc(), 60 * 60);
@@ -3060,7 +3040,7 @@ void tst_QDateTime::timeZones() const
QCOMPARE(dt1.time(), QTime(0, 0, 0));
QCOMPARE(dt1.timeZone(), nzTz);
- QDateTime dt2 = QDateTime::fromTime_t(1338465600, nzTz);
+ QDateTime dt2 = QDateTime::fromSecsSinceEpoch(1338465600, nzTz);
QCOMPARE(dt2.date(), dt1.date());
QCOMPARE(dt2.time(), dt1.time());
QCOMPARE(dt2.timeSpec(), dt1.timeSpec());
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 06ff09dc6c..0b864e71d4 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -49,6 +49,7 @@ private slots:
void find(); // copied from tst_QMap
void constFind(); // copied from tst_QMap
void contains(); // copied from tst_QMap
+ void qhash();
void take(); // copied from tst_QMap
void operator_eq(); // copied from tst_QMap
void rehash_isnt_quadratic();
@@ -695,6 +696,69 @@ void tst_QHash::contains()
QVERIFY(!map1.contains(43));
}
+namespace {
+class QGlobalQHashSeedResetter
+{
+ int oldSeed;
+public:
+ // not entirely correct (may lost changes made by another thread between the query
+ // of the old and the setting of the new seed), but qSetGlobalQHashSeed doesn't
+ // return the old value, so this is the best we can do:
+ explicit QGlobalQHashSeedResetter(int newSeed)
+ : oldSeed(qGlobalQHashSeed())
+ {
+ qSetGlobalQHashSeed(newSeed);
+ }
+ ~QGlobalQHashSeedResetter()
+ {
+ qSetGlobalQHashSeed(oldSeed);
+ }
+};
+
+template <typename Key, typename T>
+QHash<T, Key> inverted(const QHash<Key, T> &in)
+{
+ QHash<T, Key> result;
+ for (auto it = in.begin(), end = in.end(); it != end; ++it)
+ result[it.value()] = it.key();
+ return result;
+}
+
+template <typename AssociativeContainer>
+void make_test_data(AssociativeContainer &c)
+{
+ c["one"] = "1";
+ c["two"] = "2";
+}
+
+}
+
+void tst_QHash::qhash()
+{
+ const QGlobalQHashSeedResetter seed1(0);
+
+ QHash<QString, QString> hash1;
+ make_test_data(hash1);
+ const QHash<QString, QString> hsah1 = inverted(hash1);
+
+ const QGlobalQHashSeedResetter seed2(1);
+
+ QHash<QString, QString> hash2;
+ make_test_data(hash2);
+ const QHash<QString, QString> hsah2 = inverted(hash2);
+
+ QCOMPARE(hash1, hash2);
+ QCOMPARE(hsah1, hsah2);
+ QCOMPARE(qHash(hash1), qHash(hash2));
+ QCOMPARE(qHash(hsah1), qHash(hsah2));
+
+ // by construction this is almost impossible to cause false collisions:
+ QVERIFY(hash1 != hsah1);
+ QVERIFY(hash2 != hsah2);
+ QVERIFY(qHash(hash1) != qHash(hsah1));
+ QVERIFY(qHash(hash2) != qHash(hsah2));
+}
+
//copied from tst_QMap
void tst_QHash::take()
{
@@ -996,11 +1060,7 @@ void tst_QHash::rehash_isnt_quadratic()
// this test should be incredibly slow if rehash() is quadratic
for (int j = 0; j < 5; ++j) {
QHash<int, int> testHash;
-#if defined(Q_OS_WINCE) // mobiles do not have infinite mem...
- for (int i = 0; i < 50000; ++i)
-#else
for (int i = 0; i < 500000; ++i)
-#endif
testHash.insertMulti(1, 1);
}
}
diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
index 1295a36c1a..3c22770fba 100644
--- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
+++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp
@@ -35,10 +35,40 @@ class tst_QLatin1String : public QObject
Q_OBJECT
private Q_SLOTS:
+ void at();
+ void midLeftRight();
void nullString();
void emptyString();
};
+
+void tst_QLatin1String::at()
+{
+ const QLatin1String l1("Hello World");
+ QCOMPARE(l1.at(0), QLatin1Char('H'));
+ QCOMPARE(l1.at(l1.size() - 1), QLatin1Char('d'));
+ QCOMPARE(l1[0], QLatin1Char('H'));
+ QCOMPARE(l1[l1.size() - 1], QLatin1Char('d'));
+}
+
+void tst_QLatin1String::midLeftRight()
+{
+ const QLatin1String l1("Hello World");
+ QCOMPARE(l1.mid(0), l1);
+ QCOMPARE(l1.mid(0, l1.size()), l1);
+ QCOMPARE(l1.left(l1.size()), l1);
+ QCOMPARE(l1.right(l1.size()), l1);
+
+ QCOMPARE(l1.mid(6), QLatin1String("World"));
+ QCOMPARE(l1.mid(6, 5), QLatin1String("World"));
+ QCOMPARE(l1.right(5), QLatin1String("World"));
+
+ QCOMPARE(l1.mid(6, 1), QLatin1String("W"));
+ QCOMPARE(l1.right(5).left(1), QLatin1String("W"));
+
+ QCOMPARE(l1.left(5), QLatin1String("Hello"));
+}
+
void tst_QLatin1String::nullString()
{
// default ctor
diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp
index 3aee0ff17d..6e020ac35b 100644
--- a/tests/auto/corelib/tools/qline/tst_qline.cpp
+++ b/tests/auto/corelib/tools/qline/tst_qline.cpp
@@ -44,6 +44,12 @@ private slots:
void testLength();
void testLength_data();
+ void testCenter();
+ void testCenter_data();
+
+ void testCenterF();
+ void testCenterF_data();
+
void testNormalVector();
void testNormalVector_data();
@@ -268,6 +274,77 @@ void tst_QLine::testLength()
QCOMPARE(l.dy(), qreal(vy));
}
+void tst_QLine::testCenter()
+{
+ QFETCH(int, x1);
+ QFETCH(int, y1);
+ QFETCH(int, x2);
+ QFETCH(int, y2);
+ QFETCH(int, centerX);
+ QFETCH(int, centerY);
+
+ const QPoint c = QLine(x1, y1, x2, y2).center();
+ QCOMPARE(centerX, c.x());
+ QCOMPARE(centerY, c.y());
+}
+
+void tst_QLine::testCenter_data()
+{
+ QTest::addColumn<int>("x1");
+ QTest::addColumn<int>("y1");
+ QTest::addColumn<int>("x2");
+ QTest::addColumn<int>("y2");
+ QTest::addColumn<int>("centerX");
+ QTest::addColumn<int>("centerY");
+
+ QTest::newRow("[0, 0]") << 0 << 0 << 0 << 0 << 0 << 0;
+ QTest::newRow("top") << 0 << 0 << 2 << 0 << 1 << 0;
+ QTest::newRow("right") << 0 << 0 << 0 << 2 << 0 << 1;
+ QTest::newRow("bottom") << 0 << 0 << -2 << 0 << -1 << 0;
+ QTest::newRow("left") << 0 << 0 << 0 << -2 << 0 << -1;
+
+ QTest::newRow("precision+") << 0 << 0 << 1 << 1 << 0 << 0;
+ QTest::newRow("precision-") << -1 << -1 << 0 << 0 << 0 << 0;
+
+ const int max = std::numeric_limits<int>::max();
+ const int min = std::numeric_limits<int>::min();
+ QTest::newRow("max") << max << max << max << max << max << max;
+ QTest::newRow("min") << min << min << min << min << min << min;
+ QTest::newRow("minmax") << min << min << max << max << 0 << 0;
+}
+
+void tst_QLine::testCenterF()
+{
+ QFETCH(double, x1);
+ QFETCH(double, y1);
+ QFETCH(double, x2);
+ QFETCH(double, y2);
+ QFETCH(double, centerX);
+ QFETCH(double, centerY);
+
+ const QPointF c = QLineF(x1, y1, x2, y2).center();
+ QCOMPARE(centerX, c.x());
+ QCOMPARE(centerY, c.y());
+}
+
+void tst_QLine::testCenterF_data()
+{
+ QTest::addColumn<double>("x1");
+ QTest::addColumn<double>("y1");
+ QTest::addColumn<double>("x2");
+ QTest::addColumn<double>("y2");
+ QTest::addColumn<double>("centerX");
+ QTest::addColumn<double>("centerY");
+
+ QTest::newRow("[0, 0]") << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("top") << 0.0 << 0.0 << 1.0 << 0.0 << 0.5 << 0.0;
+ QTest::newRow("right") << 0.0 << 0.0 << 0.0 << 1.0 << 0.0 << 0.5;
+ QTest::newRow("bottom") << 0.0 << 0.0 << -1.0 << 0.0 << -0.5 << 0.0;
+ QTest::newRow("left") << 0.0 << 0.0 << 0.0 << -1.0 << 0.0 << -0.5;
+
+ const double max = std::numeric_limits<qreal>::max();
+ QTest::newRow("max") << max << max << max << max << max << max;
+}
void tst_QLine::testNormalVector_data()
{
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index ee706e9f3d..8d9a789507 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -52,15 +52,6 @@
# include <fenv.h>
#endif
-#ifdef Q_OS_WINCE
-#include <windows.h> // needed for GetUserDefaultLCID
-#define _control87 _controlfp
-extern "C" DWORD GetThreadLocale(void) {
- return GetUserDefaultLCID();
-}
-
-#endif
-
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
# include <stdlib.h>
#endif
@@ -85,9 +76,7 @@ private slots:
#endif
void ctor();
-#if !defined(Q_OS_WINCE)
void emptyCtor();
-#endif
void legacyNames();
void unixLocaleName();
void matchingLocales();
@@ -156,8 +145,8 @@ tst_QLocale::tst_QLocale()
qRegisterMetaType<QLocale::FormatType>("QLocale::FormatType");
// Test if in Central European Time zone
- uint x1 = QDateTime(QDate(1990, 1, 1), QTime()).toTime_t();
- uint x2 = QDateTime(QDate(1990, 6, 1), QTime()).toTime_t();
+ uint x1 = QDateTime(QDate(1990, 1, 1), QTime()).toSecsSinceEpoch();
+ uint x2 = QDateTime(QDate(1990, 6, 1), QTime()).toSecsSinceEpoch();
europeanTimeZone = (x1 == 631148400 && x2 == 644191200);
}
@@ -394,10 +383,7 @@ void tst_QLocale::ctor()
#undef TEST_CTOR
}
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
-// Not when Q_OS_WINCE is defined because the test uses unsupported
-// Windows CE QProcess functionality (std streams, env)
-// Also Qt needs to be compiled without QT_NO_PROCESS
+#if !defined(QT_NO_PROCESS)
static inline bool runSysApp(const QString &binary,
const QStringList &env,
QString *output,
@@ -447,7 +433,6 @@ static inline bool runSysAppTest(const QString &binary,
}
#endif
-#if !defined(Q_OS_WINCE)
void tst_QLocale::emptyCtor()
{
#ifdef QT_NO_PROCESS
@@ -517,7 +502,6 @@ void tst_QLocale::emptyCtor()
#undef TEST_CTOR
#endif
}
-#endif
void tst_QLocale::legacyNames()
{
diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
index 2f285f3393..a98d37d733 100644
--- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
+++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp
@@ -927,11 +927,7 @@ void tst_QRegExp::rainersSlowRegExpCopyBug()
{
// this test should take an extreme amount of time if QRegExp is broken
QRegExp original(email);
-#if defined(Q_OS_WINCE)
- for (int i = 0; i < 100; ++i) {
-#else
for (int i = 0; i < 100000; ++i) {
-#endif
QRegExp copy = original;
(void)copy.exactMatch("~");
QRegExp copy2 = original;
@@ -980,13 +976,9 @@ void Thread::run()
str += "abbbdekcz";
int x;
-#if defined(Q_OS_WINCE)
- for (int j = 0; j < 100; ++j) {
-#else
- for (int j = 0; j < 10000; ++j) {
-#endif
+ for (int j = 0; j < 10000; ++j)
x = rx.indexIn(str);
- }
+
QCOMPARE(x, 3072);
}
@@ -1022,13 +1014,9 @@ void Thread2::run()
str += "abbbdekcz";
int x;
-#if defined(Q_OS_WINCE)
- for (int j = 0; j < 100; ++j) {
-#else
- for (int j = 0; j < 10000; ++j) {
-#endif
+ for (int j = 0; j < 10000; ++j)
x = rx.indexIn(str);
- }
+
QCOMPARE(x, 3072);
}
diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
index c212589f59..145ba7ff72 100644
--- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
+++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
@@ -45,6 +45,7 @@ private slots:
void sizeWhenReserved();
void free();
void reserveAndRead();
+ void reserveAndReadInPacketMode();
void reserveFrontAndRead();
void chop();
void ungetChar();
@@ -58,6 +59,12 @@ void tst_QRingBuffer::constructing()
{
QRingBuffer ringBuffer;
+ const int chunkSize = ringBuffer.chunkSize();
+ ringBuffer.setChunkSize(0);
+ QCOMPARE(ringBuffer.chunkSize(), Q_INT64_C(0));
+ ringBuffer.setChunkSize(chunkSize);
+ QCOMPARE(ringBuffer.chunkSize(), chunkSize);
+
QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
QVERIFY(ringBuffer.isEmpty());
QCOMPARE(ringBuffer.nextDataBlockSize(), Q_INT64_C(0));
@@ -237,6 +244,25 @@ void tst_QRingBuffer::reserveAndRead()
QCOMPARE(ringBuffer.size(), Q_INT64_C(0));
}
+void tst_QRingBuffer::reserveAndReadInPacketMode()
+{
+ QRingBuffer ringBuffer(0);
+ // try to allocate 255 buffers
+ for (int i = 1; i < 256; ++i) {
+ char *ringPos = ringBuffer.reserve(i);
+ QVERIFY(ringPos);
+ }
+
+ // count and check the size of stored buffers
+ int buffersCount = 0;
+ while (!ringBuffer.isEmpty()) {
+ QByteArray ba = ringBuffer.read();
+ ++buffersCount;
+ QCOMPARE(ba.size(), buffersCount);
+ }
+ QCOMPARE(buffersCount, 255);
+}
+
void tst_QRingBuffer::reserveFrontAndRead()
{
QRingBuffer ringBuffer;
diff --git a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp
index 7fde84af5d..21efaede00 100644
--- a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp
+++ b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp
@@ -278,12 +278,16 @@ void tst_QScopedPointer::isNull()
{
QScopedPointer<int> p;
QVERIFY(p.isNull());
+ QVERIFY(p == nullptr);
+ QVERIFY(nullptr == p);
}
/* Invoke on a set value. */
{
QScopedPointer<int> p(new int(69));
QVERIFY(!p.isNull());
+ QVERIFY(p != nullptr);
+ QVERIFY(nullptr != p);
}
}
diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
index 0cccdb8262..7bebe5e9e0 100644
--- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
@@ -342,7 +342,7 @@ namespace QTest {
"\n"
"#ifdef Q_OS_WIN\n"
"#include <windows.h>\n"
- "#if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)\n"
+ "#if defined(Q_CC_MSVC)\n"
"#include <crtdbg.h>\n"
"#endif\n"
"static void q_test_setup()\n"
@@ -358,7 +358,7 @@ namespace QTest {
"#endif\n"
"int main(int argc, char **argv)\n"
"{\n"
- "#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) && !defined(Q_OS_WINCE)\n"
+ "#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)\n"
" _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, CrtDbgHook);\n"
"#endif\n";
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index b5912badf2..1bba41816b 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -57,11 +57,13 @@ private slots:
void basics_data();
void basics();
void operators();
+ void nullptrOps();
void swap();
void moveSemantics();
void useOfForwardDeclared();
void memoryManagement();
void dropLastReferenceOfForwardDeclared();
+ void nonVirtualDestructors();
void lock();
void downCast();
void functionCallDownCast();
@@ -362,6 +364,50 @@ void tst_QSharedPointer::operators()
QCOMPARE(qHash(p2), qHash(p2.data()));
}
+void tst_QSharedPointer::nullptrOps()
+{
+ QSharedPointer<char> p1(nullptr);
+ QSharedPointer<char> p2 = nullptr;
+ QSharedPointer<char> null;
+
+ QVERIFY(p1 == null);
+ QVERIFY(p1 == nullptr);
+ QVERIFY(nullptr == p1);
+ QVERIFY(!p1);
+ QVERIFY(!p1.data());
+ QVERIFY(p2 == null);
+ QVERIFY(p2 == nullptr);
+ QVERIFY(nullptr == p2);
+ QVERIFY(!p2);
+ QVERIFY(!p2.data());
+ QVERIFY(p1 == p2);
+
+ QSharedPointer<char> p3 = p1;
+ QVERIFY(p3 == p1);
+ QVERIFY(p3 == null);
+ QVERIFY(p3 == nullptr);
+ QVERIFY(nullptr == p3);
+ QVERIFY(!p3.data());
+
+ p3 = nullptr;
+
+ // check for non-ambiguity
+ QSharedPointer<char> p1_zero(0);
+ QSharedPointer<char> p2_zero = 0;
+
+ p3 = 0;
+
+ QSharedPointer<char> p4(new char);
+ QVERIFY(p4);
+ QVERIFY(p4.data());
+ QVERIFY(p4 != nullptr);
+ QVERIFY(nullptr != p4);
+ QVERIFY(p4 != p1);
+ QVERIFY(p4 != p2);
+ QVERIFY(p4 != null);
+ QVERIFY(p4 != p3);
+}
+
void tst_QSharedPointer::swap()
{
QSharedPointer<int> p1, p2(new int(42)), control = p2;
@@ -578,6 +624,56 @@ void tst_QSharedPointer::dropLastReferenceOfForwardDeclared()
QCOMPARE(forwardDeclaredDestructorRunCount, 1);
}
+// NVD for "non-virtual destructor"
+struct NVDData
+{
+ static int destructorCounter;
+ ~NVDData() { ++destructorCounter; }
+
+ int dummy;
+};
+int NVDData::destructorCounter;
+
+struct NVDDerivedData : NVDData
+{
+ static int destructorCounter;
+ ~NVDDerivedData() { ++destructorCounter; }
+};
+int NVDDerivedData::destructorCounter;
+
+void tst_QSharedPointer::nonVirtualDestructors()
+{
+ NVDData::destructorCounter = NVDDerivedData::destructorCounter = 0;
+ {
+ QSharedPointer<NVDData> ptr(new NVDData);
+ }
+ QCOMPARE(NVDData::destructorCounter, 1);
+ QCOMPARE(NVDDerivedData::destructorCounter, 0);
+
+ NVDData::destructorCounter = NVDDerivedData::destructorCounter = 0;
+ {
+ QSharedPointer<NVDDerivedData> ptr(new NVDDerivedData);
+ }
+ QCOMPARE(NVDData::destructorCounter, 1);
+ QCOMPARE(NVDDerivedData::destructorCounter, 1);
+
+ NVDData::destructorCounter = NVDDerivedData::destructorCounter = 0;
+ {
+ QSharedPointer<NVDData> bptr;
+ QSharedPointer<NVDDerivedData> ptr(new NVDDerivedData);
+ bptr = ptr;
+ }
+ QCOMPARE(NVDData::destructorCounter, 1);
+ QCOMPARE(NVDDerivedData::destructorCounter, 1);
+
+ NVDData::destructorCounter = NVDDerivedData::destructorCounter = 0;
+ {
+ QSharedPointer<NVDData> ptr(new NVDDerivedData);
+ }
+ QCOMPARE(NVDData::destructorCounter, 1);
+ QCOMPARE(NVDDerivedData::destructorCounter, 1);
+}
+
void tst_QSharedPointer::lock()
{
QSharedPointer<int> sp = QSharedPointer<int>::create();
@@ -1310,6 +1406,18 @@ template<typename T> int CustomDeleter<T>::callCount = 0;
void tst_QSharedPointer::customDeleter()
{
{
+ QSharedPointer<Data> ptr(0, &Data::doDelete);
+ QSharedPointer<Data> ptr2(0, &Data::alsoDelete);
+ QSharedPointer<Data> ptr3(0, &Data::virtualDelete);
+ }
+ safetyCheck();
+ {
+ QSharedPointer<Data> ptr(nullptr, &Data::doDelete);
+ QSharedPointer<Data> ptr2(nullptr, &Data::alsoDelete);
+ QSharedPointer<Data> ptr3(nullptr, &Data::virtualDelete);
+ }
+ safetyCheck();
+ {
QSharedPointer<Data> ptr(new Data, &Data::doDelete);
QSharedPointer<Data> ptr2(new Data, &Data::alsoDelete);
QSharedPointer<Data> ptr3(new Data, &Data::virtualDelete);
@@ -1492,6 +1600,33 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(refcount, 2);
safetyCheck();
+ CustomDeleter<NVDData> nvdeleter;
+ nvdeleter.callCount = 0;
+ {
+ QSharedPointer<NVDData> ptr(new NVDData, nvdeleter);
+ }
+ QCOMPARE(nvdeleter.callCount, 1);
+ safetyCheck();
+
+ CustomDeleter<NVDDerivedData> nvderiveddeleter;
+ nvdeleter.callCount = 0;
+ nvderiveddeleter.callCount = 0;
+ {
+ QSharedPointer<NVDDerivedData> ptr(new NVDDerivedData, nvderiveddeleter);
+ }
+ QCOMPARE(nvdeleter.callCount, 0);
+ QCOMPARE(nvderiveddeleter.callCount, 1);
+ safetyCheck();
+
+ nvdeleter.callCount = 0;
+ nvderiveddeleter.callCount = 0;
+ {
+ QSharedPointer<NVDData> ptr(new NVDDerivedData, nvderiveddeleter);
+ }
+ QCOMPARE(nvdeleter.callCount, 0);
+ QCOMPARE(nvderiveddeleter.callCount, 1);
+ safetyCheck();
+
// a custom deleter with a different pointer parameter
{
QSharedPointer<char> ptr(static_cast<char *>(malloc(1)), free);
@@ -1771,13 +1906,11 @@ void tst_QSharedPointer::threadStressTest_data()
QTest::newRow("1+1") << 1 << 1;
QTest::newRow("2+10") << 2 << 10;
-#ifndef Q_OS_WINCE
- // Windows CE cannot run this many threads
+
QTest::newRow("5+10") << 5 << 10;
QTest::newRow("5+30") << 5 << 30;
QTest::newRow("100+100") << 100 << 100;
-#endif
}
void tst_QSharedPointer::threadStressTest()
@@ -1811,11 +1944,7 @@ void tst_QSharedPointer::threadStressTest()
base.clear();
-#ifdef Q_OS_WINCE
- srand(QDateTime::currentDateTime().toTime_t());
-#else
srand(time(NULL));
-#endif
// start threads
for (int i = 0; i < allThreads.count(); ++i)
if (allThreads[i]) allThreads[i]->start();
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index fdce9a71be..6df9ad7cdf 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -37,10 +37,6 @@
# undef QT_ASCII_CAST_WARNINGS
#endif
-#if defined(Q_OS_WIN) && defined(Q_OS_WINCE)
-#define Q_OS_WIN_AND_WINCE
-#endif
-
#include <QtTest/QtTest>
#include <qregexp.h>
#include <qregularexpression.h>
@@ -529,7 +525,7 @@ private slots:
void integer_conversion();
void tortureSprintfDouble();
void toNum();
-#if !defined(Q_OS_WIN) || defined(Q_OS_WIN_AND_WINCE)
+#if !defined(Q_OS_WIN)
void localeAwareCompare_data();
void localeAwareCompare();
#endif
@@ -1055,10 +1051,6 @@ void tst_QString::acc_01()
QVERIFY(a.isNull());
QVERIFY(*a.toLatin1().constData() == '\0');
{
-#if defined(Q_OS_WINCE)
- int argc = 0;
- QCoreApplication app(argc, 0);
-#endif
QFile f("COMPARE.txt");
f.open(QIODevice::ReadOnly);
QTextStream ts( &f );
@@ -1202,7 +1194,7 @@ void tst_QString::macTypes()
#ifndef Q_OS_MAC
QSKIP("This is a Mac-only test");
#else
- extern void tst_QString_macTypes(); // in qstring_mac.mm
+ extern void tst_QString_macTypes(); // in qcore_foundation.mm
tst_QString_macTypes();
#endif
}
@@ -5374,15 +5366,11 @@ void tst_QString::tortureSprintfDouble()
#include <locale.h>
-#if !defined(Q_OS_WIN) || defined(Q_OS_WIN_AND_WINCE)
-// On Q_OS_WIN others than Win CE, we cannot set the system or user locale
+#if !defined(Q_OS_WIN)
+// On Q_OS_WIN, we cannot set the system or user locale
void tst_QString::localeAwareCompare_data()
{
-#ifdef Q_OS_WIN_AND_WINCE
- QTest::addColumn<ulong>("locale");
-#else
QTest::addColumn<QString>("locale");
-#endif
QTest::addColumn<QString>("s1");
QTest::addColumn<QString>("s2");
QTest::addColumn<int>("result");
@@ -5392,15 +5380,9 @@ void tst_QString::localeAwareCompare_data()
Latin-1-specific characters (I think). Compare with Swedish
below.
*/
-#ifdef Q_OS_WIN_AND_WINCE // assume c locale to be english
- QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1;
- QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
- QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
-#else
QTest::newRow("c1") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1;
QTest::newRow("c2") << QString("C") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
QTest::newRow("c3") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
-#endif
/*
It's hard to test English, because it's treated differently
@@ -5410,15 +5392,9 @@ void tst_QString::localeAwareCompare_data()
comparison of Latin-1 values, although I'm not sure. So I
just test digits to make sure that it's not totally broken.
*/
-#ifdef Q_OS_WIN_AND_WINCE
- QTest::newRow("english1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("4") << 1;
- QTest::newRow("english2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("4") << QString("6") << -1;
- QTest::newRow("english3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("6") << -1;
-#else
QTest::newRow("english1") << QString("en_US") << QString("5") << QString("4") << 1;
QTest::newRow("english2") << QString("en_US") << QString("4") << QString("6") << -1;
QTest::newRow("english3") << QString("en_US") << QString("5") << QString("6") << -1;
-#endif
/*
In Swedish, a with ring above (E5) comes before a with
diaresis (E4), which comes before o diaresis (F6), which
@@ -5429,11 +5405,6 @@ void tst_QString::localeAwareCompare_data()
QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1;
-#elif defined(Q_OS_WIN_AND_WINCE)
- QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1;
- QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
- QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
- QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1;
#else
QTest::newRow("swedish1") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1;
QTest::newRow("swedish2") << QString("sv_SE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
@@ -5459,10 +5430,6 @@ void tst_QString::localeAwareCompare_data()
QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1;
-#elif defined(Q_OS_WIN_AND_WINCE)
- QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
- QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
- QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1;
#else
QTest::newRow("german1") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
QTest::newRow("german2") << QString("de_DE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
@@ -5472,11 +5439,7 @@ void tst_QString::localeAwareCompare_data()
void tst_QString::localeAwareCompare()
{
-#ifdef Q_OS_WIN_AND_WINCE
- QFETCH(ulong, locale);
-#else
QFETCH(QString, locale);
-#endif
QFETCH(QString, s1);
QFETCH(QString, s2);
QFETCH(int, result);
@@ -5484,11 +5447,7 @@ void tst_QString::localeAwareCompare()
QStringRef r1(&s1, 0, s1.length());
QStringRef r2(&s2, 0, s2.length());
-#ifdef Q_OS_WIN_AND_WINCE
- DWORD oldLcid = GetUserDefaultLCID();
- SetUserDefaultLCID(locale);
- QCOMPARE(locale, GetUserDefaultLCID());
-#elif defined (Q_OS_MAC) || defined(QT_USE_ICU)
+#if defined (Q_OS_DARWIN) || defined(QT_USE_ICU)
QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
#else
if (!locale.isEmpty()) {
@@ -5550,14 +5509,10 @@ void tst_QString::localeAwareCompare()
QVERIFY(testres == 0);
}
-#ifdef Q_OS_WIN_AND_WINCE
- SetUserDefaultLCID(oldLcid);
-#else
if (!locale.isEmpty())
setlocale(LC_ALL, "");
-#endif
}
-#endif //!defined(Q_OS_WIN) || defined(Q_OS_WIN_AND_WINCE)
+#endif //!defined(Q_OS_WIN)
void tst_QString::reverseIterators()
{
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/.gitignore b/tests/auto/corelib/tools/qstringapisymmetry/.gitignore
new file mode 100644
index 0000000000..d28de05438
--- /dev/null
+++ b/tests/auto/corelib/tools/qstringapisymmetry/.gitignore
@@ -0,0 +1 @@
+tst_qstringapisymmetry
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/qstringapisymmetry.pro b/tests/auto/corelib/tools/qstringapisymmetry/qstringapisymmetry.pro
new file mode 100644
index 0000000000..76e89c9acd
--- /dev/null
+++ b/tests/auto/corelib/tools/qstringapisymmetry/qstringapisymmetry.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qstringapisymmetry
+QT = core testlib
+SOURCES = tst_qstringapisymmetry.cpp
+contains(QT_CONFIG,c++14): CONFIG += c++14
diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
new file mode 100644
index 0000000000..7305a00d94
--- /dev/null
+++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+** 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$
+**
+****************************************************************************/
+
+#undef QT_NO_CAST_FROM_ASCII
+#undef QT_NO_CAST_TO_ASCII
+#undef QT_ASCII_CAST_WARNINGS
+
+#include <QString>
+#include <QChar>
+#include <QStringRef>
+#include <QLatin1String>
+
+#include <QTest>
+
+Q_DECLARE_METATYPE(QLatin1String)
+Q_DECLARE_METATYPE(QStringRef)
+
+template <typename T>
+QString toQString(const T &t) { return QString(t); }
+QString toQString(const QStringRef &ref) { return ref.toString(); }
+
+// FIXME: these are missing at the time of writing, add them, then remove the dummies here:
+#define MAKE_RELOP(op, A1, A2) \
+ static bool operator op (A1 lhs, A2 rhs) \
+ { return toQString(lhs) op toQString(rhs); } \
+ /*end*/
+#define MAKE_ALL(A1, A2) \
+ MAKE_RELOP(==, A1, A2) \
+ MAKE_RELOP(!=, A1, A2) \
+ MAKE_RELOP(<, A1, A2) \
+ MAKE_RELOP(>, A1, A2) \
+ MAKE_RELOP(<=, A1, A2) \
+ MAKE_RELOP(>=, A1, A2) \
+ /*end*/
+
+MAKE_ALL(QByteArray, QChar)
+MAKE_ALL(QByteArray, QLatin1String)
+
+MAKE_ALL(const char*, QChar)
+
+#undef MAKE_ALL
+#undef MAKE_RELOP
+// END FIXME
+
+class tst_QStringApiSymmetry : public QObject
+{
+ Q_OBJECT
+
+ void compare_data(bool hasConceptOfNullAndEmpty=true);
+ template <typename LHS, typename RHS>
+ void compare_impl() const;
+
+private Q_SLOTS:
+ // test all combinations of {QChar, QStringRef, QString, QLatin1String, QByteArray, const char*}
+ void compare_QChar_QChar_data() { compare_data(false); }
+ void compare_QChar_QChar() { compare_impl<QChar, QChar>(); }
+ void compare_QChar_QStringRef_data() { compare_data(false); }
+ void compare_QChar_QStringRef() { compare_impl<QChar, QStringRef>(); }
+ void compare_QChar_QString_data() { compare_data(false); }
+ void compare_QChar_QString() { compare_impl<QChar, QString>(); }
+ void compare_QChar_QLatin1String_data() { compare_data(false); }
+ void compare_QChar_QLatin1String() { compare_impl<QChar, QLatin1String>(); }
+ void compare_QChar_QByteArray_data() { compare_data(false); }
+ void compare_QChar_QByteArray() { compare_impl<QChar, QByteArray>(); }
+ void compare_QChar_const_char_star_data() { compare_data(false); }
+ void compare_QChar_const_char_star() { compare_impl<QChar, const char *>(); }
+
+ void compare_QStringRef_QChar_data() { compare_data(false); }
+ void compare_QStringRef_QChar() { compare_impl<QStringRef, QChar>(); }
+ void compare_QStringRef_QStringRef_data() { compare_data(); }
+ void compare_QStringRef_QStringRef() { compare_impl<QStringRef, QStringRef>(); }
+ void compare_QStringRef_QString_data() { compare_data(); }
+ void compare_QStringRef_QString() { compare_impl<QStringRef, QString>(); }
+ void compare_QStringRef_QLatin1String_data() { compare_data(); }
+ void compare_QStringRef_QLatin1String() { compare_impl<QStringRef, QLatin1String>(); }
+ void compare_QStringRef_QByteArray_data() { compare_data(); }
+ void compare_QStringRef_QByteArray() { compare_impl<QStringRef, QByteArray>(); }
+ void compare_QStringRef_const_char_star_data() { compare_data(); }
+ void compare_QStringRef_const_char_star() { compare_impl<QStringRef, const char *>(); }
+
+ void compare_QString_QChar_data() { compare_data(false); }
+ void compare_QString_QChar() { compare_impl<QString, QChar>(); }
+ void compare_QString_QStringRef_data() { compare_data(); }
+ void compare_QString_QStringRef() { compare_impl<QString, QStringRef>(); }
+ void compare_QString_QString_data() { compare_data(); }
+ void compare_QString_QString() { compare_impl<QString, QString>(); }
+ void compare_QString_QLatin1String_data() { compare_data(); }
+ void compare_QString_QLatin1String() { compare_impl<QString, QLatin1String>(); }
+ void compare_QString_QByteArray_data() { compare_data(); }
+ void compare_QString_QByteArray() { compare_impl<QString, QByteArray>(); }
+ void compare_QString_const_char_star_data() { compare_data(); }
+ void compare_QString_const_char_star() { compare_impl<QString, const char *>(); }
+
+ void compare_QLatin1String_QChar_data() { compare_data(false); }
+ void compare_QLatin1String_QChar() { compare_impl<QLatin1String, QChar>(); }
+ void compare_QLatin1String_QStringRef_data() { compare_data(); }
+ void compare_QLatin1String_QStringRef() { compare_impl<QLatin1String, QStringRef>(); }
+ void compare_QLatin1String_QString_data() { compare_data(); }
+ void compare_QLatin1String_QString() { compare_impl<QLatin1String, QString>(); }
+ void compare_QLatin1String_QLatin1String_data() { compare_data(); }
+ void compare_QLatin1String_QLatin1String() { compare_impl<QLatin1String, QLatin1String>(); }
+ void compare_QLatin1String_QByteArray_data() { compare_data(); }
+ void compare_QLatin1String_QByteArray() { compare_impl<QLatin1String, QByteArray>(); }
+ void compare_QLatin1String_const_char_star_data() { compare_data(); }
+ void compare_QLatin1String_const_char_star() { compare_impl<QLatin1String, const char *>(); }
+
+ void compare_QByteArray_QChar_data() { compare_data(false); }
+ void compare_QByteArray_QChar() { compare_impl<QByteArray, QChar>(); }
+ void compare_QByteArray_QStringRef_data() { compare_data(); }
+ void compare_QByteArray_QStringRef() { compare_impl<QByteArray, QStringRef>(); }
+ void compare_QByteArray_QString_data() { compare_data(); }
+ void compare_QByteArray_QString() { compare_impl<QByteArray, QString>(); }
+ void compare_QByteArray_QLatin1String_data() { compare_data(); }
+ void compare_QByteArray_QLatin1String() { compare_impl<QByteArray, QLatin1String>(); }
+ void compare_QByteArray_QByteArray_data() { compare_data(); }
+ void compare_QByteArray_QByteArray() { compare_impl<QByteArray, QByteArray>(); }
+ void compare_QByteArray_const_char_star_data() { compare_data(); }
+ void compare_QByteArray_const_char_star() { compare_impl<QByteArray, const char *>(); }
+
+ void compare_const_char_star_QChar_data() { compare_data(false); }
+ void compare_const_char_star_QChar() { compare_impl<const char *, QChar>(); }
+ void compare_const_char_star_QStringRef_data() { compare_data(); }
+ void compare_const_char_star_QStringRef() { compare_impl<const char *, QStringRef>(); }
+ void compare_const_char_star_QString_data() { compare_data(); }
+ void compare_const_char_star_QString() { compare_impl<const char *, QString>(); }
+ void compare_const_char_star_QLatin1String_data() { compare_data(false); }
+ void compare_const_char_star_QLatin1String() { compare_impl<const char *, QLatin1String>(); }
+ void compare_const_char_star_QByteArray_data() { compare_data(); }
+ void compare_const_char_star_QByteArray() { compare_impl<const char *, QByteArray>(); }
+ //void compare_const_char_star_const_char_star_data() { compare_data(); }
+ //void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
+
+};
+
+void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty)
+{
+ QTest::addColumn<QStringRef>("lhsUnicode");
+ QTest::addColumn<QLatin1String>("lhsLatin1");
+ QTest::addColumn<QStringRef>("rhsUnicode");
+ QTest::addColumn<QLatin1String>("rhsLatin1");
+ QTest::addColumn<int>("caseSensitiveCompareResult");
+ QTest::addColumn<int>("caseInsensitiveCompareResult");
+
+ if (hasConceptOfNullAndEmpty) {
+ QTest::newRow("null <> null") << QStringRef() << QLatin1String()
+ << QStringRef() << QLatin1String()
+ << 0 << 0;
+ static const QString empty("");
+ QTest::newRow("null <> empty") << QStringRef() << QLatin1String()
+ << QStringRef(&empty) << QLatin1String("")
+ << 0 << 0;
+ }
+
+#define ROW(lhs, rhs) \
+ do { \
+ static const QString pinned[] = { \
+ QString(QLatin1String(lhs)), \
+ QString(QLatin1String(rhs)), \
+ }; \
+ QTest::newRow(qUtf8Printable(QLatin1String("'" lhs "' <> '" rhs "': "))) \
+ << QStringRef(&pinned[0]) << QLatin1String(lhs) \
+ << QStringRef(&pinned[1]) << QLatin1String(rhs) \
+ << qstrcmp(lhs, rhs) << qstricmp(lhs, rhs); \
+ } while (false)
+ ROW("", "0");
+ ROW("0", "");
+ ROW("0", "1");
+ ROW("0", "0");
+ ROW("\xE4", "\xE4"); // ä <> ä
+ ROW("\xE4", "\xC4"); // ä <> Ä
+#undef ROW
+}
+
+template <class Str> Str make(const QStringRef &sf, QLatin1String l1, const QByteArray &u8);
+template <> QChar make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf.isEmpty() ? QChar() : sf.at(0); }
+template <> QStringRef make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf; }
+template <> QString make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf.toString(); }
+template <> QLatin1String make(const QStringRef &, QLatin1String l1, const QByteArray &) { return l1; }
+template <> QByteArray make(const QStringRef &, QLatin1String, const QByteArray &u8) { return u8; }
+template <> const char * make(const QStringRef &, QLatin1String, const QByteArray &u8) { return u8.data(); }
+
+template <typename> struct is_utf8_encoded : std::false_type {};
+template <> struct is_utf8_encoded<const char*> : std::true_type {};
+template <> struct is_utf8_encoded<QByteArray> : std::true_type {};
+
+template <typename> struct is_latin1_encoded : std::false_type {};
+template <> struct is_latin1_encoded<QLatin1String> : std::true_type {};
+
+template <typename LHS, typename RHS>
+struct has_nothrow_compare {
+ enum { value = is_utf8_encoded<LHS>::value == is_utf8_encoded<RHS>::value };
+};
+
+template <typename LHS, typename RHS>
+void tst_QStringApiSymmetry::compare_impl() const
+{
+ QFETCH(QStringRef, lhsUnicode);
+ QFETCH(QLatin1String, lhsLatin1);
+ QFETCH(QStringRef, rhsUnicode);
+ QFETCH(QLatin1String, rhsLatin1);
+ QFETCH(int, caseSensitiveCompareResult);
+
+ const auto lhsU8 = lhsUnicode.toUtf8();
+ const auto rhsU8 = rhsUnicode.toUtf8();
+
+ const auto lhs = make<LHS>(lhsUnicode, lhsLatin1, lhsU8);
+ const auto rhs = make<RHS>(rhsUnicode, rhsLatin1, rhsU8);
+
+#ifdef Q_COMPILER_NOEXCEPT
+# define QVERIFY_NOEXCEPT(expr) do { \
+ if (has_nothrow_compare<LHS, RHS>::value) {} else \
+ QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \
+ QVERIFY(noexcept(expr)); } while (0)
+#else
+# define QVERIFY_NOEXCEPT(expr)
+#endif
+
+#define CHECK(op) \
+ QVERIFY_NOEXCEPT(lhs op rhs); \
+ do { if (caseSensitiveCompareResult op 0) { \
+ QVERIFY(lhs op rhs); \
+ } else { \
+ QVERIFY(!(lhs op rhs)); \
+ } } while (false)
+
+ CHECK(==);
+ CHECK(!=);
+ CHECK(<);
+ CHECK(>);
+ CHECK(<=);
+ CHECK(>=);
+#undef CHECK
+}
+
+QTEST_APPLESS_MAIN(tst_QStringApiSymmetry)
+
+#include "tst_qstringapisymmetry.moc"
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 7a361c0693..f6a1432f5c 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -73,8 +73,22 @@ void runScenario()
QCOMPARE(r, r2);
r = stringref Q stringref;
QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
+ r = stringref P stringref;
+ QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
r = string P l1string;
QCOMPARE(r, r2);
+ r = l1string P stringref;
+ QCOMPARE(r, QString(l1string + stringref.toString()));
+ r = stringref P l1string;
+ QCOMPARE(r, QString(stringref.toString() + l1string));
+ r = stringref P string;
+ QCOMPARE(r, QString(stringref.toString() + string));
+ r = string P stringref;
+ QCOMPARE(r, QString(string + stringref.toString()));
+ r = stringref P achar;
+ QCOMPARE(r, QString(stringref.toString() + achar));
+ r = achar P stringref;
+ QCOMPARE(r, QString(achar + stringref.toString()));
r = string Q QStringLiteral(LITERAL);
QCOMPARE(r, r2);
r = QStringLiteral(LITERAL) Q string;
diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
index dc3547f9ba..0fdafd9b01 100644
--- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
@@ -32,9 +32,6 @@
#include <qstringlist.h>
#include <locale.h>
-#ifdef Q_OS_WINCE
-#include <windows.h> // needed for GetUserDefaultLCID
-#endif
class tst_QStringList : public QObject
{
@@ -205,13 +202,7 @@ void tst_QStringList::sort()
list2 << "BETA" << "Gamma" << "alpha" << "beta" << "epsilon" << "gAmma" << "gamma";
QCOMPARE( list1, list2 );
-#ifdef Q_OS_WINCE
- DWORD oldLcid = GetUserDefaultLCID();
- // Assume c locale to be english
- SetUserDefaultLCID(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
-#else
char *current_locale = setlocale(LC_ALL, "C");
-#endif
QStringList list3, list4;
list3 << "alpha" << "beta" << "BETA" << "gamma" << "Gamma" << "gAmma" << "epsilon";
list3.sort(Qt::CaseInsensitive);
@@ -224,11 +215,7 @@ void tst_QStringList::sort()
QCOMPARE(list4.at(0), QString("alpha"));
QVERIFY(list4.indexOf("epsilon") > 0);
QVERIFY(list4.indexOf("epsilon") < (list4.count() - 1));
-#ifdef Q_OS_WINCE
- SetUserDefaultLCID(oldLcid);
-#else
setlocale(LC_ALL, current_locale);
-#endif
}
void tst_QStringList::replaceInStrings()
diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
index 25b97ceaa8..d2374fe0ae 100644
--- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
+++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp
@@ -81,6 +81,7 @@ private slots:
void integer_conversion();
void trimmed();
void truncate();
+ void chop();
void left();
void right();
void mid();
@@ -1904,6 +1905,48 @@ void tst_QStringRef::truncate()
}
}
+void tst_QStringRef::chop()
+{
+ const QString originalString = QStringLiteral("OriginalString~");
+ const QStringRef cref(&originalString);
+ {
+ const int n = 1;
+ QStringRef ref = cref;
+ QString str = originalString;
+ ref.chop(n);
+ str.chop(n);
+ QCOMPARE(ref.toString(), QLatin1String("OriginalString"));
+ QCOMPARE(ref.toString(), str);
+ }
+ {
+ const int n = -1;
+ QStringRef ref = cref;
+ QString str = originalString;
+ ref.chop(n);
+ str.chop(n);
+ QCOMPARE(ref.toString(), originalString);
+ QCOMPARE(ref.toString(), str);
+ }
+ {
+ const int n = 0;
+ QStringRef ref = cref;
+ QString str = originalString;
+ ref.chop(n);
+ str.chop(n);
+ QCOMPARE(ref.toString(), originalString);
+ QCOMPARE(ref.toString(), str);
+ }
+ {
+ const int n = 1000;
+ QStringRef ref = cref;
+ QString str = originalString;
+ ref.chop(n);
+ str.chop(n);
+ QCOMPARE(ref.toString(), str);
+ QVERIFY(ref.isEmpty());
+ }
+}
+
void tst_QStringRef::left()
{
QString originalString = "OrginalString~";
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index cf43e391b5..383f357206 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -68,11 +68,7 @@ protected:
void tst_QTimeLine::range()
{
-#ifdef Q_OS_WINCE //On WinCE timer resolution is bad - using longer times instead
- QTimeLine timeLine(2000);
-#else
QTimeLine timeLine(200);
-#endif
QCOMPARE(timeLine.startFrame(), 0);
QCOMPARE(timeLine.endFrame(), 0);
timeLine.setFrameRange(0, 1);
diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
index 34d9256244..c37a15089a 100644
--- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
+++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <QtCore/qversionnumber.h>
+#include <QtCore/qlibraryinfo.h>
class tst_QVersionNumber : public QObject
{
@@ -79,6 +80,7 @@ private slots:
void serialize_data();
void serialize();
void moveSemantics();
+ void qtVersion();
};
void tst_QVersionNumber::singleInstanceData()
@@ -636,6 +638,17 @@ void tst_QVersionNumber::moveSemantics()
#endif
}
+void tst_QVersionNumber::qtVersion()
+{
+ QVersionNumber v = QLibraryInfo::version();
+ QVERIFY(!v.isNull());
+ QCOMPARE(v.majorVersion(), QT_VERSION_MAJOR);
+ // we can't compare the minor and micro version:
+ // the library may change without the test being recompiled
+
+ QCOMPARE(v.toString(), QString(qVersion()));
+}
+
QTEST_APPLESS_MAIN(tst_QVersionNumber)
#include "tst_qversionnumber.moc"
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index f9e1c454e7..e45771a704 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -18,7 +18,6 @@ SUBDIRS=\
qdate \
qdatetime \
qeasingcurve \
- qelapsedtimer \
qexplicitlyshareddatapointer \
qfreelist \
qhash \
@@ -51,6 +50,7 @@ SUBDIRS=\
qstl \
qstring \
qstring_no_cast_from_bytearray \
+ qstringapisymmetry \
qstringbuilder \
qstringiterator \
qstringlist \