diff options
Diffstat (limited to 'tests')
391 files changed, 9644 insertions, 4372 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index c40e3d1140..cadd97fb3a 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -19,7 +19,7 @@ SUBDIRS += \ installed_cmake.depends = cmake -ios: SUBDIRS = corelib gui +uikit: SUBDIRS = corelib gui wince: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools cmake installed_cmake @@ -34,7 +34,7 @@ cross_compile: SUBDIRS -= tools cmake installed_cma # Disable the QtDBus tests if we can't connect to the session bus !cross_compile:qtHaveModule(dbus) { !system("dbus-send --session --type=signal / local.AutotestCheck.Hello >/dev/null 2>&1") { - contains(QT_CONFIG, dbus-linked): \ + qtConfig(dbus-linked): \ error("QtDBus is enabled but session bus is not available. Please check the installation.") else: \ warning("QtDBus is enabled with runtime support, but session bus is not available. Skipping QtDBus tests.") 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/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 554f0dc68d..bdd862e316 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -332,7 +332,8 @@ void tst_QTextCodec::codecForLocale() // find a codec that is not the codecForLocale() QTextCodec *codec2 = 0; - foreach (int mib, QTextCodec::availableMibs()) { + const auto availableMibs = QTextCodec::availableMibs(); + for (int mib : availableMibs ) { if (mib != codec->mibEnum()) { codec2 = QTextCodec::codecForMib(mib); if (codec2) @@ -2148,7 +2149,7 @@ public: void tst_QTextCodec::threadSafety() { QList<QByteArray> codecList = QTextCodec::availableCodecs(); - QList<int> mibList = QTextCodec::availableMibs(); + const QVector<int> mibList = QTextCodec::availableMibs().toVector(); QThreadPool::globalInstance()->setMaxThreadCount(12); QVector<QByteArray> res; @@ -2167,7 +2168,7 @@ void tst_QTextCodec::threadSafety() QThreadPool::globalInstance()->waitForDone(); QCOMPARE(res.toList(), codecList); - QCOMPARE(res2.toList(), mibList); + QCOMPARE(res2, mibList); } void tst_QTextCodec::invalidNames() @@ -2189,10 +2190,9 @@ void tst_QTextCodec::invalidNames() void tst_QTextCodec::checkAliases_data() { QTest::addColumn<QByteArray>("codecName"); - QList<QByteArray> codecList = QTextCodec::availableCodecs(); - foreach (const QByteArray &a, codecList) { + const QList<QByteArray> codecList = QTextCodec::availableCodecs(); + for (const QByteArray &a : codecList) QTest::newRow( a.constData() ) << a; - } } void tst_QTextCodec::checkAliases() @@ -2203,7 +2203,8 @@ void tst_QTextCodec::checkAliases() QCOMPARE(QTextCodec::codecForName(codecName), c); QCOMPARE(QTextCodec::codecForName(c->name()), c); - foreach(const QByteArray &a, c->aliases()) { + const auto aliases = c->aliases(); + for (const QByteArray &a : aliases) { QCOMPARE(QTextCodec::codecForName(a), c); } } diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index 16265c6187..5666726a8c 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -29,7 +29,7 @@ #include <QtTest/QtTest> #include <qtextcodec.h> -#include <qsharedpointer.h> +#include <QScopedPointer> static const char utf8bom[] = "\xEF\xBB\xBF"; @@ -180,7 +180,7 @@ void tst_Utf8::charByChar() { // from utf16 to utf8 char by char: - QSharedPointer<QTextEncoder> encoder = QSharedPointer<QTextEncoder>(codec->makeEncoder()); + const QScopedPointer<QTextEncoder> encoder(codec->makeEncoder()); QByteArray encoded; for (int i = 0; i < utf16.length(); ++i) { @@ -194,7 +194,7 @@ void tst_Utf8::charByChar() } { // from utf8 to utf16 char by char: - QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); + const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder()); QString decoded; for (int i = 0; i < utf8.length(); ++i) { @@ -219,7 +219,7 @@ void tst_Utf8::invalidUtf8() QFETCH(QByteArray, utf8); QFETCH_GLOBAL(bool, useLocale); - QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); + const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder()); decoder->toUnicode(utf8); // Only enforce correctness on our UTF-8 decoder @@ -280,7 +280,7 @@ void tst_Utf8::nonCharacters() QFETCH(QString, utf16); QFETCH_GLOBAL(bool, useLocale); - QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); + const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder()); decoder->toUnicode(utf8); // Only enforce correctness on our UTF-8 decoder @@ -289,7 +289,7 @@ void tst_Utf8::nonCharacters() else if (decoder->hasFailure()) qWarning("System codec reports failure when it shouldn't. Should report bug upstream."); - QSharedPointer<QTextEncoder> encoder(codec->makeEncoder()); + const QScopedPointer<QTextEncoder> encoder(codec->makeEncoder()); encoder->fromUnicode(utf16); if (!useLocale) QVERIFY(!encoder->hasFailure()); 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/qflags/qflags.pro b/tests/auto/corelib/global/qflags/qflags.pro index 29dfb0684c..c3c11fa81b 100644 --- a/tests/auto/corelib/global/qflags/qflags.pro +++ b/tests/auto/corelib/global/qflags/qflags.pro @@ -2,5 +2,5 @@ CONFIG += testcase TARGET = tst_qflags QT = core testlib SOURCES = tst_qflags.cpp -contains(QT_CONFIG, c++11): CONFIG += c++11 -contains(QT_CONFIG, c++14): CONFIG += c++14 +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index bb4d1f4bf2..9b92a4ff15 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -81,7 +81,7 @@ void tst_QGlobal::qIsNull() void tst_QGlobal::for_each() { - QList<int> list; + QVector<int> list; list << 0 << 1 << 2 << 3 << 4 << 5; int counter = 0; @@ -100,7 +100,7 @@ void tst_QGlobal::for_each() // check whether we can pass a constructor as container argument counter = 0; - foreach (int i, QList<int>(list)) { + foreach (int i, QVector<int>(list)) { QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); @@ -589,7 +589,7 @@ Q_DECLARE_METATYPE(stringpair) void tst_QGlobal::qprintable() { - QFETCH(QList<stringpair>, localestrings); + QFETCH(QVector<stringpair>, localestrings); QFETCH(int, utf8index); QVERIFY(utf8index >= 0 && utf8index < localestrings.count()); @@ -600,21 +600,21 @@ void tst_QGlobal::qprintable() QString string = QString::fromUtf8(utf8string); - foreach (const stringpair &pair, localestrings) { + for (const stringpair &pair : qAsConst(localestrings)) { QTextCodec *codec = QTextCodec::codecForName(pair.first); if (!codec) continue; QTextCodec::setCodecForLocale(codec); // test qPrintable() QVERIFY(qstrcmp(qPrintable(string), pair.second) == 0); - foreach (const stringpair &pair2, localestrings) { + for (const stringpair &pair2 : qAsConst(localestrings)) { if (pair2.second == pair.second) continue; QVERIFY(qstrcmp(qPrintable(string), pair2.second) != 0); } // test qUtf8Printable() QVERIFY(qstrcmp(qUtf8Printable(string), utf8string) == 0); - foreach (const stringpair &pair2, localestrings) { + for (const stringpair &pair2 : qAsConst(localestrings)) { if (qstrcmp(pair2.second, utf8string) == 0) continue; QVERIFY(qstrcmp(qUtf8Printable(string), pair2.second) != 0); @@ -626,7 +626,7 @@ void tst_QGlobal::qprintable() void tst_QGlobal::qprintable_data() { - QTest::addColumn<QList<stringpair> >("localestrings"); + QTest::addColumn<QVector<stringpair> >("localestrings"); QTest::addColumn<int>("utf8index"); // index of utf8 string // Unicode: HIRAGANA LETTER A, I, U, E, O (U+3442, U+3444, U+3446, U+3448, U+344a) @@ -634,7 +634,7 @@ void tst_QGlobal::qprintable_data() static const char *const eucjpstring = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"; static const char *const sjisstring = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"; - QList<stringpair> japanesestrings; + QVector<stringpair> japanesestrings; japanesestrings << stringpair("UTF-8", utf8string) << stringpair("EUC-JP", eucjpstring) << stringpair("Shift_JIS", sjisstring); diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index b5b75be3a6..93eee7307a 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -1,7 +1,7 @@ CONFIG += testcase CONFIG -= app_bundle debug_and_release_target -contains(QT_CONFIG, c++11): CONFIG += c++11 -contains(QT_CONFIG, c++14): CONFIG += c++14 +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 TARGET = ../tst_qlogging QT = core testlib SOURCES = ../tst_qlogging.cpp diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index ce227a6c8b..c2d7338042 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -30,7 +30,7 @@ #include <qdebug.h> #include <qglobal.h> #include <QtCore/QProcess> -#include <QtTest/QtTest> +#include <QtTest/QTest> class tst_qmessagehandler : public QObject { @@ -841,7 +841,7 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(!output.isEmpty()); QCOMPARE(!output.contains("QT_MESSAGE_PATTERN"), valid); - foreach (const QByteArray &e, expected) { + for (const QByteArray &e : qAsConst(expected)) { if (!output.contains(e)) { qDebug() << output; qDebug() << "expected: " << e; 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..0542833456 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 } @@ -49,14 +49,14 @@ SUBDIRS=\ qprocess \ qtextstream -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qabstractfileengine \ qfileinfo \ qipaddress \ qurlinternal \ qloggingregistry -win32:!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +win32:!qtConfig(private_tests): SUBDIRS -= \ qfilesystementry winrt: SUBDIRS -= \ 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 d6bc75317a..021d581aac 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(); @@ -159,17 +155,19 @@ private slots: void copyRemovesTemporaryFile() const; void copyShouldntOverwrite(); void copyFallback(); +#ifndef Q_OS_WINRT void link(); void linkToDir(); void absolutePathLinkToRelativePath(); void readBrokenLink(); +#endif void readTextFile_data(); void readTextFile(); void readTextFile2(); 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 +223,8 @@ private slots: void mapWrittenFile_data(); void mapWrittenFile(); -#ifndef Q_OS_WINCE void openStandardStreamsFileDescriptors(); void openStandardStreamsBufferedStreams(); -#endif void resize_data(); void resize(); @@ -491,7 +487,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 +539,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 +570,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) || defined(Q_OS_WINRT) QEXPECT_FAIL("noreadfile", "Windows does not currently support non-readable files.", Abort); #endif if (filename.isEmpty()) @@ -626,7 +622,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 +633,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 +652,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 +664,6 @@ void tst_QFile::size() f.close(); QT_CLOSE(fd); } -#endif } void tst_QFile::sizeNoExist() @@ -920,7 +908,6 @@ private: }; #endif // !QT_NO_PROCESS -#if !defined(Q_OS_WINCE) void tst_QFile::readAllStdin() { #ifdef QT_NO_PROCESS @@ -1011,7 +998,6 @@ void tst_QFile::readLineStdin_lineByLine() } #endif } -#endif void tst_QFile::text() { @@ -1112,7 +1098,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 +1135,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 +1197,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; @@ -1244,7 +1228,7 @@ void tst_QFile::permissions() QFile::remove(file); } -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) if (qt_ntfs_permission_lookup) QEXPECT_FAIL("readonly", "QTBUG-25630", Abort); #endif @@ -1369,15 +1353,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 +1376,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; @@ -1437,6 +1415,7 @@ static QString getWorkingDirectoryForLink(const QString &linkFileName) } #endif +#ifndef Q_OS_WINRT void tst_QFile::link() { QFile::remove("myLink.lnk"); @@ -1457,7 +1436,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) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); QCOMPARE(QDir::fromNativeSeparators(wd), QDir::cleanPath(info1.absolutePath())); #endif @@ -1511,6 +1490,7 @@ void tst_QFile::readBrokenLink() QVERIFY(QFile::link("ole/..", "myLink2.lnk")); QCOMPARE(QFileInfo("myLink2.lnk").symLinkTarget(), QDir::currentPath()); } +#endif // Q_OS_WINRT void tst_QFile::readTextFile_data() { @@ -1595,7 +1575,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 +1654,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 +1799,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 +2004,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 +2271,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 +2286,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 +2415,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 +2628,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 +2652,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 +2679,6 @@ void tst_QFile::handle() #endif QCOMPARE(c, '*'); -#endif //test round trip of adopted stdio file handle QFile file2; @@ -2957,10 +2921,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 +2962,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 +3085,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 +3117,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 +3215,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 +3274,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 59f271d727..3f3533c9a1 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() { QByteArray testData("Data to read"); @@ -789,10 +760,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) { @@ -822,10 +790,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; @@ -866,10 +831,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() { @@ -903,17 +865,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())); @@ -940,9 +897,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); @@ -953,8 +908,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 @@ -1076,10 +1029,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; @@ -1102,10 +1052,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() { @@ -1158,10 +1104,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; @@ -1183,7 +1126,6 @@ void tst_QProcess::atEnd() QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); } -#endif class TestThread : public QThread { @@ -1205,9 +1147,7 @@ protected: process.start("testProcessEcho/testProcessEcho"); -#if !defined(Q_OS_WINCE) QCOMPARE(process.write("abc\0", 4), qint64(4)); -#endif exitCode = exec(); } @@ -1256,8 +1196,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; @@ -1271,10 +1209,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; @@ -1300,10 +1235,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()); @@ -1313,10 +1245,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; @@ -1339,10 +1268,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()); @@ -1351,7 +1277,6 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() QVERIFY(process->waitForBytesWritten(5000)); QTestEventLoop::instance().exitLoop(); } -#endif void tst_QProcess::spaceArgsTest_data() { @@ -1430,14 +1355,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('"'); @@ -1454,14 +1377,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 } } @@ -1482,26 +1403,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); } @@ -1706,8 +1613,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")); @@ -1725,9 +1630,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"); @@ -1802,9 +1705,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(); @@ -1842,25 +1743,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; @@ -1871,7 +1763,6 @@ void tst_QProcess::spaceInName() QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); } -#endif void tst_QProcess::lockupsInStartDetached() { @@ -1886,8 +1777,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; @@ -1902,7 +1791,6 @@ void tst_QProcess::atEnd2() } QCOMPARE(lines.size(), 7); } -#endif void tst_QProcess::waitForReadyReadForNonexistantProcess() { @@ -1932,8 +1820,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..."; @@ -1961,10 +1847,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"); @@ -2082,10 +1965,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"); @@ -2126,10 +2006,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"); @@ -2163,16 +2040,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()); @@ -2209,8 +2081,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"; @@ -2239,10 +2109,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; @@ -2260,11 +2127,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; @@ -2300,7 +2164,6 @@ void tst_QProcess::setNonExistentWorkingDirectory() QVERIFY2(process.errorString().startsWith("chdir:"), process.errorString().toLocal8Bit()); #endif } -#endif void tst_QProcess::startFinishStartFinish() { @@ -2310,11 +2173,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/io/qurlinternal/qurlinternal.pro b/tests/auto/corelib/io/qurlinternal/qurlinternal.pro index ae5e023446..3828512dce 100644 --- a/tests/auto/corelib/io/qurlinternal/qurlinternal.pro +++ b/tests/auto/corelib/io/qurlinternal/qurlinternal.pro @@ -1,5 +1,5 @@ CONFIG += testcase -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) TARGET = tst_qurlinternal SOURCES += tst_qurlinternal.cpp ../../codecs/utf8/utf8data.cpp QT = core core-private testlib 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/json.pro b/tests/auto/corelib/json/json.pro index b3038d7ca1..dc9cd3e383 100644 --- a/tests/auto/corelib/json/json.pro +++ b/tests/auto/corelib/json/json.pro @@ -6,7 +6,7 @@ CONFIG += testcase !android:TESTDATA += bom.json test.json test.bjson test3.json test2.json else:RESOURCES += json.qrc -!contains(QT_CONFIG, doubleconversion):!contains(QT_CONFIG, system-doubleconversion) { +!qtConfig(doubleconversion):!qtConfig(system-doubleconversion) { DEFINES += QT_NO_DOUBLECONVERSION } diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 5878d56a47..1194260efa 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; }; @@ -1184,14 +1186,14 @@ void tst_QtJson::toVariantMap() QCOMPARE(map.size(), 3); QCOMPARE(map.value("Key"), QVariant(QString("Value"))); - QCOMPARE(map.value("null"), QVariant()); + QCOMPARE(map.value("null"), QVariant::fromValue(nullptr)); QCOMPARE(map.value("Array").type(), QVariant::List); QVariantList list = map.value("Array").toList(); QCOMPARE(list.size(), 4); QCOMPARE(list.at(0), QVariant(true)); QCOMPARE(list.at(1), QVariant(999.)); QCOMPARE(list.at(2), QVariant(QLatin1String("string"))); - QCOMPARE(list.at(3), QVariant()); + QCOMPARE(list.at(3), QVariant::fromValue(nullptr)); } void tst_QtJson::toVariantHash() @@ -1213,14 +1215,14 @@ void tst_QtJson::toVariantHash() QCOMPARE(hash.size(), 3); QCOMPARE(hash.value("Key"), QVariant(QString("Value"))); - QCOMPARE(hash.value("null"), QVariant()); + QCOMPARE(hash.value("null"), QVariant::fromValue(nullptr)); QCOMPARE(hash.value("Array").type(), QVariant::List); QVariantList list = hash.value("Array").toList(); QCOMPARE(list.size(), 4); QCOMPARE(list.at(0), QVariant(true)); QCOMPARE(list.at(1), QVariant(999.)); QCOMPARE(list.at(2), QVariant(QLatin1String("string"))); - QCOMPARE(list.at(3), QVariant()); + QCOMPARE(list.at(3), QVariant::fromValue(nullptr)); } void tst_QtJson::toVariantList() @@ -1244,14 +1246,14 @@ void tst_QtJson::toVariantList() QCOMPARE(list.size(), 3); QCOMPARE(list[0], QVariant(QString("Value"))); - QCOMPARE(list[1], QVariant()); + QCOMPARE(list[1], QVariant::fromValue(nullptr)); QCOMPARE(list[2].type(), QVariant::List); QVariantList vlist = list[2].toList(); QCOMPARE(vlist.size(), 4); QCOMPARE(vlist.at(0), QVariant(true)); QCOMPARE(vlist.at(1), QVariant(999.)); QCOMPARE(vlist.at(2), QVariant(QLatin1String("string"))); - QCOMPARE(vlist.at(3), QVariant()); + QCOMPARE(vlist.at(3), QVariant::fromValue(nullptr)); } void tst_QtJson::toJson() @@ -2749,8 +2751,9 @@ void tst_QtJson::unicodeKeys() QCOMPARE(error.error, QJsonParseError::NoError); QJsonObject o = doc.object(); - QCOMPARE(o.keys().size(), 5); - Q_FOREACH (const QString &key, o.keys()) { + const auto keys = o.keys(); + QCOMPARE(keys.size(), 5); + for (const QString &key : keys) { QString suffix = key.mid(key.indexOf(QLatin1Char('_'))); QCOMPARE(o[key].toString(), QString("hello") + suffix); } @@ -2788,5 +2791,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..75b98bcd09 100644 --- a/tests/auto/corelib/kernel/kernel.pro +++ b/tests/auto/corelib/kernel/kernel.pro @@ -1,6 +1,8 @@ TEMPLATE=subdirs SUBDIRS=\ qcoreapplication \ + qdeadlinetimer \ + qelapsedtimer \ qeventdispatcher \ qeventloop \ qmath \ @@ -31,11 +33,11 @@ SUBDIRS=\ qobject \ qsocketnotifier -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qsocketnotifier \ qsharedmemory # This test is only applicable on Windows !win32*|winrt: SUBDIRS -= qwineventnotifier -android|ios: SUBDIRS -= qsharedmemory qsystemsemaphore +android|uikit: SUBDIRS -= qclipboard qobject qsharedmemory qsystemsemaphore diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index a49bb9ae1f..d166351490 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -3,4 +3,4 @@ TARGET = tst_qcoreapplication QT = core testlib core-private SOURCES = tst_qcoreapplication.cpp HEADERS = tst_qcoreapplication.h -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) 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/kernel/qdeadlinetimer/qdeadlinetimer.pro b/tests/auto/corelib/kernel/qdeadlinetimer/qdeadlinetimer.pro new file mode 100644 index 0000000000..12ad7dabc2 --- /dev/null +++ b/tests/auto/corelib/kernel/qdeadlinetimer/qdeadlinetimer.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_qdeadlinetimer +QT = core testlib +SOURCES = tst_qdeadlinetimer.cpp + diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp new file mode 100644 index 0000000000..7642604cfe --- /dev/null +++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp @@ -0,0 +1,625 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QString> +#include <QtCore/QTime> +#include <QtCore/QDeadlineTimer> +#include <QtTest/QtTest> + +#if QT_HAS_INCLUDE(<chrono>) +# include <chrono> +#endif + +static const int minResolution = 100; // the minimum resolution for the tests + +Q_DECLARE_METATYPE(Qt::TimerType) + +class tst_QDeadlineTimer : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void initTestCase_data(); + void basics(); + void foreverness(); + void current(); + void deadlines(); + void setDeadline(); + void expire(); + void stdchrono(); +}; + +void tst_QDeadlineTimer::initTestCase_data() +{ + qRegisterMetaType<Qt::TimerType>(); + QTest::addColumn<Qt::TimerType>("timerType"); + QTest::newRow("precise") << Qt::PreciseTimer; + QTest::newRow("coarse") << Qt::CoarseTimer; +} + +void tst_QDeadlineTimer::basics() +{ + QDeadlineTimer deadline; + QCOMPARE(deadline.timerType(), Qt::CoarseTimer); + + QFETCH_GLOBAL(Qt::TimerType, timerType); + deadline = QDeadlineTimer(timerType); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline, QDeadlineTimer(timerType)); + QVERIFY(!(deadline != QDeadlineTimer(timerType))); + QVERIFY(!(deadline < QDeadlineTimer())); + QVERIFY(deadline <= QDeadlineTimer()); + QVERIFY(deadline >= QDeadlineTimer()); + QVERIFY(!(deadline > QDeadlineTimer())); + QVERIFY(!(deadline < deadline)); + QVERIFY(deadline <= deadline); + QVERIFY(deadline >= deadline); + QVERIFY(!(deadline > deadline)); + + // should have expired, but we may be running too early after boot + QTRY_VERIFY_WITH_TIMEOUT(deadline.hasExpired(), 100); + + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QCOMPARE(deadline.deadline(), qint64(0)); + QCOMPARE(deadline.deadlineNSecs(), qint64(0)); + + deadline.setRemainingTime(0, timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + deadline.setPreciseRemainingTime(0, 0, timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + deadline.setDeadline(0, timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QCOMPARE(deadline.deadline(), qint64(0)); + QCOMPARE(deadline.deadlineNSecs(), qint64(0)); + + deadline.setPreciseDeadline(0, 0, timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QCOMPARE(deadline.deadline(), qint64(0)); + QCOMPARE(deadline.deadlineNSecs(), qint64(0)); +} + +void tst_QDeadlineTimer::foreverness() +{ + QFETCH_GLOBAL(Qt::TimerType, timerType); + // we don't check whether timerType() is our type since it's possible it detects it's forever + + QDeadlineTimer deadline = QDeadlineTimer::Forever; + QCOMPARE(deadline.timerType(), Qt::CoarseTimer); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline = QDeadlineTimer(-1, timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline.setRemainingTime(-1, timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline.setPreciseRemainingTime(-1, 0, timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline.setPreciseRemainingTime(-1, -1, timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline.setDeadline(std::numeric_limits<qint64>::max(), timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + deadline.setPreciseDeadline(std::numeric_limits<qint64>::max(), 0, timerType); + QVERIFY(deadline.isForever()); + QVERIFY(!deadline.hasExpired()); + QCOMPARE(deadline.remainingTime(), qint64(-1)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), std::numeric_limits<qint64>::max()); + + QCOMPARE(deadline, deadline); + QVERIFY(!(deadline < deadline)); + QVERIFY(deadline <= deadline); + QVERIFY(deadline >= deadline); + QVERIFY(!(deadline > deadline)); + + // adding to forever must still be forever + QDeadlineTimer deadline2 = deadline + 1; + QVERIFY(deadline2.isForever()); + QVERIFY(!deadline2.hasExpired()); + QCOMPARE(deadline2.remainingTime(), qint64(-1)); + QCOMPARE(deadline2.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline2.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline2.deadlineNSecs(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline2.timerType(), deadline.timerType()); + + QCOMPARE(deadline2 - deadline, qint64(0)); + QCOMPARE(deadline2, deadline); + QVERIFY(!(deadline2 < deadline)); + QVERIFY(deadline2 <= deadline); + QVERIFY(deadline2 >= deadline); + QVERIFY(!(deadline2 > deadline)); + + // subtracting from forever is *also* forever + deadline2 = deadline - 1; + QVERIFY(deadline2.isForever()); + QVERIFY(!deadline2.hasExpired()); + QCOMPARE(deadline2.remainingTime(), qint64(-1)); + QCOMPARE(deadline2.remainingTimeNSecs(), qint64(-1)); + QCOMPARE(deadline2.deadline(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline2.deadlineNSecs(), std::numeric_limits<qint64>::max()); + QCOMPARE(deadline2.timerType(), deadline.timerType()); + + QCOMPARE(deadline2 - deadline, qint64(0)); + QCOMPARE(deadline2, deadline); + QVERIFY(!(deadline2 < deadline)); + QVERIFY(deadline2 <= deadline); + QVERIFY(deadline2 >= deadline); + QVERIFY(!(deadline2 > deadline)); + + // compare and order against a default-constructed object + QDeadlineTimer expired; + QVERIFY(!(deadline == expired)); + QVERIFY(deadline != expired); + QVERIFY(!(deadline < expired)); + QVERIFY(!(deadline <= expired)); + QVERIFY(deadline >= expired); + QVERIFY(deadline > expired); +} + +void tst_QDeadlineTimer::current() +{ + QFETCH_GLOBAL(Qt::TimerType, timerType); + auto deadline = QDeadlineTimer::current(timerType); + QVERIFY(deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + // subtracting from current should be "more expired" + QDeadlineTimer earlierDeadline = deadline - 1; + QVERIFY(earlierDeadline.hasExpired()); + QVERIFY(!earlierDeadline.isForever()); + QCOMPARE(earlierDeadline.timerType(), timerType); + QCOMPARE(earlierDeadline.remainingTime(), qint64(0)); + QCOMPARE(earlierDeadline.remainingTimeNSecs(), qint64(0)); + QVERIFY(earlierDeadline.deadline() != 0); + QVERIFY(earlierDeadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(earlierDeadline.deadlineNSecs() != 0); + QVERIFY(earlierDeadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + QCOMPARE(earlierDeadline.deadline(), deadline.deadline() - 1); + QCOMPARE(earlierDeadline.deadlineNSecs(), deadline.deadlineNSecs() - 1000*1000); + + QCOMPARE(earlierDeadline - deadline, qint64(-1)); + QVERIFY(earlierDeadline != deadline); + QVERIFY(earlierDeadline < deadline); + QVERIFY(earlierDeadline <= deadline); + QVERIFY(!(earlierDeadline >= deadline)); + QVERIFY(!(earlierDeadline > deadline)); +} + +void tst_QDeadlineTimer::deadlines() +{ + QFETCH_GLOBAL(Qt::TimerType, timerType); + + QDeadlineTimer deadline(4 * minResolution, timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (3 * minResolution)); + QVERIFY(deadline.remainingTime() <= (4 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() > (3000000 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() <= (4000000 * minResolution)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + deadline.setRemainingTime(4 * minResolution, timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (3 * minResolution)); + QVERIFY(deadline.remainingTime() <= (4 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() > (3000000 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() <= (4000000 * minResolution)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + deadline.setPreciseRemainingTime(0, 4000000 * minResolution, timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (3 * minResolution)); + QVERIFY(deadline.remainingTime() <= (4 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() > (3000000 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() <= (4000000 * minResolution)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + deadline.setPreciseRemainingTime(1, 0, timerType); // 1 sec + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (1000 - minResolution)); + QVERIFY(deadline.remainingTime() <= 1000); + QVERIFY(deadline.remainingTimeNSecs() > (1000 - minResolution)*1000*1000); + QVERIFY(deadline.remainingTimeNSecs() <= (1000*1000*1000)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + + // adding to a future deadline must still be further in the future + QDeadlineTimer laterDeadline = deadline + 1; + QVERIFY(!laterDeadline.hasExpired()); + QVERIFY(!laterDeadline.isForever()); + QCOMPARE(laterDeadline.timerType(), timerType); + QVERIFY(laterDeadline.remainingTime() > (1000 - minResolution)); + QVERIFY(laterDeadline.remainingTime() <= 1001); + QVERIFY(laterDeadline.remainingTimeNSecs() > (1001 - minResolution)*1000*1000); + QVERIFY(laterDeadline.remainingTimeNSecs() <= (1001*1000*1000)); + QVERIFY(laterDeadline.deadline() != 0); + QVERIFY(laterDeadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(laterDeadline.deadlineNSecs() != 0); + QVERIFY(laterDeadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + QCOMPARE(laterDeadline.deadline(), deadline.deadline() + 1); + QCOMPARE(laterDeadline.deadlineNSecs(), deadline.deadlineNSecs() + 1000*1000); + + QCOMPARE(laterDeadline - deadline, qint64(1)); + QVERIFY(laterDeadline != deadline); + QVERIFY(!(laterDeadline < deadline)); + QVERIFY(!(laterDeadline <= deadline)); + QVERIFY(laterDeadline >= deadline); + QVERIFY(laterDeadline > deadline); + + // compare and order against a default-constructed object + QDeadlineTimer expired; + QVERIFY(!(deadline == expired)); + QVERIFY(deadline != expired); + QVERIFY(!(deadline < expired)); + QVERIFY(!(deadline <= expired)); + QVERIFY(deadline >= expired); + QVERIFY(deadline > expired); + + // compare and order against a forever deadline + QDeadlineTimer forever_(QDeadlineTimer::Forever); + QVERIFY(!(deadline == forever_)); + QVERIFY(deadline != forever_); + QVERIFY(deadline < forever_); + QVERIFY(deadline <= forever_); + QVERIFY(!(deadline >= forever_)); + QVERIFY(!(deadline > forever_)); +} + +void tst_QDeadlineTimer::setDeadline() +{ + QFETCH_GLOBAL(Qt::TimerType, timerType); + auto now = QDeadlineTimer::current(timerType); + QDeadlineTimer deadline; + + deadline.setDeadline(now.deadline(), timerType); + QVERIFY(deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QCOMPARE(deadline.deadline(), now.deadline()); + // don't check deadlineNSecs! + + deadline.setPreciseDeadline(now.deadlineNSecs() / (1000 * 1000 * 1000), + now.deadlineNSecs() % (1000 * 1000 * 1000), timerType); + QVERIFY(deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QCOMPARE(deadline.deadline(), now.deadline()); + QCOMPARE(deadline.deadlineNSecs(), now.deadlineNSecs()); + + now = QDeadlineTimer::current(timerType); + deadline.setDeadline(now.deadline() + 4 * minResolution, timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (3 * minResolution)); + QVERIFY(deadline.remainingTime() <= (4 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() > (3000000 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() <= (4000000 * minResolution)); + QCOMPARE(deadline.deadline(), now.deadline() + 4 * minResolution); // yes, it's exact + // don't check deadlineNSecs! + + now = QDeadlineTimer::current(timerType); + qint64 nsec = now.deadlineNSecs() + 4000000 * minResolution; + deadline.setPreciseDeadline(nsec / (1000 * 1000 * 1000), + nsec % (1000 * 1000 * 1000), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTime() > (3 * minResolution)); + QVERIFY(deadline.remainingTime() <= (4 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() > (3000000 * minResolution)); + QVERIFY(deadline.remainingTimeNSecs() <= (4000000 * minResolution)); + QCOMPARE(deadline.deadline(), nsec / (1000 * 1000)); + QCOMPARE(deadline.deadlineNSecs(), nsec); +} + +void tst_QDeadlineTimer::expire() +{ + QFETCH_GLOBAL(Qt::TimerType, timerType); + + QDeadlineTimer deadline(minResolution, timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + + qint64 previousDeadline = deadline.deadlineNSecs(); + + QTest::qSleep(2 * minResolution); + + QCOMPARE(deadline.remainingTime(), qint64(0)); + QCOMPARE(deadline.remainingTimeNSecs(), qint64(0)); + QVERIFY(deadline.deadline() != 0); + QVERIFY(deadline.deadline() != std::numeric_limits<qint64>::max()); + QVERIFY(deadline.deadlineNSecs() != 0); + QVERIFY(deadline.deadlineNSecs() != std::numeric_limits<qint64>::max()); + QCOMPARE(deadline.deadlineNSecs(), previousDeadline); +} + +void tst_QDeadlineTimer::stdchrono() +{ +#if !QT_HAS_INCLUDE(<chrono>) + QSKIP("std::chrono not found on this system"); +#else + using namespace std::chrono; + QFETCH_GLOBAL(Qt::TimerType, timerType); + + // create some forevers + QDeadlineTimer deadline = milliseconds::max(); + QVERIFY(deadline.isForever()); + deadline = milliseconds::max(); + QVERIFY(deadline.isForever()); + deadline.setRemainingTime(milliseconds::max(), timerType); + QVERIFY(deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + deadline = nanoseconds::max(); + QVERIFY(deadline.isForever()); + deadline.setRemainingTime(nanoseconds::max(), timerType); + QVERIFY(deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + deadline = hours::max(); + QVERIFY(deadline.isForever()); + deadline.setRemainingTime(hours::max(), timerType); + QVERIFY(deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + + deadline = time_point<system_clock>::max(); + QVERIFY(deadline.isForever()); + deadline.setDeadline(time_point<system_clock>::max(), timerType); + QVERIFY(deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + deadline = time_point<steady_clock>::max(); + QVERIFY(deadline.isForever()); + deadline.setDeadline(time_point<steady_clock>::max(), timerType); + QVERIFY(deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + + QVERIFY(deadline == time_point<steady_clock>::max()); + QVERIFY(deadline == time_point<system_clock>::max()); + QCOMPARE(deadline.remainingTimeAsDuration(), nanoseconds::max()); + + // make it expired + deadline = time_point<system_clock>(); + QVERIFY(deadline.hasExpired()); + deadline.setDeadline(time_point<system_clock>(), timerType); + QVERIFY(deadline.hasExpired()); + QCOMPARE(deadline.timerType(), timerType); + deadline = time_point<steady_clock>(); + QVERIFY(deadline.hasExpired()); + deadline.setDeadline(time_point<steady_clock>(), timerType); + QVERIFY(deadline.hasExpired()); + QCOMPARE(deadline.timerType(), timerType); + + QCOMPARE(deadline.remainingTimeAsDuration(), nanoseconds::zero()); + + auto steady_before = steady_clock::now(); + auto system_before = system_clock::now(); + + QTest::qSleep(minResolution); + auto now = QDeadlineTimer::current(timerType); + QTest::qSleep(minResolution); + + auto steady_after = steady_clock::now(); + auto system_after = system_clock::now(); + + { + auto diff = duration_cast<milliseconds>(steady_after - now.deadline<steady_clock>()); + QVERIFY2(diff.count() > minResolution/2, QByteArray::number(qint64(diff.count()))); + QVERIFY2(diff.count() < 3*minResolution/2, QByteArray::number(qint64(diff.count()))); + QDeadlineTimer dt_after(steady_after, timerType); + QVERIFY2(now < dt_after, + ("now = " + QLocale().toString(now.deadlineNSecs()) + + "; after = " + QLocale().toString(dt_after.deadlineNSecs())).toLatin1()); + + diff = duration_cast<milliseconds>(now.deadline<steady_clock>() - steady_before); + QVERIFY2(diff.count() > minResolution/2, QByteArray::number(qint64(diff.count()))); + QVERIFY2(diff.count() < 3*minResolution/2, QByteArray::number(qint64(diff.count()))); + QDeadlineTimer dt_before(steady_before, timerType); + QVERIFY2(now > dt_before, + ("now = " + QLocale().toString(now.deadlineNSecs()) + + "; before = " + QLocale().toString(dt_before.deadlineNSecs())).toLatin1()); + } + { + auto diff = duration_cast<milliseconds>(system_after - now.deadline<system_clock>()); + QVERIFY2(diff.count() > minResolution/2, QByteArray::number(qint64(diff.count()))); + QVERIFY2(diff.count() < 3*minResolution/2, QByteArray::number(qint64(diff.count()))); + QDeadlineTimer dt_after(system_after, timerType); + QVERIFY2(now < dt_after, + ("now = " + QLocale().toString(now.deadlineNSecs()) + + "; after = " + QLocale().toString(dt_after.deadlineNSecs())).toLatin1()); + + diff = duration_cast<milliseconds>(now.deadline<system_clock>() - system_before); + QVERIFY2(diff.count() > minResolution/2, QByteArray::number(qint64(diff.count()))); + QVERIFY2(diff.count() < 3*minResolution/2, QByteArray::number(qint64(diff.count()))); + QDeadlineTimer dt_before(system_before, timerType); + QVERIFY2(now > dt_before, + ("now = " + QLocale().toString(now.deadlineNSecs()) + + "; before = " + QLocale().toString(dt_before.deadlineNSecs())).toLatin1()); + } + + // make it regular + now = QDeadlineTimer::current(timerType); + deadline.setRemainingTime(milliseconds(4 * minResolution), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTimeAsDuration() > milliseconds(3 * minResolution)); + QVERIFY(deadline.remainingTimeAsDuration() < milliseconds(5 * minResolution)); + QVERIFY(deadline.remainingTimeAsDuration() > nanoseconds(3000000 * minResolution)); + QVERIFY(deadline.remainingTimeAsDuration() < nanoseconds(5000000 * minResolution)); + QVERIFY(deadline.deadline<steady_clock>() > (steady_clock::now() + milliseconds(3 * minResolution))); + QVERIFY(deadline.deadline<steady_clock>() < (steady_clock::now() + milliseconds(5 * minResolution))); + QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + milliseconds(3 * minResolution))); + QVERIFY(deadline.deadline<system_clock>() < (system_clock::now() + milliseconds(5 * minResolution))); + if (timerType == Qt::CoarseTimer) { + QVERIFY(deadline > (now + milliseconds(3 * minResolution))); + QVERIFY(deadline < (now + milliseconds(5 * minResolution))); + QVERIFY(deadline > (now + nanoseconds(3000000 * minResolution))); + QVERIFY(deadline < (now + nanoseconds(5000000 * minResolution))); + QVERIFY(deadline > milliseconds(3 * minResolution)); + QVERIFY(deadline < milliseconds(5 * minResolution)); + QVERIFY(deadline > nanoseconds(3000000 * minResolution)); + QVERIFY(deadline < nanoseconds(5000000 * minResolution)); + QVERIFY(deadline >= steady_clock::now()); + QVERIFY(deadline >= system_clock::now()); + } + + now = QDeadlineTimer::current(timerType); + deadline = QDeadlineTimer(seconds(1), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTimeAsDuration() > (seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.remainingTimeAsDuration() <= seconds(1)); + QVERIFY(deadline.deadline<steady_clock>() > (steady_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + seconds(1) + milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + seconds(1) + milliseconds(minResolution))); + if (timerType == Qt::CoarseTimer) { + QVERIFY(deadline > (seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline <= seconds(1)); + } + + now = QDeadlineTimer::current(timerType); + deadline.setRemainingTime(hours(1), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTimeAsDuration() > (hours(1) - milliseconds(minResolution))); + QVERIFY(deadline.remainingTimeAsDuration() <= hours(1)); + QVERIFY(deadline.deadline<steady_clock>() > (steady_clock::now() + hours(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + hours(1) + milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + hours(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + hours(1) + milliseconds(minResolution))); + + now = QDeadlineTimer::current(timerType); + deadline.setDeadline(system_clock::now() + seconds(1), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTimeAsDuration() > (seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.remainingTimeAsDuration() <= seconds(1)); + QVERIFY(deadline.deadline<steady_clock>() > (steady_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + seconds(1) + milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + seconds(1) + milliseconds(minResolution))); + + now = QDeadlineTimer::current(timerType); + deadline.setDeadline(steady_clock::now() + seconds(1), timerType); + QVERIFY(!deadline.hasExpired()); + QVERIFY(!deadline.isForever()); + QCOMPARE(deadline.timerType(), timerType); + QVERIFY(deadline.remainingTimeAsDuration() > (seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.remainingTimeAsDuration() <= seconds(1)); + QVERIFY(deadline.deadline<steady_clock>() > (steady_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + seconds(1) + milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + seconds(1) - milliseconds(minResolution))); + QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + seconds(1) + milliseconds(minResolution))); +#endif +} + +QTEST_MAIN(tst_QDeadlineTimer) + +#include "tst_qdeadlinetimer.moc" 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..295a42aa9c 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 +qtConfig(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/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index fbb6a30917..86f47f3511 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -669,6 +669,9 @@ template<> struct TestValueFactory<QMetaType::QModelIndex> { template<> struct TestValueFactory<QMetaType::QPersistentModelIndex> { static QPersistentModelIndex *create() { return new QPersistentModelIndex(); } }; +template<> struct TestValueFactory<QMetaType::Nullptr> { + static std::nullptr_t *create() { return new std::nullptr_t; } +}; template<> struct TestValueFactory<QMetaType::QRegExp> { static QRegExp *create() { @@ -1798,6 +1801,7 @@ DECLARE_NONSTREAMABLE(QJsonArray) DECLARE_NONSTREAMABLE(QJsonDocument) DECLARE_NONSTREAMABLE(QObject*) DECLARE_NONSTREAMABLE(QWidget*) +DECLARE_NONSTREAMABLE(std::nullptr_t) #define DECLARE_GUI_CLASS_NONSTREAMABLE(MetaTypeName, MetaTypeId, RealType) \ DECLARE_NONSTREAMABLE(RealType) 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..52bf8e9004 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(); @@ -146,6 +147,7 @@ private slots: void noDeclarativeParentChangedOnDestruction(); void deleteLaterInAboutToBlockHandler(); void mutableFunctor(); + void checkArgumentsForNarrowing(); }; struct QObjectCreatedOnShutdown @@ -923,8 +925,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 +970,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 +1595,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); @@ -6655,6 +6671,515 @@ void tst_QObject::mutableFunctor() QCOMPARE(functor.count, 0); // but the original object should have been copied at connect time } +void tst_QObject::checkArgumentsForNarrowing() +{ + enum UnscopedEnum {}; + enum SignedUnscopedEnum { SignedUnscopedEnumV1 = -1, SignedUnscopedEnumV2 = 1 }; + + QVERIFY(sizeof(UnscopedEnum) <= sizeof(int)); + QVERIFY(sizeof(SignedUnscopedEnum) <= sizeof(int)); + + // floating point to integral + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, bool>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, bool>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, bool>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, char>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, short>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, int>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<float, long long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, long long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, long long>::value)); + + + // floating point to a smaller floating point + if (sizeof(double) > sizeof(float)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<double, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, float>::value)); + } + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<float, double>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<float, long double>::value)); + + if (sizeof(long double) > sizeof(double)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long double, float>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<double, long double>::value)); + + + // integral to floating point + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<char, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<char, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<char, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, long double>::value)); + + + // enum to floating point + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, long double>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, float>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, double>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, long double>::value)); + + + // integral to smaller integral + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<bool, bool>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<char, char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<signed char, signed char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<signed char, short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<signed char, int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<signed char, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<signed char, long long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, unsigned char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, unsigned short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, unsigned int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, unsigned long long>::value)); + + if (sizeof(bool) > sizeof(char)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, unsigned char>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<bool, unsigned char>::value)); + + if (sizeof(bool) > sizeof(short)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, unsigned short>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<bool, unsigned short>::value)); + + if (sizeof(bool) > sizeof(int)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, unsigned int>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<bool, unsigned int>::value)); + + if (sizeof(bool) > sizeof(long)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, unsigned long>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<bool, unsigned long>::value)); + + if (sizeof(bool) > sizeof(long long)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<bool, unsigned long long>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<bool, unsigned long long>::value)); + + if (sizeof(short) > sizeof(char)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, signed char>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, signed char>::value)); + } + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<short, short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<short, int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<short, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<short, long long>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, unsigned short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, unsigned int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, unsigned long long>::value)); + + if (sizeof(int) > sizeof(short)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned short>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, unsigned short>::value)); + } + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<int, int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<int, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<int, long long>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned int, unsigned int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned int, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned int, unsigned long long>::value)); + + if (sizeof(long) > sizeof(int)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned int>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, unsigned int>::value)); + } + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<long, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<long, long long>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned long, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned long, unsigned long long>::value)); + + if (sizeof(long long) > sizeof(long)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, unsigned long>::value)); + } + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<long long, long long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned long long, unsigned long long>::value)); + + + // integral to integral with different signedness. smaller ones tested above + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned long long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, long long>::value)); + + // enum to smaller integral + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, UnscopedEnum>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, SignedUnscopedEnum>::value)); + + if (std::is_signed<typename std::underlying_type<UnscopedEnum>::type>::value) { + if (sizeof(UnscopedEnum) > sizeof(char)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, signed char>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, signed char>::value)); + + if (sizeof(UnscopedEnum) > sizeof(short)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, short>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, short>::value)); + + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, int>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, long>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, long long>::value)); + } else { + if (sizeof(UnscopedEnum) > sizeof(bool)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, bool>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, bool>::value)); + + if (sizeof(UnscopedEnum) > sizeof(char)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned char>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned char>::value)); + + if (sizeof(UnscopedEnum) > sizeof(short)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned short>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned short>::value)); + + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned int>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned long>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<UnscopedEnum, unsigned long long>::value)); + } + + QVERIFY(std::is_signed<typename std::underlying_type<SignedUnscopedEnum>::type>::value); + + if (sizeof(SignedUnscopedEnum) > sizeof(char)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, signed char>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, signed char>::value)); + + if (sizeof(SignedUnscopedEnum) > sizeof(short)) + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, short>::value)); + else + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, short>::value)); + + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, int>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, long>::value)); + QVERIFY(!(QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, long long>::value)); + + + enum class ScopedEnumBackedBySChar : signed char { A }; + enum class ScopedEnumBackedByUChar : unsigned char { A }; + enum class ScopedEnumBackedByShort : short { A }; + enum class ScopedEnumBackedByUShort : unsigned short { A }; + enum class ScopedEnumBackedByInt : int { A }; + enum class ScopedEnumBackedByUInt : unsigned int { A }; + enum class ScopedEnumBackedByLong : long { A }; + enum class ScopedEnumBackedByULong : unsigned long { A }; + enum class ScopedEnumBackedByLongLong : long long { A }; + enum class ScopedEnumBackedByULongLong : unsigned long long { A }; + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, ScopedEnumBackedBySChar>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, ScopedEnumBackedByUChar>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, ScopedEnumBackedByShort>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, ScopedEnumBackedByUShort>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, ScopedEnumBackedByInt>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, ScopedEnumBackedByUInt>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, ScopedEnumBackedByLong>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, ScopedEnumBackedByULong>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, ScopedEnumBackedByLongLong>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, ScopedEnumBackedByULongLong>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, signed char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, unsigned short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, unsigned int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, long long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, unsigned long long>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, signed char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, long long>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned char>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned short>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned int>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, unsigned long long>::value)); + + if (sizeof(short) > sizeof(char)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, char>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, signed char>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, unsigned char>::value)); + } + + if (sizeof(int) > sizeof(short)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, short>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, unsigned short>::value)); + } + + if (sizeof(long) > sizeof(int)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, int>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, unsigned int>::value)); + } + + if (sizeof(long long) > sizeof(long)) { + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, unsigned long>::value)); + } + + // different signedness of the underlying type + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<SignedUnscopedEnum, unsigned long long>::value)); + + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedBySChar, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByShort, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByInt, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLong, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long long>::value)); + + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, signed char>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, short>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, int>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, long>::value)); + QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, long long>::value)); + + // other types which should be always unaffected + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<void *, void *>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString, QString>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString &, QString &>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<const QString &, const QString &>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QObject, QObject>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QObject *, QObject *>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<const QObject *, const QObject *>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<std::nullptr_t, std::nullptr_t>::value)); + + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString, QObject>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString, QVariant>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString, void *>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<QString, long long>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<bool, const QObject *&>::value)); + QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<int (*)(bool), void (QObject::*)()>::value)); +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); diff --git a/tests/auto/corelib/kernel/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/qsocketnotifier/qsocketnotifier.pro b/tests/auto/corelib/kernel/qsocketnotifier/qsocketnotifier.pro index 58e4b98af7..04806de5f7 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/qsocketnotifier.pro +++ b/tests/auto/corelib/kernel/qsocketnotifier/qsocketnotifier.pro @@ -3,6 +3,6 @@ TARGET = tst_qsocketnotifier QT = core-private network-private testlib SOURCES = tst_qsocketnotifier.cpp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) include(../../../network/socket/platformsocketengine/platformsocketengine.pri) 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/qvariant.pro b/tests/auto/corelib/kernel/qvariant/qvariant.pro index 33e8b6e2ad..96071f9f73 100644 --- a/tests/auto/corelib/kernel/qvariant/qvariant.pro +++ b/tests/auto/corelib/kernel/qvariant/qvariant.pro @@ -5,7 +5,7 @@ INCLUDEPATH += $$PWD/../../../other/qvariant_common SOURCES = tst_qvariant.cpp RESOURCES += qvariant.qrc DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -contains(QT_CONFIG, c++11): CONFIG += c++11 -!contains(QT_CONFIG, doubleconversion):!contains(QT_CONFIG, system-doubleconversion) { +qtConfig(c++11): CONFIG += c++11 +!qtConfig(doubleconversion):!qtConfig(system-doubleconversion) { DEFINES += QT_NO_DOUBLECONVERSION } diff --git a/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin b/tests/auto/corelib/kernel/qvariant/stream/qt5.0/qdatetime.bin Binary files differindex 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 diff --git a/tests/auto/corelib/mimetypes/mimetypes.pro b/tests/auto/corelib/mimetypes/mimetypes.pro index 9063d677e7..9dd091374f 100644 --- a/tests/auto/corelib/mimetypes/mimetypes.pro +++ b/tests/auto/corelib/mimetypes/mimetypes.pro @@ -4,5 +4,5 @@ SUBDIRS = \ qmimetype \ qmimedatabase -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qmimetype diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 61ca1a5ddd..9e369792f1 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/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index 874429aab7..ee7cf7ded8 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -61,7 +61,8 @@ void tst_QPlugin::initTestCase() void tst_QPlugin::loadDebugPlugin() { - foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) { + const auto fileNames = dir.entryList(QStringList() << "*debug*", QDir::Files); + for (const QString &fileName : fileNames) { if (!QLibrary::isLibrary(fileName)) continue; QPluginLoader loader(dir.filePath(fileName)); @@ -87,8 +88,8 @@ void tst_QPlugin::loadDebugPlugin() void tst_QPlugin::loadReleasePlugin() { - foreach (QString fileName, dir.entryList(QStringList() << "*release*", QDir::Files)) { - if (!QLibrary::isLibrary(fileName)) + const auto fileNames = dir.entryList(QStringList() << "*release*", QDir::Files); + for (const QString &fileName : fileNames) { continue; QPluginLoader loader(dir.filePath(fileName)); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro index 83d00f7cd8..c681f5585c 100644 --- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro +++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro @@ -5,7 +5,7 @@ SUBDIRS = lib \ theplugin \ tst !android: !win32: !mac: SUBDIRS += almostplugin -macx-*: contains(QT_CONFIG, private_tests): SUBDIRS += machtest +macx-*: qtConfig(private_tests): SUBDIRS += machtest TARGET = tst_qpluginloader # no special install rule for subdir diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro index 101392927c..5f9fa6664b 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro +++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = ../tst_qpluginloader QT = core testlib -contains(QT_CONFIG, private_tests): QT += core-private +qtConfig(private_tests): QT += core-private SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp HEADERS = ../theplugin/plugininterface.h CONFIG -= app_bundle 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..49a3b3e4db 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 @@ -202,6 +200,13 @@ void testAdoptedThreadStorageWin(void *p) } QObject::connect(QThread::currentThread(), SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); } +#ifdef Q_OS_WINRT +unsigned __stdcall testAdoptedThreadStorageWinRT(void *p) +{ + testAdoptedThreadStorageWin(p); + return 0; +} +#endif void *testAdoptedThreadStorageUnix(void *pointers) { testAdoptedThreadStorageWin(pointers); @@ -219,13 +224,14 @@ void tst_QThreadStorage::adoptedThreads() const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers); QCOMPARE(state, 0); pthread_join(thread, 0); -#elif defined Q_OS_WIN && !defined(Q_OS_WINRT) +#elif defined Q_OS_WINRT + HANDLE thread; + thread = (HANDLE) _beginthreadex(NULL, 0, testAdoptedThreadStorageWinRT, &pointers, 0, 0); + QVERIFY(thread); + WaitForSingleObjectEx(thread, INFINITE, FALSE); +#elif defined Q_OS_WIN 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 a100de4c41..310c5f6fd3 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/qcollator/qcollator.pro b/tests/auto/corelib/tools/qcollator/qcollator.pro index ed879ee70e..7725194e3d 100644 --- a/tests/auto/corelib/tools/qcollator/qcollator.pro +++ b/tests/auto/corelib/tools/qcollator/qcollator.pro @@ -3,4 +3,4 @@ TARGET = tst_qcollator QT = core testlib SOURCES = tst_qcollator.cpp DEFINES += QT_NO_CAST_TO_ASCII -contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU +qtConfig(icu): DEFINES += QT_USE_ICU 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/qfreelist/qfreelist.pro b/tests/auto/corelib/tools/qfreelist/qfreelist.pro index fb108338bd..4825987bcf 100644 --- a/tests/auto/corelib/tools/qfreelist/qfreelist.pro +++ b/tests/auto/corelib/tools/qfreelist/qfreelist.pro @@ -2,4 +2,4 @@ CONFIG += testcase TARGET = tst_qfreelist QT = core-private testlib SOURCES = tst_qfreelist.cpp -!contains(QT_CONFIG,private_tests): SOURCES += $$QT_SOURCE_TREE/src/corelib/tools/qfreelist.cpp +!qtConfig(private_tests): SOURCES += $$QT_SOURCE_TREE/src/corelib/tools/qfreelist.cpp 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/qlatin1string.pro b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro index a996dab23e..61054b40e4 100644 --- a/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro +++ b/tests/auto/corelib/tools/qlatin1string/qlatin1string.pro @@ -3,7 +3,7 @@ TARGET = tst_qlatin1string QT = core testlib SOURCES = tst_qlatin1string.cpp DEFINES += QT_NO_CAST_TO_ASCII -contains(QT_CONFIG,c++11): CONFIG += c++11 -contains(QT_CONFIG,c++14): CONFIG += c++14 +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 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/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index d9004d1eb6..595ee258e7 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -4,7 +4,7 @@ QT = core testlib core-private embedded: QT += gui SOURCES = ../tst_qlocale.cpp -!contains(QT_CONFIG, doubleconversion):!contains(QT_CONFIG, system-doubleconversion) { +!qtConfig(doubleconversion):!qtConfig(system-doubleconversion) { DEFINES += QT_NO_DOUBLECONVERSION } 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/qregularexpression/qregularexpression.pro b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro index c030f04a27..e1840808ff 100644 --- a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro +++ b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = defaultoptimize forceoptimize -contains(QT_CONFIG,private_tests):SUBDIRS += alwaysoptimize +qtConfig(private_tests): SUBDIRS += alwaysoptimize diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 5825bdb6d6..2a93250ba5 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -61,6 +61,9 @@ struct Match QStringList captured; QHash<QString, QString> namedCaptured; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Match, Q_MOVABLE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(Match) @@ -85,9 +88,9 @@ bool operator==(const QRegularExpressionMatch &rem, const Match &m) } } - Q_FOREACH (const QString &name, m.namedCaptured.keys()) { - QString remCaptured = rem.captured(name); - QString mCaptured = m.namedCaptured.value(name); + for (auto it = m.namedCaptured.begin(), end = m.namedCaptured.end(); it != end; ++it) { + const QString remCaptured = rem.captured(it.key()); + const QString mCaptured = it.value(); if (remCaptured != mCaptured || remCaptured.isNull() != mCaptured.isNull() || remCaptured.isEmpty() != mCaptured.isEmpty()) { @@ -115,12 +118,11 @@ bool operator!=(const Match &m, const QRegularExpressionMatch &rem) } -bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList) +bool operator==(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList) { QRegularExpressionMatchIterator i = iterator; - foreach (const Match &expectedMatch, expectedMatchList) - { + for (const Match &expectedMatch : expectedMatchList) { if (!i.hasNext()) return false; @@ -135,17 +137,17 @@ bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Mat return true; } -bool operator==(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +bool operator==(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) { return operator==(iterator, expectedMatchList); } -bool operator!=(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList) +bool operator!=(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList) { return !operator==(iterator, expectedMatchList); } -bool operator!=(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +bool operator!=(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator) { return !operator==(expectedMatchList, iterator); } @@ -1117,9 +1119,9 @@ void tst_QRegularExpression::globalMatch_data() QTest::addColumn<int>("offset"); QTest::addColumn<QRegularExpression::MatchType>("matchType"); QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions"); - QTest::addColumn<QList<Match> >("matchList"); + QTest::addColumn<QVector<Match> >("matchList"); - QList<Match> matchList; + QVector<Match> matchList; Match m; matchList.clear(); @@ -1375,7 +1377,7 @@ void tst_QRegularExpression::globalMatch() QFETCH(int, offset); QFETCH(QRegularExpression::MatchType, matchType); QFETCH(QRegularExpression::MatchOptions, matchOptions); - QFETCH(QList<Match>, matchList); + QFETCH(QVector<Match>, matchList); testMatch<QRegularExpressionMatchIterator>(regexp, static_cast<QREGlobalMatchStringPMF>(&QRegularExpression::globalMatch), 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..d0a0feb125 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); @@ -1603,9 +1738,6 @@ void tst_QSharedPointer::creating() void tst_QSharedPointer::creatingVariadic() { -#if !defined(Q_COMPILER_RVALUE_REFS) || !defined(Q_COMPILER_VARIADIC_TEMPLATES) - QSKIP("This compiler is not in C++11 mode or it doesn't support rvalue refs and variadic templates"); -#else int i = 42; { @@ -1633,12 +1765,10 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(ptr->i, 2); QCOMPARE(ptr->ptr, (void*)0); -#ifdef Q_COMPILER_NULLPTR NoDefaultConstructor2(nullptr, 3); // control check ptr = QSharedPointer<NoDefaultConstructor2>::create(nullptr, 3); QCOMPARE(ptr->i, 3); QCOMPARE(ptr->ptr, (void*)nullptr); -#endif } { NoDefaultConstructorRef1 x(i); // control check @@ -1674,7 +1804,6 @@ void tst_QSharedPointer::creatingVariadic() QCOMPARE(ptr->str, QString("bytearray")); QCOMPARE(ptr->i, 42); } -#endif } void tst_QSharedPointer::creatingQObject() @@ -1771,13 +1900,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 +1938,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/qstring.pro b/tests/auto/corelib/tools/qstring/qstring.pro index 1ff9a4fc9e..a94ad3405a 100644 --- a/tests/auto/corelib/tools/qstring/qstring.pro +++ b/tests/auto/corelib/tools/qstring/qstring.pro @@ -3,11 +3,11 @@ TARGET = tst_qstring QT = core testlib SOURCES = tst_qstring.cpp DEFINES += QT_NO_CAST_TO_ASCII -contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU -contains(QT_CONFIG,c++11): CONFIG += c++11 +qtConfig(icu): DEFINES += QT_USE_ICU +qtConfig(c++11): CONFIG += c++11 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -!contains(QT_CONFIG, doubleconversion):!contains(QT_CONFIG, system-doubleconversion) { +!qtConfig(doubleconversion):!qtConfig(system-doubleconversion) { DEFINES += QT_NO_DOUBLECONVERSION } diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 44b8135410..a0a872710c 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> @@ -88,11 +84,11 @@ public: template <typename MemFun> void apply0(QString &s, MemFun mf) const - { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(ch); } + { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(ch); } template <typename MemFun, typename A1> void apply1(QString &s, MemFun mf, A1 a1) const - { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(a1, ch); } + { for (QChar ch : qAsConst(this->pinned)) (s.*mf)(a1, ch); } }; template <> @@ -258,6 +254,9 @@ public: }; } // unnamed namespace +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(CharStarContainer, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(CharStarContainer) @@ -531,7 +530,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 @@ -649,7 +648,7 @@ QString verifyZeroTermination(const QString &str) } while (0) \ /**/ -typedef QList<int> IntList; +typedef QVector<int> IntList; tst_QString::tst_QString() { @@ -1057,10 +1056,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 ); @@ -1204,7 +1199,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 } @@ -5082,6 +5077,12 @@ void tst_QString::operator_eqeq_nullstring() QVERIFY( QString("") == "" ); QVERIFY( "" == QString("") ); + QVERIFY(QString() == nullptr); + QVERIFY(nullptr == QString()); + + QVERIFY(QString("") == nullptr); + QVERIFY(nullptr == QString("")); + QVERIFY( QString().size() == 0 ); QVERIFY( QString("").size() == 0 ); @@ -5095,6 +5096,8 @@ void tst_QString::operator_smaller() QString null; QString empty(""); QString foo("foo"); + const char *nullC = nullptr; + const char *emptyC = ""; QVERIFY( !(null < QString()) ); QVERIFY( !(null > QString()) ); @@ -5105,6 +5108,12 @@ void tst_QString::operator_smaller() QVERIFY( !(null < empty) ); QVERIFY( !(null > empty) ); + QVERIFY( !(nullC < empty) ); + QVERIFY( !(nullC > empty) ); + + QVERIFY( !(null < emptyC) ); + QVERIFY( !(null > emptyC) ); + QVERIFY( null < foo ); QVERIFY( !(null > foo) ); QVERIFY( foo > null ); @@ -5436,15 +5445,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"); @@ -5454,15 +5459,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 @@ -5472,15 +5471,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 @@ -5491,11 +5484,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; @@ -5521,10 +5509,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; @@ -5534,11 +5518,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); @@ -5546,11 +5526,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()) { @@ -5612,14 +5588,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..bc38b17949 --- /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 +qtConfig(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/qtimezone/qtimezone.pro b/tests/auto/corelib/tools/qtimezone/qtimezone.pro index 4459ed6020..afc4c59dfe 100644 --- a/tests/auto/corelib/tools/qtimezone/qtimezone.pro +++ b/tests/auto/corelib/tools/qtimezone/qtimezone.pro @@ -2,6 +2,6 @@ CONFIG += testcase TARGET = tst_qtimezone QT = core-private testlib SOURCES = tst_qtimezone.cpp -contains(QT_CONFIG,icu) { +qtConfig(icu) { DEFINES += QT_USE_ICU } diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qvector/qvector.pro index d49516923f..b9a4ae747b 100644 --- a/tests/auto/corelib/tools/qvector/qvector.pro +++ b/tests/auto/corelib/tools/qvector/qvector.pro @@ -1,5 +1,5 @@ CONFIG += testcase -contains(QT_CONFIG, c++11):CONFIG += c++11 +qtConfig(c++11): CONFIG += c++11 TARGET = tst_qvector QT = core testlib SOURCES = $$PWD/tst_qvector.cpp diff --git a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro index 834fc85a29..e2ae91cb64 100644 --- a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro +++ b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro @@ -1,6 +1,6 @@ CONFIG += testcase -contains(QT_CONFIG, c++11):CONFIG += c++11 -contains(QT_CONFIG, c++14):CONFIG += c++14 +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 TARGET = tst_qversionnumber QT = core testlib SOURCES = tst_qversionnumber.cpp 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 \ diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 9556a167c5..79cd17b5b3 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -65,6 +65,16 @@ static inline int best(int a, int b, int c) return qMin(qMin(a, b), c); } +template <typename C> +const C sorted_by_name(C c) { // return by const value so we can feed directly into range-for loops below + using T = typename C::value_type; + auto byName = [](const T &lhs, const T &rhs) { + return lhs.name() < rhs.name(); + }; + std::sort(c.begin(), c.end(), byName); + return c; +} + /** * Opens \a filename and returns content produced as per * xmlconf/xmltest/canonxml.html. @@ -97,7 +107,8 @@ static QByteArray makeCanonical(const QString &filename, while (!reader.atEnd()) { reader.readNext(); if (reader.isDTD()) { - if (!reader.notationDeclarations().isEmpty()) { + const auto notationDeclarations = reader.notationDeclarations(); + if (!notationDeclarations.isEmpty()) { QString dtd; QTextStream writeDtd(&dtd); @@ -105,10 +116,7 @@ static QByteArray makeCanonical(const QString &filename, writeDtd << docType; writeDtd << " ["; writeDtd << endl; - QMap<QString, QXmlStreamNotationDeclaration> sortedNotationDeclarations; - foreach (QXmlStreamNotationDeclaration notation, reader.notationDeclarations()) - sortedNotationDeclarations.insert(notation.name().toString(), notation); - foreach (QXmlStreamNotationDeclaration notation, sortedNotationDeclarations.values()) { + for (const QXmlStreamNotationDeclaration ¬ation : sorted_by_name(notationDeclarations)) { writeDtd << "<!NOTATION "; writeDtd << notation.name().toString(); if (notation.publicId().isEmpty()) { @@ -135,11 +143,7 @@ static QByteArray makeCanonical(const QString &filename, } } else if (reader.isStartElement()) { writer.writeStartElement(reader.namespaceUri().toString(), reader.name().toString()); - - QMap<QString, QXmlStreamAttribute> sortedAttributes; - foreach(QXmlStreamAttribute attribute, reader.attributes()) - sortedAttributes.insert(attribute.name().toString(), attribute); - foreach(QXmlStreamAttribute attribute, sortedAttributes.values()) + for (const QXmlStreamAttribute &attribute : sorted_by_name(reader.attributes())) writer.writeAttribute(attribute); writer.writeCharacters(QString()); // write empty string to avoid having empty xml tags } else if (reader.isCharacters()) { @@ -236,6 +240,8 @@ public: */ class MissedBaseline { + friend class QVector<MissedBaseline>; + MissedBaseline() {} // for QVector, don't use public: MissedBaseline(const QString &aId, const QByteArray &aExpected, @@ -247,13 +253,20 @@ public: qFatal("%s: aId must not be an empty string", Q_FUNC_INFO); } + void swap(MissedBaseline &other) Q_DECL_NOTHROW + { + qSwap(id, other.id); + qSwap(expected, other.expected); + qSwap(output, other.output); + } + QString id; QByteArray expected; QByteArray output; }; - QList<GeneralFailure> failures; - QList<MissedBaseline> missedBaselines; + QVector<GeneralFailure> failures; + QVector<MissedBaseline> missedBaselines; /** * The count of how many tests that were run. @@ -507,6 +520,9 @@ private: QString m_ch; QStack<QUrl> m_baseURI; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_SHARED(TestSuiteHandler::MissedBaseline) +QT_END_NAMESPACE class tst_QXmlStream: public QObject { @@ -718,8 +734,9 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " qualifiedName=\"" << reader.qualifiedName().toString() << '"'; if (!reader.prefix().isEmpty()) writer << " prefix=\"" << reader.prefix().toString() << '"'; - if (reader.attributes().size()) { - foreach(QXmlStreamAttribute attribute, reader.attributes()) { + const auto attributes = reader.attributes(); + if (attributes.size()) { + for (const QXmlStreamAttribute &attribute : attributes) { writer << endl << " Attribute("; if (!attribute.name().isEmpty()) writer << " name=\"" << attribute.name().toString() << '"'; @@ -734,8 +751,9 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " )" << endl; } } - if (reader.namespaceDeclarations().size()) { - foreach(QXmlStreamNamespaceDeclaration namespaceDeclaration, reader.namespaceDeclarations()) { + const auto namespaceDeclarations = reader.namespaceDeclarations(); + if (namespaceDeclarations.size()) { + for (const QXmlStreamNamespaceDeclaration &namespaceDeclaration : namespaceDeclarations) { writer << endl << " NamespaceDeclaration("; if (!namespaceDeclaration.prefix().isEmpty()) writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << '"'; @@ -744,8 +762,9 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " )" << endl; } } - if (reader.notationDeclarations().size()) { - foreach(QXmlStreamNotationDeclaration notationDeclaration, reader.notationDeclarations()) { + const auto notationDeclarations = reader.notationDeclarations(); + if (notationDeclarations.size()) { + for (const QXmlStreamNotationDeclaration ¬ationDeclaration : notationDeclarations) { writer << endl << " NotationDeclaration("; if (!notationDeclaration.name().isEmpty()) writer << " name=\"" << notationDeclaration.name().toString() << '"'; @@ -756,8 +775,9 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " )" << endl; } } - if (reader.entityDeclarations().size()) { - foreach(QXmlStreamEntityDeclaration entityDeclaration, reader.entityDeclarations()) { + const auto entityDeclarations = reader.entityDeclarations(); + if (entityDeclarations.size()) { + for (const QXmlStreamEntityDeclaration &entityDeclaration : entityDeclarations) { writer << endl << " EntityDeclaration("; if (!entityDeclaration.name().isEmpty()) writer << " name=\"" << entityDeclaration.name().toString() << '"'; @@ -803,7 +823,8 @@ void tst_QXmlStream::testReader_data() const QTest::addColumn<QString>("ref"); QDir dir; dir.cd(QFINDTESTDATA("data/")); - foreach(QString filename , dir.entryList(QStringList() << "*.xml")) { + const auto fileNames = dir.entryList(QStringList() << "*.xml"); + for (const QString &filename : fileNames) { QString reference = QFileInfo(filename).baseName() + ".ref"; QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference); } diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index c5cddee5f5..1769583fca 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -26,6 +26,6 @@ SUBDIRS+=\ qdbusthreading \ qdbusxmlparser -!contains(QT_CONFIG,private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qdbusmarshall \ diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 0def290eff..0edc5a92ea 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1818,7 +1818,7 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() LLDateTimeMap lldtmap; lldtmap[-1] = QDateTime(); QDateTime now = QDateTime::currentDateTime(); - lldtmap[now.toTime_t()] = now; // array of struct of int64 and struct of 3 ints and struct of 4 ints and int + lldtmap[now.toSecsSinceEpoch()] = now; // array of struct of int64 and struct of 3 ints and struct of 4 ints and int QTest::newRow("lldtmap") << "LLDateTimeMap" << "a{x((iii)(iiii)i)}" << QVariant::fromValue(lldtmap); MyStruct s; diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 4a09dca544..95daa256b5 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1057,6 +1057,48 @@ void tst_QDBusConnection::multipleInterfacesInQObject() QVERIFY_HOOKCALLED(); } +void tst_QDBusConnection::connectSignal() +{ + if (!QCoreApplication::instance()) + QSKIP("Test requires a QCoreApplication"); + + QDBusConnection con = QDBusConnection::sessionBus(); + + QDBusMessage signal = QDBusMessage::createSignal("/", "org.qtproject.TestCase", + "oneSignal"); + signal << "one parameter"; + + SignalReceiver recv; + QVERIFY(con.connect(con.baseService(), signal.path(), signal.interface(), + signal.member(), &recv, SLOT(oneSlot(QString)))); + QVERIFY(con.send(signal)); + QTest::qWait(100); + QCOMPARE(recv.argumentReceived, signal.arguments().at(0).toString()); + QCOMPARE(recv.signalsReceived, 1); + + // disconnect and try with a signature + recv.argumentReceived.clear(); + recv.signalsReceived = 0; + QVERIFY(con.disconnect(con.baseService(), signal.path(), signal.interface(), + signal.member(), &recv, SLOT(oneSlot(QString)))); + QVERIFY(con.connect(con.baseService(), signal.path(), signal.interface(), + signal.member(), "s", &recv, SLOT(oneSlot(QString)))); + QVERIFY(con.send(signal)); + QTest::qWait(100); + QCOMPARE(recv.argumentReceived, signal.arguments().at(0).toString()); + QCOMPARE(recv.signalsReceived, 1); + + // confirm that we are, indeed, a unique connection + recv.argumentReceived.clear(); + recv.signalsReceived = 0; + QVERIFY(!con.connect(con.baseService(), signal.path(), signal.interface(), + signal.member(), "s", &recv, SLOT(oneSlot(QString)))); + QVERIFY(con.send(signal)); + QTest::qWait(100); + QCOMPARE(recv.argumentReceived, signal.arguments().at(0).toString()); + QCOMPARE(recv.signalsReceived, 1); +} + void tst_QDBusConnection::slotsWithLessParameters() { if (!QCoreApplication::instance()) @@ -1068,25 +1110,36 @@ void tst_QDBusConnection::slotsWithLessParameters() "oneSignal"); signal << "one parameter"; - signalsReceived = 0; + SignalReceiver recv; QVERIFY(con.connect(con.baseService(), signal.path(), signal.interface(), - signal.member(), this, SLOT(oneSlot()))); + signal.member(), &recv, SLOT(oneSlot()))); QVERIFY(con.send(signal)); QTest::qWait(100); - QCOMPARE(signalsReceived, 1); + QCOMPARE(recv.argumentReceived, QString()); + QCOMPARE(recv.signalsReceived, 1); // disconnect and try with a signature - signalsReceived = 0; + recv.signalsReceived = 0; QVERIFY(con.disconnect(con.baseService(), signal.path(), signal.interface(), - signal.member(), this, SLOT(oneSlot()))); + signal.member(), &recv, SLOT(oneSlot()))); QVERIFY(con.connect(con.baseService(), signal.path(), signal.interface(), - signal.member(), "s", this, SLOT(oneSlot()))); + signal.member(), "s", &recv, SLOT(oneSlot()))); + QVERIFY(con.send(signal)); + QTest::qWait(100); + QCOMPARE(recv.argumentReceived, QString()); + QCOMPARE(recv.signalsReceived, 1); + + // confirm that we are, indeed, a unique connection + recv.signalsReceived = 0; + QVERIFY(!con.connect(con.baseService(), signal.path(), signal.interface(), + signal.member(), "s", &recv, SLOT(oneSlot()))); QVERIFY(con.send(signal)); QTest::qWait(100); - QCOMPARE(signalsReceived, 1); + QCOMPARE(recv.argumentReceived, QString()); + QCOMPARE(recv.signalsReceived, 1); } -void tst_QDBusConnection::secondCallWithCallback() +void SignalReceiver::secondCallWithCallback() { QDBusConnection con = QDBusConnection::sessionBus(); QDBusMessage msg = QDBusMessage::createMethodCall(con.baseService(), "/test", QString(), @@ -1106,12 +1159,12 @@ void tst_QDBusConnection::nestedCallWithCallback() QDBusMessage msg = QDBusMessage::createMethodCall(connection.baseService(), "/test", QString(), "ThisFunctionDoesntExist"); - signalsReceived = 0; - connection.callWithCallback(msg, this, SLOT(exitLoop()), SLOT(secondCallWithCallback()), 10); + SignalReceiver recv; + connection.callWithCallback(msg, &recv, SLOT(exitLoop()), SLOT(secondCallWithCallback()), 10); QTestEventLoop::instance().enterLoop(15); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(signalsReceived, 1); + QCOMPARE(recv.signalsReceived, 1); QCOMPARE_HOOKCOUNT(2); } diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h index b9eb0d9db7..b4d689e6f4 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -69,20 +69,30 @@ public: MyObjectWithoutInterface(QObject *parent = 0) : QObject(parent), callCount(0) {} }; -class tst_QDBusConnection: public QObject +class SignalReceiver : public QObject { Q_OBJECT - - int signalsReceived; public: - static int hookCallCount; - tst_QDBusConnection(); + QString argumentReceived; + int signalsReceived; + SignalReceiver() : signalsReceived(0) {} public slots: + void oneSlot(const QString &arg) { ++signalsReceived; argumentReceived = arg;} void oneSlot() { ++signalsReceived; } void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); } void secondCallWithCallback(); +}; + +class tst_QDBusConnection: public QObject +{ + Q_OBJECT + +public: + static int hookCallCount; + tst_QDBusConnection(); +public slots: void init(); void cleanup(); @@ -115,6 +125,7 @@ private slots: void callSelfByAnotherName(); void multipleInterfacesInQObject(); + void connectSignal(); void slotsWithLessParameters(); void nestedCallWithCallback(); diff --git a/tests/auto/dbus/qdbusmarshall/qdbusmarshall.pro b/tests/auto/dbus/qdbusmarshall/qdbusmarshall.pro index e9a41c0fb4..caedb5a0f2 100644 --- a/tests/auto/dbus/qdbusmarshall/qdbusmarshall.pro +++ b/tests/auto/dbus/qdbusmarshall/qdbusmarshall.pro @@ -6,4 +6,4 @@ SUBDIRS = qpong qdbusmarshall QT = core-private testlib -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/dbus/qdbusmarshall/qdbusmarshall/qdbusmarshall.pro b/tests/auto/dbus/qdbusmarshall/qdbusmarshall/qdbusmarshall.pro index b0442a0ee4..031cc252c8 100644 --- a/tests/auto/dbus/qdbusmarshall/qdbusmarshall/qdbusmarshall.pro +++ b/tests/auto/dbus/qdbusmarshall/qdbusmarshall/qdbusmarshall.pro @@ -5,10 +5,9 @@ DESTDIR = ./ QT = core-private dbus-private testlib -contains(QT_CONFIG, dbus-linked) { +qtConfig(dbus-linked) { DEFINES += QT_LINKED_LIBDBUS - LIBS += $$QT_LIBS_DBUS - QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS + QMAKE_USE += dbus } else { SOURCES += ../../../../../src/dbus/qdbus_symbols.cpp } diff --git a/tests/auto/dbus/qdbustype/qdbustype.pro b/tests/auto/dbus/qdbustype/qdbustype.pro index 17ae349675..75a9980732 100644 --- a/tests/auto/dbus/qdbustype/qdbustype.pro +++ b/tests/auto/dbus/qdbustype/qdbustype.pro @@ -2,10 +2,9 @@ CONFIG += testcase parallel_test TARGET = tst_qdbustype QT = core-private dbus-private testlib SOURCES += tst_qdbustype.cpp -contains(QT_CONFIG, dbus-linked) { +qtConfig(dbus-linked) { DEFINES += QT_LINKED_LIBDBUS - LIBS += $$QT_LIBS_DBUS - QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS + QMAKE_USE += dbus } else { SOURCES += ../../../../src/dbus/qdbus_symbols.cpp } diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro index d3393663ed..8d8a2df393 100644 --- a/tests/auto/gui/gui.pro +++ b/tests/auto/gui/gui.pro @@ -3,7 +3,7 @@ TEMPLATE=subdirs SUBDIRS = \ kernel -!ios: SUBDIRS += \ +!uikit: SUBDIRS += \ image \ math3d \ painting \ @@ -13,4 +13,4 @@ SUBDIRS = \ util \ itemmodels \ -!contains(QT_CONFIG, opengl(es2)?): SUBDIRS -= qopengl qopenglconfig +!qtConfig(opengl(es2)?): SUBDIRS -= qopengl qopenglconfig diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro index 9199763c40..5a74df4c78 100644 --- a/tests/auto/gui/image/image.pro +++ b/tests/auto/gui/image/image.pro @@ -14,6 +14,6 @@ SUBDIRS=\ !qtHaveModule(network): SUBDIRS -= \ qimagereader -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qpixmapcache \ diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro index 485472c70c..46bfb2a586 100644 --- a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro @@ -3,14 +3,5 @@ TARGET = tst_qicoimageformat SOURCES+= tst_qicoimageformat.cpp QT += testlib -wince { - CONFIG(debug, debug|release):{ - addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qico4d.dll - } else { - addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qico4.dll - } - addPlugins.path = imageformats - DEPLOYMENT += addPlugins -} TESTDATA += icons/* android:RESOURCES+=qicoimageformat.qrc diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index a0914b7700..4218d0751f 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -393,7 +393,6 @@ void tst_QIcon::addFile() icon.addFile(QLatin1String(":/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); icon.addFile(QLatin1String(":/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); -#ifndef Q_OS_WINCE QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == QPixmap(QLatin1String(":/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == @@ -406,13 +405,6 @@ void tst_QIcon::addFile() QPixmap(QLatin1String(":/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == QPixmap(QLatin1String(":/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); -#else - // WinCE only includes the 16x16 images for size reasons - QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); - QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); -#endif } static bool sizeLess(const QSize &a, const QSize &b) diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro index 36d64a275f..39ce4e26cb 100644 --- a/tests/auto/gui/image/qimage/qimage.pro +++ b/tests/auto/gui/image/qimage/qimage.pro @@ -3,7 +3,7 @@ TARGET = tst_qimage SOURCES += tst_qimage.cpp QT += core-private gui-private testlib -contains(QT_CONFIG, c++11): CONFIG += c++11 +qtConfig(c++11): CONFIG += c++11 android: RESOURCES+=qimage.qrc diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 85d258de5b..a1ab812aaa 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -39,6 +39,10 @@ #include <private/qimage_p.h> #include <private/qdrawhelper_p.h> +#ifdef Q_OS_DARWIN +#include <CoreGraphics/CoreGraphics.h> +#endif + Q_DECLARE_METATYPE(QImage::Format) Q_DECLARE_METATYPE(Qt::GlobalColor) @@ -108,6 +112,7 @@ private slots: void smoothScale(); void smoothScale2_data(); void smoothScale2(); + void smoothScale3_data(); void smoothScale3(); void smoothScale4(); @@ -197,6 +202,14 @@ private slots: void pixelColor(); void pixel(); + void ditherGradient_data(); + void ditherGradient(); + +#ifdef Q_OS_DARWIN + void toCGImage_data(); + void toCGImage(); +#endif + private: const QString m_prefix; }; @@ -292,17 +305,13 @@ void tst_QImage::swap() void tst_QImage::create() { bool cr = true; -#if !defined(Q_OS_WINCE) QT_TRY { -#endif //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian); QImage image(7000000, 7000000, QImage::Format_Indexed8); image.setColorCount(256); cr = !image.isNull(); -#if !defined(Q_OS_WINCE) } QT_CATCH (...) { } -#endif QVERIFY( !cr ); } @@ -1750,9 +1759,12 @@ static inline int rand8() return int(256. * (qrand() / (RAND_MAX + 1.0))); } -// compares img.scale against the bilinear filtering used by QPainter -void tst_QImage::smoothScale3() +void tst_QImage::smoothScale3_data() { + QTest::addColumn<QImage>("img"); + QTest::addColumn<qreal>("scale_x"); + QTest::addColumn<qreal>("scale_y"); + QImage img(128, 128, QImage::Format_RGB32); for (int y = 0; y < img.height(); ++y) { for (int x = 0; x < img.width(); ++x) { @@ -1765,36 +1777,49 @@ void tst_QImage::smoothScale3() } } - qreal scales[2] = { .5, 2 }; + QTest::newRow("(0.5, 0.5)") << img << qreal(0.5) << qreal(0.5); + QTest::newRow("(0.5, 1.0)") << img << qreal(0.5) << qreal(1.0); + QTest::newRow("(1.0, 0.5)") << img << qreal(1.0) << qreal(0.5); + QTest::newRow("(0.5, 2.0)") << img << qreal(0.5) << qreal(2.0); + QTest::newRow("(1.0, 2.0)") << img << qreal(1.0) << qreal(2.0); + QTest::newRow("(2.0, 0.5)") << img << qreal(2.0) << qreal(0.5); + QTest::newRow("(2.0, 1.0)") << img << qreal(2.0) << qreal(1.0); + QTest::newRow("(2.0, 2.0)") << img << qreal(2) << qreal(2); +} +// compares img.scale against the bilinear filtering used by QPainter +void tst_QImage::smoothScale3() +{ + QFETCH(QImage, img); + QFETCH(qreal, scale_x); + QFETCH(qreal, scale_y); - for (int i = 0; i < 2; ++i) { - QImage a = img.scaled(img.size() * scales[i], Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - QImage b(a.size(), a.format()); - b.fill(0x0); + QImage a = img.scaled(img.width() * scale_x, img.height() * scale_y, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + QImage b(a.size(), a.format()); + b.fill(0x0); - QPainter p(&b); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.scale(scales[i], scales[i]); - p.drawImage(0, 0, img); - p.end(); - int err = 0; - - for (int y = 0; y < a.height(); ++y) { - for (int x = 0; x < a.width(); ++x) { - QRgb ca = a.pixel(x, y); - QRgb cb = b.pixel(x, y); - - // tolerate a little bit of rounding errors - bool r = true; - r &= qAbs(qRed(ca) - qRed(cb)) <= 18; - r &= qAbs(qGreen(ca) - qGreen(cb)) <= 18; - r &= qAbs(qBlue(ca) - qBlue(cb)) <= 18; - if (!r) - err++; - } + QPainter p(&b); + p.setRenderHint(QPainter::SmoothPixmapTransform); + p.scale(scale_x, scale_y); + p.drawImage(0, 0, img); + p.end(); + int err = 0; + + for (int y = 0; y < a.height(); ++y) { + for (int x = 0; x < a.width(); ++x) { + QRgb ca = a.pixel(x, y); + QRgb cb = b.pixel(x, y); + + // tolerate a little bit of rounding errors + int tolerance = 3; + bool r = true; + r &= qAbs(qRed(ca) - qRed(cb)) <= tolerance; + r &= qAbs(qGreen(ca) - qGreen(cb)) <= tolerance; + r &= qAbs(qBlue(ca) - qBlue(cb)) <= tolerance; + if (!r) + err++; } - QCOMPARE(err, 0); } + QCOMPARE(err, 0); } // Tests smooth upscale is smooth @@ -1819,11 +1844,7 @@ void tst_QImage::smoothScale4() void tst_QImage::smoothScaleBig() { -#if defined(Q_OS_WINCE) - int bigValue = 2000; -#else int bigValue = 200000; -#endif QImage tall(4, bigValue, QImage::Format_ARGB32); tall.fill(0x0); @@ -3222,5 +3243,114 @@ void tst_QImage::pixel() } } +void tst_QImage::ditherGradient_data() +{ + QTest::addColumn<QImage>("image"); + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<int>("flags"); + QTest::addColumn<int>("minimumExpectedGradient"); + + QImage rgb32(256, 16, QImage::Format_RGB32); + QLinearGradient gradient(QRectF(rgb32.rect()).topLeft(), QRectF(rgb32.rect()).topRight()); + gradient.setColorAt(0.0, QColor(0, 0, 0)); + gradient.setColorAt(1.0, QColor(255, 255, 255)); + QPainter p; + p.begin(&rgb32); + p.fillRect(rgb32.rect(), gradient); + p.end(); + + QTest::newRow("rgb32 -> rgb444 (no dither)") << rgb32 << QImage::Format_RGB444 << 0 << 16; + QTest::newRow("rgb32 -> rgb444 (dithering)") << rgb32 << QImage::Format_RGB444 << int(Qt::PreferDither | Qt::OrderedDither) << 33; + QTest::newRow("rgb32 -> argb4444pm (dithering)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 33; + QTest::newRow("rgb32 -> rgb16 (no dither)") << rgb32 << QImage::Format_RGB16 << 0 << 32; + QTest::newRow("rgb32 -> rgb16 (dithering)") << rgb32 << QImage::Format_RGB16 << int(Qt::PreferDither | Qt::OrderedDither) << 65; + QTest::newRow("rgb32 -> rgb666 (no dither)") << rgb32 << QImage::Format_RGB666 << 0 << 64; + QTest::newRow("rgb32 -> rgb666 (dithering)") << rgb32 << QImage::Format_RGB666 << int(Qt::PreferDither | Qt::OrderedDither) << 129; + + // Test we get the same results for opaque input in the ARGBPM implementation. + rgb32 = qMove(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); + QTest::newRow("argb32pm -> argb4444pm (no dither)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << 0 << 16; + QTest::newRow("argb32pm -> rgb444 (dithering)") << rgb32 << QImage::Format_RGB444 << int(Qt::PreferDither | Qt::OrderedDither) << 33; + QTest::newRow("argb32pm -> argb4444pm (dithering)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 33; + QTest::newRow("argb32pm -> argb8565pm (no dither)") << rgb32 << QImage::Format_ARGB8565_Premultiplied << 0 << 32; + QTest::newRow("argb32pm -> argb8565pm (dithering)") << rgb32 << QImage::Format_ARGB8565_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 65; + QTest::newRow("argb32pm -> argb6666pm (no dither)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << 0 << 64; + QTest::newRow("argb32pm -> argb6666pm (dithering)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 129; + + QImage rgb30(1024, 16, QImage::Format_RGB30); + QLinearGradient gradient30(QRectF(rgb30.rect()).topLeft(), QRectF(rgb30.rect()).topRight()); + gradient30.setColorAt(0.0, QColor(0, 0, 0)); + gradient30.setColorAt(1.0, QColor(255, 255, 255)); + p.begin(&rgb30); + p.fillRect(rgb30.rect(), gradient30); + p.end(); + + QTest::newRow("rgb30 -> rgb32 (no dither)") << rgb30 << QImage::Format_RGB32 << 0 << 256; + QTest::newRow("rgb30 -> rgb32 (dithering)") << rgb30 << QImage::Format_RGB32 << int(Qt::PreferDither | Qt::OrderedDither) << 513; + QTest::newRow("rgb30 -> rgb888 (no dither)") << rgb30 << QImage::Format_RGB888 << 0 << 256; + QTest::newRow("rgb30 -> rgb888 (dithering)") << rgb30 << QImage::Format_RGB888 << int(Qt::PreferDither | Qt::OrderedDither) << 513; +} + +void tst_QImage::ditherGradient() +{ + QFETCH(QImage, image); + QFETCH(QImage::Format, format); + QFETCH(int, flags); + QFETCH(int, minimumExpectedGradient); + + QImage converted = image.convertToFormat(format, (Qt::ImageConversionFlags)flags); + int observedGradientSteps = 0; + int lastTotal = -1; + for (int i = 0; i < converted.width(); ++i) { + int total = 0; + for (int j = 0; j < converted.height(); ++j) { + uint c = converted.pixel(i, j); + QCOMPARE(qAlpha(c), 255); + total += qRed(c); + } + if (total > lastTotal) { + observedGradientSteps++; + lastTotal = total; + } + } + QVERIFY(observedGradientSteps >= minimumExpectedGradient); +} + +#ifdef Q_OS_DARWIN + +void tst_QImage::toCGImage_data() +{ + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<bool>("supported"); + + // Populate test data with supported status for all QImage formats. + QSet<QImage::Format> supported = + { QImage::Format_ARGB32, QImage::Format_RGB32, QImage::Format_RGBA8888_Premultiplied, + QImage::Format_RGBA8888, QImage::Format_RGBX8888, QImage::Format_ARGB32_Premultiplied }; + + for (int i = QImage::Format_Invalid; i < QImage::Format_Grayscale8; ++i) { + QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) + << QImage::Format(i) << supported.contains(QImage::Format(i)); + } +} + +// Verify that toCGImage() returns a valid CGImageRef for supported image formats. +void tst_QImage::toCGImage() +{ + QFETCH(QImage::Format, format); + QFETCH(bool, supported); + + QImage qimage(64, 64, format); + qimage.fill(Qt::red); + + CGImageRef cgimage = qimage.toCGImage(); + QCOMPARE(cgimage != nullptr, supported); + + CGImageRelease(cgimage); +} + +#endif + + QTEST_GUILESS_MAIN(tst_QImage) #include "tst_qimage.moc" diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 7a94217641..191aabdf6a 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -239,7 +239,7 @@ void tst_QImageWriter::writeImage2_data() foreach (const QString format, formats) { const QString fileName = QLatin1String("solidcolor_") + QString::number(imgFormat) + QLatin1Char('.') + format; - QTest::newRow(fileName.toLatin1()) << fileName + QTest::newRow(fileName.toLatin1()) << writePrefix + fileName << format.toLatin1() << image; } @@ -496,9 +496,6 @@ void tst_QImageWriter::saveToTemporaryFile() QVERIFY(writer.write(image)); else qWarning() << file.errorString(); -#if defined(Q_OS_WINCE) - file.reset(); -#endif QCOMPARE(QImage(writer.fileName()), image); } { @@ -513,18 +510,15 @@ void tst_QImageWriter::saveToTemporaryFile() } { // 3) Via QImageWriter's API, with a named temp file - QTemporaryFile file("tempXXXXXX"); + QTemporaryFile file(writePrefix + QLatin1String("tempXXXXXX")); QVERIFY2(file.open(), qPrintable(file.errorString())); QImageWriter writer(&file, "PNG"); QVERIFY(writer.write(image)); -#if defined(Q_OS_WINCE) - file.reset(); -#endif QCOMPARE(QImage(writer.fileName()), image); } { // 4) Via QImage's API, with a named temp file - QTemporaryFile file("tempXXXXXX"); + QTemporaryFile file(writePrefix + QLatin1String("tempXXXXXX")); QVERIFY2(file.open(), qPrintable(file.errorString())); QVERIFY(image.save(&file, "PNG")); file.reset(); diff --git a/tests/auto/gui/image/qmovie/qmovie.pro b/tests/auto/gui/image/qmovie/qmovie.pro index a04ad73b80..6a7e23be99 100644 --- a/tests/auto/gui/image/qmovie/qmovie.pro +++ b/tests/auto/gui/image/qmovie/qmovie.pro @@ -5,8 +5,8 @@ qtHaveModule(widgets): QT += widgets SOURCES += tst_qmovie.cpp MOC_DIR=tmp -!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF -!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG +qtConfig(gif): DEFINES += QTEST_HAVE_GIF +qtConfig(jpeg): DEFINES += QTEST_HAVE_JPEG RESOURCES += resources.qrc TESTDATA += animations/* diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro index 5a4656998a..e6a020af1a 100644 --- a/tests/auto/gui/image/qpixmap/qpixmap.pro +++ b/tests/auto/gui/image/qpixmap/qpixmap.pro @@ -5,9 +5,7 @@ QT += core-private gui-private testlib qtHaveModule(widgets): QT += widgets widgets-private SOURCES += tst_qpixmap.cpp -!wince:!winrt { - win32:LIBS += -lgdi32 -luser32 -} +win32:!winrt:LIBS += -lgdi32 -luser32 RESOURCES += qpixmap.qrc TESTDATA += convertFromImage/* convertFromToHICON/* loadFromData/* images/* diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 6adfe05fb0..79d3a57d73 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -442,22 +442,16 @@ void tst_QPixmap::fill_data() QTest::newRow(("syscolor_" + QByteArray::number(color)).constData()) << uint(color) << true << false; -#if defined (Q_OS_WINCE) - QPixmap pixmap(1,1); - if (QApplication::desktop()->grab().depth() >= 24) { -#else - QPixmap pixmap(1, 1); { -#endif - QTest::newRow("alpha_7f_red") << 0x7fff0000u << false << false; - QTest::newRow("alpha_3f_blue") << 0x3f0000ffu << false << false; - QTest::newRow("alpha_b7_green") << 0xbf00ff00u << false << false; - QTest::newRow("alpha_7f_white") << 0x7fffffffu << false << false; - QTest::newRow("alpha_3f_white") << 0x3fffffffu << false << false; - QTest::newRow("alpha_b7_white") << 0xb7ffffffu << false << false; - QTest::newRow("alpha_7f_black") << 0x7f000000u << false << false; - QTest::newRow("alpha_3f_black") << 0x3f000000u << false << false; - QTest::newRow("alpha_b7_black") << 0xbf000000u << false << false; - } + QPixmap pixmap(1, 1); + QTest::newRow("alpha_7f_red") << 0x7fff0000u << false << false; + QTest::newRow("alpha_3f_blue") << 0x3f0000ffu << false << false; + QTest::newRow("alpha_b7_green") << 0xbf00ff00u << false << false; + QTest::newRow("alpha_7f_white") << 0x7fffffffu << false << false; + QTest::newRow("alpha_3f_white") << 0x3fffffffu << false << false; + QTest::newRow("alpha_b7_white") << 0xb7ffffffu << false << false; + QTest::newRow("alpha_7f_black") << 0x7f000000u << false << false; + QTest::newRow("alpha_3f_black") << 0x3f000000u << false << false; + QTest::newRow("alpha_b7_black") << 0xbf000000u << false << false; QTest::newRow("bitmap_color0") << uint(Qt::color0) << true << true; QTest::newRow("bitmap_color1") << uint(Qt::color1) << true << true; @@ -891,9 +885,6 @@ void tst_QPixmap::fromWinHBITMAP() HGDIOBJ old_brush = SelectObject(bitmap_dc, CreateSolidBrush(RGB(red, green, blue))); Rectangle(bitmap_dc, 0, 0, 100, 100); -#ifdef Q_OS_WINCE //the device context has to be deleted before QPixmap::fromWinHBITMAP() - DeleteDC(bitmap_dc); -#endif QPixmap pixmap = qt_pixmapFromWinHBITMAP(bitmap); QCOMPARE(pixmap.width(), 100); QCOMPARE(pixmap.height(), 100); @@ -906,9 +897,7 @@ void tst_QPixmap::fromWinHBITMAP() DeleteObject(SelectObject(bitmap_dc, old_brush)); DeleteObject(SelectObject(bitmap_dc, bitmap)); -#ifndef Q_OS_WINCE DeleteDC(bitmap_dc); -#endif ReleaseDC(0, display_dc); } @@ -1010,7 +999,6 @@ void tst_QPixmap::fromWinHICON_data() void tst_QPixmap::fromWinHICON() { -#ifndef Q_OS_WINCE QFETCH(int, width); QFETCH(int, height); QFETCH(QString, image); @@ -1028,7 +1016,6 @@ void tst_QPixmap::fromWinHICON() // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere QVERIFY(compareImages(imageFromHICON, imageFromFile)); -#endif // Q_OS_WINCE } #endif // Q_OS_WIN && !Q_OS_WINRT diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 5000e1a926..631962ad34 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -25,7 +25,7 @@ SUBDIRS=\ qopenglwindow \ qrasterwindow -win32:!wince:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop +win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtHaveModule(widgets): SUBDIRS -= \ qmouseevent_modal \ @@ -34,4 +34,6 @@ win32:!wince:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtHaveModule(network): SUBDIRS -= \ qguieventloop -!contains(QT_CONFIG, opengl(es2)?): SUBDIRS -= qopenglwindow +!qtConfig(opengl(es2)?): SUBDIRS -= qopenglwindow + +uikit: SUBDIRS -= qclipboard diff --git a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro index a42b359f29..7e98704aea 100644 --- a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro +++ b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro @@ -5,4 +5,4 @@ QT += core-private network gui-private testlib SOURCES += tst_noqteventloop.cpp -contains(QT_CONFIG,dynamicgl):win32:!wince*:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 diff --git a/tests/auto/gui/kernel/qclipboard/copier/main.cpp b/tests/auto/gui/kernel/qclipboard/copier/main.cpp index 22f2aa3bb8..32e91a9939 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/main.cpp +++ b/tests/auto/gui/kernel/qclipboard/copier/main.cpp @@ -33,11 +33,9 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); QString paste = QStringLiteral("testString.!"); -#ifndef Q_OS_WINCE const QStringList arguments = app.arguments(); if (arguments.size() > 1) paste = arguments.at(1); -#endif #ifndef QT_NO_CLIPBOARD QGuiApplication::clipboard()->setText(paste); #endif diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp index c96d903fb7..7fca8af1cb 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp +++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp @@ -66,13 +66,9 @@ int main(int argc, char **argv) return 0; } -#ifndef Q_OS_WINCE QString expected; if (parser.isSet(textOption)) expected = parser.value(textOption); -#else // !Q_OS_WINCE - const QString expected = QStringLiteral("testString.!"); -#endif // Q_OS_WINCE if (!expected.isEmpty()) { #ifndef QT_NO_CLIPBOARD const QString actual = QGuiApplication::clipboard()->text(); diff --git a/tests/auto/gui/kernel/qclipboard/test/test.pro b/tests/auto/gui/kernel/qclipboard/test/test.pro index 40bf9c8d8e..59b77b11ba 100644 --- a/tests/auto/gui/kernel/qclipboard/test/test.pro +++ b/tests/auto/gui/kernel/qclipboard/test/test.pro @@ -13,10 +13,6 @@ win32 { } } -wince* { - DEPLOYMENT += rsc reg_resource -} - !winrt: TEST_HELPER_INSTALLS = \ ../copier/copier \ ../paster/paster diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 6bad45fefe..bfa15744c2 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -313,10 +313,6 @@ void tst_QClipboard::setMimeData() QMimeData *mimeData = new QMimeData; const QString TestName(QLatin1String("tst_QClipboard::setMimeData() mimeData")); mimeData->setObjectName(TestName); -#if defined(Q_OS_WINCE) - // need to set text on CE - mimeData->setText(QLatin1String("Qt/CE foo")); -#endif QGuiApplication::clipboard()->setMimeData(mimeData); QCOMPARE(QGuiApplication::clipboard()->mimeData(), (const QMimeData *)mimeData); diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 32d0aa504c..f8bcb14ab3 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -106,11 +106,29 @@ void tst_QGuiApplication::displayName() int argc = 1; char *argv[] = { const_cast<char*>("tst_qguiapplication") }; QGuiApplication app(argc, argv); + QSignalSpy spy(&app, &QGuiApplication::applicationDisplayNameChanged); + QCOMPARE(::qAppName(), QString::fromLatin1("tst_qguiapplication")); QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("tst_qguiapplication")); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("tst_qguiapplication")); + + QGuiApplication::setApplicationName("The Core Application"); + QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application")); + QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The Core Application")); + QCOMPARE(spy.count(), 1); + QGuiApplication::setApplicationDisplayName("The GUI Application"); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application")); + QCOMPARE(spy.count(), 2); + + QGuiApplication::setApplicationName("The Core Application 2"); + QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application 2")); + QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application")); + QCOMPARE(spy.count(), 2); + + QGuiApplication::setApplicationDisplayName("The GUI Application 2"); + QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application 2")); + QCOMPARE(spy.count(), 3); } void tst_QGuiApplication::desktopFileName() diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index 8002303723..cca0e95c29 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -31,8 +31,6 @@ #include <QtGui> #include <QtTest/QtTest> -#include "../../../qtest-config.h" - Q_DECLARE_METATYPE(QMetaType::Type) class tst_QGuiMetaType: public QObject @@ -75,14 +73,14 @@ private slots: F(QVector4D, QVector4D) \ F(QQuaternion, QQuaternion) -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR # define FOR_EACH_GUI_METATYPE(F) \ FOR_EACH_GUI_METATYPE_BASE(F) \ F(QCursor, QCursor) -#else // !QTEST_NO_CURSOR +#else // !QT_NO_CURSOR # define FOR_EACH_GUI_METATYPE(F) \ FOR_EACH_GUI_METATYPE_BASE(F) -#endif // !QTEST_NO_CURSOR +#endif // !QT_NO_CURSOR namespace { @@ -131,7 +129,7 @@ template<> struct TypeComparator<QMetaType::QBitmap> { return v1.size() == v2.size(); } }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR template<> struct TypeComparator<QMetaType::QCursor> { static bool equal(const QCursor &v1, const QCursor &v2) @@ -176,7 +174,7 @@ template<> struct TestValueFactory<QMetaType::QRegion> { template<> struct TestValueFactory<QMetaType::QBitmap> { static QBitmap *create() { return new QBitmap(16, 32); } }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR template<> struct TestValueFactory<QMetaType::QCursor> { static QCursor *create() { return new QCursor(Qt::WaitCursor); } }; diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 8be7227c54..a057ec2207 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -52,8 +52,6 @@ #include "tst_qvariant_common.h" -#include "../../../../qtest-config.h" - class tst_QGuiVariant : public QObject { Q_OBJECT @@ -172,7 +170,7 @@ void tst_QGuiVariant::canConvert_data() var = QVariant::fromValue(QColor()); QTest::newRow("Color") << var << N << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR var = QVariant::fromValue(QCursor()); QTest::newRow("Cursor") << var << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; @@ -508,7 +506,7 @@ void tst_QGuiVariant::writeToReadFromDataStream_data() QTest::newRow( "bitmap_valid" ) << QVariant::fromValue( bitmap ) << false; QTest::newRow( "brush_valid" ) << QVariant::fromValue( QBrush( Qt::red ) ) << false; QTest::newRow( "color_valid" ) << QVariant::fromValue( QColor( Qt::red ) ) << false; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QTest::newRow( "cursor_valid" ) << QVariant::fromValue( QCursor( Qt::PointingHandCursor ) ) << false; #endif QTest::newRow( "font_valid" ) << QVariant::fromValue( QFont( "times", 12 ) ) << false; @@ -716,14 +714,14 @@ void tst_QGuiVariant::implicitConstruction() F(Quaternion) \ F(PolygonF) -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR # define FOR_EACH_GUI_CLASS(F) \ FOR_EACH_GUI_CLASS_BASE(F) \ F(Cursor) -#else // !QTEST_NO_CURSOR +#else // !QT_NO_CURSOR # define FOR_EACH_GUI_CLASS(F) \ FOR_EACH_GUI_CLASS_BASE(F) -#endif // QTEST_NO_CURSOR +#endif // QT_NO_CURSOR #define CONSTRUCT(TYPE) \ { \ @@ -741,14 +739,14 @@ void tst_QGuiVariant::implicitConstruction() void tst_QGuiVariant::guiVariantAtExit() { // crash test, it should not crash at QGuiApplication exit -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR static QVariant cursor = QCursor(); #endif static QVariant point = QPoint(); static QVariant icon = QIcon(); static QVariant image = QImage(); static QVariant palette = QPalette(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR Q_UNUSED(cursor); #endif Q_UNUSED(point); diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 0d0b6ae81e..6394a956bd 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -725,7 +725,7 @@ void tst_QKeySequence::listFromString() void tst_QKeySequence::translated_data() { -#if defined (Q_OS_MAC) || defined (Q_OS_WINCE) +#if defined (Q_OS_DARWIN) QSKIP("Test not applicable"); #endif @@ -756,7 +756,7 @@ void tst_QKeySequence::translated_data() void tst_QKeySequence::translated() { -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QFETCH(QString, transKey); QFETCH(QString, compKey); diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp index 6af6738bdb..a1de205571 100644 --- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp @@ -75,6 +75,7 @@ public slots: void cleanupTestCase(); void init(); private slots: + void mouseEventBasic(); void checkMousePressEvent_data(); void checkMousePressEvent(); void checkMouseReleaseEvent_data(); @@ -107,6 +108,26 @@ void tst_QMouseEvent::init() testMouseWidget->mouseReleaseModifiers = 0; } +void tst_QMouseEvent::mouseEventBasic() +{ + QPointF local(100, 100); + QPointF scene(200, 200); + QPointF screen(300, 300); + QMouseEvent me(QEvent::MouseButtonPress, local, scene, screen, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QCOMPARE(me.isAccepted(), true); + QCOMPARE(me.button(), Qt::LeftButton); + QCOMPARE(me.buttons(), Qt::LeftButton); + QCOMPARE(me.localPos(), local); + QCOMPARE(me.windowPos(), scene); + QCOMPARE(me.screenPos(), screen); + + QPointF changedLocal(33, 66); + me.setLocalPos(changedLocal); + QCOMPARE(me.localPos(), changedLocal); + QCOMPARE(me.windowPos(), scene); + QCOMPARE(me.screenPos(), screen); +} + void tst_QMouseEvent::checkMousePressEvent_data() { QTest::addColumn<int>("buttonPressed"); diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 74fd64bf59..e6fd67e3a8 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -213,11 +213,10 @@ private: QTouchDevice *touchPadDevice; }; -tst_QTouchEvent::tst_QTouchEvent() : touchScreenDevice(new QTouchDevice), touchPadDevice(new QTouchDevice) +tst_QTouchEvent::tst_QTouchEvent() + : touchScreenDevice(QTest::createTouchDevice()) + , touchPadDevice(QTest::createTouchDevice(QTouchDevice::TouchPad)) { - touchPadDevice->setType(QTouchDevice::TouchPad); - QWindowSystemInterface::registerTouchDevice(touchScreenDevice); - QWindowSystemInterface::registerTouchDevice(touchPadDevice); } void tst_QTouchEvent::cleanup() @@ -1490,10 +1489,6 @@ bool WindowTouchEventFilter::eventFilter(QObject *, QEvent *event) void tst_QTouchEvent::testQGuiAppDelivery() { - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - QWindow w; w.setGeometry(100, 100, 100, 100); w.show(); @@ -1521,38 +1516,33 @@ void tst_QTouchEvent::testQGuiAppDelivery() QCOMPARE(filter.d.isEmpty(), true); // Now the real thing. - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchBegin + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 1); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchBegin); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); points[0].state = Qt::TouchPointMoved; - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchUpdate + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 2); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchUpdate); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate); points[0].state = Qt::TouchPointReleased; - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchEnd + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 3); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchEnd); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd); } void tst_QTouchEvent::testMultiDevice() { - QTouchDevice *deviceOne = new QTouchDevice; - deviceOne->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(deviceOne); - QTouchDevice *deviceTwo = new QTouchDevice; - deviceTwo->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(deviceTwo); + QTouchDevice *deviceTwo = QTest::createTouchDevice(); QWindow w; w.setGeometry(100, 100, 100, 100); @@ -1564,7 +1554,7 @@ void tst_QTouchEvent::testMultiDevice() QList<QWindowSystemInterface::TouchPoint> pointsOne, pointsTwo; - // deviceOne reports a single point, deviceTwo reports the beginning of a multi-point sequence. + // touchScreenDevice reports a single point, deviceTwo reports the beginning of a multi-point sequence. // Even though there is a point with id 0 for both devices, they should be delivered cleanly, independently. QWindowSystemInterface::TouchPoint tp; tp.id = 0; @@ -1580,20 +1570,20 @@ void tst_QTouchEvent::testMultiDevice() tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin); pointsTwo.append(tp); - QWindowSystemInterface::handleTouchEvent(&w, deviceOne, pointsOne); + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, pointsOne); QWindowSystemInterface::handleTouchEvent(&w, deviceTwo, pointsTwo); QCoreApplication::processEvents(); - QCOMPARE(filter.d.contains(deviceOne), true); + QCOMPARE(filter.d.contains(touchScreenDevice), true); QCOMPARE(filter.d.contains(deviceTwo), true); - QCOMPARE(filter.d.value(deviceOne).lastSeenType, QEvent::TouchBegin); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin); - QCOMPARE(filter.d.value(deviceOne).points.count(), 1); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); - QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), QRectF(area0)); - QCOMPARE(filter.d.value(deviceOne).points.at(0).state(), pointsOne[0].state); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).screenRect(), QRectF(area0)); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).state(), pointsOne[0].state); QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 0fe40e8db3..81ab693ee7 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -1,12 +1,16 @@ [positioning:default] ubuntu-14.04 +ubuntu-16.04 [modalWindowPosition] ubuntu-14.04 +ubuntu-16.04 [modalWithChildWindow] ubuntu-14.04 +ubuntu-16.04 [setVisible] ubuntu-14.04 [modalWindowEnterEventOnHide_QTBUG35109] ubuntu-14.04 +ubuntu-16.04 [modalDialogClosingOneOfTwoModal] osx diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 08e1b1d3a0..844b3e8507 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -5,4 +5,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp -contains(QT_CONFIG,dynamicgl):win32:!wince:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 70446e803a..a41c574454 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -40,7 +40,7 @@ #if defined(Q_OS_QNX) #include <QOpenGLContext> -#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) # include <QtCore/qt_windows.h> #endif @@ -106,7 +106,7 @@ private slots: private: QPoint m_availableTopLeft; QSize m_testWindowSize; - QTouchDevice *touchDevice; + QTouchDevice *touchDevice = QTest::createTouchDevice(); }; void tst_QWindow::initTestCase() @@ -120,9 +120,6 @@ void tst_QWindow::initTestCase() if (screenWidth > 2000) width = 100 * ((screenWidth + 500) / 1000); m_testWindowSize = QSize(width, width); - touchDevice = new QTouchDevice; - touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(touchDevice); } void tst_QWindow::cleanup() @@ -2098,7 +2095,7 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109() static bool isNativeWindowVisible(const QWindow *window) { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) return IsWindowVisible(reinterpret_cast<HWND>(window->winId())); #else Q_UNIMPLEMENTED(); diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro index 0f7595c871..831fffab30 100644 --- a/tests/auto/gui/painting/painting.pro +++ b/tests/auto/gui/painting/painting.pro @@ -16,7 +16,7 @@ SUBDIRS=\ qwmatrix \ qpolygon \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qpathclipper \ diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8a97a9261f..1bd7f67810 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -39,9 +39,7 @@ #include <qimage.h> #include <qthread.h> #include <limits.h> -#if !defined(Q_OS_WINCE) #include <math.h> -#endif #include <qpaintengine.h> #ifndef QT_NO_WIDGETS #include <qdesktopwidget.h> @@ -297,6 +295,9 @@ private slots: void QTBUG50153_drawImage_assert(); + void rotateImage_data(); + void rotateImage(); + private: void fillData(); void setPenColor(QPainter& p); @@ -5061,6 +5062,64 @@ void tst_QPainter::QTBUG50153_drawImage_assert() } } +void tst_QPainter::rotateImage_data() +{ + QTest::addColumn<QImage>("image"); + QTest::addColumn<bool>("smooth"); + + QImage image(128, 128, QImage::Format_RGB32); + for (int y = 0; y < 128; ++y) { + for (int x = 0; x < 128; ++x) { + image.setPixel(x, y, qRgb(x + y, x + y, x + y)); + } + } + + QTest::newRow("fast") << image << false; + QTest::newRow("smooth") << image << true; +} + +void tst_QPainter::rotateImage() +{ + QFETCH(QImage, image); + QFETCH(bool, smooth); + + QImage dest(184, 184, QImage::Format_ARGB32_Premultiplied); + dest.fill(Qt::transparent); + + QPainter painter(&dest); + QTransform transform; + transform.translate(92, 0); + transform.rotate(45); + painter.setTransform(transform); + painter.setRenderHint(QPainter::SmoothPixmapTransform, smooth); + painter.drawImage(0, 0, image); + painter.end(); + + QRgb lastRow = qRgba(0, 0, 0, 0); + for (int y = 0; y < 184; ++y) { + QRgb row = qRgba(0, 0, 0, 0); + for (int x = 0; x < 184; ++x) { + QRgb pixel = dest.pixel(x, y); + if (qAlpha(pixel) < 255) + continue; + if (qAlpha(row) == 0) { + row = pixel; + } else { + QCOMPARE(qRed(pixel), qGreen(pixel)); + QCOMPARE(qGreen(pixel), qBlue(pixel)); + QVERIFY(qAbs(qRed(row) - qRed(pixel)) <= 2); + QVERIFY(qAbs(qGreen(row) - qGreen(pixel)) <= 2); + QVERIFY(qAbs(qBlue(row) - qBlue(pixel)) <= 2); + } + + } + if (qAlpha(row) && qAlpha(lastRow)) + QVERIFY(qGray(lastRow) <= qGray(row)); + lastRow = row; + } + +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 0261f60479..98f63984b3 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -840,22 +840,23 @@ void tst_QPainterPath::testArcMoveTo_data() QTest::addColumn<QRectF>("rect"); QTest::addColumn<qreal>("angle"); - QList<QRectF> rects; - rects << QRectF(100, 100, 100, 100) - << QRectF(100, 100, -100, 100) - << QRectF(100, 100, 100, -100) - << QRectF(100, 100, -100, -100); - - for (int domain=0; domain<rects.size(); ++domain) { + static Q_CONSTEXPR QRectF rects[] = { + QRectF(100, 100, 100, 100), + QRectF(100, 100, -100, 100), + QRectF(100, 100, 100, -100), + QRectF(100, 100, -100, -100), + }; + + for (uint domain = 0; domain < sizeof rects / sizeof *rects; ++domain) { const QByteArray dB = QByteArray::number(domain); for (int i=-360; i<=360; ++i) { QTest::newRow(("test " + dB + ' ' + QByteArray::number(i)).constData()) - << rects.at(domain) << (qreal) i; + << rects[domain] << (qreal) i; } // test low angles - QTest::newRow("low angles 1") << rects.at(domain) << (qreal) 1e-10; - QTest::newRow("low angles 2") << rects.at(domain) << (qreal)-1e-10; + QTest::newRow("low angles 1") << rects[domain] << (qreal) 1e-10; + QTest::newRow("low angles 2") << rects[domain] << (qreal)-1e-10; } } diff --git a/tests/auto/gui/painting/qpathclipper/qpathclipper.pro b/tests/auto/gui/painting/qpathclipper/qpathclipper.pro index e153460bf2..671220f94b 100644 --- a/tests/auto/gui/painting/qpathclipper/qpathclipper.pro +++ b/tests/auto/gui/painting/qpathclipper/qpathclipper.pro @@ -5,6 +5,6 @@ HEADERS += paths.h SOURCES += tst_qpathclipper.cpp paths.cpp QT += gui-private testlib -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) unix:!darwin:!haiku:!integrity: LIBS += -lm diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp index 4d6f52bf8a..13b6e28f5f 100644 --- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp +++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp @@ -43,6 +43,10 @@ public: tst_QPolygon(); private slots: + void boundingRect_data(); + void boundingRect(); + void boundingRectF_data(); + void boundingRectF(); void makeEllipse(); void swap(); }; @@ -51,6 +55,79 @@ tst_QPolygon::tst_QPolygon() { } +void tst_QPolygon::boundingRect_data() +{ + QTest::addColumn<QPolygon>("poly"); + QTest::addColumn<QRect>("brect"); + +#define ROW(args, rect) \ + do { \ + QPolygon poly; \ + poly.setPoints args; \ + QTest::newRow(#args) << poly << QRect rect; \ + } while (0) + + QTest::newRow("empty") << QPolygon() << QRect(0, 0, 0, 0); + ROW((1, 0,1), ( 0, 1, 1, 1)); + ROW((2, 0,1, 1,0), ( 0, 0, 2, 2)); + ROW((3, -1,1, -1,-1, 1,0), (-1,-1, 3, 3)); +#undef ROW +} + +void tst_QPolygon::boundingRect() +{ + QFETCH(QPolygon, poly); + QFETCH(QRect, brect); + + QCOMPARE(poly.boundingRect(), brect); +} + +namespace { +struct MyPolygonF : QPolygonF +{ + // QPolygonF doesn't have setPoints... + void setPoints(int nPoints, int firstx, int firsty, ...) { + va_list ap; + reserve(nPoints); + *this << QPointF(firstx, firsty); + va_start(ap, firsty); + while (--nPoints) { + const int x = va_arg(ap, int); + const int y = va_arg(ap, int); + *this << QPointF(x, y); + } + va_end(ap); + } +}; +} + +void tst_QPolygon::boundingRectF_data() +{ + QTest::addColumn<QPolygonF>("poly"); + QTest::addColumn<QRectF>("brect"); + +#define ROW(args, rect) \ + do { \ + MyPolygonF poly; \ + poly.setPoints args; \ + QTest::newRow(#args) << QPolygonF(poly) << QRectF rect; \ + } while (0) + + QTest::newRow("empty") << QPolygonF() << QRectF(0, 0, 0, 0); + ROW((1, 0,1), ( 0, 1, 0, 0)); + ROW((2, 0,1, 1,0), ( 0, 0, 1, 1)); + ROW((3, -1,1, -1,-1, 1,0), (-1,-1, 2, 2)); +#undef ROW +} + +void tst_QPolygon::boundingRectF() +{ + QFETCH(QPolygonF, poly); + QFETCH(QRectF, brect); + + QCOMPARE(poly.boundingRect(), brect); +} + void tst_QPolygon::makeEllipse() { // create an ellipse with R1 = R2 = R, i.e. a circle diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index d24435198e..6a297dbfc2 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -47,6 +47,7 @@ public: private slots: void moveSemantics(); void boundingRect(); + void rangeFor(); void rects(); void swap(); void setRects(); @@ -136,17 +137,34 @@ void tst_QRegion::boundingRect() } +void tst_QRegion::rangeFor() +{ + // compile-only test for range-for over QRegion, so really useless + // content otherwise: + QRect rect(10, -20, 30, 40); + QRegion region(rect); + int equal = 0; + for (const QRect &r : region) // check this compiles + equal += int(r == rect); // can't use QCOMPARE here b/c of the + // MSVC 201272013 parse bug re: + // do-while in range-for loops + QCOMPARE(equal, 1); +} + void tst_QRegion::rects() { { QRect rect; QRegion region(rect); QVERIFY(region.isEmpty()); + QCOMPARE(region.begin(), region.end()); QVERIFY(region.rects().isEmpty()); } { QRect rect(10, -20, 30, 40); QRegion region(rect); + QCOMPARE(region.end(), region.begin() + 1); + QCOMPARE(*region.begin(), rect); QCOMPARE(region.rects().count(), 1); QCOMPARE(region.rects()[0], rect); } @@ -192,6 +210,7 @@ void tst_QRegion::setRects() region.setRects(&rect, 0); QVERIFY(region.isEmpty()); QCOMPARE(region, QRegion()); + QCOMPARE(region.begin(), region.end()); QVERIFY(!region.boundingRect().isValid()); QVERIFY(region.rects().isEmpty()); } @@ -199,6 +218,7 @@ void tst_QRegion::setRects() QRegion region; QRect rect; region.setRects(&rect, 1); + QCOMPARE(region.begin(), region.end()); QVERIFY(!region.boundingRect().isValid()); QVERIFY(region.rects().isEmpty()); } @@ -206,8 +226,10 @@ void tst_QRegion::setRects() QRegion region; QRect rect(10, -20, 30, 40); region.setRects(&rect, 1); + QCOMPARE(region.end(), region.begin() + 1); QCOMPARE(region.rects().count(), 1); QCOMPARE(region.rects()[0], rect); + QCOMPARE(*region.begin(), rect); } } @@ -320,8 +342,12 @@ void tst_QRegion::emptyPolygonRegion() QRegion r(pa); QTEST(r.isEmpty(), "isEmpty"); + QTEST(int(std::distance(r.begin(), r.end())), "numRects"); + QVector<QRect> rects; + std::copy(r.begin(), r.end(), std::back_inserter(rects)); QTEST(r.rects().count(), "numRects"); QTEST(r.rects(), "rects"); + QCOMPARE(r.rects(), rects); } @@ -860,6 +886,7 @@ void tst_QRegion::isEmpty() QFETCH(QRegion, region); QVERIFY(region.isEmpty()); + QCOMPARE(region.begin(), region.end()); QCOMPARE(region, QRegion()); QCOMPARE(region.rectCount(), 0); QCOMPARE(region.boundingRect(), QRect()); @@ -892,6 +919,11 @@ void tst_QRegion::regionFromPath() path.addRect(0, 100, 100, 1000); QRegion rgn(path.toFillPolygon().toPolygon()); + + QCOMPARE(rgn.end(), rgn.begin() + 2); + QCOMPARE(rgn.begin()[0], QRect(0, 0, 10, 10)); + QCOMPARE(rgn.begin()[1], QRect(0, 100, 100, 1000)); + QCOMPARE(rgn.rects().size(), 2); QCOMPARE(rgn.rects().at(0), QRect(0, 0, 10, 10)); QCOMPARE(rgn.rects().at(1), QRect(0, 100, 100, 1000)); @@ -905,8 +937,14 @@ void tst_QRegion::regionFromPath() path.addRect(10, 10, 80, 80); QRegion rgn(path.toFillPolygon().toPolygon()); - QCOMPARE(rgn.rects().size(), 4); + QCOMPARE(rgn.end(), rgn.begin() + 4); + QCOMPARE(rgn.begin()[0], QRect(0, 0, 100, 10)); + QCOMPARE(rgn.begin()[1], QRect(0, 10, 10, 80)); + QCOMPARE(rgn.begin()[2], QRect(90, 10, 10, 80)); + QCOMPARE(rgn.begin()[3], QRect(0, 90, 100, 10)); + + QCOMPARE(rgn.rects().size(), 4); QCOMPARE(rgn.rects().at(0), QRect(0, 0, 100, 10)); QCOMPARE(rgn.rects().at(1), QRect(0, 10, 10, 80)); QCOMPARE(rgn.rects().at(2), QRect(90, 10, 10, 80)); diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp index e05d7dd022..a79526c434 100644 --- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp +++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp @@ -114,7 +114,7 @@ void tst_QWMatrix::mapping_data() << QRect( 0, 0, 30, 40 ) << QPolygon( QRect( -300, -400, 300, 400 ) ); -#if (defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(M_PI) +#if defined(Q_OS_WIN) && !defined(M_PI) #define M_PI 3.14159265897932384626433832795f #endif diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index a4ef016e39..aaef6e5125 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -8,4 +8,4 @@ QT += gui-private core-private testlib SOURCES += tst_qopengl.cpp -linux:contains(QT_CONFIG, xcb-glx):contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, egl): DEFINES += USE_GLX +linux:qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 15244744bf..ed48a4978a 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -41,7 +41,7 @@ #include <QtGui/QOffscreenSurface> #include <QtGui/QGenericMatrix> #include <QtGui/QMatrix4x4> -#include <QtGui/private/qopengltextureblitter_p.h> +#include <QtGui/qopengltextureblitter.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qopenglextensions_p.h> #include <qpa/qplatformintegration.h> diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp index d3404e335a..be3ef968ef 100644 --- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp +++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp @@ -48,6 +48,8 @@ private slots: void getSetCheck(); void maximumBlockCount(); void anchorAt(); + void imageAt(); + void formatAt(); }; tst_QAbstractTextDocumentLayout::tst_QAbstractTextDocumentLayout() @@ -156,7 +158,7 @@ void tst_QAbstractTextDocumentLayout::anchorAt() // anchorAt on start returns link QRect linkBr = metrics.boundingRect("foo"); - QPointF linkPoint(linkBr.width() + blockStart.x(), (linkBr.height() / 2) + blockStart.y()); + QPointF linkPoint((linkBr.width() / 2) + blockStart.x(), (linkBr.height() / 2) + blockStart.y()); QCOMPARE(documentLayout->anchorAt(linkPoint), QString("link")); // anchorAt() on top of preedit at end should not assert @@ -171,5 +173,61 @@ void tst_QAbstractTextDocumentLayout::anchorAt() QCOMPARE(documentLayout->anchorAt(preeditPoint), QString()); } +void tst_QAbstractTextDocumentLayout::imageAt() +{ + QTextDocument doc; + doc.setHtml("foo<a href=\"link\"><img src=\"image\" width=\"50\" height=\"50\"/></a>"); + QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); + QTextBlock firstBlock = doc.begin(); + QTextLayout *layout = firstBlock.layout(); + layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + + doc.setPageSize(QSizeF(1000, 1000)); + QFontMetrics metrics(layout->font()); + QPointF blockStart = documentLayout->blockBoundingRect(firstBlock).topLeft(); + + QRect fooBr = metrics.boundingRect("foo"); + QPointF imagePoint(fooBr.width() + blockStart.x() + 25, blockStart.y() + 25); + // imageAt on image returns source + QCOMPARE(documentLayout->imageAt(imagePoint), QString("image")); + // anchorAt on image returns link + QCOMPARE(documentLayout->anchorAt(imagePoint), QString("link")); + + // imageAt on start returns nothing (there's the "foo" text) + QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y()); + QCOMPARE(documentLayout->imageAt(fooPoint), QString()); +} + +void tst_QAbstractTextDocumentLayout::formatAt() +{ + QTextDocument doc; + doc.setHtml("foo<i><a href=\"link\"><img src=\"image\" width=\"50\" height=\"50\"/></a></i>"); + QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); + QTextBlock firstBlock = doc.begin(); + QTextLayout *layout = firstBlock.layout(); + layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + + doc.setPageSize(QSizeF(1000, 1000)); + QFontMetrics metrics(layout->font()); + QPointF blockStart = documentLayout->blockBoundingRect(firstBlock).topLeft(); + + QRect fooBr = metrics.boundingRect("foo"); + QPointF imagePoint(fooBr.width() + blockStart.x() + 25, blockStart.y() + 25); + + QTextFormat format = documentLayout->formatAt(imagePoint); + QVERIFY(format.isCharFormat()); + QVERIFY(format.toCharFormat().isAnchor()); + QVERIFY(format.toCharFormat().fontItalic()); + QVERIFY(format.isImageFormat()); + + // move over the unformatted "foo" text) + QPointF fooPoint(blockStart.x() + (fooBr.width() / 2), (fooBr.height() / 2) + blockStart.y()); + format = documentLayout->formatAt(fooPoint); + QVERIFY(format.isCharFormat()); + QVERIFY(!format.toCharFormat().isAnchor()); + QVERIFY(!format.toCharFormat().fontItalic()); + QVERIFY(!format.isImageFormat()); +} + QTEST_MAIN(tst_QAbstractTextDocumentLayout) #include "tst_qabstracttextdocumentlayout.moc" diff --git a/tests/auto/gui/text/qcssparser/qcssparser.pro b/tests/auto/gui/text/qcssparser/qcssparser.pro index 88d1fcfd2d..776b4b3de2 100644 --- a/tests/auto/gui/text/qcssparser/qcssparser.pro +++ b/tests/auto/gui/text/qcssparser/qcssparser.pro @@ -3,16 +3,10 @@ TARGET = tst_qcssparser SOURCES += tst_qcssparser.cpp QT += xml gui-private testlib -requires(contains(QT_CONFIG,private_tests)) -DEFINES += SRCDIR=\\\"$$PWD\\\" +TESTDATA += testdata -wince* { - addFiles.files = testdata - addFiles.path = . - timesFont.files = C:/Windows/Fonts/times.ttf - timesFont.path = . - DEPLOYMENT += addFiles timesFont -} +requires(qtConfig(private_tests)) +DEFINES += SRCDIR=\\\"$$PWD\\\" android { RESOURCES += \ diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 847d6e2e2f..45cfd6f43a 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -27,9 +27,6 @@ ****************************************************************************/ #include <QtTest/QtTest> #include <QtXml/QtXml> -#if defined(Q_OS_WINCE) -#include <QtGui/QFontDatabase> -#endif #include <QtGui/QFontInfo> #include <QtGui/QFontMetrics> @@ -39,10 +36,6 @@ class tst_QCssParser : public QObject { Q_OBJECT -public slots: - void initTestCase(); - void cleanupTestCase(); - private slots: void scanner_data(); void scanner(); @@ -85,41 +78,16 @@ private slots: void extractBorder(); void noTextDecoration(); void quotedAndUnquotedIdentifiers(); - -private: -#if defined(Q_OS_WINCE) - int m_timesFontId; -#endif }; -void tst_QCssParser::initTestCase() -{ -#if defined(Q_OS_WINCE) - QFontDatabase fontDB; - m_timesFontId = -1; - if (!fontDB.families().contains("Times New Roman")) { - m_timesFontId = QFontDatabase::addApplicationFont("times.ttf"); - QVERIFY(m_timesFontId != -1); - } -#endif -} - -void tst_QCssParser::cleanupTestCase() -{ -#if defined(Q_OS_WINCE) - if (m_timesFontId != -1) - QFontDatabase::removeApplicationFont(m_timesFontId); -#endif -} - void tst_QCssParser::scanner_data() { QTest::addColumn<QString>("input"); QTest::addColumn<QString>("output"); -#if defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) || defined(Q_OS_WINRT) QDir d(":/"); -#elif !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE) +#elif !defined(Q_OS_IRIX) QDir d(SRCDIR); #else QDir d(QDir::current()); @@ -145,10 +113,14 @@ static const char *tokenName(QCss::TokenType t) case QCss::CDC: return "CDC"; case QCss::INCLUDES: return "INCLUDES"; case QCss::DASHMATCH: return "DASHMATCH"; + case QCss::BEGINSWITH: return "BEGINSWITH"; + case QCss::ENDSWITH: return "ENDSWITH"; + case QCss::CONTAINS: return "CONTAINS"; case QCss::LBRACE: return "LBRACE"; case QCss::PLUS: return "PLUS"; case QCss::GREATER: return "GREATER"; case QCss::COMMA: return "COMMA"; + case QCss::TILDE: return "TILDE"; case QCss::STRING: return "STRING"; case QCss::INVALID: return "INVALID"; case QCss::IDENT: return "IDENT"; @@ -509,7 +481,7 @@ void tst_QCssParser::selector_data() QCss::BasicSelector basic; basic.elementName = "p"; - basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds; + basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfDirectAdjecent; sel.basicSelectors << basic; basic = QCss::BasicSelector(); @@ -601,14 +573,29 @@ void tst_QCssParser::selector_data() QCss::BasicSelector basic; basic.elementName = "e"; - basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds; + basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfDirectAdjecent; sel.basicSelectors << basic; basic.elementName = "f"; basic.relationToNext = QCss::BasicSelector::NoRelation; sel.basicSelectors << basic; - QTest::newRow("precede") << QString("e + f") << sel; + QTest::newRow("lastsibling") << QString("e + f") << sel; + } + + { + QCss::Selector sel; + QCss::BasicSelector basic; + + basic.elementName = "e"; + basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfIndirectAdjecent; + sel.basicSelectors << basic; + + basic.elementName = "f"; + basic.relationToNext = QCss::BasicSelector::NoRelation; + sel.basicSelectors << basic; + + QTest::newRow("previoussibling") << QString("e ~ f") << sel; } { @@ -647,11 +634,11 @@ void tst_QCssParser::selector_data() QCss::AttributeSelector attrSel; attrSel.name = "foo"; attrSel.value = "warning"; - attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains; + attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchIncludes; basic.attributeSelectors << attrSel; sel.basicSelectors << basic; - QTest::newRow("attr-contains") << QString("e[foo~=\"warning\"]") << sel; + QTest::newRow("attr-includes") << QString("e[foo~=\"warning\"]") << sel; } { @@ -662,11 +649,26 @@ void tst_QCssParser::selector_data() QCss::AttributeSelector attrSel; attrSel.name = "lang"; attrSel.value = "en"; - attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchBeginsWith; + attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchDashMatch; + basic.attributeSelectors << attrSel; + sel.basicSelectors << basic; + + QTest::newRow("attr-dash") << QString("e[lang|=\"en\"]") << sel; + } + + { + QCss::Selector sel; + QCss::BasicSelector basic; + + basic.elementName = "e"; + QCss::AttributeSelector attrSel; + attrSel.name = "foo"; + attrSel.value = "warning"; + attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains; basic.attributeSelectors << attrSel; sel.basicSelectors << basic; - QTest::newRow("attr-contains") << QString("e[lang|=\"en\"]") << sel; + QTest::newRow("attr-contains") << QString("e[foo*=\"warning\"]") << sel; } { @@ -677,7 +679,7 @@ void tst_QCssParser::selector_data() QCss::AttributeSelector attrSel; attrSel.name = "class"; - attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains; + attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchIncludes; attrSel.value = "warning"; basic.attributeSelectors.append(attrSel); @@ -999,11 +1001,20 @@ void tst_QCssParser::styleSelector_data() QTest::newRow("attrmatch") << true << QString("[foo=bar]") << QString("<p foo=\"bar\" />") << QString(); QTest::newRow("noattrmatch") << false << QString("[foo=bar]") << QString("<p foo=\"xyz\" />") << QString(); - QTest::newRow("contains") << true << QString("[foo~=bar]") << QString("<p foo=\"baz bleh bar\" />") << QString(); - QTest::newRow("notcontains") << false << QString("[foo~=bar]") << QString("<p foo=\"test\" />") << QString(); + QTest::newRow("includes") << true << QString("[foo~=bar]") << QString("<p foo=\"baz bleh bar\" />") << QString(); + QTest::newRow("notincludes") << false << QString("[foo~=bar]") << QString("<p foo=\"bazblehbar\" />") << QString(); - QTest::newRow("beingswith") << true << QString("[foo|=bar]") << QString("<p foo=\"bar-bleh\" />") << QString(); - QTest::newRow("notbeingswith") << false << QString("[foo|=bar]") << QString("<p foo=\"bleh-bar\" />") << QString(); + QTest::newRow("dashmatch") << true << QString("[foo|=bar]") << QString("<p foo=\"bar-bleh\" />") << QString(); + QTest::newRow("nodashmatch") << false << QString("[foo|=bar]") << QString("<p foo=\"barbleh\" />") << QString(); + + QTest::newRow("beginswith") << true << QString("[foo^=bar]") << QString("<p foo=\"barbleh\" />") << QString(); + QTest::newRow("nobeginswith") << false << QString("[foo^=bar]") << QString("<p foo=\"blehbleh\" />") << QString(); + + QTest::newRow("endswith") << true << QString("[foo$=bar]") << QString("<p foo=\"barbar\" />") << QString(); + QTest::newRow("noendswith") << false << QString("[foo$=bar]") << QString("<p foo=\"blehbleh\" />") << QString(); + + QTest::newRow("contains") << true << QString("[foo*=bar]") << QString("<p foo=\"blehbarbleh\" />") << QString(); + QTest::newRow("nocontains") << false << QString("[foo*=bar]") << QString("<p foo=\"blehbleh\" />") << QString(); QTest::newRow("attr2") << true << QString("[bar=foo]") << QString("<p bleh=\"bar\" bar=\"foo\" />") << QString(); @@ -1084,10 +1095,19 @@ void tst_QCssParser::styleSelector_data() << QString("<p1 /><p2 />") << QString("p2"); - QTest::newRow("noprevioussibling") << false << QString("p2 + p1") + QTest::newRow("notprevioussibling") << false << QString("p2 + p1") << QString("<p1 /><p2 />") << QString("p2"); + QTest::newRow("anyprevioussibling") << true << QString("p1 ~ p3") + << QString("<p1 /><p2 /><p3 />") + << QString("p3"); + + QTest::newRow("noprevioussibling") << false << QString("p3 ~ p2") + << QString("<p1 /><p2 /><p3 />") + << QString("p3"); + + QTest::newRow("ancestry_firstmismatch") << false << QString("parent child[foo=bar]") << QString("<parent><child /></parent>") << QString("parent/child"); diff --git a/tests/auto/gui/text/qfont/BLACKLIST b/tests/auto/gui/text/qfont/BLACKLIST index d859dee03e..8890ec1ef3 100644 --- a/tests/auto/gui/text/qfont/BLACKLIST +++ b/tests/auto/gui/text/qfont/BLACKLIST @@ -1,2 +1,4 @@ [exactMatch] +# QTBUG-46054 opensuse-13.1 +opensuse-42.1 diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index d8a6afb804..ca984a26a5 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -62,6 +62,7 @@ private slots: void styleName(); void defaultFamily_data(); void defaultFamily(); + void toAndFromString(); void sharing(); }; @@ -508,11 +509,11 @@ void tst_QFont::defaultFamily_data() QTest::addColumn<QFont::StyleHint>("styleHint"); QTest::addColumn<QStringList>("acceptableFamilies"); - QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << "Droid Serif" << getPlatformGenericFont("serif")); - QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace")); - QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive")); - QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy")); - QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif")); + QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << "Droid Serif" << getPlatformGenericFont("serif").split(",")); + QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace").split(",")); + QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive").split(",")); + QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy").split(",")); + QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif").split(",")); } void tst_QFont::defaultFamily() @@ -539,6 +540,26 @@ void tst_QFont::defaultFamily() QVERIFY2(isAcceptable, msgNotAcceptableFont(familyForHint, acceptableFamilies)); } +void tst_QFont::toAndFromString() +{ + QFont defaultFont = QGuiApplication::font(); + QString family = defaultFont.family(); + + QFontDatabase fdb; + const QStringList stylesList = fdb.styles(family); + if (stylesList.size() == 0) + QSKIP("Default font doesn't have any styles"); + + for (const QString &style : stylesList) { + QFont result; + QFont initial = fdb.font(family, style, defaultFont.pointSize()); + + result.fromString(initial.toString()); + + QCOMPARE(result, initial); + } +} + void tst_QFont::sharing() { // QFontCache references the engineData diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index 54bc802cf0..fbca313ea3 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -101,8 +101,6 @@ void tst_QFontCache::engineData() } if (req.pointSize < 0) req.pointSize = req.pixelSize*72.0/d->dpi; - if (req.stretch == 0) - req.stretch = 100; req.family = cacheKey; diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 5dba2fc06a..8a08cdc182 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -2,12 +2,7 @@ CONFIG += testcase TARGET = tst_qfontdatabase SOURCES += tst_qfontdatabase.cpp QT += testlib core-private gui-private - -wince* { - additionalFiles.files = FreeMono.ttf - additionalFiles.path = . - DEPLOYMENT += additionalFiles -} +TESTDATA += LED_REAL.TTF android { RESOURCES += testdata.qrc diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index adaf3b1f7a..f71d808390 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -64,6 +64,8 @@ private slots: void aliases(); void fallbackFonts(); + void liberationFont(); + private: const QString m_testFont; }; @@ -275,5 +277,23 @@ void tst_QFontDatabase::fallbackFonts() } } +void tst_QFontDatabase::liberationFont() +{ + QString libSans("Liberation Sans"); + QString libSansNarrow("Liberation Sans Narrow"); + + QFontDatabase db; + if (!db.hasFamily(libSans) || !db.hasFamily(libSansNarrow)) + QSKIP("Requires Liberation Sans installed"); + + QFont fontLS(libSans); + QFont fontLSN(libSansNarrow); + + QFontMetrics fmLS(fontLS); + QFontMetrics fmLSN(fontLSN); + + QVERIFY(fmLS.width(QStringLiteral("foo bar")) > fmLSN.width(QStringLiteral("foo bar"))); +} + QTEST_MAIN(tst_QFontDatabase) #include "tst_qfontdatabase.moc" diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro index 3abca8ce89..c08019a561 100644 --- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro +++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro @@ -6,12 +6,5 @@ SOURCES += \ tst_qglyphrun.cpp -wince* { - additionalFiles.files = test.ttf - additionalFiles.path = ../../../shared/resources/ - DEPLOYMENT += additionalFiles -} else { - RESOURCES += \ - testdata.qrc -} - +RESOURCES += \ + testdata.qrc diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc index 8f8e32ed24..c7ac9641d1 100644 --- a/tests/auto/gui/text/qrawfont/testdata.qrc +++ b/tests/auto/gui/text/qrawfont/testdata.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/"> <file>testfont_bold_italic.ttf</file> + <file>testfont_os2_v1.ttf</file> <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> </qresource> </RCC> diff --git a/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf b/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf Binary files differnew file mode 100644 index 0000000000..ee8b67d892 --- /dev/null +++ b/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 471b32dd50..3cf108ed62 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -93,6 +93,7 @@ private slots: private: QString testFont; QString testFontBoldItalic; + QString testFontOs2V1; #endif // QT_NO_RAWFONT }; @@ -110,6 +111,7 @@ void tst_QRawFont::initTestCase() { testFont = QFINDTESTDATA("testfont.ttf"); testFontBoldItalic = QFINDTESTDATA("testfont_bold_italic.ttf"); + testFontOs2V1 = QFINDTESTDATA("testfont_os2_v1.ttf"); if (testFont.isEmpty() || testFontBoldItalic.isEmpty()) QFAIL("qrawfont unittest font files not found!"); @@ -184,6 +186,7 @@ void tst_QRawFont::correctFontData_data() QTest::addColumn<QFont::HintingPreference>("hintingPreference"); QTest::addColumn<qreal>("unitsPerEm"); QTest::addColumn<qreal>("pixelSize"); + QTest::addColumn<int>("capHeight"); int hintingPreferences[] = { int(QFont::PreferDefaultHinting), @@ -207,7 +210,8 @@ void tst_QRawFont::correctFontData_data() << QFont::Normal << QFont::HintingPreference(*hintingPreference) << qreal(1000.0) - << qreal(10.0); + << qreal(10.0) + << 7; fileName = testFontBoldItalic; title = fileName @@ -221,7 +225,23 @@ void tst_QRawFont::correctFontData_data() << QFont::Bold << QFont::HintingPreference(*hintingPreference) << qreal(1000.0) - << qreal(10.0); + << qreal(10.0) + << 7; + + fileName = testFontOs2V1; + title = fileName + + QLatin1String(": hintingPreference=") + + QString::number(*hintingPreference); + + QTest::newRow(qPrintable(title)) + << fileName + << QString::fromLatin1("QtBidiTestFont") + << QFont::StyleNormal + << QFont::Normal + << QFont::HintingPreference(*hintingPreference) + << qreal(1000.0) + << qreal(10.0) + << 7; ++hintingPreference; } @@ -236,6 +256,7 @@ void tst_QRawFont::correctFontData() QFETCH(QFont::HintingPreference, hintingPreference); QFETCH(qreal, unitsPerEm); QFETCH(qreal, pixelSize); + QFETCH(int, capHeight); QRawFont font(fileName, 10, hintingPreference); QVERIFY(font.isValid()); @@ -246,6 +267,11 @@ void tst_QRawFont::correctFontData() QCOMPARE(font.hintingPreference(), hintingPreference); QCOMPARE(font.unitsPerEm(), unitsPerEm); QCOMPARE(font.pixelSize(), pixelSize); + + // Some platforms return the actual fractional height of the + // H character when the value is missing from the OS/2 table, + // so we ceil it off to match (any touched pixel counts). + QCOMPARE(qCeil(font.capHeight()), capHeight); } void tst_QRawFont::glyphIndices() diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro index 0f4906ce4d..09d0dd4126 100644 --- a/tests/auto/gui/text/qstatictext/qstatictext.pro +++ b/tests/auto/gui/text/qstatictext/qstatictext.pro @@ -4,4 +4,4 @@ QT += testlib SOURCES += tst_qstatictext.cpp -contains(QT_CONFIG, private_tests): QT += core-private gui-private +qtConfig(private_tests): QT += core-private gui-private diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index b2b2f25615..3b47f4b17b 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -2903,15 +2903,28 @@ void tst_QTextDocument::testUndoBlocks() doc->undo(); QCOMPARE(doc->toPlainText(), QString("")); + cursor.insertText("town"); + cursor.beginEditBlock(); // Edit block 1 - Deletion/Insertion + cursor.setPosition(0, QTextCursor::KeepAnchor); + cursor.insertText("r"); + cursor.endEditBlock(); + cursor.insertText("est"); // Merged into edit block 1 + QCOMPARE(doc->toPlainText(), QString("rest")); + doc->undo(); + QCOMPARE(doc->toPlainText(), QString("town")); + doc->undo(); + QCOMPARE(doc->toPlainText(), QString("")); + + // This case would not happen in practice. If the user typed out this text, it would all be part of one + // edit block. This would cause the undo to clear all text. But for the purpose of testing the beginEditBlock + // and endEditBlock calls with respect to qtextdocument this is tested. cursor.insertText("quod"); - cursor.beginEditBlock(); + cursor.beginEditBlock(); // Edit block 1 - Insertion cursor.insertText(" erat"); cursor.endEditBlock(); - cursor.insertText(" demonstrandum"); + cursor.insertText(" demonstrandum"); // Merged into edit block 1 QCOMPARE(doc->toPlainText(), QString("quod erat demonstrandum")); doc->undo(); - QCOMPARE(doc->toPlainText(), QString("quod erat")); - doc->undo(); QCOMPARE(doc->toPlainText(), QString("quod")); doc->undo(); QCOMPARE(doc->toPlainText(), QString("")); diff --git a/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro b/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro index 1419e32012..0bbe0c8c4e 100644 --- a/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro +++ b/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro @@ -6,5 +6,5 @@ SOURCES += tst_qtextpiecetable.cpp HEADERS += ../qtextdocument/common.h requires(!win32) -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 0beea6528b..36907b9258 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -150,7 +150,7 @@ static void doShapingTests() } } else { // decomposed shaping - if (string.at(0) == 0x1fc1 || string.at(0) == 0x1fed) + if (string.at(0) == QChar(0x1fc1) || string.at(0) == QChar(0x1fed)) return; if (string.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != string) return; diff --git a/tests/auto/gui/text/qzip/qzip.pro b/tests/auto/gui/text/qzip/qzip.pro index ebcd6ec022..ee92855093 100644 --- a/tests/auto/gui/text/qzip/qzip.pro +++ b/tests/auto/gui/text/qzip/qzip.pro @@ -2,12 +2,7 @@ CONFIG += testcase TARGET = tst_qzip QT += gui-private testlib SOURCES += tst_qzip.cpp - -wince* { - addFiles.files = testdata - addFiles.path = . - DEPLOYMENT += addFiles -} +TESTDATA += testdata android { RESOURCES += \ diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp index 50e9a0f0ef..c0bf5fef8e 100644 --- a/tests/auto/gui/text/qzip/tst_qzip.cpp +++ b/tests/auto/gui/text/qzip/tst_qzip.cpp @@ -50,7 +50,7 @@ void tst_QZip::basicUnpack() QZipReader::FileInfo fi = files.at(0); QVERIFY(fi.isValid()); - QCOMPARE(fi.filePath, QString("test/")); + QCOMPARE(fi.filePath, QString("test")); QCOMPARE(uint(fi.isDir), (uint) 1); QCOMPARE(uint(fi.isFile), (uint) 0); QCOMPARE(uint(fi.isSymLink), (uint) 0); diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index dc67794a98..bb4984767f 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -22,13 +22,15 @@ SUBDIRS=\ qtextpiecetable \ qtextscriptengine \ qtexttable \ - -contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter + qzip \ + qtextodfwriter win32:SUBDIRS -= qtextpiecetable -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qfontcache \ qcssparser \ qtextlayout \ qtextpiecetable \ + qzip \ + qtextodfwriter diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp index 58164f1fa1..f57ed12ed3 100644 --- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp @@ -46,7 +46,7 @@ void tst_qdesktopservices::openUrl() { // At the bare minimum check that they return false for invalid url's QCOMPARE(QDesktopServices::openUrl(QUrl()), false); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) // this test is only valid on windows on other systems it might mean open a new document in the application handling .file const QRegularExpression messagePattern("ShellExecute 'file://invalid\\.file' failed \\(error \\d+\\)\\."); QVERIFY(messagePattern.isValid()); diff --git a/tests/auto/network/access/access.pro b/tests/auto/network/access/access.pro index bc76190e30..1d78cf253b 100644 --- a/tests/auto/network/access/access.pro +++ b/tests/auto/network/access/access.pro @@ -12,9 +12,12 @@ SUBDIRS=\ qftp \ qhttpnetworkreply \ qabstractnetworkcache \ + hpack \ + http2 -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qhttpnetworkconnection \ qhttpnetworkreply \ qftp \ - + hpack \ + http2 diff --git a/tests/auto/network/access/hpack/hpack.pro b/tests/auto/network/access/hpack/hpack.pro new file mode 100644 index 0000000000..3c8b8e7944 --- /dev/null +++ b/tests/auto/network/access/hpack/hpack.pro @@ -0,0 +1,6 @@ +QT += core core-private network network-private testlib +CONFIG += testcase parallel_test c++14 +TEMPLATE = app +TARGET = tst_hpack + +SOURCES += tst_hpack.cpp diff --git a/tests/auto/network/access/hpack/tst_hpack.cpp b/tests/auto/network/access/hpack/tst_hpack.cpp new file mode 100644 index 0000000000..bd337c9f5f --- /dev/null +++ b/tests/auto/network/access/hpack/tst_hpack.cpp @@ -0,0 +1,852 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2014 Governikus GmbH & Co. KG. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtNetwork/private/bitstreams_p.h> +#include <QtNetwork/private/hpack_p.h> + +#include <QtCore/qbytearray.h> + +#include <cstdlib> +#include <vector> +#include <string> + +QT_USE_NAMESPACE + +using namespace HPack; + +class tst_Hpack: public QObject +{ + Q_OBJECT + +public: + tst_Hpack(); +private Q_SLOTS: + void bitstreamConstruction(); + void bitstreamWrite(); + void bitstreamReadWrite(); + void bitstreamCompression(); + void bitstreamErrors(); + + void lookupTableConstructor(); + + void lookupTableStatic_data(); + void lookupTableStatic(); + void lookupTableDynamic(); + + void hpackEncodeRequest_data(); + void hpackEncodeRequest(); + void hpackDecodeRequest_data(); + void hpackDecodeRequest(); + + void hpackEncodeResponse_data(); + void hpackEncodeResponse(); + void hpackDecodeResponse_data(); + void hpackDecodeResponse(); + + // TODO: more-more-more tests needed! + +private: + void hpackEncodeRequest(bool withHuffman); + void hpackEncodeResponse(bool withHuffman); + + HttpHeader header1; + std::vector<uchar> buffer1; + BitOStream request1; + + HttpHeader header2; + std::vector<uchar> buffer2; + BitOStream request2; + + HttpHeader header3; + std::vector<uchar> buffer3; + BitOStream request3; +}; + +using StreamError = BitIStream::Error; + +tst_Hpack::tst_Hpack() + : request1(buffer1), + request2(buffer2), + request3(buffer3) +{ +} + +void tst_Hpack::bitstreamConstruction() +{ + const uchar bytes[] = {0xDE, 0xAD, 0xBE, 0xEF}; + const int size = int(sizeof bytes); + + // Default ctors: + std::vector<uchar> buffer; + { + const BitOStream out(buffer); + QVERIFY(out.bitLength() == 0); + QVERIFY(out.byteLength() == 0); + + const BitIStream in; + QVERIFY(in.bitLength() == 0); + QVERIFY(in.streamOffset() == 0); + QVERIFY(in.error() == StreamError::NoError); + } + + // Create istream with some data: + { + BitIStream in(bytes, bytes + size); + QVERIFY(in.bitLength() == size * 8); + QVERIFY(in.streamOffset() == 0); + QVERIFY(in.error() == StreamError::NoError); + // 'Read' some data back: + for (int i = 0; i < size; ++i) { + uchar bitPattern = 0; + const auto bitsRead = in.peekBits(i * 8, 8, &bitPattern); + QVERIFY(bitsRead == 8); + QVERIFY(bitPattern == bytes[i]); + } + } + + // Copy ctors: + { + // Ostreams - copy is disabled. + // Istreams: + const BitIStream in1; + const BitIStream in2(in1); + QVERIFY(in2.bitLength() == in1.bitLength()); + QVERIFY(in2.streamOffset() == in1.streamOffset()); + QVERIFY(in2.error() == StreamError::NoError); + + const BitIStream in3(bytes, bytes + size); + const BitIStream in4(in3); + QVERIFY(in4.bitLength() == in3.bitLength()); + QVERIFY(in4.streamOffset() == in3.streamOffset()); + QVERIFY(in4.error() == StreamError::NoError); + } +} + +void tst_Hpack::bitstreamWrite() +{ + // Known representations, + // https://http2.github.io/http2-spec/compression.html. + // 5.1 Integer Representation + + // Test bit/byte lengths of the + // resulting data: + std::vector<uchar> buffer; + BitOStream out(buffer); + out.write(3); + // 11, fits into 8-bit prefix: + QVERIFY(out.bitLength() == 8); + QVERIFY(out.byteLength() == 1); + QVERIFY(out.begin()[0] == 3); + + out.clear(); + QVERIFY(out.bitLength() == 0); + QVERIFY(out.byteLength() == 0); + + // This number does not fit into 8-bit + // prefix we'll need 2 bytes: + out.write(256); + QVERIFY(out.byteLength() == 2); + QVERIFY(out.bitLength() == 16); + QVERIFY(out.begin()[0] == 0xff); + QVERIFY(out.begin()[1] == 1); + + out.clear(); + + // See 5.2 String Literal Representation. + + // We use Huffman code, + // char 'a' has a prefix code 00011 (5 bits) + out.write(QByteArray("aaa", 3), true); + QVERIFY(out.byteLength() == 3); + QVERIFY(out.bitLength() == 24); + // Now we must have in our stream: + // 10000010 | 00011000| 11000111 + const uchar *encoded = out.begin(); + QVERIFY(encoded[0] == 0x82); + QVERIFY(encoded[1] == 0x18); + QVERIFY(encoded[2] == 0xC7); + // TODO: add more tests ... +} + +void tst_Hpack::bitstreamReadWrite() +{ + // We can write into the bit stream: + // 1) bit patterns + // 2) integers (see HPACK, 5.1) + // 3) string (see HPACK, 5.2) + std::vector<uchar> buffer; + BitOStream out(buffer); + out.writeBits(0xf, 3); + QVERIFY(out.byteLength() == 1); + QVERIFY(out.bitLength() == 3); + + // Now, read it back: + { + BitIStream in(out.begin(), out.end()); + uchar bitPattern = 0; + const auto bitsRead = in.peekBits(0, 3, &bitPattern); + // peekBits pack into the most significant byte/bit: + QVERIFY(bitsRead == 3); + QVERIFY((bitPattern >> 5) == 7); + } + + const quint32 testInt = 133; + out.write(testInt); + + // This integer does not fit into the current 5-bit prefix, + // so byteLength == 2. + QVERIFY(out.byteLength() == 2); + const auto bitLength = out.bitLength(); + QVERIFY(bitLength > 3); + + // Now, read it back: + { + BitIStream in(out.begin(), out.end()); + in.skipBits(3); // Bit pattern + quint32 value = 0; + QVERIFY(in.read(&value)); + QVERIFY(in.error() == StreamError::NoError); + QCOMPARE(value, testInt); + } + + const QByteArray testString("ABCDE", 5); + out.write(testString, true); // Compressed + out.write(testString, false); // Non-compressed + QVERIFY(out.byteLength() > 2); + QVERIFY(out.bitLength() > bitLength); + + // Now, read it back: + { + BitIStream in(out.begin(), out.end()); + in.skipBits(bitLength); // Bit pattern and integer + QByteArray value; + // Read compressed string first ... + QVERIFY(in.read(&value)); + QCOMPARE(value, testString); + QCOMPARE(in.error(), StreamError::NoError); + // Now non-compressed ... + QVERIFY(in.read(&value)); + QCOMPARE(value, testString); + QCOMPARE(in.error(), StreamError::NoError); + } +} + +void tst_Hpack::bitstreamCompression() +{ + // Similar to bitstreamReadWrite but + // writes/reads a lot of mixed strings/integers. + std::vector<std::string> strings; + std::vector<quint32> integers; + std::vector<bool> isA; // integer or string. + const std::string bytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()[]/*"); + const unsigned nValues = 100000; + + quint64 totalStringBytes = 0; + std::vector<uchar> buffer; + BitOStream out(buffer); + for (unsigned i = 0; i < nValues; ++i) { + const bool isString = std::rand() % 1000 > 500; + isA.push_back(isString); + if (!isString) { + integers.push_back(std::rand() % 1000); + out.write(integers.back()); + } else { + const auto start = std::rand() % (bytes.length() / 2); + auto end = start * 2; + if (!end) + end = bytes.length() / 2; + strings.push_back(bytes.substr(start, end - start)); + const auto &s = strings.back(); + totalStringBytes += s.size(); + QByteArray data(s.c_str(), int(s.size())); + const bool compressed(std::rand() % 1000 > 500); + out.write(data, compressed); + } + } + + qDebug() << "Compressed(?) byte length:" << out.byteLength() + << "total string bytes:" << totalStringBytes; + qDebug() << "total integer bytes (for quint32):" << integers.size() * sizeof(quint32); + + QVERIFY(out.byteLength() > 0); + QVERIFY(out.bitLength() > 0); + + BitIStream in(out.begin(), out.end()); + + for (unsigned i = 0, iS = 0, iI = 0; i < nValues; ++i) { + if (isA[i]) { + QByteArray data; + QVERIFY(in.read(&data)); + QCOMPARE(in.error(), StreamError::NoError); + QCOMPARE(data.toStdString(), strings[iS]); + ++iS; + } else { + quint32 value = 0; + QVERIFY(in.read(&value)); + QCOMPARE(in.error(), StreamError::NoError); + QCOMPARE(value, integers[iI]); + ++iI; + } + } +} + +void tst_Hpack::bitstreamErrors() +{ + { + BitIStream in; + quint32 val = 0; + QVERIFY(!in.read(&val)); + QCOMPARE(in.error(), StreamError::NotEnoughData); + } + { + // Integer in a stream, that does not fit into quint32. + const uchar bytes[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + BitIStream in(bytes, bytes + sizeof bytes); + quint32 val = 0; + QVERIFY(!in.read(&val)); + QCOMPARE(in.error(), StreamError::InvalidInteger); + } + { + const uchar byte = 0x82; // 1 - Huffman compressed, 2 - the (fake) byte length. + BitIStream in(&byte, &byte + 1); + QByteArray val; + QVERIFY(!in.read(&val)); + QCOMPARE(in.error(), StreamError::NotEnoughData); + } +} + +void tst_Hpack::lookupTableConstructor() +{ + { + FieldLookupTable nonIndexed(4096, false); + QVERIFY(nonIndexed.dynamicDataSize() == 0); + QVERIFY(nonIndexed.numberOfDynamicEntries() == 0); + QVERIFY(nonIndexed.numberOfStaticEntries() != 0); + QVERIFY(nonIndexed.numberOfStaticEntries() == nonIndexed.numberOfEntries()); + // Now we add some fake field and verify what 'non-indexed' means ... no search + // by name. + QVERIFY(nonIndexed.prependField("custom-key", "custom-value")); + // 54: 10 + 12 in name/value pair above + 32 required by HPACK specs ... + QVERIFY(nonIndexed.dynamicDataSize() == 54); + QVERIFY(nonIndexed.numberOfDynamicEntries() == 1); + QCOMPARE(nonIndexed.numberOfEntries(), nonIndexed.numberOfStaticEntries() + 1); + // Should fail to find it (invalid index 0) - search is disabled. + QVERIFY(nonIndexed.indexOf("custom-key", "custom-value") == 0); + } + { + // "key" + "value" == 8 bytes, + 32 (HPACK's requirement) == 40. + // Let's ask for a max-size 32 so that entry does not fit: + FieldLookupTable nonIndexed(32, false); + QVERIFY(nonIndexed.prependField("key", "value")); + QVERIFY(nonIndexed.numberOfEntries() == nonIndexed.numberOfStaticEntries()); + QVERIFY(nonIndexed.indexOf("key", "value") == 0); + } + { + FieldLookupTable indexed(4096, true); + QVERIFY(indexed.dynamicDataSize() == 0); + QVERIFY(indexed.numberOfDynamicEntries() == 0); + QVERIFY(indexed.numberOfStaticEntries() != 0); + QVERIFY(indexed.numberOfStaticEntries() == indexed.numberOfEntries()); + QVERIFY(indexed.prependField("custom-key", "custom-value")); + QVERIFY(indexed.dynamicDataSize() == 54); + QVERIFY(indexed.numberOfDynamicEntries() == 1); + QVERIFY(indexed.numberOfEntries() == indexed.numberOfStaticEntries() + 1); + QVERIFY(indexed.indexOf("custom-key") == indexed.numberOfStaticEntries() + 1); + QVERIFY(indexed.indexOf("custom-key", "custom-value") == indexed.numberOfStaticEntries() + 1); + } +} + +void tst_Hpack::lookupTableStatic_data() +{ + QTest::addColumn<QByteArray>("expectedName"); + QTest::addColumn<QByteArray>("expectedValue"); + + // Some predefined fields to find + // (they are always defined/required by HPACK). + QTest::newRow(":authority|") << QByteArray(":authority") << QByteArray(""); + QTest::newRow(":method|GET") << QByteArray(":method") << QByteArray("GET"); + QTest::newRow(":method|POST") << QByteArray(":method") << QByteArray("POST"); + QTest::newRow(":path|/") << QByteArray(":path") << QByteArray("/"); + QTest::newRow(":path|/index.html") << QByteArray(":path") << QByteArray("/index.html"); + QTest::newRow(":scheme|http") << QByteArray(":scheme") << QByteArray("http"); + QTest::newRow(":scheme|https") << QByteArray(":scheme") << QByteArray("https"); + QTest::newRow(":status|200") << QByteArray(":status") << QByteArray("200"); + QTest::newRow(":status|204") << QByteArray(":status") << QByteArray("204"); + QTest::newRow(":status|206") << QByteArray(":status") << QByteArray("206"); + QTest::newRow(":status|304") << QByteArray(":status") << QByteArray("304"); + QTest::newRow(":status|400") << QByteArray(":status") << QByteArray("400"); + QTest::newRow(":status|404") << QByteArray(":status") << QByteArray("404"); + QTest::newRow(":status|500") << QByteArray(":status") << QByteArray("500"); +} + +void tst_Hpack::lookupTableStatic() +{ + const FieldLookupTable table(0, false /*all static, no need in 'search index'*/); + + QFETCH(QByteArray, expectedName); + QFETCH(QByteArray, expectedValue); + + const quint32 index = table.indexOf(expectedName, expectedValue); + QVERIFY(index != 0); + + QByteArray name, value; + QVERIFY(table.field(index, &name, &value)); + QCOMPARE(name, expectedName); + QCOMPARE(value, expectedValue); +} + +void tst_Hpack::lookupTableDynamic() +{ + // HPACK's table size: + // for every field -> size += field.name.length() + field.value.length() + 32. + // Let's set some size limit and try to fill table with enough entries to have several + // items evicted. + const quint32 tableSize = 8192; + const char stringData[] = "abcdefghijklmnopABCDEFGHIJKLMNOP0123456789()[]:"; + const quint32 dataSize = sizeof stringData - 1; + + FieldLookupTable table(tableSize, true); + + std::vector<QByteArray> fieldsToFind; + quint32 evicted = 0; + + while (true) { + // Strings are repeating way too often, I want to + // have at least some items really evicted and not found, + // therefore these weird dances with start/len. + const quint32 start = std::rand() % (dataSize - 10); + quint32 len = std::rand() % (dataSize - start); + if (!len) + len = 1; + + const QByteArray val(stringData + start, len); + fieldsToFind.push_back(val); + const quint32 entriesBefore = table.numberOfDynamicEntries(); + QVERIFY(table.prependField(val, val)); + QVERIFY(table.indexOf(val)); + QVERIFY(table.indexOf(val) == table.indexOf(val, val)); + QByteArray fieldName, fieldValue; + table.field(table.indexOf(val), &fieldName, &fieldValue); + + QVERIFY(val == fieldName); + QVERIFY(val == fieldValue); + + if (table.numberOfDynamicEntries() <= entriesBefore) { + // We had to evict several items ... + evicted += entriesBefore - table.numberOfDynamicEntries() + 1; + if (evicted >= 200) + break; + } + } + + QVERIFY(table.dynamicDataSize() <= tableSize); + QVERIFY(table.numberOfDynamicEntries() > 0); + QVERIFY(table.indexOf(fieldsToFind.back())); // We MUST have it in a table! + + using size_type = std::vector<QByteArray>::size_type; + for (size_type i = 0, e = fieldsToFind.size(); i < e; ++i) { + const auto &val = fieldsToFind[i]; + const quint32 index = table.indexOf(val); + if (!index) { + QVERIFY(i < size_type(evicted)); + } else { + QVERIFY(index == table.indexOf(val, val)); + QByteArray fieldName, fieldValue; + QVERIFY(table.field(index, &fieldName, &fieldValue)); + QVERIFY(val == fieldName); + QVERIFY(val == fieldValue); + } + } + + table.clearDynamicTable(); + + QVERIFY(table.numberOfDynamicEntries() == 0); + QVERIFY(table.dynamicDataSize() == 0); + QVERIFY(table.indexOf(fieldsToFind.back()) == 0); + + QVERIFY(table.prependField("name1", "value1")); + QVERIFY(table.prependField("name2", "value2")); + + QVERIFY(table.indexOf("name1") == table.numberOfStaticEntries() + 2); + QVERIFY(table.indexOf("name2", "value2") == table.numberOfStaticEntries() + 1); + QVERIFY(table.indexOf("name1", "value2") == 0); + QVERIFY(table.indexOf("name2", "value1") == 0); + QVERIFY(table.indexOf("name3") == 0); + + QVERIFY(!table.indexIsValid(table.numberOfEntries() + 1)); + + QVERIFY(table.prependField("name1", "value1")); + QVERIFY(table.numberOfDynamicEntries() == 3); + table.evictEntry(); + QVERIFY(table.indexOf("name1") != 0); + table.evictEntry(); + QVERIFY(table.indexOf("name2") == 0); + QVERIFY(table.indexOf("name1") != 0); + table.evictEntry(); + QVERIFY(table.dynamicDataSize() == 0); + QVERIFY(table.numberOfDynamicEntries() == 0); + QVERIFY(table.indexOf("name1") == 0); +} + +void tst_Hpack::hpackEncodeRequest_data() +{ + QTest::addColumn<bool>("compression"); + QTest::newRow("no-string-compression") << false; + QTest::newRow("with-string-compression") << true; +} + +void tst_Hpack::hpackEncodeRequest(bool withHuffman) +{ + // This function uses examples from HPACK specs + // (see appendix). + + Encoder encoder(4096, withHuffman); + // HPACK, C.3.1 First Request + /* + :method: GET + :scheme: http + :path: / + :authority: www.example.com + + Hex dump of encoded data (without Huffman): + + 8286 8441 0f77 7777 2e65 7861 6d70 6c65 | ...A.www.example + 2e63 6f6d + + Hex dump of encoded data (with Huffman): + + 8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff + */ + request1.clear(); + header1 = {{":method", "GET"}, + {":scheme", "http"}, + {":path", "/"}, + {":authority", "www.example.com"}}; + QVERIFY(encoder.encodeRequest(request1, header1)); + QVERIFY(encoder.dynamicTableSize() == 57); + + // HPACK, C.3.2 Second Request + /* + Header list to encode: + + :method: GET + :scheme: http + :path: / + :authority: www.example.com + cache-control: no-cache + + Hex dump of encoded data (without Huffman): + + 8286 84be 5808 6e6f 2d63 6163 6865 + + Hex dump of encoded data (with Huffman): + + 8286 84be 5886 a8eb 1064 9cbf + */ + + request2.clear(); + header2 = {{":method", "GET"}, + {":scheme", "http"}, + {":path", "/"}, + {":authority", "www.example.com"}, + {"cache-control", "no-cache"}}; + encoder.encodeRequest(request2, header2); + QVERIFY(encoder.dynamicTableSize() == 110); + + // HPACK, C.3.3 Third Request + /* + Header list to encode: + + :method: GET + :scheme: https + :path: /index.html + :authority: www.example.com + custom-key: custom-value + + Hex dump of encoded data (without Huffman): + + 8287 85bf 400a 6375 7374 6f6d 2d6b 6579 + 0c63 7573 746f 6d2d 7661 6c75 65 + + Hex dump of encoded data (with Huffman): + + 8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 + a849 e95b b8e8 b4bf + */ + request3.clear(); + header3 = {{":method", "GET"}, + {":scheme", "https"}, + {":path", "/index.html"}, + {":authority", "www.example.com"}, + {"custom-key", "custom-value"}}; + encoder.encodeRequest(request3, header3); + QVERIFY(encoder.dynamicTableSize() == 164); +} + +void tst_Hpack::hpackEncodeRequest() +{ + QFETCH(bool, compression); + + hpackEncodeRequest(compression); + + // See comments above about these hex dumps ... + const uchar bytes1NH[] = {0x82, 0x86, 0x84, 0x41, + 0x0f, 0x77, 0x77, 0x77, + 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x63, 0x6f, 0x6d}; + + const uchar bytes1WH[] = {0x82, 0x86, 0x84, 0x41, + 0x8c, 0xf1, 0xe3, 0xc2, + 0xe5, 0xf2, 0x3a, 0x6b, + 0xa0, 0xab, 0x90, 0xf4, + 0xff}; + + const uchar *hexDump1 = compression ? bytes1WH : bytes1NH; + const quint64 byteLength1 = compression ? sizeof bytes1WH : sizeof bytes1NH; + + QCOMPARE(request1.byteLength(), byteLength1); + QCOMPARE(request1.bitLength(), byteLength1 * 8); + + for (quint32 i = 0, e = request1.byteLength(); i < e; ++i) + QCOMPARE(hexDump1[i], request1.begin()[i]); + + const uchar bytes2NH[] = {0x82, 0x86, 0x84, 0xbe, + 0x58, 0x08, 0x6e, 0x6f, + 0x2d, 0x63, 0x61, 0x63, + 0x68, 0x65}; + + const uchar bytes2WH[] = {0x82, 0x86, 0x84, 0xbe, + 0x58, 0x86, 0xa8, 0xeb, + 0x10, 0x64, 0x9c, 0xbf}; + + const uchar *hexDump2 = compression ? bytes2WH : bytes2NH; + const auto byteLength2 = compression ? sizeof bytes2WH : sizeof bytes2NH; + QVERIFY(request2.byteLength() == byteLength2); + QVERIFY(request2.bitLength() == byteLength2 * 8); + for (quint32 i = 0, e = request2.byteLength(); i < e; ++i) + QCOMPARE(hexDump2[i], request2.begin()[i]); + + const uchar bytes3NH[] = {0x82, 0x87, 0x85, 0xbf, + 0x40, 0x0a, 0x63, 0x75, + 0x73, 0x74, 0x6f, 0x6d, + 0x2d, 0x6b, 0x65, 0x79, + 0x0c, 0x63, 0x75, 0x73, + 0x74, 0x6f, 0x6d, 0x2d, + 0x76, 0x61, 0x6c, 0x75, + 0x65}; + const uchar bytes3WH[] = {0x82, 0x87, 0x85, 0xbf, + 0x40, 0x88, 0x25, 0xa8, + 0x49, 0xe9, 0x5b, 0xa9, + 0x7d, 0x7f, 0x89, 0x25, + 0xa8, 0x49, 0xe9, 0x5b, + 0xb8, 0xe8, 0xb4, 0xbf}; + + const uchar *hexDump3 = compression ? bytes3WH : bytes3NH; + const quint64 byteLength3 = compression ? sizeof bytes3WH : sizeof bytes3NH; + QCOMPARE(request3.byteLength(), byteLength3); + QCOMPARE(request3.bitLength(), byteLength3 * 8); + for (quint32 i = 0, e = request3.byteLength(); i < e; ++i) + QCOMPARE(hexDump3[i], request3.begin()[i]); +} + +void tst_Hpack::hpackDecodeRequest_data() +{ + QTest::addColumn<bool>("compression"); + QTest::newRow("no-string-compression") << false; + QTest::newRow("with-string-compression") << true; +} + +void tst_Hpack::hpackDecodeRequest() +{ + QFETCH(bool, compression); + hpackEncodeRequest(compression); + + QVERIFY(request1.byteLength()); + QVERIFY(request2.byteLength()); + QVERIFY(request3.byteLength()); + + Decoder decoder(4096); + BitIStream inputStream1(request1.begin(), request1.end()); + QVERIFY(decoder.decodeHeaderFields(inputStream1)); + QCOMPARE(decoder.dynamicTableSize(), quint32(57)); + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header1); + } + + BitIStream inputStream2{request2.begin(), request2.end()}; + QVERIFY(decoder.decodeHeaderFields(inputStream2)); + QCOMPARE(decoder.dynamicTableSize(), quint32(110)); + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header2); + } + + BitIStream inputStream3(request3.begin(), request3.end()); + QVERIFY(decoder.decodeHeaderFields(inputStream3)); + QCOMPARE(decoder.dynamicTableSize(), quint32(164)); + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header3); + } +} + +void tst_Hpack::hpackEncodeResponse_data() +{ + hpackEncodeRequest_data(); +} + +void tst_Hpack::hpackEncodeResponse() +{ + QFETCH(bool, compression); + + hpackEncodeResponse(compression); + + // TODO: we can also test bytes - using hex dumps from HPACK's specs, + // for now only test a table behavior/expected sizes. +} + +void tst_Hpack::hpackEncodeResponse(bool withCompression) +{ + Encoder encoder(256, withCompression); // 256 - this will result in entries evicted. + + // HPACK, C.5.1 First Response + /* + Header list to encode: + + :status: 302 + cache-control: private + date: Mon, 21 Oct 2013 20:13:21 GMT + location: https://www.example.com + */ + request1.clear(); + header1 = {{":status", "302"}, + {"cache-control", "private"}, + {"date", "Mon, 21 Oct 2013 20:13:21 GMT"}, + {"location", "https://www.example.com"}}; + + QVERIFY(encoder.encodeResponse(request1, header1)); + QCOMPARE(encoder.dynamicTableSize(), quint32(222)); + + // HPACK, C.5.2 Second Response + /* + + + The (":status", "302") header field is evicted from the dynamic + table to free space to allow adding the (":status", "307") header field. + + Header list to encode: + + :status: 307 + cache-control: private + date: Mon, 21 Oct 2013 20:13:21 GMT + location: https://www.example.com + */ + request2.clear(); + header2 = {{":status", "307"}, + {"cache-control", "private"}, + {"date", "Mon, 21 Oct 2013 20:13:21 GMT"}, + {"location", "https://www.example.com"}}; + QVERIFY(encoder.encodeResponse(request2, header2)); + QCOMPARE(encoder.dynamicTableSize(), quint32(222)); + + // HPACK, C.5.3 Third Response + /* + Several header fields are evicted from the dynamic table + during the processing of this header list. + + Header list to encode: + + :status: 200 + cache-control: private + date: Mon, 21 Oct 2013 20:13:22 GMT + location: https://www.example.com + content-encoding: gzip + set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1 + */ + request3.clear(); + header3 = {{":status", "200"}, + {"cache-control", "private"}, + {"date", "Mon, 21 Oct 2013 20:13:22 GMT"}, + {"location", "https://www.example.com"}, + {"content-encoding", "gzip"}, + {"set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"}}; + QVERIFY(encoder.encodeResponse(request3, header3)); + QCOMPARE(encoder.dynamicTableSize(), quint32(215)); +} + +void tst_Hpack::hpackDecodeResponse_data() +{ + hpackEncodeRequest_data(); +} + +void tst_Hpack::hpackDecodeResponse() +{ + QFETCH(bool, compression); + + hpackEncodeResponse(compression); + + QVERIFY(request1.byteLength()); + Decoder decoder(256); // This size will result in entries evicted. + BitIStream inputStream1(request1.begin(), request1.end()); + QVERIFY(decoder.decodeHeaderFields(inputStream1)); + QCOMPARE(decoder.dynamicTableSize(), quint32(222)); + + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header1); + } + + QVERIFY(request2.byteLength()); + BitIStream inputStream2(request2.begin(), request2.end()); + QVERIFY(decoder.decodeHeaderFields(inputStream2)); + QCOMPARE(decoder.dynamicTableSize(), quint32(222)); + + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header2); + } + + QVERIFY(request3.byteLength()); + BitIStream inputStream3(request3.begin(), request3.end()); + QVERIFY(decoder.decodeHeaderFields(inputStream3)); + QCOMPARE(decoder.dynamicTableSize(), quint32(215)); + + { + const auto &decoded = decoder.decodedHeader(); + QVERIFY(decoded == header3); + } +} + +QTEST_MAIN(tst_Hpack) + +#include "tst_hpack.moc" diff --git a/tests/auto/network/access/http2/certs/fluke.cert b/tests/auto/network/access/http2/certs/fluke.cert new file mode 100644 index 0000000000..ace4e4f0eb --- /dev/null +++ b/tests/auto/network/access/http2/certs/fluke.cert @@ -0,0 +1,75 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com + Validity + Not Before: Dec 4 01:10:32 2007 GMT + Not After : Apr 21 01:10:32 2035 GMT + Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (1024 bit) + Modulus (1024 bit): + 00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1: + 1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11: + 21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3: + d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05: + aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45: + 84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91: + 02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91: + 5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c: + 3b:f6:45:f3:27:6a:9b:94:9d + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Netscape Comment: + OpenSSL Generated Certificate + X509v3 Subject Key Identifier: + 21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC + X509v3 Authority Key Identifier: + DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com + serial:8E:A8:B4:E8:91:B7:54:2E + + Signature Algorithm: sha1WithRSAEncryption + 6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4: + a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35: + 53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1: + a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1: + a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3: + 24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93: + ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42: + c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15: + 40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34: + 8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3: + b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34: + 7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35: + 31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d: + c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06: + ec:6a:f2:c3 +-----BEGIN CERTIFICATE----- +MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x +DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs +dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50 +cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe +Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w +CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE +ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN +b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY +SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd +AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM +IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv +Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV +BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB +U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u +bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR +t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ +AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp +nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8 ++JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN +XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx +kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD +-----END CERTIFICATE----- diff --git a/tests/auto/network/access/http2/certs/fluke.key b/tests/auto/network/access/http2/certs/fluke.key new file mode 100644 index 0000000000..9d1664d609 --- /dev/null +++ b/tests/auto/network/access/http2/certs/fluke.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ +VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1 +CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB +AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz +/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri +KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s +1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4 +VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE +oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW +A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub +K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c +VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC +AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/access/http2/http2.pro b/tests/auto/network/access/http2/http2.pro new file mode 100644 index 0000000000..e130f30784 --- /dev/null +++ b/tests/auto/network/access/http2/http2.pro @@ -0,0 +1,8 @@ +QT += core core-private network network-private testlib + +CONFIG += testcase parallel_test c++11 +TARGET = tst_http2 +HEADERS += http2srv.h +SOURCES += tst_http2.cpp http2srv.cpp + +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp new file mode 100755 index 0000000000..f919937fc3 --- /dev/null +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -0,0 +1,640 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtNetwork/private/http2protocol_p.h> +#include <QtNetwork/private/bitstreams_p.h> + +#include "http2srv.h" + +#ifndef QT_NO_SSL +#include <QtNetwork/qsslconfiguration.h> +#include <QtNetwork/qsslsocket.h> +#include <QtNetwork/qsslkey.h> +#endif + +#include <QtNetwork/qtcpsocket.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qlist.h> +#include <QtCore/qfile.h> + +#include <cstdlib> +#include <cstring> +#include <limits> + +QT_BEGIN_NAMESPACE + +using namespace Http2; +using namespace HPack; + +namespace +{ + +inline bool is_valid_client_stream(quint32 streamID) +{ + // A valid client stream ID is an odd integer number in the range [1, INT_MAX]. + return (streamID & 0x1) && streamID <= std::numeric_limits<qint32>::max(); +} + +} + +Http2Server::Http2Server(bool h2c, const Http2Settings &ss, const Http2Settings &cs) + : serverSettings(ss), + clearTextHTTP2(h2c) +{ + for (const auto &s : cs) + expectedClientSettings[quint16(s.identifier)] = s.value; + + responseBody = "<html>\n" + "<head>\n" + "<title>Sample \"Hello, World\" Application</title>\n" + "</head>\n" + "<body bgcolor=white>\n" + "<table border=\"0\" cellpadding=\"10\">\n" + "<tr>\n" + "<td>\n" + "<img src=\"images/springsource.png\">\n" + "</td>\n" + "<td>\n" + "<h1>Sample \"Hello, World\" Application</h1>\n" + "</td>\n" + "</tr>\n" + "</table>\n" + "<p>This is the home page for the HelloWorld Web application. </p>\n" + "</body>\n" + "</html>"; +} + +Http2Server::~Http2Server() +{ +} + +void Http2Server::setResponseBody(const QByteArray &body) +{ + responseBody = body; +} + +void Http2Server::startServer() +{ +#ifdef QT_NO_SSL + // Let the test fail with timeout. + if (!clearTextHTTP2) + return; +#endif + if (listen()) + emit serverStarted(serverPort()); +} + + +void Http2Server::sendServerSettings() +{ + Q_ASSERT(socket); + + if (!serverSettings.size()) + return; + + writer.start(FrameType::SETTINGS, FrameFlag::EMPTY, connectionStreamID); + for (const auto &s : serverSettings) { + writer.append(s.identifier); + writer.append(s.value); + if (s.identifier == Settings::INITIAL_WINDOW_SIZE_ID) + streamRecvWindowSize = s.value; + } + writer.write(*socket); + // Now, let's update our peer on a session recv window size: + const quint32 updatedSize = 10 * streamRecvWindowSize; + if (sessionRecvWindowSize < updatedSize) { + const quint32 delta = updatedSize - sessionRecvWindowSize; + sessionRecvWindowSize = updatedSize; + sessionCurrRecvWindow = updatedSize; + sendWINDOW_UPDATE(connectionStreamID, delta); + } + + waitingClientAck = true; + settingsSent = true; +} + +void Http2Server::sendGOAWAY(quint32 streamID, quint32 error, quint32 lastStreamID) +{ + Q_ASSERT(socket); + + writer.start(FrameType::GOAWAY, FrameFlag::EMPTY, streamID); + writer.append(lastStreamID); + writer.append(error); + writer.write(*socket); +} + +void Http2Server::sendRST_STREAM(quint32 streamID, quint32 error) +{ + Q_ASSERT(socket); + + writer.start(FrameType::RST_STREAM, FrameFlag::EMPTY, streamID); + writer.append(error); + writer.write(*socket); +} + +void Http2Server::sendDATA(quint32 streamID, quint32 windowSize) +{ + Q_ASSERT(socket); + + const auto it = suspendedStreams.find(streamID); + Q_ASSERT(it != suspendedStreams.end()); + + const quint32 offset = it->second; + Q_ASSERT(offset < quint32(responseBody.size())); + + const quint32 bytes = std::min<quint32>(windowSize, responseBody.size() - offset); + const quint32 frameSizeLimit(clientSetting(Settings::MAX_FRAME_SIZE_ID, Http2::maxFrameSize)); + const uchar *src = reinterpret_cast<const uchar *>(responseBody.constData() + offset); + const bool last = offset + bytes == quint32(responseBody.size()); + + writer.start(FrameType::DATA, FrameFlag::EMPTY, streamID); + writer.writeDATA(*socket, frameSizeLimit, src, bytes); + + if (last) { + writer.start(FrameType::DATA, FrameFlag::END_STREAM, streamID); + writer.setPayloadSize(0); + writer.write(*socket); + suspendedStreams.erase(it); + activeRequests.erase(streamID); + + Q_ASSERT(closedStreams.find(streamID) == closedStreams.end()); + closedStreams.insert(streamID); + } else { + it->second += bytes; + } +} + +void Http2Server::sendWINDOW_UPDATE(quint32 streamID, quint32 delta) +{ + Q_ASSERT(socket); + + writer.start(FrameType::WINDOW_UPDATE, FrameFlag::EMPTY, streamID); + writer.append(delta); + writer.write(*socket); +} + +void Http2Server::incomingConnection(qintptr socketDescriptor) +{ + if (clearTextHTTP2) { + socket.reset(new QTcpSocket); + const bool set = socket->setSocketDescriptor(socketDescriptor); + Q_UNUSED(set) Q_ASSERT(set); + // Stop listening: + close(); + QMetaObject::invokeMethod(this, "connectionEstablished", + Qt::QueuedConnection); + } else { +#ifndef QT_NO_SSL + socket.reset(new QSslSocket); + QSslSocket *sslSocket = static_cast<QSslSocket *>(socket.data()); + // Add HTTP2 as supported protocol: + auto conf = QSslConfiguration::defaultConfiguration(); + auto protos = conf.allowedNextProtocols(); + protos.prepend(QSslConfiguration::ALPNProtocolHTTP2); + conf.setAllowedNextProtocols(protos); + sslSocket->setSslConfiguration(conf); + // SSL-related setup ... + sslSocket->setPeerVerifyMode(QSslSocket::VerifyNone); + sslSocket->setProtocol(QSsl::TlsV1_2OrLater); + connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)), + this, SLOT(ignoreErrorSlot())); + QFile file(SRCDIR "certs/fluke.key"); + file.open(QIODevice::ReadOnly); + QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); + sslSocket->setPrivateKey(key); + auto localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); + sslSocket->setLocalCertificateChain(localCert); + sslSocket->setSocketDescriptor(socketDescriptor, QAbstractSocket::ConnectedState); + // Stop listening. + close(); + // Start SSL handshake and ALPN: + connect(sslSocket, SIGNAL(encrypted()), this, SLOT(connectionEstablished())); + sslSocket->startServerEncryption(); +#else + Q_UNREACHABLE(); +#endif + } +} + +quint32 Http2Server::clientSetting(Http2::Settings identifier, quint32 defaultValue) +{ + const auto it = expectedClientSettings.find(quint16(identifier)); + if (it != expectedClientSettings.end()) + return it->second; + return defaultValue; +} + +void Http2Server::connectionEstablished() +{ + using namespace Http2; + + connect(socket.data(), SIGNAL(readyRead()), + this, SLOT(readReady())); + + waitingClientPreface = true; + waitingClientAck = false; + waitingClientSettings = false; + settingsSent = false; + // We immediately send our settings so that our client + // can use flow control correctly. + sendServerSettings(); + + if (socket->bytesAvailable()) + readReady(); +} + +void Http2Server::ignoreErrorSlot() +{ +#ifndef QT_NO_SSL + static_cast<QSslSocket *>(socket.data())->ignoreSslErrors(); +#endif +} + +// Now HTTP2 "server" part: +/* +This code is overly simplified but it tests the basic HTTP2 expected behavior: +1. CONNECTION PREFACE +2. SETTINGS +3. sends our own settings (to modify the flow control) +4. collects and reports requests +5. if asked - sends responds to those requests +6. does some very basic error handling +7. tests frames validity/stream logic at the very basic level. +*/ + +void Http2Server::readReady() +{ + if (connectionError) + return; + + if (waitingClientPreface) { + handleConnectionPreface(); + } else { + const auto status = reader.read(*socket); + switch (status) { + case FrameStatus::incompleteFrame: + break; + case FrameStatus::goodFrame: + handleIncomingFrame(); + break; + default: + connectionError = true; + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + } + } + + if (socket->bytesAvailable()) + QMetaObject::invokeMethod(this, "readReady", Qt::QueuedConnection); +} + +void Http2Server::handleConnectionPreface() +{ + Q_ASSERT(waitingClientPreface); + + if (socket->bytesAvailable() < clientPrefaceLength) + return; // Wait for more data ... + + char buf[clientPrefaceLength] = {}; + socket->read(buf, clientPrefaceLength); + if (std::memcmp(buf, Http2clientPreface, clientPrefaceLength)) { + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + emit clientPrefaceError(); + connectionError = true; + return; + } + + waitingClientPreface = false; + waitingClientSettings = true; +} + +void Http2Server::handleIncomingFrame() +{ + // Frames that our implementation can send include: + // 1. SETTINGS (happens only during connection preface, + // handled already by this point) + // 2. SETTIGNS with ACK should be sent only as a response + // to a server's SETTINGS + // 3. HEADERS + // 4. CONTINUATION + // 5. DATA + // 6. PING + // 7. RST_STREAM + // 8. GOAWAY + + inboundFrame = std::move(reader.inboundFrame()); + + if (continuedRequest.size()) { + if (inboundFrame.type() != FrameType::CONTINUATION || + inboundFrame.streamID() != continuedRequest.front().streamID()) { + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + emit invalidFrame(); + connectionError = true; + return; + } + } + + switch (inboundFrame.type()) { + case FrameType::SETTINGS: + handleSETTINGS(); + break; + case FrameType::HEADERS: + case FrameType::CONTINUATION: + continuedRequest.push_back(std::move(inboundFrame)); + processRequest(); + break; + case FrameType::DATA: + handleDATA(); + break; + case FrameType::RST_STREAM: + // TODO: this is not tested for now. + break; + case FrameType::PING: + // TODO: this is not tested for now. + break; + case FrameType::GOAWAY: + // TODO: this is not tested for now. + break; + case FrameType::WINDOW_UPDATE: + handleWINDOW_UPDATE(); + break; + default:; + } +} + +void Http2Server::handleSETTINGS() +{ + // SETTINGS is either a part of the connection preface, + // or a SETTINGS ACK. + Q_ASSERT(inboundFrame.type() == FrameType::SETTINGS); + + if (inboundFrame.flags().testFlag(FrameFlag::ACK)) { + if (!waitingClientAck || inboundFrame.dataSize()) { + emit invalidFrame(); + connectionError = true; + waitingClientAck = false; + return; + } + + waitingClientAck = false; + emit serverSettingsAcked(); + return; + } + + // QHttp2ProtocolHandler always sends some settings, + // and the size is a multiple of 6. + if (!inboundFrame.dataSize() || inboundFrame.dataSize() % 6) { + sendGOAWAY(connectionStreamID, FRAME_SIZE_ERROR, connectionStreamID); + emit clientPrefaceError(); + connectionError = true; + return; + } + + const uchar *src = inboundFrame.dataBegin(); + const uchar *end = src + inboundFrame.dataSize(); + + const auto notFound = expectedClientSettings.end(); + + while (src != end) { + const auto id = qFromBigEndian<quint16>(src); + const auto value = qFromBigEndian<quint32>(src + 2); + if (expectedClientSettings.find(id) == notFound || + expectedClientSettings[id] != value) { + emit clientPrefaceError(); + connectionError = true; + return; + } + + src += 6; + } + + // Send SETTINGS ACK: + writer.start(FrameType::SETTINGS, FrameFlag::ACK, connectionStreamID); + writer.write(*socket); + waitingClientSettings = false; + emit clientPrefaceOK(); +} + +void Http2Server::handleDATA() +{ + Q_ASSERT(inboundFrame.type() == FrameType::DATA); + + const auto streamID = inboundFrame.streamID(); + + if (!is_valid_client_stream(streamID) || + closedStreams.find(streamID) != closedStreams.end()) { + emit invalidFrame(); + connectionError = true; + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + return; + } + + const auto payloadSize = inboundFrame.payloadSize(); + if (sessionCurrRecvWindow < payloadSize) { + // Client does not respect our session window size! + emit invalidRequest(streamID); + connectionError = true; + sendGOAWAY(connectionStreamID, FLOW_CONTROL_ERROR, connectionStreamID); + return; + } + + auto it = streamWindows.find(streamID); + if (it == streamWindows.end()) + it = streamWindows.insert(std::make_pair(streamID, streamRecvWindowSize)).first; + + + if (it->second < payloadSize) { + emit invalidRequest(streamID); + connectionError = true; + sendGOAWAY(connectionStreamID, FLOW_CONTROL_ERROR, connectionStreamID); + return; + } + + it->second -= payloadSize; + if (it->second < streamRecvWindowSize / 2) { + sendWINDOW_UPDATE(streamID, streamRecvWindowSize / 2); + it->second += streamRecvWindowSize / 2; + } + + sessionCurrRecvWindow -= payloadSize; + + if (sessionCurrRecvWindow < sessionRecvWindowSize / 2) { + // This is some quite naive and trivial logic on when to update. + + sendWINDOW_UPDATE(connectionStreamID, sessionRecvWindowSize / 2); + sessionCurrRecvWindow += sessionRecvWindowSize / 2; + } + + if (inboundFrame.flags().testFlag(FrameFlag::END_STREAM)) { + closedStreams.insert(streamID); // Enter "half-closed remote" state. + streamWindows.erase(it); + emit receivedData(streamID); + } +} + +void Http2Server::handleWINDOW_UPDATE() +{ + const auto streamID = inboundFrame.streamID(); + if (!streamID) // We ignore this for now to keep things simple. + return; + + if (streamID && suspendedStreams.find(streamID) == suspendedStreams.end()) { + if (closedStreams.find(streamID) == closedStreams.end()) { + sendRST_STREAM(streamID, PROTOCOL_ERROR); + emit invalidFrame(); + connectionError = true; + } + + return; + } + + const quint32 delta = qFromBigEndian<quint32>(inboundFrame.dataBegin()); + if (!delta || delta > quint32(std::numeric_limits<qint32>::max())) { + sendRST_STREAM(streamID, PROTOCOL_ERROR); + emit invalidFrame(); + connectionError = true; + return; + } + + emit windowUpdate(streamID); + sendDATA(streamID, delta); +} + +void Http2Server::sendResponse(quint32 streamID, bool emptyBody) +{ + Q_ASSERT(activeRequests.find(streamID) != activeRequests.end()); + + writer.start(FrameType::HEADERS, FrameFlag::END_HEADERS, streamID); + if (emptyBody) + writer.addFlag(FrameFlag::END_STREAM); + + HttpHeader header = {{":status", "200"}}; + if (!emptyBody) { + header.push_back(HPack::HeaderField("content-length", + QString("%1").arg(responseBody.size()).toLatin1())); + } + + HPack::BitOStream ostream(writer.outboundFrame().buffer); + const bool result = encoder.encodeResponse(ostream, header); + Q_ASSERT(result); + Q_UNUSED(result) + + const quint32 maxFrameSize(clientSetting(Settings::MAX_FRAME_SIZE_ID, Http2::maxFrameSize)); + writer.writeHEADERS(*socket, maxFrameSize); + + if (!emptyBody) { + Q_ASSERT(suspendedStreams.find(streamID) == suspendedStreams.end()); + + const quint32 windowSize = clientSetting(Settings::INITIAL_WINDOW_SIZE_ID, + Http2::defaultSessionWindowSize); + // Suspend to immediately resume it. + suspendedStreams[streamID] = 0; // start sending from offset 0 + sendDATA(streamID, windowSize); + } else { + activeRequests.erase(streamID); + closedStreams.insert(streamID); + } +} + +void Http2Server::processRequest() +{ + Q_ASSERT(continuedRequest.size()); + + if (!continuedRequest.back().flags().testFlag(FrameFlag::END_HEADERS)) + return; + + // We test here: + // 1. stream is 'idle'. + // 2. has priority set and dependency (it's 0x0 at the moment). + // 3. header can be decompressed. + const auto &headersFrame = continuedRequest.front(); + const auto streamID = headersFrame.streamID(); + if (!is_valid_client_stream(streamID)) { + emit invalidRequest(streamID); + connectionError = true; + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + return; + } + + if (closedStreams.find(streamID) != closedStreams.end()) { + emit invalidFrame(); + connectionError = true; + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + return; + } + + quint32 dep = 0; + uchar w = 0; + if (!headersFrame.priority(&dep, &w)) { + emit invalidFrame(); + sendRST_STREAM(streamID, PROTOCOL_ERROR); + return; + } + + // Assemble headers ... + quint32 totalSize = 0; + for (const auto &frame : continuedRequest) { + if (std::numeric_limits<quint32>::max() - frame.dataSize() < totalSize) { + // Resulted in overflow ... + emit invalidFrame(); + connectionError = true; + sendGOAWAY(connectionStreamID, PROTOCOL_ERROR, connectionStreamID); + return; + } + totalSize += frame.dataSize(); + } + + std::vector<uchar> hpackBlock(totalSize); + auto dst = hpackBlock.begin(); + for (const auto &frame : continuedRequest) { + if (!frame.dataSize()) + continue; + std::copy(frame.dataBegin(), frame.dataBegin() + frame.dataSize(), dst); + dst += frame.dataSize(); + } + + HPack::BitIStream inputStream{&hpackBlock[0], &hpackBlock[0] + hpackBlock.size()}; + + if (!decoder.decodeHeaderFields(inputStream)) { + emit decompressionFailed(streamID); + sendRST_STREAM(streamID, COMPRESSION_ERROR); + closedStreams.insert(streamID); + return; + } + + // Actually, if needed, we can do a comparison here. + activeRequests[streamID] = decoder.decodedHeader(); + if (headersFrame.flags().testFlag(FrameFlag::END_STREAM)) + emit receivedRequest(streamID); + // else - we're waiting for incoming DATA frames ... + continuedRequest.clear(); +} + +QT_END_NAMESPACE diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h new file mode 100755 index 0000000000..73b1d80f8e --- /dev/null +++ b/tests/auto/network/access/http2/http2srv.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HTTP2SRV_H +#define HTTP2SRV_H + +#include <QtNetwork/private/http2protocol_p.h> +#include <QtNetwork/private/http2frames_p.h> +#include <QtNetwork/private/hpack_p.h> + +#include <QtNetwork/qabstractsocket.h> +#include <QtCore/qscopedpointer.h> +#include <QtNetwork/qtcpserver.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qglobal.h> + +#include <vector> +#include <map> +#include <set> + +QT_BEGIN_NAMESPACE + +struct Http2Setting +{ + Http2::Settings identifier; + quint32 value = 0; + + Http2Setting(Http2::Settings ident, quint32 v) + : identifier(ident), + value(v) + {} +}; + +using Http2Settings = std::vector<Http2Setting>; + +class Http2Server : public QTcpServer +{ + Q_OBJECT +public: + Http2Server(bool clearText, const Http2Settings &serverSettings, + const Http2Settings &clientSettings); + + ~Http2Server(); + + // To be called before server started: + void setResponseBody(const QByteArray &body); + + // Invokables, since we can call them from the main thread, + // but server (can) work on its own thread. + Q_INVOKABLE void startServer(); + Q_INVOKABLE void sendServerSettings(); + Q_INVOKABLE void sendGOAWAY(quint32 streamID, quint32 error, + quint32 lastStreamID); + Q_INVOKABLE void sendRST_STREAM(quint32 streamID, quint32 error); + Q_INVOKABLE void sendDATA(quint32 streamID, quint32 windowSize); + Q_INVOKABLE void sendWINDOW_UPDATE(quint32 streamID, quint32 delta); + + Q_INVOKABLE void handleConnectionPreface(); + Q_INVOKABLE void handleIncomingFrame(); + Q_INVOKABLE void handleSETTINGS(); + Q_INVOKABLE void handleDATA(); + Q_INVOKABLE void handleWINDOW_UPDATE(); + + Q_INVOKABLE void sendResponse(quint32 streamID, bool emptyBody); + +private: + void processRequest(); + +Q_SIGNALS: + void serverStarted(quint16 port); + // Error/success notifications: + void clientPrefaceOK(); + void clientPrefaceError(); + void serverSettingsAcked(); + void invalidFrame(); + void invalidRequest(quint32 streamID); + void decompressionFailed(quint32 streamID); + void receivedRequest(quint32 streamID); + void receivedData(quint32 streamID); + void windowUpdate(quint32 streamID); + +private slots: + void connectionEstablished(); + void readReady(); + +private: + void incomingConnection(qintptr socketDescriptor) Q_DECL_OVERRIDE; + + quint32 clientSetting(Http2::Settings identifier, quint32 defaultValue); + + QScopedPointer<QAbstractSocket> socket; + + // Connection preface: + bool waitingClientPreface = false; + bool waitingClientSettings = false; + bool settingsSent = false; + bool waitingClientAck = false; + + Http2Settings serverSettings; + std::map<quint16, quint32> expectedClientSettings; + + bool connectionError = false; + + Http2::FrameReader reader; + Http2::Frame inboundFrame; + Http2::FrameWriter writer; + + using FrameSequence = std::vector<Http2::Frame>; + FrameSequence continuedRequest; + + std::map<quint32, quint32> streamWindows; + + HPack::Decoder decoder{HPack::FieldLookupTable::DefaultSize}; + HPack::Encoder encoder{HPack::FieldLookupTable::DefaultSize, true}; + + using Http2Requests = std::map<quint32, HPack::HttpHeader>; + Http2Requests activeRequests; + // 'remote half-closed' streams to keep + // track of streams with END_STREAM set: + std::set<quint32> closedStreams; + // streamID + offset in response body to send. + std::map<quint32, quint32> suspendedStreams; + + // We potentially reset this once (see sendServerSettings) + // and do not change later: + quint32 sessionRecvWindowSize = Http2::defaultSessionWindowSize; + // This changes in the range [0, sessionRecvWindowSize] + // while handling DATA frames: + quint32 sessionCurrRecvWindow = sessionRecvWindowSize; + // This we potentially update only once (sendServerSettings). + quint32 streamRecvWindowSize = Http2::defaultSessionWindowSize; + + QByteArray responseBody; + bool clearTextHTTP2 = false; + +protected slots: + void ignoreErrorSlot(); +}; + +QT_END_NAMESPACE + +#endif + diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp new file mode 100644 index 0000000000..582a103b2e --- /dev/null +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -0,0 +1,441 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include "http2srv.h" + +#include <QtNetwork/qnetworkaccessmanager.h> +#include <QtNetwork/qnetworkrequest.h> +#include <QtNetwork/qnetworkreply.h> +#include <QtCore/qglobal.h> +#include <QtCore/qobject.h> +#include <QtCore/qthread.h> +#include <QtCore/qurl.h> + +#ifndef QT_NO_SSL +#ifndef QT_NO_OPENSSL +#include <QtNetwork/private/qsslsocket_openssl_symbols_p.h> +#endif // NO_OPENSSL +#endif // NO_SSL + + +#include <cstdlib> + +// At the moment our HTTP/2 imlpementation requires ALPN and this means OpenSSL. +#if !defined(QT_NO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_TLSEXT) +const bool clearTextHTTP2 = false; +#else +const bool clearTextHTTP2 = true; +#endif + +QT_BEGIN_NAMESPACE + +class tst_Http2 : public QObject +{ + Q_OBJECT +public: + tst_Http2(); + ~tst_Http2(); +private slots: + // Tests: + void singleRequest(); + void multipleRequests(); + void flowControlClientSide(); + void flowControlServerSide(); + +protected slots: + // Slots to listen to our in-process server: + void serverStarted(quint16 port); + void clientPrefaceOK(); + void clientPrefaceError(); + void serverSettingsAcked(); + void invalidFrame(); + void invalidRequest(quint32 streamID); + void decompressionFailed(quint32 streamID); + void receivedRequest(quint32 streamID); + void receivedData(quint32 streamID); + void windowUpdated(quint32 streamID); + void replyFinished(); + +private: + void clearHTTP2State(); + // Run event for 'ms' milliseconds. + // The default value '5000' is enough for + // small payload. + void runEventLoop(int ms = 5000); + void stopEventLoop(); + // TODO: different parameters like client/server settings ... + Http2Server *newServer(const Http2Settings &serverSettings); + // Send a get or post request, depending on a payload (empty or not). + void sendRequest(int streamNumber, + QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority, + const QByteArray &payload = QByteArray()); + + quint16 serverPort = 0; + QThread *workerThread = nullptr; + QNetworkAccessManager manager; + + QEventLoop eventLoop; + QTimer timer; + + int nRequests = 0; + + int windowUpdates = 0; + bool prefaceOK = false; + bool serverGotSettingsACK = false; + + static const Http2Settings defaultServerSettings; +}; + +const Http2Settings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; + +tst_Http2::tst_Http2() + : workerThread(new QThread) +{ + workerThread->start(); + + timer.setInterval(10000); + timer.setSingleShot(true); + + connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); +} + +tst_Http2::~tst_Http2() +{ + workerThread->quit(); + workerThread->wait(5000); + + if (workerThread->isFinished()) { + delete workerThread; + } else { + connect(workerThread, &QThread::finished, + workerThread, &QThread::deleteLater); + } +} + +void tst_Http2::singleRequest() +{ + clearHTTP2State(); + + serverPort = 0; + nRequests = 1; + + auto srv = newServer(defaultServerSettings); + + QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection); + runEventLoop(); + + QVERIFY(serverPort != 0); + + const QString urlAsString(clearTextHTTP2 ? QString("http://127.0.0.1:%1/index.html") + : QString("https://127.0.0.1:%1/index.html")); + const QUrl url(urlAsString.arg(serverPort)); + + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); + + auto reply = manager.get(request); + connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); + // Since we're using self-signed certificates, + // ignore SSL errors: + reply->ignoreSslErrors(); + + runEventLoop(); + + QVERIFY(nRequests == 0); + QVERIFY(prefaceOK); + QVERIFY(serverGotSettingsACK); + + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(reply->isFinished()); + + QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection); +} + +void tst_Http2::multipleRequests() +{ + clearHTTP2State(); + + serverPort = 0; + nRequests = 10; + + auto srv = newServer(defaultServerSettings); + + QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection); + + runEventLoop(); + QVERIFY(serverPort != 0); + + // Just to make the order a bit more interesting + // we'll index this randomly: + QNetworkRequest::Priority priorities[] = {QNetworkRequest::HighPriority, + QNetworkRequest::NormalPriority, + QNetworkRequest::LowPriority}; + + + + for (int i = 0; i < nRequests; ++i) + sendRequest(i, priorities[std::rand() % 3]); + + runEventLoop(); + + QVERIFY(nRequests == 0); + QVERIFY(prefaceOK); + QVERIFY(serverGotSettingsACK); + + QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection); +} + +void tst_Http2::flowControlClientSide() +{ + // Create a server but impose limits: + // 1. Small MAX frame size, so we test CONTINUATION frames. + // 2. Small client windows so server responses cause client streams + // to suspend and server sends WINDOW_UPDATE frames. + // 3. Few concurrent streams, to test protocol handler can resume + // suspended requests. + using namespace Http2; + + clearHTTP2State(); + + serverPort = 0; + nRequests = 10; + windowUpdates = 0; + + const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 3}}; + + auto srv = newServer(serverSettings); + + const QByteArray respond(int(Http2::defaultSessionWindowSize * 50), 'x'); + srv->setResponseBody(respond); + + QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection); + + runEventLoop(); + QVERIFY(serverPort != 0); + + for (int i = 0; i < nRequests; ++i) + sendRequest(i); + + runEventLoop(120000); + + QVERIFY(nRequests == 0); + QVERIFY(prefaceOK); + QVERIFY(serverGotSettingsACK); + QVERIFY(windowUpdates > 0); + + QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection); +} + +void tst_Http2::flowControlServerSide() +{ + // Quite aggressive test: + // low MAX_FRAME_SIZE forces a lot of small DATA frames, + // payload size exceedes stream/session RECV window sizes + // so that our implementation should deal with WINDOW_UPDATE + // on a session/stream level correctly + resume/suspend streams + // to let all replies finish without any error. + using namespace Http2; + + clearHTTP2State(); + + serverPort = 0; + nRequests = 30; + + const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; + + auto srv = newServer(serverSettings); + + const QByteArray payload(int(Http2::defaultSessionWindowSize * 500), 'x'); + + QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection); + + runEventLoop(); + QVERIFY(serverPort != 0); + + for (int i = 0; i < nRequests; ++i) + sendRequest(i, QNetworkRequest::NormalPriority, payload); + + runEventLoop(120000); + + QVERIFY(nRequests == 0); + QVERIFY(prefaceOK); + QVERIFY(serverGotSettingsACK); + + QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection); + srv = nullptr; +} + +void tst_Http2::serverStarted(quint16 port) +{ + serverPort = port; + stopEventLoop(); +} + +void tst_Http2::clearHTTP2State() +{ + windowUpdates = 0; + prefaceOK = false; + serverGotSettingsACK = false; +} + +void tst_Http2::runEventLoop(int ms) +{ + timer.setInterval(ms); + timer.start(); + eventLoop.exec(); +} + +void tst_Http2::stopEventLoop() +{ + timer.stop(); + eventLoop.quit(); +} + +Http2Server *tst_Http2::newServer(const Http2Settings &serverSettings) +{ + using namespace Http2; + // Client's settings are fixed by qhttp2protocolhandler. + const Http2Settings clientSettings = {{Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)}, + {Settings::ENABLE_PUSH_ID, quint32(0)}}; + auto srv = new Http2Server(clearTextHTTP2, serverSettings, clientSettings); + + using Srv = Http2Server; + using Cl = tst_Http2; + + connect(srv, &Srv::serverStarted, this, &Cl::serverStarted); + connect(srv, &Srv::clientPrefaceOK, this, &Cl::clientPrefaceOK); + connect(srv, &Srv::clientPrefaceError, this, &Cl::clientPrefaceError); + connect(srv, &Srv::serverSettingsAcked, this, &Cl::serverSettingsAcked); + connect(srv, &Srv::invalidFrame, this, &Cl::invalidFrame); + connect(srv, &Srv::invalidRequest, this, &Cl::invalidRequest); + connect(srv, &Srv::receivedRequest, this, &Cl::receivedRequest); + connect(srv, &Srv::receivedData, this, &Cl::receivedData); + connect(srv, &Srv::windowUpdate, this, &Cl::windowUpdated); + + srv->moveToThread(workerThread); + + return srv; +} + +void tst_Http2::sendRequest(int streamNumber, + QNetworkRequest::Priority priority, + const QByteArray &payload) +{ + static const QString urlAsString(clearTextHTTP2 ? "http://127.0.0.1:%1/stream%2.html" + : "https://127.0.0.1:%1/stream%2.html"); + + const QUrl url(urlAsString.arg(serverPort).arg(streamNumber)); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); + request.setPriority(priority); + + QNetworkReply *reply = nullptr; + if (payload.size()) + reply = manager.post(request, payload); + else + reply = manager.get(request); + + reply->ignoreSslErrors(); + connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); +} + +void tst_Http2::clientPrefaceOK() +{ + prefaceOK = true; +} + +void tst_Http2::clientPrefaceError() +{ + prefaceOK = false; +} + +void tst_Http2::serverSettingsAcked() +{ + serverGotSettingsACK = true; +} + +void tst_Http2::invalidFrame() +{ +} + +void tst_Http2::invalidRequest(quint32 streamID) +{ + Q_UNUSED(streamID) +} + +void tst_Http2::decompressionFailed(quint32 streamID) +{ + Q_UNUSED(streamID) +} + +void tst_Http2::receivedRequest(quint32 streamID) +{ + qDebug() << " server got a request on stream" << streamID; + Http2Server *srv = qobject_cast<Http2Server *>(sender()); + Q_ASSERT(srv); + QMetaObject::invokeMethod(srv, "sendResponse", Qt::QueuedConnection, + Q_ARG(quint32, streamID), + Q_ARG(bool, false /*non-empty body*/)); +} + +void tst_Http2::receivedData(quint32 streamID) +{ + qDebug() << " server got a 'POST' request on stream" << streamID; + Http2Server *srv = qobject_cast<Http2Server *>(sender()); + Q_ASSERT(srv); + QMetaObject::invokeMethod(srv, "sendResponse", Qt::QueuedConnection, + Q_ARG(quint32, streamID), + Q_ARG(bool, true /*HEADERS only*/)); +} + +void tst_Http2::windowUpdated(quint32 streamID) +{ + Q_UNUSED(streamID) + + ++windowUpdates; +} + +void tst_Http2::replyFinished() +{ + QVERIFY(nRequests); + + if (const auto reply = qobject_cast<QNetworkReply *>(sender())) + QCOMPARE(reply->error(), QNetworkReply::NoError); + + --nRequests; + if (!nRequests) + stopEventLoop(); +} + +QT_END_NAMESPACE + +QTEST_MAIN(tst_Http2) + +#include "tst_http2.moc" diff --git a/tests/auto/network/access/qftp/qftp.pro b/tests/auto/network/access/qftp/qftp.pro index 4294f27e74..1959c1acac 100644 --- a/tests/auto/network/access/qftp/qftp.pro +++ b/tests/auto/network/access/qftp/qftp.pro @@ -2,12 +2,5 @@ CONFIG += testcase TARGET = tst_qftp SOURCES += tst_qftp.cpp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core network network-private testlib - -wince { - addFiles.files = rfc3252.txt - addFiles.path = . - DEPLOYMENT += addFiles -} - diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index edeb471401..a13fa86405 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -276,14 +276,9 @@ void tst_QFtp::init() inFileDirExistsFunction = false; -#if !defined(Q_OS_WINCE) srand(time(0)); uniqueExtension = QString::number((quintptr)this) + QString::number(rand()) + QString::number((qulonglong)time(0)); -#else - srand(0); - uniqueExtension = QString::number((quintptr)this) + QString::number(rand()) + QLatin1Char('0'); -#endif } void tst_QFtp::cleanup() @@ -1353,11 +1348,7 @@ void tst_QFtp::abort_data() QTest::newRow( "get_fluke02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/rfc3252") << QByteArray(); // Qt/CE test environment has too little memory for this test -#if !defined(Q_OS_WINCE) QByteArray bigData( 10*1024*1024, 0 ); -#else - QByteArray bigData( 1*1024*1024, 0 ); -#endif bigData.fill( 'B' ); QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData; } diff --git a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro index bd20fd33dd..d32b651b86 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qhttpnetworkconnection SOURCES += tst_qhttpnetworkconnection.cpp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core-private network-private testlib diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index ef742aaa9a..84766f5484 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -151,14 +151,7 @@ void tst_QHttpNetworkConnection::head() QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Head); QHttpNetworkReply *reply = connection.sendRequest(request); - QTime stopWatch; - stopWatch.start(); - do { - QCoreApplication::instance()->processEvents(); - if (stopWatch.elapsed() >= 30000) - break; - } while (!reply->isFinished()); - + QTRY_VERIFY_WITH_TIMEOUT(reply->isFinished(), 30000); QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); // only check it if it is set and expected @@ -208,15 +201,7 @@ void tst_QHttpNetworkConnection::get() QHttpNetworkRequest request(protocol + host + path); QHttpNetworkReply *reply = connection.sendRequest(request); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (stopWatch.elapsed() >= 30000) - break; - } + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable(), 30000); QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); @@ -224,17 +209,8 @@ void tst_QHttpNetworkConnection::get() if (reply->contentLength() != -1 && contentLength != -1) QCOMPARE(reply->contentLength(), qint64(contentLength)); - stopWatch.start(); - QByteArray ba; - do { - QCoreApplication::instance()->processEvents(); - while (reply->bytesAvailable()) - ba += reply->readAny(); - if (stopWatch.elapsed() >= 30000) - break; - } while (!reply->isFinished()); - - QVERIFY(reply->isFinished()); + QTRY_VERIFY_WITH_TIMEOUT(reply->isFinished(), 30000); + QByteArray ba = reply->readAll(); //do not require server generated error pages to be a fixed size if (downloadSize != -1) QCOMPARE(ba.size(), downloadSize); @@ -303,13 +279,7 @@ void tst_QHttpNetworkConnection::put() connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); - QTime stopWatch; - stopWatch.start(); - do { - QCoreApplication::instance()->processEvents(); - if (stopWatch.elapsed() >= 30000) - break; - } while (!reply->isFinished() && !finishedCalled && !finishedWithErrorCalled); + QTRY_VERIFY_WITH_TIMEOUT(reply->isFinished() || finishedCalled || finishedWithErrorCalled, 30000); if (reply->isFinished()) { QByteArray ba; @@ -385,16 +355,7 @@ void tst_QHttpNetworkConnection::post() QHttpNetworkReply *reply = connection.sendRequest(request); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (stopWatch.elapsed() >= 30000) - break; - } - + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable(), 30000); QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); @@ -411,17 +372,8 @@ void tst_QHttpNetworkConnection::post() } } - stopWatch.start(); - QByteArray ba; - do { - QCoreApplication::instance()->processEvents(); - while (reply->bytesAvailable()) - ba += reply->readAny(); - if (stopWatch.elapsed() >= 30000) - break; - } while (!reply->isFinished()); - - QVERIFY(reply->isFinished()); + QTRY_VERIFY_WITH_TIMEOUT(reply->isFinished(), 30000); + QByteArray ba = reply->readAll(); //don't require fixed size for generated error pages if (downloadSize != -1) QCOMPARE(ba.size(), downloadSize); @@ -536,17 +488,7 @@ void tst_QHttpNetworkConnection::get401() connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (finishedCalled) - break; - if (finishedWithErrorCalled) - break; - if (stopWatch.elapsed() >= 30000) - break; - } + QTRY_VERIFY_WITH_TIMEOUT(finishedCalled || finishedWithErrorCalled, 30000); QCOMPARE(reply->statusCode(), statusCode); delete reply; } @@ -595,16 +537,8 @@ void tst_QHttpNetworkConnection::compression() if (!autoCompress) request.setHeaderField("Accept-Encoding", contentCoding.toLatin1()); QHttpNetworkReply *reply = connection.sendRequest(request); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (stopWatch.elapsed() >= 30000) - break; - } + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable(), 30000); QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); bool isLengthOk = (reply->contentLength() == qint64(contentLength) @@ -613,17 +547,8 @@ void tst_QHttpNetworkConnection::compression() QVERIFY(isLengthOk); - stopWatch.start(); - QByteArray ba; - do { - QCoreApplication::instance()->processEvents(); - while (reply->bytesAvailable()) - ba += reply->readAny(); - if (stopWatch.elapsed() >= 30000) - break; - } while (!reply->isFinished()); - - QVERIFY(reply->isFinished()); + QTRY_VERIFY_WITH_TIMEOUT(reply->isFinished(), 30000); + QByteArray ba = reply->readAll(); QCOMPARE(ba.size(), downloadSize); delete reply; @@ -694,17 +619,7 @@ void tst_QHttpNetworkConnection::ignoresslerror() connect(reply, SIGNAL(finished()), SLOT(finishedReply())); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (statusCode == 100 && finishedWithErrorCalled) - break; - if (stopWatch.elapsed() >= 30000) - break; - } + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable() || (statusCode == 100 && finishedWithErrorCalled), 30000); QCOMPARE(reply->statusCode(), statusCode); delete reply; } @@ -746,15 +661,7 @@ void tst_QHttpNetworkConnection::nossl() connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (finishedWithErrorCalled) - break; - if (stopWatch.elapsed() >= 30000) - break; - } + QTRY_VERIFY_WITH_TIMEOUT(finishedWithErrorCalled, 30000); QCOMPARE(netErrorCode, networkError); delete reply; } @@ -774,6 +681,15 @@ void tst_QHttpNetworkConnection::getMultiple_data() QTest::newRow("1 connection, pipelining allowed, 100 requests") << quint16(1) << true << 100; } +static bool allRepliesFinished(const QList<QHttpNetworkReply*> *_replies) +{ + const QList<QHttpNetworkReply*> &replies = *_replies; + for (int i = 0; i < replies.length(); i++) + if (!replies.at(i)->isFinished()) + return false; + return true; +} + void tst_QHttpNetworkConnection::getMultiple() { QFETCH(quint16, connectionCount); @@ -797,27 +713,7 @@ void tst_QHttpNetworkConnection::getMultiple() replies.append(reply); } - QTime stopWatch; - stopWatch.start(); - int finishedCount = 0; - do { - QCoreApplication::instance()->processEvents(); - if (stopWatch.elapsed() >= 60000) - break; - - finishedCount = 0; - for (int i = 0; i < replies.length(); i++) - if (replies.at(i)->isFinished()) - finishedCount++; - - } while (finishedCount != replies.length()); - - // redundant - for (int i = 0; i < replies.length(); i++) - QVERIFY(replies.at(i)->isFinished()); - - qDebug() << "===" << stopWatch.elapsed() << "msec ==="; - + QTRY_VERIFY_WITH_TIMEOUT(allRepliesFinished(&replies), 60000); qDeleteAll(requests); qDeleteAll(replies); } @@ -854,24 +750,10 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( replies.append(reply); } - QTime stopWatch; - stopWatch.start(); - int finishedCount = 0; - do { - QCoreApplication::instance()->processEvents(); - if (stopWatch.elapsed() >= 60000) - break; - - finishedCount = 0; - for (int i = 0; i < replies.length(); i++) - if (replies.at(i)->isFinished()) - finishedCount++; - - } while (finishedCount != replies.length()); + QTRY_VERIFY_WITH_TIMEOUT(allRepliesFinished(&replies), 60000); int pipelinedCount = 0; for (int i = 0; i < replies.length(); i++) { - QVERIFY(replies.at(i)->isFinished()); QVERIFY (!(replies.at(i)->request().isPipeliningAllowed() == false && replies.at(i)->isPipeliningUsed())); @@ -885,8 +767,6 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( // requests had been pipelined) QVERIFY(pipelinedCount >= requestCount / 2); - qDebug() << "===" << stopWatch.elapsed() << "msec ==="; - qDeleteAll(requests); qDeleteAll(replies); } @@ -1062,17 +942,7 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject() QHttpNetworkReply *reply = connection->sendRequest(request); reply->setDownstreamLimited(true); - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (stopWatch.elapsed() >= 30000) - break; - } - - QVERIFY(reply->bytesAvailable()); + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable(), 30000); QCOMPARE(reply->statusCode() ,200); QVERIFY(!reply->isFinished()); // must not be finished diff --git a/tests/auto/network/access/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/network/access/qhttpnetworkreply/qhttpnetworkreply.pro index 1810a38f6e..31570e6f01 100644 --- a/tests/auto/network/access/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/network/access/qhttpnetworkreply/qhttpnetworkreply.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qhttpnetworkreply SOURCES += tst_qhttpnetworkreply.cpp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core-private network-private testlib diff --git a/tests/auto/network/access/qnetworkreply/qnetworkreply.pro b/tests/auto/network/access/qnetworkreply/qnetworkreply.pro index bd10c77252..d3a92436ac 100644 --- a/tests/auto/network/access/qnetworkreply/qnetworkreply.pro +++ b/tests/auto/network/access/qnetworkreply/qnetworkreply.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -!winrt:!wince: SUBDIRS += echo +!winrt:SUBDIRS += echo test.depends += $$SUBDIRS SUBDIRS += test diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 772bb55990..47e7f5ed15 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -10,7 +10,7 @@ RESOURCES += ../qnetworkreply.qrc TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ ../index.html ../smb-file.txt -contains(QT_CONFIG,xcb): CONFIG+=insignificant_test # unstable, QTBUG-21102 +qtConfig(xcb): CONFIG+=insignificant_test # unstable, QTBUG-21102 win32:CONFIG += insignificant_test # QTBUG-24226 !winrt: TEST_HELPER_INSTALLS = ../echo/echo diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 93bdbdd6a5..43e05c95f9 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -205,6 +205,7 @@ private Q_SLOTS: void invalidProtocol(); void getFromData_data(); void getFromData(); + void getFromFile_data(); void getFromFile(); void getFromFileSpecial_data(); void getFromFileSpecial(); @@ -650,8 +651,10 @@ private slots: #endif void slotError(QAbstractSocket::SocketError err) { - Q_ASSERT(!client.isNull()); - qDebug() << "slotError" << err << client->errorString(); + if (client.isNull()) + qDebug() << "slotError" << err; + else + qDebug() << "slotError" << err << client->errorString(); } public slots: @@ -1674,14 +1677,26 @@ void tst_QNetworkReply::getFromData() QCOMPARE(reply->readAll(), expected); } +void tst_QNetworkReply::getFromFile_data() +{ + QTest::addColumn<bool>("backgroundAttribute"); + + QTest::newRow("no-background-attribute") << false; + QTest::newRow("background-attribute") << true; +} + void tst_QNetworkReply::getFromFile() { + QFETCH(bool, backgroundAttribute); + // create the file: QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX"); file.setAutoRemove(true); QVERIFY2(file.open(), qPrintable(file.errorString())); QNetworkRequest request(QUrl::fromLocalFile(file.fileName())); + if (backgroundAttribute) + request.setAttribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(true)); QNetworkReplyPtr reply; static const char fileData[] = "This is some data that is in the file.\r\n"; @@ -1691,6 +1706,7 @@ void tst_QNetworkReply::getFromFile() QCOMPARE(file.size(), qint64(data.size())); RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply)); + QVERIFY(waitForFinish(reply) != Timeout); QCOMPARE(reply->url(), request.url()); QCOMPARE(reply->error(), QNetworkReply::NoError); @@ -4319,9 +4335,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QSKIP("No qprocess support", SkipAll); #else -#if defined(Q_OS_WINCE) - QSKIP("Currently no stdin/out supported for Windows CE"); -#else #ifdef Q_OS_WIN if (qstrcmp(QTest::currentDataTag(), "small") == 0) QSKIP("When passing a CR-LF-LF sequence through Windows stdio, it gets converted, " @@ -4355,7 +4368,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QCOMPARE(file.size(), qint64(data.size())); QByteArray contents = file.readAll(); QCOMPARE(contents, data); -#endif #endif // QT_NO_PROCESS } @@ -6328,17 +6340,7 @@ void tst_QNetworkReply::getAndThenDeleteObject() reply->setReadBufferSize(1); reply->setParent((QObject*)0); // must be 0 because else it is the manager - QTime stopWatch; - stopWatch.start(); - forever { - QCoreApplication::instance()->processEvents(); - if (reply->bytesAvailable()) - break; - if (stopWatch.elapsed() >= 30000) - break; - } - - QVERIFY(reply->bytesAvailable()); + QTRY_VERIFY_WITH_TIMEOUT(reply->bytesAvailable(), 30000); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QVERIFY(!reply->isFinished()); // must not be finished @@ -6561,12 +6563,7 @@ void tst_QNetworkReply::getFromHttpIntoBuffer2() QFETCH(bool, useDownloadBuffer); // On my Linux Desktop the results are already visible with 128 kB, however we use this to have good results. -#if defined(Q_OS_WINCE_WM) - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else enum {UploadSize = 32*1024*1024}; // 32 MB -#endif GetFromHttpIntoBuffer2Server server(UploadSize, true, false); @@ -7892,10 +7889,6 @@ void tst_QNetworkReply::backgroundRequestInterruption() QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); QVERIFY(reply->isFinished()); -#ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("ftp, bg, nobg", "See QTBUG-32435", Abort); -#endif QCOMPARE(reply->error(), error); #endif } diff --git a/tests/auto/network/kernel/kernel.pro b/tests/auto/network/kernel/kernel.pro index bb13c7dd7d..42df80dfa1 100644 --- a/tests/auto/network/kernel/kernel.pro +++ b/tests/auto/network/kernel/kernel.pro @@ -7,6 +7,7 @@ SUBDIRS=\ qauthenticator \ qnetworkproxy \ qnetworkinterface \ + qnetworkdatagram \ qnetworkaddressentry \ qhostaddress \ @@ -17,7 +18,7 @@ winrt: SUBDIRS -= \ osx: SUBDIRS -= \ # QTBUG-41847 qhostinfo \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qauthenticator \ qhostinfo \ diff --git a/tests/auto/network/kernel/qauthenticator/qauthenticator.pro b/tests/auto/network/kernel/qauthenticator/qauthenticator.pro index 5e4759b690..5038eea9af 100644 --- a/tests/auto/network/kernel/qauthenticator/qauthenticator.pro +++ b/tests/auto/network/kernel/qauthenticator/qauthenticator.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qauthenticator -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core network-private testlib SOURCES += tst_qauthenticator.cpp DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro index 19d74dfd9b..a79fa2f59d 100644 --- a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro +++ b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro @@ -5,10 +5,4 @@ SOURCES += tst_qhostaddress.cpp QT = core network testlib -win32: { -wince { - LIBS += -lws2 -} else { - LIBS += -lws2_32 -} -} +win32:LIBS += -lws2_32 diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index 4fb97fe1f2..419c781aab 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -62,6 +62,8 @@ private slots: void specialAddresses(); void compare_data(); void compare(); + void isEqual_data(); + void isEqual(); void assignment(); void scopeId(); void hashKey(); @@ -291,6 +293,7 @@ void tst_QHostAddress::compare_data() QTest::newRow("5") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::Broadcast) << false; QTest::newRow("6") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << false; QTest::newRow("7") << QHostAddress() << QHostAddress(QHostAddress::LocalHostIPv6) << false; + QTest::newRow("any4-any6") << QHostAddress(QHostAddress::AnyIPv4) << QHostAddress(QHostAddress::AnyIPv6) << false; Q_IPV6ADDR localhostv4mapped = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 } }; QTest::newRow("v4-v4mapped") << QHostAddress(QHostAddress::LocalHost) << QHostAddress("::ffff:127.0.0.1") << false; @@ -309,6 +312,53 @@ void tst_QHostAddress::compare() QCOMPARE(qHash(first), qHash(second)); } +void tst_QHostAddress::isEqual_data() +{ + QTest::addColumn<QHostAddress>("first"); + QTest::addColumn<QHostAddress>("second"); + QTest::addColumn<int>("flags"); + QTest::addColumn<bool>("result"); + + // QHostAddress::StrictConversion is already tested in compare() + QTest::newRow("localhost4to6-local") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertLocalHost << true; + QTest::newRow("localhost4to6-compat") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertV4CompatToIPv4 << false; + QTest::newRow("localhost4to6-mapped") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertV4MappedToIPv4 << false; + QTest::newRow("localhost4to6-unspec") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertUnspecifiedAddress << false; + QTest::newRow("0.0.0.1-::1-local") << QHostAddress("0.0.0.1") << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("v4-v4compat-local") << QHostAddress("192.168.1.1") << QHostAddress("::192.168.1.1") << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("v4-v4mapped-local") << QHostAddress("192.168.1.1") << QHostAddress("::ffff:192.168.1.1") << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("0.0.0.1-::1-unspec") << QHostAddress("0.0.0.1") << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertUnspecifiedAddress << false; + QTest::newRow("v4-v4compat-unspec") << QHostAddress("192.168.1.1") << QHostAddress("::192.168.1.1") << (int)QHostAddress::ConvertUnspecifiedAddress << false; + QTest::newRow("v4-v4mapped-unspec") << QHostAddress("192.168.1.1") << QHostAddress("::ffff:192.168.1.1") << (int)QHostAddress::ConvertUnspecifiedAddress << false; + QTest::newRow("0.0.0.1-::1-compat") << QHostAddress("0.0.0.1") << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertV4CompatToIPv4 << false; + QTest::newRow("v4-v4compat-compat") << QHostAddress("192.168.1.1") << QHostAddress("::192.168.1.1") << (int)QHostAddress::ConvertV4CompatToIPv4 << true; + QTest::newRow("v4-v4mapped-compat") << QHostAddress("192.168.1.1") << QHostAddress("::ffff:192.168.1.1") << (int)QHostAddress::ConvertV4CompatToIPv4 << false; + QTest::newRow("0.0.0.1-::1-mapped") << QHostAddress("0.0.0.1") << QHostAddress(QHostAddress::LocalHostIPv6) << (int)QHostAddress::ConvertV4MappedToIPv4 << false; + QTest::newRow("v4-v4compat-mapped") << QHostAddress("192.168.1.1") << QHostAddress("::192.168.1.1") << (int)QHostAddress::ConvertV4MappedToIPv4 << false; + QTest::newRow("v4-v4mapped-mapped") << QHostAddress("192.168.1.1") << QHostAddress("::FFFF:192.168.1.1") << (int)QHostAddress::ConvertV4MappedToIPv4 << true; + QTest::newRow("undef-any-local") << QHostAddress() << QHostAddress(QHostAddress::Any) << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("undef-any-unspec") << QHostAddress() << QHostAddress(QHostAddress::Any) << (int)QHostAddress::ConvertUnspecifiedAddress << false; + QTest::newRow("anyv6-anyv4-compat") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertV4CompatToIPv4 << true; + QTest::newRow("anyv6-anyv4-mapped") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertV4MappedToIPv4 << false; + QTest::newRow("anyv6-anyv4-unspec") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertUnspecifiedAddress << true; + QTest::newRow("any-anyv4-unspec") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertUnspecifiedAddress << true; + QTest::newRow("any-anyv6-unspec") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::ConvertUnspecifiedAddress << true; + QTest::newRow("anyv6-anyv4-local") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("any-anyv4-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4) << (int)QHostAddress::ConvertLocalHost << false; + QTest::newRow("any-anyv6-local") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv6) << (int)QHostAddress::ConvertLocalHost << false; +} + +void tst_QHostAddress::isEqual() +{ + QFETCH(QHostAddress, first); + QFETCH(QHostAddress, second); + QFETCH(int, flags); + QFETCH(bool, result); + + QCOMPARE(first.isEqual(second, QHostAddress::ConversionModeFlag(flags)), result); + QCOMPARE(second.isEqual(first, QHostAddress::ConversionModeFlag(flags)), result); +} + void tst_QHostAddress::assignment() { QHostAddress address; diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index 12858c97ee..67a37faeb5 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -3,14 +3,10 @@ TARGET = tst_qhostinfo SOURCES += tst_qhostinfo.cpp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core-private network-private testlib -wince { - LIBS += ws2.lib -} else { - win32:LIBS += -lws2_32 -} +win32:LIBS += -lws2_32 # needed for getaddrinfo with official MinGW mingw:DEFINES += _WIN32_WINNT=0x0501 diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 13d4442ada..f6d9b71aa2 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -66,11 +66,7 @@ #include "private/qhostinfo_p.h" #if !defined(QT_NO_GETADDRINFO) -# if !defined(Q_OS_WINCE) # include <sys/types.h> -# else -# include <types.h> -# endif # if defined(Q_OS_UNIX) # include <sys/socket.h> # endif @@ -399,11 +395,7 @@ protected: void tst_QHostInfo::threadSafety() { const int nattempts = 5; -#if defined(Q_OS_WINCE) - const int runs = 10; -#else const int runs = 100; -#endif LookupThread thr[nattempts]; for (int j = 0; j < runs; ++j) { for (int i = 0; i < nattempts; ++i) diff --git a/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro new file mode 100644 index 0000000000..a2fe44060e --- /dev/null +++ b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro @@ -0,0 +1,5 @@ +CONFIG += testcase console +CONFIG -= app_bundle +TARGET = tst_qnetworkdatagram +SOURCES += tst_qnetworkdatagram.cpp +QT = core network testlib diff --git a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp new file mode 100644 index 0000000000..3295580432 --- /dev/null +++ b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QNetworkDatagram> +#include <QtTest> +#include <QCoreApplication> + +class tst_QNetworkDatagram : public QObject +{ + Q_OBJECT + +public: + tst_QNetworkDatagram(); + +private Q_SLOTS: + void getSetCheck(); + void makeReply_data(); + void makeReply(); +}; + +tst_QNetworkDatagram::tst_QNetworkDatagram() +{ +} + +void tst_QNetworkDatagram::getSetCheck() +{ + QNetworkDatagram dg; + + QVERIFY(dg.isNull()); + QVERIFY(!dg.isValid()); + QCOMPARE(dg.senderAddress(), QHostAddress()); + QCOMPARE(dg.destinationAddress(), QHostAddress()); + QCOMPARE(dg.senderPort(), -1); + QCOMPARE(dg.destinationPort(), -1); + QCOMPARE(dg.hopLimit(), -1); + QCOMPARE(dg.interfaceIndex(), 0U); + + dg.setHopLimit(1); + QCOMPARE(dg.hopLimit(), 1); + dg.setHopLimit(255); + QCOMPARE(dg.hopLimit(), 255); + + dg.setInterfaceIndex(1); + QCOMPARE(dg.interfaceIndex(), 1U); + dg.setInterfaceIndex(1234567U); + QCOMPARE(dg.interfaceIndex(), 1234567U); + + dg.setSender(QHostAddress::Any, 12345); + QCOMPARE(dg.senderAddress(), QHostAddress(QHostAddress::Any)); + QCOMPARE(dg.senderPort(), 12345); + dg.setSender(QHostAddress::LocalHost); + QCOMPARE(dg.senderAddress(), QHostAddress(QHostAddress::LocalHost)); + QCOMPARE(dg.senderPort(), 0); + + dg.setDestination(QHostAddress::LocalHostIPv6, 12345); + QCOMPARE(dg.destinationAddress(), QHostAddress(QHostAddress::LocalHostIPv6)); + QCOMPARE(dg.destinationPort(), 12345); + dg.setDestination(QHostAddress::Broadcast, 137); + QCOMPARE(dg.destinationAddress(), QHostAddress(QHostAddress::Broadcast)); + QCOMPARE(dg.destinationPort(), 137); +} + +void tst_QNetworkDatagram::makeReply_data() +{ + qRegisterMetaType<QNetworkDatagram>(); + QTest::addColumn<QNetworkDatagram>("dgram"); + QTest::addColumn<QString>("localAddress"); + + QNetworkDatagram dgram("some data", QHostAddress("192.0.2.1"), 10001); + dgram.setHopLimit(64); + dgram.setSender(QHostAddress::LocalHost, 12345); + QTest::newRow("ipv4") << dgram << "192.0.2.1"; + + dgram.setDestination(QHostAddress("224.0.0.1"), 10002); + QTest::newRow("ipv4-multicast") << dgram << QString(); + + dgram.setSender(QHostAddress::LocalHostIPv6, 12346); + dgram.setDestination(QHostAddress("2001:db8::1"), 12347); + QTest::newRow("ipv6") << dgram << "2001:db8::1"; + + dgram.setSender(QHostAddress("fe80::1%1"), 10003); + dgram.setDestination(QHostAddress("fe80::2%1"), 10004); + dgram.setInterfaceIndex(1); + QTest::newRow("ipv6-linklocal") << dgram << "fe80::2%1"; + + dgram.setDestination(QHostAddress("ff02::1%1"), 10005); + QTest::newRow("ipv6-multicast") << dgram << QString(); +} + +void tst_QNetworkDatagram::makeReply() +{ + QFETCH(QNetworkDatagram, dgram); + QFETCH(QString, localAddress); + + { + QNetworkDatagram reply = dgram.makeReply("World"); + QCOMPARE(reply.data(), QByteArray("World")); + QCOMPARE(reply.senderAddress(), QHostAddress(localAddress)); + QCOMPARE(reply.senderPort(), localAddress.isEmpty() ? -1 : dgram.destinationPort()); + QCOMPARE(reply.destinationAddress(), dgram.senderAddress()); + QCOMPARE(reply.destinationPort(), dgram.senderPort()); + QCOMPARE(reply.interfaceIndex(), dgram.interfaceIndex()); + QCOMPARE(reply.hopLimit(), -1); + } + + QNetworkDatagram copy = dgram; + copy.setData(copy.data()); + { + QNetworkDatagram reply = qMove(copy).makeReply("World"); + QCOMPARE(reply.data(), QByteArray("World")); + QCOMPARE(reply.senderAddress(), QHostAddress(localAddress)); + QCOMPARE(reply.senderPort(), localAddress.isEmpty() ? -1 : dgram.destinationPort()); + QCOMPARE(reply.destinationAddress(), dgram.senderAddress()); + QCOMPARE(reply.destinationPort(), dgram.senderPort()); + QCOMPARE(reply.interfaceIndex(), dgram.interfaceIndex()); + QCOMPARE(reply.hopLimit(), -1); + } +} + +QTEST_MAIN(tst_QNetworkDatagram) +#include "tst_qnetworkdatagram.moc" diff --git a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri index a3b4e89450..46c722deba 100644 --- a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri +++ b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri @@ -4,15 +4,9 @@ QNETWORK_SRC = $$QT_SOURCE_TREE/src/network INCLUDEPATH += $$QNETWORK_SRC -win32 { - wince { - LIBS += -lws2 - } else { - LIBS += -lws2_32 - } -} +win32:LIBS += -lws2_32 -unix:contains(QT_CONFIG, reduce_exports) { +unix:qtConfig(reduce_exports) { SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine_unix.cpp SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine.cpp SOURCES += $$QNETWORK_SRC/socket/qabstractsocketengine.cpp diff --git a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pro b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pro index eee762037d..ab96bb444e 100644 --- a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pro +++ b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pro @@ -4,7 +4,7 @@ SOURCES += tst_platformsocketengine.cpp include(../platformsocketengine/platformsocketengine.pri) -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) MOC_DIR=tmp diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index b3ecd884cd..43b5422635 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -495,9 +495,6 @@ void tst_PlatformSocketEngine::readWriteBufferSize() qint64 bufferSize = device.receiveBufferSize(); QVERIFY(bufferSize != -1); device.setReceiveBufferSize(bufferSize + 1); -#if defined(Q_OS_WINCE) - QEXPECT_FAIL(0, "Not supported by default on WinCE", Continue); -#endif QVERIFY(device.receiveBufferSize() > bufferSize); bufferSize = device.sendBufferSize(); @@ -607,8 +604,8 @@ void tst_PlatformSocketEngine::invalidSend() PLATFORMSOCKETENGINE socket; QVERIFY(socket.initialize(QAbstractSocket::TcpSocket)); - QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was" - " called by a socket other than QAbstractSocket::UdpSocket"); + QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was called" + " not in QAbstractSocket::BoundState or QAbstractSocket::ConnectedState"); QCOMPARE(socket.writeDatagram("hei", 3, QIpPacketHeader(QHostAddress::LocalHost, 143)), (qlonglong) -1); } @@ -650,7 +647,7 @@ void tst_PlatformSocketEngine::receiveUrgentData() QByteArray response; // Native OOB data test doesn't work on HP-UX or WinCE -#if !defined(Q_OS_HPUX) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_HPUX) // The server sends an urgent message msg = 'Q'; QCOMPARE(int(::send(socketDescriptor, &msg, sizeof(msg), MSG_OOB)), 1); diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 12ce576e23..56a4fb8aee 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -7,6 +7,6 @@ include(../platformsocketengine/platformsocketengine.pri) MOC_DIR=tmp -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT = core-private network-private testlib diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 7237542e5c..68f3ea059b 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -626,11 +626,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QTime stopWatch; stopWatch.start(); -#if defined(Q_OS_WINCE) - QTestEventLoop::instance().enterLoop(240); -#else QTestEventLoop::instance().enterLoop(60); -#endif if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); diff --git a/tests/auto/network/socket/qlocalsocket/test/test.pro b/tests/auto/network/socket/qlocalsocket/test/test.pro index 6a5df7f9b6..ab9ed90b1d 100644 --- a/tests/auto/network/socket/qlocalsocket/test/test.pro +++ b/tests/auto/network/socket/qlocalsocket/test/test.pro @@ -2,13 +2,7 @@ CONFIG += testcase DEFINES += QLOCALSERVER_DEBUG DEFINES += QLOCALSOCKET_DEBUG - -wince* { - DEFINES += QT_LOCALSOCKET_TCP - DEFINES += SRCDIR=\\\"../\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/../\\\" -} +DEFINES += SRCDIR=\\\"$$PWD/../\\\" QT = core network testlib diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 17d7697f94..8cc06a77ba 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -868,10 +868,8 @@ void tst_QLocalSocket::threadedConnection_data() QTest::newRow("1 client") << 1; QTest::newRow("2 clients") << 2; QTest::newRow("5 clients") << 5; -#ifndef Q_OS_WINCE QTest::newRow("10 clients") << 10; QTest::newRow("20 clients") << 20; -#endif } void tst_QLocalSocket::threadedConnection() diff --git a/tests/auto/network/socket/qsctpsocket/qsctpsocket.pro b/tests/auto/network/socket/qsctpsocket/qsctpsocket.pro new file mode 100644 index 0000000000..49a40ce9b5 --- /dev/null +++ b/tests/auto/network/socket/qsctpsocket/qsctpsocket.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qsctpsocket +QT = core network testlib + +SOURCES += tst_qsctpsocket.cpp + diff --git a/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp new file mode 100644 index 0000000000..fc976fbd0d --- /dev/null +++ b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp @@ -0,0 +1,488 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QDebug> +#include <QEventLoop> +#include <QByteArray> +#include <QString> +#include <QHostAddress> +#include <QHostInfo> +#include <QNetworkInterface> +#include <QTime> + +#include <QSctpSocket> +#include <QSctpServer> + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/sctp.h> + +#define SOCKET int +#define INVALID_SOCKET -1 + +class tst_QSctpSocket : public QObject +{ + Q_OBJECT + +public: + static void enterLoop(int secs) + { + ++loopLevel; + QTestEventLoop::instance().enterLoop(secs); + --loopLevel; + } + static void exitLoop() + { + // Safe exit - if we aren't in an event loop, don't + // exit one. + if (loopLevel > 0) + QTestEventLoop::instance().exitLoop(); + } + static bool timeout() + { + return QTestEventLoop::instance().timeout(); + } + +private slots: + void constructing(); + void bind_data(); + void bind(); + void setInvalidSocketDescriptor(); + void setSocketDescriptor(); + void socketDescriptor(); + void hostNotFound(); + void connecting(); + void readAndWrite(); + void loop_data(); + void loop(); + void loopInTCPMode_data(); + void loopInTCPMode(); + void readDatagramAfterClose(); + void clientSendDataOnDelayedDisconnect(); + +protected slots: + void exitLoopSlot(); + +private: + static int loopLevel; +}; + +int tst_QSctpSocket::loopLevel = 0; + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::constructing() +{ + QSctpSocket socket; + + // Check the initial state of the QSctpSocket. + QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); + QVERIFY(socket.isSequential()); + QVERIFY(!socket.isOpen()); + QVERIFY(!socket.isValid()); + QCOMPARE(socket.socketType(), QAbstractSocket::SctpSocket); + QCOMPARE(socket.maxChannelCount(), 0); + QCOMPARE(socket.readChannelCount(), 0); + QCOMPARE(socket.writeChannelCount(), 0); + + char c; + QCOMPARE(socket.getChar(&c), false); + QCOMPARE(socket.bytesAvailable(), Q_INT64_C(0)); + QCOMPARE(socket.canReadLine(), false); + QCOMPARE(socket.readLine(), QByteArray()); + QCOMPARE(socket.socketDescriptor(), qintptr(-1)); + QCOMPARE(int(socket.localPort()), 0); + QVERIFY(socket.localAddress() == QHostAddress()); + QCOMPARE(int(socket.peerPort()), 0); + QVERIFY(socket.peerAddress() == QHostAddress()); + QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); + QCOMPARE(socket.errorString(), QString("Unknown error")); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::bind_data() +{ + QTest::addColumn<QString>("stringAddr"); + QTest::addColumn<bool>("successExpected"); + QTest::addColumn<QString>("stringExpectedLocalAddress"); + + // iterate all interfaces, add all addresses on them as test data + QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); + for (const QNetworkInterface &interface : interfaces) { + if (!interface.isValid()) + continue; + + for (const QNetworkAddressEntry &entry : interface.addressEntries()) { + if (entry.ip().isInSubnet(QHostAddress::parseSubnet("fe80::/10")) + || entry.ip().isInSubnet(QHostAddress::parseSubnet("169.254/16"))) + continue; // link-local bind will fail, at least on Linux, so skip it. + + QString ip(entry.ip().toString()); + QTest::newRow(ip.toLatin1().constData()) << ip << true << ip; + } + } + + // additionally, try bind to known-bad addresses, and make sure this doesn't work + // these ranges are guaranteed to be reserved for 'documentation purposes', + // and thus, should be unused in the real world. Not that I'm assuming the + // world is full of competent administrators, or anything. + QStringList knownBad; + knownBad << "198.51.100.1"; + knownBad << "2001:0DB8::1"; + foreach (const QString &badAddress, knownBad) { + QTest::newRow(badAddress.toLatin1().constData()) << badAddress << false << QString(); + } +} + +// Testing bind function +void tst_QSctpSocket::bind() +{ + QFETCH(QString, stringAddr); + QFETCH(bool, successExpected); + QFETCH(QString, stringExpectedLocalAddress); + + QHostAddress addr(stringAddr); + QHostAddress expectedLocalAddress(stringExpectedLocalAddress); + + QSctpSocket socket; + qDebug() << "Binding " << addr; + + if (successExpected) + QVERIFY2(socket.bind(addr), qPrintable(socket.errorString())); + else + QVERIFY(!socket.bind(addr)); + + QCOMPARE(socket.localAddress(), expectedLocalAddress); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::setInvalidSocketDescriptor() +{ + QSctpSocket socket; + QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET)); + QVERIFY(!socket.setSocketDescriptor(-5, QAbstractSocket::UnconnectedState)); + QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET)); + + QCOMPARE(socket.error(), QAbstractSocket::UnsupportedSocketOperationError); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::setSocketDescriptor() +{ + QSctpServer server; + + server.setMaxChannelCount(16); + QVERIFY(server.listen()); + + SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); + + QVERIFY(sock != INVALID_SOCKET); + QSctpSocket socket; + QVERIFY(socket.setSocketDescriptor(sock, QAbstractSocket::UnconnectedState)); + QCOMPARE(socket.socketDescriptor(), qintptr(sock)); + QCOMPARE(socket.readChannelCount(), 0); + QCOMPARE(socket.writeChannelCount(), 0); + + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(socket.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + + QCOMPARE(socket.readChannelCount(), server.maxChannelCount()); + QVERIFY(socket.writeChannelCount() <= server.maxChannelCount()); + + QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection(); + QVERIFY(acceptedSocket); + QCOMPARE(acceptedSocket->readChannelCount(), socket.writeChannelCount()); + QCOMPARE(acceptedSocket->writeChannelCount(), socket.readChannelCount()); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::socketDescriptor() +{ + QSctpSocket socket; + + QSctpServer server; + + QVERIFY(server.listen()); + + QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET)); + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(server.waitForNewConnection(3000)); + if (socket.state() != QAbstractSocket::ConnectedState) { + QVERIFY((socket.state() == QAbstractSocket::HostLookupState + && socket.socketDescriptor() == INVALID_SOCKET) + || socket.state() == QAbstractSocket::ConnectingState); + QVERIFY(socket.waitForConnected(3000)); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + } + QVERIFY(socket.socketDescriptor() != INVALID_SOCKET); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::hostNotFound() +{ + QSctpSocket socket; + + socket.connectToHost("nosuchserver.qt-project.org", 80); + QVERIFY(!socket.waitForConnected(3000)); + QCOMPARE(socket.state(), QTcpSocket::UnconnectedState); + QCOMPARE(socket.error(), QAbstractSocket::HostNotFoundError); +} + +// Testing connect function +void tst_QSctpSocket::connecting() +{ + QSctpServer server; + + QVERIFY(server.listen()); + + QSctpSocket socket; + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(socket.waitForConnected(3000)); + + QVERIFY(server.waitForNewConnection(3000)); + QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection(); + QVERIFY(acceptedSocket); + + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + QCOMPARE(acceptedSocket->state(), QAbstractSocket::ConnectedState); + QCOMPARE(socket.readChannelCount(), acceptedSocket->readChannelCount()); + QCOMPARE(socket.writeChannelCount(),acceptedSocket->writeChannelCount()); +} + +// Testing read/write functions +void tst_QSctpSocket::readAndWrite() +{ + QSctpServer server; + + QVERIFY(server.listen()); + + QSctpSocket socket; + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(socket.waitForConnected(3000)); + + QVERIFY(server.waitForNewConnection(3000)); + QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection(); + QVERIFY(acceptedSocket); + + QByteArray ba(1000, 1); + QVERIFY(acceptedSocket->writeDatagram(ba)); + QVERIFY(acceptedSocket->waitForBytesWritten(3000)); + + QVERIFY(socket.waitForReadyRead(3000)); + QNetworkDatagram datagram = socket.readDatagram(); + QVERIFY(datagram.isValid()); + QCOMPARE(datagram.data(), ba); + + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError); + QCOMPARE(socket.errorString(), QString("Unknown error")); + QCOMPARE(acceptedSocket->state(), QAbstractSocket::ConnectedState); + QCOMPARE(acceptedSocket->error(), QAbstractSocket::UnknownSocketError); + QCOMPARE(acceptedSocket->errorString(), QString("Unknown error")); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::loop_data() +{ + QTest::addColumn<QByteArray>("peterDatagram"); + QTest::addColumn<QByteArray>("paulDatagram"); + QTest::addColumn<int>("peterChannel"); + QTest::addColumn<int>("paulChannel"); + + QTest::newRow("\"Almond!\" | \"Joy!\"") << QByteArray("Almond!") << QByteArray("Joy!") << 0 << 0; + QTest::newRow("\"A\" | \"B\"") << QByteArray("A") << QByteArray("B") << 1 << 1; + QTest::newRow("\"AB\" | \"B\"") << QByteArray("AB") << QByteArray("B") << 0 << 1; + QTest::newRow("\"AB\" | \"BB\"") << QByteArray("AB") << QByteArray("BB") << 1 << 0; + QTest::newRow("\"A\\0B\" | \"B\\0B\"") << QByteArray::fromRawData("A\0B", 3) << QByteArray::fromRawData("B\0B", 3) << 0 << 1; + QTest::newRow("BigDatagram") << QByteArray(600, '@') << QByteArray(600, '@') << 1 << 0; +} + +void tst_QSctpSocket::loop() +{ + QFETCH(QByteArray, peterDatagram); + QFETCH(QByteArray, paulDatagram); + QFETCH(int, peterChannel); + QFETCH(int, paulChannel); + + QSctpServer server; + + server.setMaxChannelCount(10); + QVERIFY(server.listen()); + + QSctpSocket peter; + peter.setMaxChannelCount(10); + peter.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(peter.waitForConnected(3000)); + + QVERIFY(server.waitForNewConnection(3000)); + QSctpSocket *paul = server.nextPendingDatagramConnection(); + QVERIFY(paul); + + peter.setCurrentWriteChannel(peterChannel); + QVERIFY(peter.writeDatagram(peterDatagram)); + paul->setCurrentWriteChannel(paulChannel); + QVERIFY(paul->writeDatagram(paulDatagram)); + QVERIFY(peter.flush()); + QVERIFY(paul->flush()); + + peter.setCurrentReadChannel(paulChannel); + QVERIFY(peter.waitForReadyRead(3000)); + QCOMPARE(peter.bytesAvailable(), paulDatagram.size()); + QCOMPARE(peter.readDatagram().data(), paulDatagram); + + paul->setCurrentReadChannel(peterChannel); + QVERIFY(paul->waitForReadyRead(3000)); + QCOMPARE(paul->bytesAvailable(), peterDatagram.size()); + QCOMPARE(paul->readDatagram().data(), peterDatagram); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::loopInTCPMode_data() +{ + QTest::addColumn<QByteArray>("peterDatagram"); + QTest::addColumn<QByteArray>("paulDatagram"); + + QTest::newRow("\"Almond!\" | \"Joy!\"") << QByteArray("Almond!") << QByteArray("Joy!"); + QTest::newRow("\"A\" | \"B\"") << QByteArray("A") << QByteArray("B"); + QTest::newRow("\"AB\" | \"B\"") << QByteArray("AB") << QByteArray("B"); + QTest::newRow("\"AB\" | \"BB\"") << QByteArray("AB") << QByteArray("BB"); + QTest::newRow("\"A\\0B\" | \"B\\0B\"") << QByteArray::fromRawData("A\0B", 3) << QByteArray::fromRawData("B\0B", 3); + QTest::newRow("BigDatagram") << QByteArray(600, '@') << QByteArray(600, '@'); +} + +void tst_QSctpSocket::loopInTCPMode() +{ + QFETCH(QByteArray, peterDatagram); + QFETCH(QByteArray, paulDatagram); + + QSctpServer server; + + server.setMaxChannelCount(-1); + QVERIFY(server.listen()); + + QSctpSocket peter; + peter.setMaxChannelCount(-1); + peter.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(peter.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + + QTcpSocket *paul = server.nextPendingConnection(); + QVERIFY(paul); + + QCOMPARE(peter.write(peterDatagram), qint64(peterDatagram.size())); + QCOMPARE(paul->write(paulDatagram), qint64(paulDatagram.size())); + QVERIFY(peter.flush()); + QVERIFY(paul->flush()); + + QVERIFY(peter.waitForReadyRead(3000)); + QVERIFY(paul->waitForReadyRead(3000)); + + QCOMPARE(peter.bytesAvailable(), paulDatagram.size()); + QByteArray peterBuffer = peter.readAll(); + + QCOMPARE(paul->bytesAvailable(), peterDatagram.size()); + QByteArray paulBuffer = paul->readAll(); + + QCOMPARE(peterBuffer, paulDatagram); + QCOMPARE(paulBuffer, peterDatagram); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::exitLoopSlot() +{ + exitLoop(); +} + +//---------------------------------------------------------------------------------- +void tst_QSctpSocket::readDatagramAfterClose() +{ + QSctpServer server; + + QVERIFY(server.listen()); + + QSctpSocket socket; + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(socket.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + + QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection(); + QVERIFY(acceptedSocket); + + connect(&socket, &QIODevice::readyRead, this, &tst_QSctpSocket::exitLoopSlot); + + QByteArray ba(1000, 1); + QVERIFY(acceptedSocket->writeDatagram(ba)); + + enterLoop(10); + if (timeout()) + QFAIL("Network operation timed out"); + + QCOMPARE(socket.bytesAvailable(), ba.size()); + socket.close(); + QVERIFY(!socket.readDatagram().isValid()); +} + +// Test buffered socket properly send data on delayed disconnect +void tst_QSctpSocket::clientSendDataOnDelayedDisconnect() +{ + QSctpServer server; + + QVERIFY(server.listen()); + + // Connect to server, write data and close socket + QSctpSocket socket; + socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(socket.waitForConnected(3000)); + + QByteArray sendData("GET /\r\n"); + sendData = sendData.repeated(1000); + QVERIFY(socket.writeDatagram(sendData)); + socket.close(); + QCOMPARE(socket.state(), QAbstractSocket::ClosingState); + QVERIFY(socket.waitForDisconnected(3000)); + + QVERIFY(server.waitForNewConnection(3000)); + QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection(); + QVERIFY(acceptedSocket); + + QVERIFY(acceptedSocket->waitForReadyRead(3000)); + QNetworkDatagram datagram = acceptedSocket->readDatagram(); + QVERIFY(datagram.isValid()); + QCOMPARE(datagram.data(), sendData); +} + +QTEST_MAIN(tst_QSctpSocket) + +#include "tst_qsctpsocket.moc" diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index f3c24e19fd..71ceafa133 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -10,4 +10,4 @@ MOC_DIR=tmp QT = core-private network-private testlib -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index b4955df107..c945d77cda 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -785,11 +785,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QTime stopWatch; stopWatch.start(); -#if !defined(Q_OS_WINCE) QTestEventLoop::instance().enterLoop(60); -#else - QTestEventLoop::instance().enterLoop(180); -#endif if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); diff --git a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp index fdf1c48adf..1a8e7920d3 100644 --- a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp +++ b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp @@ -47,16 +47,8 @@ int main(int argc, char *argv[]) return 1; } -#if defined(Q_OS_WINCE) - QFile file(QLatin1String("/test_signal.txt")); - file.open(QIODevice::WriteOnly); - file.write("Listening\n"); - file.flush(); - file.close(); -#else printf("Listening\n"); fflush(stdout); -#endif server.waitForNewConnection(5000); qFatal("Crash"); diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index f0abfbc085..4491523383 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -1,16 +1,7 @@ CONFIG += testcase SOURCES += ../tst_qtcpserver.cpp -win32: { -wince { - LIBS += -lws2 - crashApp.files = ../crashingServer/crashingServer.exe - crashApp.path = crashingServer - DEPLOYMENT += crashApp -} else { - LIBS += -lws2_32 -} -} +win32:LIBS += -lws2_32 TARGET = ../tst_qtcpserver diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 30aab3bf34..5a0baf73b5 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -106,6 +106,8 @@ private slots: void eagainBlockingAccept(); + void canAccessPendingConnectionsWhileNotListening(); + private: #ifndef QT_NO_BEARERMANAGEMENT QNetworkSession *networkSession; @@ -467,11 +469,7 @@ void tst_QTcpServer::waitForConnectionTest() ThreadConnector connector(findLocalIpSocket.localAddress(), server.serverPort()); connector.start(); -#if defined(Q_OS_WINCE) - QVERIFY(server.waitForNewConnection(9000, &timeout)); -#else QVERIFY(server.waitForNewConnection(3000, &timeout)); -#endif QVERIFY(!timeout); } @@ -562,21 +560,6 @@ void tst_QTcpServer::addressReusable() QSKIP("No proxy support"); #endif // QT_NO_NETWORKPROXY } -#if defined(Q_OS_WINCE) - QString signalName = QString::fromLatin1("/test_signal.txt"); - QFile::remove(signalName); - // The crashingServer process will crash once it gets a connection. - QProcess process; - QString processExe = crashingServerDir + "/crashingServer"; - process.start(processExe); - QVERIFY2(process.waitForStarted(), qPrintable( - QString::fromLatin1("Could not start %1: %2").arg(processExe, process.errorString()))); - int waitCount = 5; - while (waitCount-- && !QFile::exists(signalName)) - QTest::qWait(1000); - QVERIFY(QFile::exists(signalName)); - QFile::remove(signalName); -#else // The crashingServer process will crash once it gets a connection. QProcess process; QString processExe = crashingServerDir + "/crashingServer"; @@ -584,7 +567,6 @@ void tst_QTcpServer::addressReusable() QVERIFY2(process.waitForStarted(), qPrintable( QString::fromLatin1("Could not start %1: %2").arg(processExe, process.errorString()))); QVERIFY(process.waitForReadyRead(5000)); -#endif QTcpSocket socket; socket.connectToHost(QHostAddress::LocalHost, 49199); @@ -990,5 +972,22 @@ void tst_QTcpServer::eagainBlockingAccept() server.close(); } +class NonListeningTcpServer : public QTcpServer +{ +public: + void addSocketFromOutside(QTcpSocket* s) + { + addPendingConnection(s); + } +}; + +void tst_QTcpServer::canAccessPendingConnectionsWhileNotListening() +{ + NonListeningTcpServer server; + QTcpSocket socket; + server.addSocketFromOutside(&socket); + QCOMPARE(&socket, server.nextPendingConnection()); +} + QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" diff --git a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro index fe6042b8a7..1183b23556 100644 --- a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs SUBDIRS = test -!wince:!vxworks: SUBDIRS += stressTest +!vxworks: SUBDIRS += stressTest -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 3e64b87b53..337e75b372 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -2,13 +2,7 @@ CONFIG += testcase QT = core-private network-private testlib SOURCES += ../tst_qtcpsocket.cpp -win32: { -wince { - LIBS += -lws2 -} else { - LIBS += -lws2_32 -} -} +win32:LIBS += -lws2_32 TARGET = tst_qtcpsocket diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e4812416dc..73486a2bc3 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -15,10 +15,4 @@ win32 { DESTDIR = ../ } -wince* { - addApp.files = ../clientserver/clientserver.exe - addApp.path = clientserver - DEPLOYMENT += addApp -} - TARGET = tst_qudpsocket diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index ba49e8b041..aa01384350 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -39,6 +39,7 @@ #include <qhostinfo.h> #include <qtcpsocket.h> #include <qmap.h> +#include <qnetworkdatagram.h> #include <QNetworkProxy> #include <QNetworkInterface> @@ -114,6 +115,7 @@ protected slots: void async_readDatagramSlot(); private: + QList<QHostAddress> allAddresses; #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager *netConfMan; QNetworkConfiguration networkConfiguration; @@ -173,6 +175,7 @@ void tst_QUdpSocket::initTestCase() { if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); + allAddresses = QNetworkInterface::allAddresses(); } void tst_QUdpSocket::init() @@ -252,6 +255,11 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() int(strlen(message[i]))); buf[strlen(message[i])] = '\0'; QCOMPARE(QByteArray(buf), QByteArray(message[i])); + QCOMPARE(port, clientSocket.localPort()); + if (host.toIPv4Address()) // in case the sender is IPv4 mapped in IPv6 + QCOMPARE(host.toIPv4Address(), makeNonAny(clientSocket.localAddress()).toIPv4Address()); + else + QCOMPARE(host, makeNonAny(clientSocket.localAddress())); } } @@ -325,14 +333,32 @@ void tst_QUdpSocket::broadcasting() QVERIFY(serverSocket.hasPendingDatagrams()); do { - QByteArray arr; arr.resize(serverSocket.pendingDatagramSize() + 1); - QHostAddress host; - quint16 port; const int messageLength = int(strlen(message[i])); - QCOMPARE((int) serverSocket.readDatagram(arr.data(), arr.size() - 1, &host, &port), - messageLength); + QNetworkDatagram dgram = serverSocket.receiveDatagram(); + QVERIFY(dgram.isValid()); + QByteArray arr = dgram.data(); + + QCOMPARE(arr.length(), messageLength); arr.resize(messageLength); QCOMPARE(arr, QByteArray(message[i])); + + if (dgram.senderAddress().toIPv4Address()) // in case it's a v6-mapped address + QVERIFY2(allAddresses.contains(QHostAddress(dgram.senderAddress().toIPv4Address())), + dgram.senderAddress().toString().toLatin1()); + else if (!dgram.senderAddress().isNull()) + QVERIFY2(allAddresses.contains(dgram.senderAddress()), + dgram.senderAddress().toString().toLatin1()); + QCOMPARE(dgram.senderPort(), int(broadcastSocket.localPort())); + if (!dgram.destinationAddress().isNull()) { + QVERIFY2(dgram.destinationAddress() == QHostAddress::Broadcast + || broadcastAddresses.contains(dgram.destinationAddress()), + dgram.destinationAddress().toString().toLatin1()); + QCOMPARE(dgram.destinationPort(), int(serverSocket.localPort())); + } + + int ttl = dgram.hopLimit(); + if (ttl != -1) + QVERIFY(ttl != 0); } while (serverSocket.hasPendingDatagrams()); } } @@ -435,13 +461,8 @@ void tst_QUdpSocket::ipv6Loop() char peterBuffer[16*1024]; char paulBuffer[16*1024]; -#if !defined(Q_OS_WINCE) - QVERIFY2(peter.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(peter).constData()); - QVERIFY2(paul.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(paul).constData()); -#else - QVERIFY(peter.waitForReadyRead(15000)); - QVERIFY(paul.waitForReadyRead(15000)); -#endif + QVERIFY(peter.waitForReadyRead(5000)); + QVERIFY(paul.waitForReadyRead(5000)); if (success) { QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length())); QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length())); @@ -938,9 +959,6 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() #ifdef QT_NO_PROCESS QSKIP("No qprocess support", SkipAll); #else -#if defined(Q_OS_WINCE) - QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE)."); -#endif QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); @@ -1002,9 +1020,6 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() #ifdef QT_NO_PROCESS QSKIP("No qprocess support", SkipAll); #else -#if defined(Q_OS_WINCE) - QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE)."); -#endif QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); @@ -1081,7 +1096,7 @@ void tst_QUdpSocket::zeroLengthDatagram() #ifdef FORCE_SESSION sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QCOMPARE(sender.writeDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort()), qint64(0)); + QCOMPARE(sender.writeDatagram(QNetworkDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort())), qint64(0)); QVERIFY2(receiver.waitForReadyRead(1000), QtNetworkSettings::msgSocketError(receiver).constData()); QVERIFY(receiver.hasPendingDatagrams()); @@ -1366,10 +1381,20 @@ void tst_QUdpSocket::multicast() QVERIFY(receiver.hasPendingDatagrams()); QList<QByteArray> receivedDatagrams; while (receiver.hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(receiver.pendingDatagramSize()); - receiver.readDatagram(datagram.data(), datagram.size(), 0, 0); - receivedDatagrams << datagram; + QNetworkDatagram dgram = receiver.receiveDatagram(); + receivedDatagrams << dgram.data(); + + QVERIFY2(allAddresses.contains(dgram.senderAddress()), + dgram.senderAddress().toString().toLatin1()); + QCOMPARE(dgram.senderPort(), int(sender.localPort())); + if (!dgram.destinationAddress().isNull()) { + QCOMPARE(dgram.destinationAddress(), groupAddress); + QCOMPARE(dgram.destinationPort(), int(receiver.localPort())); + } + + int ttl = dgram.hopLimit(); + if (ttl != -1) + QVERIFY(ttl != 0); } QCOMPARE(receivedDatagrams, datagrams); @@ -1464,7 +1489,8 @@ void tst_QUdpSocket::linkLocalIPv6() quint16 port = 0; foreach (const QHostAddress& addr, addresses) { QUdpSocket *s = new QUdpSocket; - QVERIFY2(s->bind(addr, port), qPrintable(s->errorString())); + QVERIFY2(s->bind(addr, port), addr.toString().toLatin1() + + '/' + QByteArray::number(port) + ": " + qPrintable(s->errorString())); port = s->localPort(); //bind same port, different networks sockets << s; } @@ -1474,24 +1500,25 @@ void tst_QUdpSocket::linkLocalIPv6() QSignalSpy neutralReadSpy(&neutral, SIGNAL(readyRead())); QByteArray testData("hello"); - QByteArray receiveBuffer("xxxxx"); foreach (QUdpSocket *s, sockets) { QSignalSpy spy(s, SIGNAL(readyRead())); neutralReadSpy.clear(); QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); QTRY_VERIFY(neutralReadSpy.count() > 0); //note may need to accept a firewall prompt - QHostAddress from; - quint16 fromPort; - QCOMPARE((int)neutral.readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); - QCOMPARE(from, s->localAddress()); - QCOMPARE(fromPort, s->localPort()); - QCOMPARE(receiveBuffer, testData); - - QVERIFY(neutral.writeDatagram(testData, s->localAddress(), s->localPort())); + + QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.senderAddress(), s->localAddress()); + QCOMPARE(dgram.senderPort(), int(s->localPort())); + QCOMPARE(dgram.data().length(), testData.length()); + QCOMPARE(dgram.data(), testData); + + QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); QTRY_VERIFY(spy.count() > 0); //note may need to accept a firewall prompt - QCOMPARE((int)s->readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); - QCOMPARE(receiveBuffer, testData); + + dgram = s->receiveDatagram(testData.length() * 2); + QCOMPARE(dgram.data(), testData); //sockets bound to other interfaces shouldn't have received anything foreach (QUdpSocket *s2, sockets) { @@ -1546,21 +1573,23 @@ void tst_QUdpSocket::linkLocalIPv4() QVERIFY(neutral.bind(QHostAddress(QHostAddress::AnyIPv4))); QByteArray testData("hello"); - QByteArray receiveBuffer("xxxxx"); foreach (QUdpSocket *s, sockets) { QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); QVERIFY2(neutral.waitForReadyRead(10000), QtNetworkSettings::msgSocketError(neutral).constData()); - QHostAddress from; - quint16 fromPort; - QCOMPARE((int)neutral.readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); - QCOMPARE(from, s->localAddress()); - QCOMPARE(fromPort, s->localPort()); - QCOMPARE(receiveBuffer, testData); - - QVERIFY(neutral.writeDatagram(testData, s->localAddress(), s->localPort())); + QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData()); - QCOMPARE((int)s->readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); - QCOMPARE(receiveBuffer, testData); + QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.senderAddress(), s->localAddress()); + QCOMPARE(dgram.senderPort(), int(s->localPort())); + QCOMPARE(dgram.data().length(), testData.length()); + QCOMPARE(dgram.data(), testData); + + QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); + + dgram = s->receiveDatagram(testData.length() * 2); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.data(), testData); //sockets bound to other interfaces shouldn't have received anything foreach (QUdpSocket *s2, sockets) { diff --git a/tests/auto/network/socket/socket.pro b/tests/auto/network/socket/socket.pro index 436ebe5c7f..307f7e92de 100644 --- a/tests/auto/network/socket/socket.pro +++ b/tests/auto/network/socket/socket.pro @@ -8,13 +8,17 @@ SUBDIRS=\ qsocks5socketengine \ qabstractsocket \ platformsocketengine \ + qsctpsocket \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ platformsocketengine \ qtcpsocket \ qhttpsocketengine \ qsocks5socketengine \ +!qtConfig(sctp): SUBDIRS -= \ + qsctpsocket \ + winrt: SUBDIRS -= \ qhttpsocketengine \ qsocks5socketengine \ diff --git a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro index 87a210c051..7c1cd5b66b 100644 --- a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro +++ b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslcertificate.cpp -!wince:win32:LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core network testlib TARGET = tst_qsslcertificate diff --git a/tests/auto/network/ssl/qsslcipher/qsslcipher.pro b/tests/auto/network/ssl/qsslcipher/qsslcipher.pro index 4cb2dfebab..81ef2d8d9a 100644 --- a/tests/auto/network/ssl/qsslcipher/qsslcipher.pro +++ b/tests/auto/network/ssl/qsslcipher/qsslcipher.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslcipher.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core network testlib TARGET = tst_qsslcipher diff --git a/tests/auto/network/ssl/qssldiffiehellmanparameters/qssldiffiehellmanparameters.pro b/tests/auto/network/ssl/qssldiffiehellmanparameters/qssldiffiehellmanparameters.pro new file mode 100644 index 0000000000..b8053f9eb3 --- /dev/null +++ b/tests/auto/network/ssl/qssldiffiehellmanparameters/qssldiffiehellmanparameters.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +CONFIG += parallel_test + +SOURCES += tst_qssldiffiehellmanparameters.cpp +!wince*:win32:LIBS += -lws2_32 +QT = core network testlib + +TARGET = tst_qssldiffiehellmanparameters diff --git a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp new file mode 100644 index 0000000000..f3b9003fbb --- /dev/null +++ b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QSslDiffieHellmanParameters> +#include <QSslSocket> +#include <QByteArray> + +class tst_QSslDiffieHellmanParameters : public QObject +{ + Q_OBJECT + +#ifndef QT_NO_SSL +private Q_SLOTS: + void constructionEmpty(); + void constructionDefault(); + void constructionDER(); + void constructionPEM(); + void unsafe512Bits(); + void unsafeNonPrime(); +#endif +}; + +#ifndef QT_NO_SSL + +void tst_QSslDiffieHellmanParameters::constructionEmpty() +{ + QSslDiffieHellmanParameters dh; + + QCOMPARE(dh.isEmpty(), true); + QCOMPARE(dh.isValid(), true); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError); +} + +void tst_QSslDiffieHellmanParameters::constructionDefault() +{ + QSslDiffieHellmanParameters dh = QSslDiffieHellmanParameters::defaultParameters(); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isValid(), true); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError); +#endif +} + +void tst_QSslDiffieHellmanParameters::constructionDER() +{ + // Uniquely generated with 'openssl dhparam -outform DER -out out.der -check -2 4096' + const auto dh = QSslDiffieHellmanParameters::fromEncoded(QByteArray::fromBase64(QByteArrayLiteral( + "MIICCAKCAgEAsbQYx57ZlyEyWF8jD5WYEswGR2aTVFsHqP3026SdyTwcjY+YlMOae0EagK" + "jDA0UlPcih1kguQOvOVgyc5gI3YbBb4pCNEdy048xITlsdqG7qC3+2VvFR3vfixEbQQll9" + "2cGIIneD/36p7KJcDnBNUwwWj/VJKhTwelTfKTj2T39si9xGMkqZiQuCaXRk6vSKZ4ZDPk" + "jiq5Ti1kHVFbL9SMWRa8zplPtDMrVfhSyw10njgD4qKd1UoUPdmhEPhRZlHaZ/cAHNSHMj" + "uhDakeMpN+XP2/sl5IpPZ3/vVOk9PhBDFO1NYzKx/b7RQgZCUmXoglKYpfBiz8OheoI0hK" + "V0fU/OCtHjRrP4hE9vIHA2aE+gaQZiYCciGcR9BjHQ7Y8K9qHyTX8UIz2G4ZKzQZK9G+pA" + "K0xD+1H3qZ/MaUhzNDQOwwihnTjjXzTjfIGqYDdbouAhw+tX51CsGonI0cL3s3QMa3CwGH" + "mw+AH2b/Z68dTSy0sC3CYn9cNbrctqyeHwQrsx9FfpOz+Z6sk2WsPgqgSp/pDVVgm5oSfO" + "2mN7WAWgUlf9TQuj1HIRCTI+PbBq2vYvn+YResMRo+8ng1QptKAAgQoVVGNRYxZ9iAZlvO" + "52DcHKlsqDuafQ1XVGmzVIrKtBi2gfLtPqY4v6g6v26l8gbzK67PpWstllHiPb4VMCAQI=" + )), QSsl::Der); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isValid(), true); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError); +#endif +} + +void tst_QSslDiffieHellmanParameters::constructionPEM() +{ + // Uniquely generated with 'openssl dhparam -outform PEM -out out.pem -check -2 4096' + const auto dh = QSslDiffieHellmanParameters::fromEncoded(QByteArrayLiteral( + "-----BEGIN DH PARAMETERS-----\n" + "MIICCAKCAgEA9QTdqhQkbGuhWzBsW5X475AjjrITpg1BHX5+mp1sstUd84Lshq1T\n" + "+S2QQQtdl25EPoUblpyyLAf8krFSH4YwR7jjLWklA8paDOwRYod0zLmVZ1Wx6og3\n" + "PRc8P+SCs+6gKTXfv//bJJhiJXnM73lDFsGHbSqN+msf20ei/zy5Rwey2t8dPjLC\n" + "Q+qkb/avlovi2t2rsUWcxMT1875TQ4HuApayqw3R3lTQe9u05b9rTrinmT7AE4mm\n" + "xGqO9FZJdXYE2sOKwwJkpM48KFyV90uJANmqJnQrkgdukaGTHwxZxgAyO6ur/RWC\n" + "kzf9STFT6IY4Qy05q+oZVJfh8xPHszKmmC8nWaLfiHMYBnL5fv+1kh/aU11Kz9TG\n" + "iDXwQ+tzhKAutQPUwe3IGQUYQMZPwZI4vegdU88/7YPXuWt7b/0Il5+2ma5FbtG2\n" + "u02PMi+J3JZsYi/tEUv1tJBVHGH0kDpgcyOm8rvkCtNbNkETzfwUPoEgA0oPMhVt\n" + "sFGub1av+jLRyFNGNBJcqXAO+Tq2zXG00DxbGY+aooJ50qU/Lh5gfnCEMDXlMM9P\n" + "T8JVpWaaNLCC+0Z5txsfYp+FO8mOttIPIF6F8FtmTnm/jhNntvqKvsU+NHylIYzr\n" + "o42EpiWwS7ktPPUS2GtG+IUdy8rvdO1xJ5kNxs7ZlygY4W1htOhbUusCAQI=\n" + "-----END DH PARAMETERS-----\n" + ), QSsl::Pem); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isValid(), true); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError); +#endif +} + +void tst_QSslDiffieHellmanParameters::unsafe512Bits() +{ + // Uniquely generated with 'openssl dhparam -outform PEM -out out.pem -check -2 512' + const auto dh = QSslDiffieHellmanParameters::fromEncoded(QByteArrayLiteral( + "-----BEGIN DH PARAMETERS-----\n" + "MEYCQQCf8goDn56akiliAtEL1ZG7VH+9wfLxsv8/B1emTUG+rMKB1yaVAU7HaAiM\n" + "Gtmo2bAWUqBczUTOTzqmWTm28P6bAgEC\n" + "-----END DH PARAMETERS-----\n" + ), QSsl::Pem); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isValid(), false); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::UnsafeParametersError); +#endif +} + +void tst_QSslDiffieHellmanParameters::unsafeNonPrime() +{ + // Uniquely generated with 'openssl dhparam -outform DER -out out.der -check -2 1024' + // and then modified by hand to make P not be a prime number. + const auto dh = QSslDiffieHellmanParameters::fromEncoded(QByteArray::fromBase64(QByteArrayLiteral( + "MIGHAoGBALLcOLg+ow8TMnbCUeNjwys6wUTIH9mn4ZSeIbD6qvCsJgg4cUxXwJQmPY" + "Xl15AsKXgkXWh0n+/N6tjH0sSRJnzDvN2H3KxFLKkvxmBYrDOJMdCuMgZD50aOsVyd" + "vholAW9zilkoYkB6sqwxY1Z2dbpTWajCsUAWZQ0AIP4Y5nesAgEC" + )), QSsl::Der); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isValid(), false); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::UnsafeParametersError); +#endif +} + +#endif // QT_NO_SSL + +QTEST_MAIN(tst_QSslDiffieHellmanParameters) +#include "tst_qssldiffiehellmanparameters.moc" diff --git a/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro b/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro index e67b64b2b7..a180086c5e 100644 --- a/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro +++ b/tests/auto/network/ssl/qsslellipticcurve/qsslellipticcurve.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslellipticcurve.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core network testlib TARGET = tst_qsslellipticcurve diff --git a/tests/auto/network/ssl/qsslerror/qsslerror.pro b/tests/auto/network/ssl/qsslerror/qsslerror.pro index 7737aae3f1..117fd4ac27 100644 --- a/tests/auto/network/ssl/qsslerror/qsslerror.pro +++ b/tests/auto/network/ssl/qsslerror/qsslerror.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslerror.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core network testlib TARGET = tst_qsslerror diff --git a/tests/auto/network/ssl/qsslkey/qsslkey.pro b/tests/auto/network/ssl/qsslkey/qsslkey.pro index 7eb04793f3..8c3877631a 100644 --- a/tests/auto/network/ssl/qsslkey/qsslkey.pro +++ b/tests/auto/network/ssl/qsslkey/qsslkey.pro @@ -1,9 +1,9 @@ CONFIG += testcase SOURCES += tst_qsslkey.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core network testlib -contains(QT_CONFIG, private_tests) { +qtConfig(private_tests) { QT += core-private network-private } diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 8afc71a216..0112af4ed7 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -34,9 +34,14 @@ #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qnetworkproxy.h> -#if !defined(QT_NO_SSL) && defined(QT_BUILD_INTERNAL) -#include "private/qsslkey_p.h" -#define TEST_CRYPTO +#ifdef QT_BUILD_INTERNAL + #ifndef QT_NO_SSL + #include "private/qsslkey_p.h" + #define TEST_CRYPTO + #endif + #ifndef QT_NO_OPENSSL + #include "private/qsslsocket_openssl_symbols_p.h" + #endif #endif class tst_QSslKey : public QObject @@ -58,7 +63,7 @@ class tst_QSslKey : public QObject QList<KeyInfo> keyInfoList; - void createPlainTestRows(); + void createPlainTestRows(bool filter = false, QSsl::EncodingFormat format = QSsl::EncodingFormat::Pem); public slots: void initTestCase(); @@ -69,6 +74,10 @@ private slots: void emptyConstructor(); void constructor_data(); void constructor(); +#ifndef QT_NO_OPENSSL + void constructorHandle_data(); + void constructorHandle(); +#endif void copyAndAssign_data(); void copyAndAssign(); void equalsOperator(); @@ -142,7 +151,7 @@ Q_DECLARE_METATYPE(QSsl::KeyAlgorithm) Q_DECLARE_METATYPE(QSsl::KeyType) Q_DECLARE_METATYPE(QSsl::EncodingFormat) -void tst_QSslKey::createPlainTestRows() +void tst_QSslKey::createPlainTestRows(bool filter, QSsl::EncodingFormat format) { QTest::addColumn<QString>("absFilePath"); QTest::addColumn<QSsl::KeyAlgorithm>("algorithm"); @@ -150,6 +159,9 @@ void tst_QSslKey::createPlainTestRows() QTest::addColumn<int>("length"); QTest::addColumn<QSsl::EncodingFormat>("format"); foreach (KeyInfo keyInfo, keyInfoList) { + if (filter && keyInfo.format != format) + continue; + QTest::newRow(keyInfo.fileInfo.fileName().toLatin1()) << keyInfo.fileInfo.absoluteFilePath() << keyInfo.algorithm << keyInfo.type << keyInfo.length << keyInfo.format; @@ -176,6 +188,45 @@ void tst_QSslKey::constructor() QVERIFY(!key.isNull()); } +#ifndef QT_NO_OPENSSL + +void tst_QSslKey::constructorHandle_data() +{ + createPlainTestRows(true); +} + +void tst_QSslKey::constructorHandle() +{ +#ifndef QT_BUILD_INTERNAL + QSKIP("This test requires -developer-build."); +#else + if (!QSslSocket::supportsSsl()) + return; + + QFETCH(QString, absFilePath); + QFETCH(QSsl::KeyAlgorithm, algorithm); + QFETCH(QSsl::KeyType, type); + QFETCH(int, length); + + QByteArray pem = readFile(absFilePath); + auto func = (type == QSsl::KeyType::PublicKey + ? q_PEM_read_bio_PUBKEY + : q_PEM_read_bio_PrivateKey); + + BIO* bio = q_BIO_new(q_BIO_s_mem()); + q_BIO_write(bio, pem.constData(), pem.length()); + QSslKey key(func(bio, nullptr, nullptr, nullptr), type); + q_BIO_free(bio); + + QVERIFY(!key.isNull()); + QCOMPARE(key.algorithm(), algorithm); + QCOMPARE(key.type(), type); + QCOMPARE(key.length(), length); +#endif +} + +#endif + void tst_QSslKey::copyAndAssign_data() { createPlainTestRows(); diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index de2be8e126..5c92ca833a 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslsocket.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core core-private network-private testlib TARGET = tst_qsslsocket @@ -15,19 +15,11 @@ win32 { } # OpenSSL support -contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { +qtConfig(openssl)|qtConfig(openssl-linked) { # Add optional SSL libs LIBS += $$OPENSSL_LIBS } -wince* { - DEFINES += SRCDIR=\\\"./\\\" +DEFINES += SRCDIR=\\\"$$PWD/\\\" - certFiles.files = certs ssl.tar.gz - certFiles.path = . - DEPLOYMENT += certFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index f36528f17d..03ddd4d6f8 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -57,7 +57,7 @@ #include "private/qsslconfiguration_p.h" Q_DECLARE_METATYPE(QSslSocket::SslMode) -typedef QList<QSslError::SslError> SslErrorList; +typedef QVector<QSslError::SslError> SslErrorList; Q_DECLARE_METATYPE(SslErrorList) Q_DECLARE_METATYPE(QSslError) Q_DECLARE_METATYPE(QSslKey) @@ -220,6 +220,10 @@ private slots: void qtbug18498_peek(); void qtbug18498_peek2(); void dhServer(); +#ifndef QT_NO_OPENSSL + void dhServerCustomParamsNull(); + void dhServerCustomParams(); +#endif void ecdhServer(); void verifyClientCertificate_data(); void verifyClientCertificate(); @@ -229,6 +233,8 @@ private slots: void simplePskConnect(); void ephemeralServerKey_data(); void ephemeralServerKey(); + void allowedProtocolNegotiation(); + void pskServer(); #endif void setEmptyDefaultConfiguration(); // this test should be last @@ -380,14 +386,14 @@ void tst_QSslSocket::cleanup() #ifndef QT_NO_SSL QSslSocketPtr tst_QSslSocket::newSocket() { - QSslSocket *socket = new QSslSocket; + const auto socket = QSslSocketPtr::create(); proxyAuthCalled = 0; - connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), + connect(socket.data(), SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); - return QSslSocketPtr(socket); + return socket; } #endif @@ -627,7 +633,8 @@ void tst_QSslSocket::sslErrors() // check the SSL errors contain HostNameMismatch and an error due to // the certificate being self-signed SslErrorList sslErrors; - foreach (const QSslError &err, socket->sslErrors()) + const auto socketSslErrors = socket->sslErrors(); + for (const QSslError &err : socketSslErrors) sslErrors << err.error(); qSort(sslErrors); QVERIFY(sslErrors.contains(QSslError::HostNameMismatch)); @@ -636,7 +643,8 @@ void tst_QSslSocket::sslErrors() // check the same errors were emitted by sslErrors QVERIFY(!sslErrorsSpy.isEmpty()); SslErrorList emittedErrors; - foreach (const QSslError &err, qvariant_cast<QList<QSslError> >(sslErrorsSpy.first().first())) + const auto sslErrorsSpyErrors = qvariant_cast<QList<QSslError> >(qAsConst(sslErrorsSpy).first().first()); + for (const QSslError &err : sslErrorsSpyErrors) emittedErrors << err.error(); qSort(emittedErrors); QCOMPARE(sslErrors, emittedErrors); @@ -645,7 +653,7 @@ void tst_QSslSocket::sslErrors() QVERIFY(!peerVerifyErrorSpy.isEmpty()); SslErrorList peerErrors; const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy; - foreach (const QVariantList &args, peerVerifyList) + for (const QVariantList &args : peerVerifyList) peerErrors << qvariant_cast<QSslError>(args.first()).error(); qSort(peerErrors); QCOMPARE(sslErrors, peerErrors); @@ -1159,7 +1167,9 @@ void tst_QSslSocket::protocolServerSide_data() #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("ssl2-ssl2") << QSsl::SslV2 << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2 #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-ssl3") << QSsl::SslV3 << QSsl::SslV3 << true; +#endif QTest::newRow("tls1.0-tls1.0") << QSsl::TlsV1_0 << QSsl::TlsV1_0 << true; QTest::newRow("tls1ssl3-tls1ssl3") << QSsl::TlsV1SslV3 << QSsl::TlsV1SslV3 << true; QTest::newRow("any-any") << QSsl::AnyProtocol << QSsl::AnyProtocol << true; @@ -1173,23 +1183,27 @@ void tst_QSslSocket::protocolServerSide_data() QTest::newRow("ssl2-any") << QSsl::SslV2 << QSsl::AnyProtocol << false; // no idea why it does not work, but we don't care about SSL 2 #endif -#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) +#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) && !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-ssl2") << QSsl::SslV3 << QSsl::SslV2 << false; #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false; QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true; QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false; -#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) +#endif +#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) && !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a // numerical IP, so OpenSSL will send a SSL 2 handshake -#else +#elif !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << true; #endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("tls1.0-ssl2") << QSsl::TlsV1_0 << QSsl::SslV2 << false; #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("tls1.0-ssl3") << QSsl::TlsV1_0 << QSsl::SslV3 << false; +#endif QTest::newRow("tls1-tls1ssl3") << QSsl::TlsV1_0 << QSsl::TlsV1SslV3 << true; QTest::newRow("tls1.0-secure") << QSsl::TlsV1_0 << QSsl::SecureProtocols << true; #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) @@ -1202,7 +1216,9 @@ void tst_QSslSocket::protocolServerSide_data() #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("tls1ssl3-ssl2") << QSsl::TlsV1SslV3 << QSsl::SslV2 << false; #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("tls1ssl3-ssl3") << QSsl::TlsV1SslV3 << QSsl::SslV3 << true; +#endif QTest::newRow("tls1ssl3-tls1.0") << QSsl::TlsV1SslV3 << QSsl::TlsV1_0 << true; QTest::newRow("tls1ssl3-secure") << QSsl::TlsV1SslV3 << QSsl::SecureProtocols << true; QTest::newRow("tls1ssl3-any") << QSsl::TlsV1SslV3 << QSsl::AnyProtocol << true; @@ -1210,7 +1226,9 @@ void tst_QSslSocket::protocolServerSide_data() #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("secure-ssl2") << QSsl::SecureProtocols << QSsl::SslV2 << false; #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << false; +#endif QTest::newRow("secure-tls1.0") << QSsl::SecureProtocols << QSsl::TlsV1_0 << true; QTest::newRow("secure-tls1ssl3") << QSsl::SecureProtocols << QSsl::TlsV1SslV3 << true; QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true; @@ -1218,7 +1236,9 @@ void tst_QSslSocket::protocolServerSide_data() #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("any-ssl2") << QSsl::AnyProtocol << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2 #endif +#if !defined(OPENSSL_NO_SSL3) QTest::newRow("any-ssl3") << QSsl::AnyProtocol << QSsl::SslV3 << true; +#endif QTest::newRow("any-tls1.0") << QSsl::AnyProtocol << QSsl::TlsV1_0 << true; QTest::newRow("any-tls1ssl3") << QSsl::AnyProtocol << QSsl::TlsV1SslV3 << true; QTest::newRow("any-secure") << QSsl::AnyProtocol << QSsl::SecureProtocols << true; @@ -1243,8 +1263,8 @@ void tst_QSslSocket::protocolServerSide() QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data(); + QSslSocket client; + socket = &client; QFETCH(QSsl::SslProtocol, clientProtocol); socket->setProtocol(clientProtocol); // upon SSL wrong version error, error will be triggered, not sslErrors @@ -1252,14 +1272,14 @@ void tst_QSslSocket::protocolServerSide() connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); QFETCH(bool, works); QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState; - QCOMPARE(int(client->state()), int(expectedState)); - QCOMPARE(client->isEncrypted(), works); + QCOMPARE(int(client.state()), int(expectedState)); + QCOMPARE(client.isEncrypted(), works); } #ifndef QT_NO_OPENSSL @@ -1284,8 +1304,8 @@ void tst_QSslSocket::serverCipherPreferences() QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data(); + QSslSocket client; + socket = &client; socket->setCiphers("AES256-SHA:AES128-SHA"); // upon SSL wrong version error, error will be triggered, not sslErrors @@ -1293,12 +1313,12 @@ void tst_QSslSocket::serverCipherPreferences() connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QVERIFY(client->isEncrypted()); - QCOMPARE(client->sessionCipher().name(), QString("AES128-SHA")); + QVERIFY(client.isEncrypted()); + QCOMPARE(client.sessionCipher().name(), QString("AES128-SHA")); } { @@ -1313,8 +1333,8 @@ void tst_QSslSocket::serverCipherPreferences() QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data(); + QSslSocket client; + socket = &client; socket->setCiphers("AES256-SHA:AES128-SHA"); // upon SSL wrong version error, error will be triggered, not sslErrors @@ -1322,12 +1342,12 @@ void tst_QSslSocket::serverCipherPreferences() connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QVERIFY(client->isEncrypted()); - QCOMPARE(client->sessionCipher().name(), QString("AES256-SHA")); + QVERIFY(client.isEncrypted()); + QCOMPARE(client.sessionCipher().name(), QString("AES256-SHA")); } } @@ -1418,21 +1438,21 @@ void tst_QSslSocket::setSocketDescriptor() QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data();; + QSslSocket client; + socket = &client; connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QCOMPARE(client->state(), QAbstractSocket::ConnectedState); - QVERIFY(client->isEncrypted()); - QVERIFY(!client->peerAddress().isNull()); - QVERIFY(client->peerPort() != 0); - QVERIFY(!client->localAddress().isNull()); - QVERIFY(client->localPort() != 0); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); + QVERIFY(client.isEncrypted()); + QVERIFY(!client.peerAddress().isNull()); + QVERIFY(client.peerPort() != 0); + QVERIFY(!client.localAddress().isNull()); + QVERIFY(client.localPort() != 0); } void tst_QSslSocket::setSslConfiguration_data() @@ -2845,10 +2865,37 @@ void tst_QSslSocket::qtbug18498_peek2() void tst_QSslSocket::dhServer() { - if (!QSslSocket::supportsSsl()) { - qWarning("SSL not supported, skipping test"); + if (!QSslSocket::supportsSsl()) + QSKIP("No SSL support"); + + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) return; - } + + SslServer server; + server.ciphers = QLatin1String("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA"); + QVERIFY(server.listen()); + + QEventLoop loop; + QTimer::singleShot(5000, &loop, SLOT(quit())); + + QSslSocket client; + socket = &client; + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); + + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + + loop.exec(); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); +} + +#ifndef QT_NO_OPENSSL +void tst_QSslSocket::dhServerCustomParamsNull() +{ + if (!QSslSocket::supportsSsl()) + QSKIP("No SSL support"); QFETCH_GLOBAL(bool, setProxy); if (setProxy) @@ -2856,22 +2903,74 @@ void tst_QSslSocket::dhServer() SslServer server; server.ciphers = QLatin1String("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA"); + + QSslConfiguration cfg = server.config; + cfg.setDiffieHellmanParameters(QSslDiffieHellmanParameters()); + server.config = cfg; + QVERIFY(server.listen()); QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data(); + QSslSocket client; + socket = &client; connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QCOMPARE(client->state(), QAbstractSocket::ConnectedState); + + QVERIFY(client.state() != QAbstractSocket::ConnectedState); } +#endif // QT_NO_OPENSSL + +#ifndef QT_NO_OPENSSL +void tst_QSslSocket::dhServerCustomParams() +{ + if (!QSslSocket::supportsSsl()) + QSKIP("No SSL support"); + + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer server; + server.ciphers = QLatin1String("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA"); + + QSslConfiguration cfg = server.config; + + // Custom 2048-bit DH parameters generated with 'openssl dhparam -outform DER -out out.der -check -2 2048' + const auto dh = QSslDiffieHellmanParameters::fromEncoded(QByteArray::fromBase64(QByteArrayLiteral( + "MIIBCAKCAQEAvVA7b8keTfjFutCtTJmP/pnQfw/prKa+GMed/pBWjrC4N1YwnI8h/A861d9WE/VWY7XMTjvjX3/0" + "aaU8wEe0EXNpFdlTH+ZMQctQTSJOyQH0RCTwJfDGPCPT9L+c9GKwEKWORH38Earip986HJc0w3UbnfIwXUdsWHiXi" + "Z6r3cpyBmTKlsXTFiDVAOUXSiO8d/zOb6zHZbDfyB/VbtZRmnA7TXVn9oMzC0g9+FXHdrV4K+XfdvNZdCegvoAZiy" + "R6ZQgNG9aZ36/AQekhg060hp55f9HDPgXqYeNeXBiferjUtU7S9b3s83XhOJAr01/0Tf5dENwCfg2gK36TM8cC4wI" + "BAg==")), QSsl::Der); + cfg.setDiffieHellmanParameters(dh); + + server.config = cfg; + + QVERIFY(server.listen()); + + QEventLoop loop; + QTimer::singleShot(5000, &loop, SLOT(quit())); + + QSslSocket client; + socket = &client; + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); + + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + + loop.exec(); + + QVERIFY(client.state() == QAbstractSocket::ConnectedState); +} +#endif // QT_NO_OPENSSL void tst_QSslSocket::ecdhServer() { @@ -2891,16 +2990,16 @@ void tst_QSslSocket::ecdhServer() QEventLoop loop; QTimer::singleShot(5000, &loop, SLOT(quit())); - QSslSocketPtr client(new QSslSocket); - socket = client.data(); + QSslSocket client; + socket = &client; connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QCOMPARE(client->state(), QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); } void tst_QSslSocket::verifyClientCertificate_data() @@ -3002,16 +3101,16 @@ void tst_QSslSocket::verifyClientCertificate() QFETCH(QList<QSslCertificate>, clientCerts); QFETCH(QSslKey, clientKey); - QSslSocketPtr client(new QSslSocket); - client->setLocalCertificateChain(clientCerts); - client->setPrivateKey(clientKey); - socket = client.data(); + QSslSocket client; + client.setLocalCertificateChain(clientCerts); + client.setPrivateKey(clientKey); + socket = &client; connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(disconnected()), &loop, SLOT(quit())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); - client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + client.connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); @@ -3033,8 +3132,8 @@ void tst_QSslSocket::verifyClientCertificate() } // check client socket - QCOMPARE(int(client->state()), int(expectedState)); - QCOMPARE(client->isEncrypted(), works); + QCOMPARE(int(client.state()), int(expectedState)); + QCOMPARE(client.isEncrypted(), works); } void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects @@ -3063,8 +3162,12 @@ class PskProvider : public QObject Q_OBJECT public: + bool m_server; + QByteArray m_identity; + QByteArray m_psk; + explicit PskProvider(QObject *parent = 0) - : QObject(parent) + : QObject(parent), m_server(false) { } @@ -3083,7 +3186,11 @@ public slots: { QVERIFY(authenticator); QCOMPARE(authenticator->identityHint(), PSK_SERVER_IDENTITY_HINT); - QVERIFY(authenticator->maximumIdentityLength() > 0); + if (m_server) + QCOMPARE(authenticator->maximumIdentityLength(), 0); + else + QVERIFY(authenticator->maximumIdentityLength() > 0); + QVERIFY(authenticator->maximumPreSharedKeyLength() > 0); if (!m_identity.isEmpty()) { @@ -3096,12 +3203,61 @@ public slots: QCOMPARE(authenticator->preSharedKey(), m_psk); } } - -private: - QByteArray m_identity; - QByteArray m_psk; }; +class PskServer : public QTcpServer +{ + Q_OBJECT +public: + PskServer() + : socket(0), + config(QSslConfiguration::defaultConfiguration()), + ignoreSslErrors(true), + peerVerifyMode(QSslSocket::AutoVerifyPeer), + protocol(QSsl::TlsV1_0), + m_pskProvider() + { + m_pskProvider.m_server = true; + } + QSslSocket *socket; + QSslConfiguration config; + bool ignoreSslErrors; + QSslSocket::PeerVerifyMode peerVerifyMode; + QSsl::SslProtocol protocol; + QString ciphers; + PskProvider m_pskProvider; + +protected: + void incomingConnection(qintptr socketDescriptor) + { + socket = new QSslSocket(this); + socket->setSslConfiguration(config); + socket->setPeerVerifyMode(peerVerifyMode); + socket->setProtocol(protocol); + if (ignoreSslErrors) + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + + if (!ciphers.isEmpty()) { + socket->setCiphers(ciphers); + } + + QVERIFY(socket->setSocketDescriptor(socketDescriptor, QAbstractSocket::ConnectedState)); + QVERIFY(!socket->peerAddress().isNull()); + QVERIFY(socket->peerPort() != 0); + QVERIFY(!socket->localAddress().isNull()); + QVERIFY(socket->localPort() != 0); + + connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired, &m_pskProvider, &PskProvider::providePsk); + + socket->startServerEncryption(); + } + +protected slots: + void ignoreErrorSlot() + { + socket->ignoreSslErrors(); + } +}; void tst_QSslSocket::simplePskConnect_data() { QTest::addColumn<PskConnectTestType>("pskTestType"); @@ -3125,7 +3281,7 @@ void tst_QSslSocket::simplePskConnect() bool pskCipherFound = false; const QList<QSslCipher> supportedCiphers = QSslSocket::supportedCiphers(); - foreach (const QSslCipher &cipher, supportedCiphers) { + for (const QSslCipher &cipher : supportedCiphers) { if (cipher.name() == PSK_CIPHER_WITHOUT_AUTH) { pskCipherFound = true; break; @@ -3403,6 +3559,129 @@ void tst_QSslSocket::ephemeralServerKey() QCOMPARE(client->sslConfiguration().ephemeralServerKey().isNull(), emptyKey); } +void tst_QSslSocket::allowedProtocolNegotiation() +{ +#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_TLSEXT) + + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + const QByteArray expectedNegotiated("cool-protocol"); + QList<QByteArray> serverProtos; + serverProtos << expectedNegotiated << "not-so-cool-protocol"; + QList<QByteArray> clientProtos; + clientProtos << "uber-cool-protocol" << expectedNegotiated << "not-so-cool-protocol"; + + + SslServer server; + server.config.setAllowedNextProtocols(serverProtos); + QVERIFY(server.listen()); + + QSslSocket clientSocket; + auto configuration = clientSocket.sslConfiguration(); + configuration.setAllowedNextProtocols(clientProtos); + clientSocket.setSslConfiguration(configuration); + + clientSocket.connectToHostEncrypted("127.0.0.1", server.serverPort()); + clientSocket.ignoreSslErrors(); + + QEventLoop loop; + QTimer::singleShot(5000, &loop, SLOT(quit())); + connect(&clientSocket, SIGNAL(encrypted()), &loop, SLOT(quit())); + loop.exec(); + + QVERIFY(server.socket->sslConfiguration().nextNegotiatedProtocol() == + clientSocket.sslConfiguration().nextNegotiatedProtocol()); + QVERIFY(server.socket->sslConfiguration().nextNegotiatedProtocol() == expectedNegotiated); + +#endif // OPENSSL_VERSION_NUMBER +} + +void tst_QSslSocket::pskServer() +{ + QFETCH_GLOBAL(bool, setProxy); + if (!QSslSocket::supportsSsl() || setProxy) + return; + + QSslSocket socket; + this->socket = &socket; + + QSignalSpy connectedSpy(&socket, SIGNAL(connected())); + QVERIFY(connectedSpy.isValid()); + + QSignalSpy disconnectedSpy(&socket, SIGNAL(disconnected())); + QVERIFY(disconnectedSpy.isValid()); + + QSignalSpy connectionEncryptedSpy(&socket, SIGNAL(encrypted())); + QVERIFY(connectionEncryptedSpy.isValid()); + + QSignalSpy pskAuthenticationRequiredSpy(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))); + QVERIFY(pskAuthenticationRequiredSpy.isValid()); + + connect(&socket, SIGNAL(connected()), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(disconnected()), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(encrypted()), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(peerVerifyError(QSslError)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(exitLoop())); + + // force a PSK cipher w/o auth + socket.setCiphers(PSK_CIPHER_WITHOUT_AUTH); + + PskProvider provider; + provider.setIdentity(PSK_CLIENT_IDENTITY); + provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY); + connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*))); + socket.setPeerVerifyMode(QSslSocket::VerifyNone); + + PskServer server; + server.m_pskProvider.setIdentity(provider.m_identity); + server.m_pskProvider.setPreSharedKey(provider.m_psk); + server.config.setPreSharedKeyIdentityHint(PSK_SERVER_IDENTITY_HINT); + QVERIFY(server.listen()); + + // Start connecting + socket.connectToHost(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + enterLoop(5); + + // Entered connected state + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode); + QVERIFY(!socket.isEncrypted()); + QCOMPARE(connectedSpy.count(), 1); + QCOMPARE(disconnectedSpy.count(), 0); + + // Enter encrypted mode + socket.startClientEncryption(); + QCOMPARE(socket.mode(), QSslSocket::SslClientMode); + QVERIFY(!socket.isEncrypted()); + QCOMPARE(connectionEncryptedSpy.count(), 0); + + // Start handshake. + enterLoop(10); + + // We must get the PSK signal in all cases + QCOMPARE(pskAuthenticationRequiredSpy.count(), 1); + + QCOMPARE(connectionEncryptedSpy.count(), 1); + QVERIFY(socket.isEncrypted()); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + + // check writing + socket.write("Hello from Qt TLS/PSK!"); + QVERIFY(socket.waitForBytesWritten()); + + // disconnect + socket.disconnectFromHost(); + enterLoop(10); + + QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); + QCOMPARE(disconnectedSpy.count(), 1); +} + #endif // QT_NO_OPENSSL #endif // QT_NO_SSL diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index ae911e43ed..c862b3d3ae 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -2,7 +2,7 @@ CONFIG += testcase testcase.timeout = 300 # this test is slow SOURCES += tst_qsslsocket_onDemandCertificates_member.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core core-private network-private testlib TARGET = tst_qsslsocket_onDemandCertificates_member @@ -15,10 +15,6 @@ win32 { } } -wince* { - DEFINES += SRCDIR=\\\"./\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +DEFINES += SRCDIR=\\\"$$PWD/\\\" -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index 25e5a5d5c7..c27a58fcd2 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += tst_qsslsocket_onDemandCertificates_static.cpp -win32:!wince: LIBS += -lws2_32 +win32:LIBS += -lws2_32 QT = core core-private network-private testlib TARGET = tst_qsslsocket_onDemandCertificates_static @@ -14,10 +14,6 @@ win32 { } } -wince* { - DEFINES += SRCDIR=\\\"./\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +DEFINES += SRCDIR=\\\"$$PWD/\\\" -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/network/ssl/ssl.pro b/tests/auto/network/ssl/ssl.pro index 25d79ebfe8..65e35ea4c0 100644 --- a/tests/auto/network/ssl/ssl.pro +++ b/tests/auto/network/ssl/ssl.pro @@ -6,8 +6,8 @@ SUBDIRS=\ qsslerror \ qsslkey \ -contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { - contains(QT_CONFIG, private_tests) { +qtConfig(ssl)|qtConfig(openssl)|qtConfig(openssl-linked) { + qtConfig(private_tests) { SUBDIRS += \ qsslsocket \ qsslsocket_onDemandCertificates_member \ @@ -19,8 +19,9 @@ winrt: SUBDIRS -= \ qsslsocket_onDemandCertificates_member \ qsslsocket_onDemandCertificates_static \ -contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { - contains(QT_CONFIG, private_tests) { - SUBDIRS += qasn1element +qtConfig(ssl)|qtConfig(openssl)|qtConfig(openssl-linked) { + qtConfig(private_tests) { + SUBDIRS += qasn1element \ + qssldiffiehellmanparameters } } diff --git a/tests/auto/opengl/qglthreads/qglthreads.pro b/tests/auto/opengl/qglthreads/qglthreads.pro index ab8bda741e..9aa21fb3a2 100644 --- a/tests/auto/opengl/qglthreads/qglthreads.pro +++ b/tests/auto/opengl/qglthreads/qglthreads.pro @@ -5,10 +5,3 @@ QT += opengl widgets testlib gui-private core-private HEADERS += tst_qglthreads.h SOURCES += tst_qglthreads.cpp - -x11 { - LIBS += $$QMAKE_LIBS_X11 -} - - - diff --git a/tests/auto/other/compiler/compiler.pro b/tests/auto/other/compiler/compiler.pro index 19f86582e9..5a00e53878 100644 --- a/tests/auto/other/compiler/compiler.pro +++ b/tests/auto/other/compiler/compiler.pro @@ -3,7 +3,7 @@ TARGET = tst_compiler SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp othersource.cpp HEADERS += baseclass.h derivedclass.h QT = core testlib -contains(QT_CONFIG, c++11): CONFIG += c++11 -contains(QT_CONFIG, c++14): CONFIG += c++14 +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 diff --git a/tests/auto/other/gestures/gestures.pro b/tests/auto/other/gestures/gestures.pro index 3d0ef7c745..0ec0435f62 100644 --- a/tests/auto/other/gestures/gestures.pro +++ b/tests/auto/other/gestures/gestures.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_gestures -QT += widgets testlib gui-private +QT += widgets testlib SOURCES += tst_gestures.cpp diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 59b285b032..d153146574 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -40,7 +40,6 @@ #include <qgraphicswidget.h> #include <qgraphicsview.h> #include <qmainwindow.h> -#include <qpa/qwindowsysteminterface.h> #include <qdebug.h> @@ -2318,9 +2317,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() w.show(); QVERIFY(waitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + QTouchDevice *device = QTest::createTouchDevice(); QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); } diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 0b1471c4b1..8d6886a6c6 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -165,7 +165,16 @@ const char *PaintCommands::imageFormatTable[] = { "Format_ARGB8555_Premultiplied", "Format_RGB888", "Format_RGB444", - "Format_ARGB4444_Premultiplied" + "Format_ARGB4444_Premultiplied", + "Format_RGBX8888", + "Format_RGBA8888", + "Format_RGBA8888_Premultiplied", + "Format_BGR30", + "Format_A2BGR30_Premultiplied", + "Format_RGB30", + "Format_A2RGB30_Premultiplied", + "Alpha8", + "Grayscale8", }; int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit) diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 3f35712489..eb575a88ea 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -71,6 +71,10 @@ private slots: void testRasterRGB32(); void testRasterRGB16_data(); void testRasterRGB16(); + void testRasterA2RGB30PM_data(); + void testRasterA2RGB30PM(); + void testRasterBGR30_data(); + void testRasterBGR30(); #ifndef QT_NO_OPENGL void testOpenGL_data(); @@ -150,6 +154,30 @@ void tst_Lancelot::testRasterRGB16() } +void tst_Lancelot::testRasterA2RGB30PM_data() +{ + setupTestSuite(); +} + + +void tst_Lancelot::testRasterA2RGB30PM() +{ + runTestSuite(Raster, QImage::Format_A2RGB30_Premultiplied); +} + + +void tst_Lancelot::testRasterBGR30_data() +{ + setupTestSuite(); +} + + +void tst_Lancelot::testRasterBGR30() +{ + runTestSuite(Raster, QImage::Format_BGR30); +} + + #ifndef QT_NO_OPENGL bool tst_Lancelot::checkSystemGLSupport() { diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index 7380398071..22c2e1fbc7 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -281,9 +281,6 @@ void tst_languageChange::retranslatability() fooFile.write("test"); fooFile.close(); dlg.setDirectory(temporaryDir.path()); -#ifdef Q_OS_WINCE - dlg.setDirectory("\\Windows"); -#endif dlg.setFileMode(QFileDialog::ExistingFiles); dlg.setViewMode(QFileDialog::Detail); stateMachine.start(); @@ -295,13 +292,8 @@ void tst_languageChange::retranslatability() // In case we use a Color dialog, we do not want to test for // strings non existing in the dialog and which do not get // translated. - if ((dialogType == ColorDialog) && -#ifndef Q_OS_WINCE - (qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350) -#else - true // On Qt/WinCE we always use compact mode -#endif - ) { + const QSize desktopSize = QApplication::desktop()->size(); + if (dialogType == ColorDialog && (desktopSize.width() < 480 || desktopSize.height() < 350)) { expected.remove("QColorDialog::&Basic colors"); expected.remove("QColorDialog::&Custom colors"); expected.remove("QColorDialog::&Define Custom Colors >>"); diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 0ce0e8d0f5..68473906b0 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -539,7 +539,7 @@ void tst_NetworkSelfTest::httpServer() { QByteArray uniqueExtension = QByteArray::number((qulonglong)this) + QByteArray::number((qulonglong)qrand()) + - QByteArray::number((qulonglong)QDateTime::currentDateTime().toTime_t()); + QByteArray::number(QDateTime::currentSecsSinceEpoch()); netChat(80, QList<Chat>() // HTTP/0.9 chat: diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 0e9f054a01..94b5847b2e 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -21,7 +21,6 @@ SUBDIRS=\ qsharedpointer_and_qwidget \ qprocess_and_guieventloop \ qtokenautomaton \ - windowsmobile \ toolsupport \ !qtHaveModule(gui): SUBDIRS -= \ @@ -52,9 +51,9 @@ cross_compile: SUBDIRS -= \ atwrapper \ compiler -wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility +!qtConfig(accessibility): SUBDIRS -= qaccessibility -!contains(QT_CONFIG, accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux +!qtConfig(accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux !mac: SUBDIRS -= \ macgui \ @@ -62,7 +61,7 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility macplist \ qaccessibilitymac -!embedded|wince: SUBDIRS -= \ +!embedded: SUBDIRS -= \ qdirectpainter winrt: SUBDIRS -= \ diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 7b3173798d..fb9de6f450 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -1,18 +1,12 @@ CONFIG += testcase TARGET = tst_qaccessibility -requires(contains(QT_CONFIG,accessibility)) +requires(qtConfig(accessibility)) QT += testlib core-private gui-private widgets-private SOURCES += tst_qaccessibility.cpp HEADERS += accessiblewidgets.h unix:!darwin:!haiku:!integity: LIBS += -lm -wince { - accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll - accessneeded.path = accessible - DEPLOYMENT += accessneeded -} - win32 { !*g++:!winrt { include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 99e3fc5bf2..2f5936f1ad 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -68,20 +68,6 @@ static inline void setFrameless(QWidget *w) w->setWindowFlags(flags); } -#if defined(Q_OS_WINCE) -extern "C" bool SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); -#define SPI_GETPLATFORMTYPE 257 -inline bool IsValidCEPlatform() { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(tszPlatform) / sizeof(*tszPlatform), tszPlatform, 0)) { - QString platform = QString::fromWCharArray(tszPlatform); - if ((platform == QLatin1String("PocketPC")) || (platform == QLatin1String("Smartphone"))) - return false; - } - return true; -} -#endif - static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, int index, const QRect &domain) { @@ -1315,6 +1301,16 @@ void tst_QAccessibility::tabTest() child2->actionInterface()->doAction(QAccessibleActionInterface::pressAction()); QCOMPARE(tabBar->currentIndex(), 1); + // Test that setAccessibleTabName changes a tab's accessible name + tabBar->setAccessibleTabName(0, "AccFoo"); + tabBar->setAccessibleTabName(1, "AccBar"); + QCOMPARE(child1->text(QAccessible::Name), QLatin1String("AccFoo")); + QCOMPARE(child2->text(QAccessible::Name), QLatin1String("AccBar")); + tabBar->setCurrentIndex(0); + QCOMPARE(interface->text(QAccessible::Name), QLatin1String("AccFoo")); + tabBar->setCurrentIndex(1); + QCOMPARE(interface->text(QAccessible::Name), QLatin1String("AccBar")); + delete tabBar; QTestAccessibility::clearEvents(); } @@ -1352,10 +1348,17 @@ void tst_QAccessibility::tabWidgetTest() QCOMPARE(tabButton1Interface->text(QAccessible::Name), QLatin1String("Tab 1")); QAccessibleInterface* tabButton2Interface = tabBarInterface->child(1); - QVERIFY(tabButton1Interface); + QVERIFY(tabButton2Interface); QCOMPARE(tabButton2Interface->role(), QAccessible::PageTab); QCOMPARE(tabButton2Interface->text(QAccessible::Name), QLatin1String("Tab 2")); + // Test that setAccessibleTabName changes a tab's accessible name + tabWidget->setCurrentIndex(0); + tabWidget->tabBar()->setAccessibleTabName(0, "Acc Tab"); + QCOMPARE(tabButton1Interface->role(), QAccessible::PageTab); + QCOMPARE(tabButton1Interface->text(QAccessible::Name), QLatin1String("Acc Tab")); + QCOMPARE(tabBarInterface->text(QAccessible::Name), QLatin1String("Acc Tab")); + QAccessibleInterface* tabButtonLeft = tabBarInterface->child(2); QVERIFY(tabButtonLeft); QCOMPARE(tabButtonLeft->role(), QAccessible::PushButton); @@ -1469,10 +1472,6 @@ void tst_QAccessibility::menuTest() QCOMPARE(iHelp->role(), QAccessible::MenuItem); QCOMPARE(iAction->role(), QAccessible::MenuItem); #ifndef Q_OS_MAC -#ifdef Q_OS_WINCE - if (!IsValidCEPlatform()) - QSKIP("Tests do not work on Mobile platforms due to native menus"); -#endif QCOMPARE(mw.mapFromGlobal(interface->rect().topLeft()), mw.menuBar()->geometry().topLeft()); QCOMPARE(interface->rect().size(), mw.menuBar()->size()); @@ -3561,10 +3560,6 @@ void tst_QAccessibility::dockWidgetTest() void tst_QAccessibility::comboBoxTest() { -#if defined(Q_OS_WINCE) - if (!IsValidCEPlatform()) - QSKIP("Test skipped on Windows Mobile test hardware"); -#endif { // not editable combobox QComboBox combo; combo.addItems(QStringList() << "one" << "two" << "three"); diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp index cb69c80f37..b32b1226b2 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp @@ -34,7 +34,7 @@ QT_BEGIN_NAMESPACE Basic::Token Basic::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -50,7 +50,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -66,7 +66,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -89,19 +89,19 @@ Basic::Token Basic::classifier3(const QChar *data) Basic::Token Basic::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -111,7 +111,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -124,11 +124,11 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -138,7 +138,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -151,12 +151,12 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; @@ -192,7 +192,7 @@ Basic::Token Basic::classifier3(const QChar *data) Basic::Token Basic::classifier14(const QChar *data) { - if (data[0] == 119) + if (data[0].unicode() == 119) { @@ -208,7 +208,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[0] == 99) + else if (data[0].unicode() == 99) { diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp index 59164ea3f4..dace6be146 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp @@ -36,7 +36,7 @@ using namespace BasicNamespace; Basic::Token Basic::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -52,7 +52,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -68,7 +68,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -91,19 +91,19 @@ Basic::Token Basic::classifier3(const QChar *data) Basic::Token Basic::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -113,7 +113,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -126,11 +126,11 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -140,7 +140,7 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -153,12 +153,12 @@ Basic::Token Basic::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; diff --git a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp index d005b64b8d..c24900eed0 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp @@ -36,7 +36,7 @@ QT_BEGIN_NAMESPACE Boilerplate::Token Boilerplate::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -52,7 +52,7 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -68,7 +68,7 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -91,19 +91,19 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) Boilerplate::Token Boilerplate::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -113,7 +113,7 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -126,11 +126,11 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -140,7 +140,7 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -153,12 +153,12 @@ Boilerplate::Token Boilerplate::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp index 87632d83ff..879f55fa32 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp @@ -34,7 +34,7 @@ QT_BEGIN_NAMESPACE NoNamespace::Token NoNamespace::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -50,7 +50,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -66,7 +66,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -89,19 +89,19 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) NoNamespace::Token NoNamespace::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -111,7 +111,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -124,11 +124,11 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -138,7 +138,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -151,12 +151,12 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; @@ -176,7 +176,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) NoNamespace::Token NoNamespace::classifier14(const QChar *data) { - if (data[0] == 119) + if (data[0].unicode() == 119) { @@ -192,7 +192,7 @@ NoNamespace::Token NoNamespace::classifier3(const QChar *data) } - else if (data[0] == 99) + else if (data[0].unicode() == 99) { diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp index 68bd051afb..5be9b3879f 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp @@ -36,7 +36,7 @@ using namespace NoToStringNS; NoToString::Token NoToString::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -52,7 +52,7 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -68,7 +68,7 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -91,19 +91,19 @@ NoToString::Token NoToString::classifier3(const QChar *data) NoToString::Token NoToString::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -113,7 +113,7 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -126,11 +126,11 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -140,7 +140,7 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -153,12 +153,12 @@ NoToString::Token NoToString::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; diff --git a/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp index 0a452c5757..69c6de2f39 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp +++ b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp @@ -36,7 +36,7 @@ using namespace TheNamespace; WithNamespace::Token WithNamespace::classifier3(const QChar *data) { - if (data[0] == 100) + if (data[0].unicode() == 100) { @@ -52,7 +52,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[0] == 97) + else if (data[0].unicode() == 97) { @@ -68,7 +68,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[0] == 103) + else if (data[0].unicode() == 103) { @@ -91,19 +91,19 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) WithNamespace::Token WithNamespace::classifier4(const QChar *data) { - if (data[0] == 70) + if (data[0].unicode() == 70) { - if (data[1] == 70) + if (data[1].unicode() == 70) { - if (data[2] == 70) + if (data[2].unicode() == 70) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -113,7 +113,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -126,11 +126,11 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[2] == 71) + else if (data[2].unicode() == 71) { - if (data[3] == 70) + if (data[3].unicode() == 70) { @@ -140,7 +140,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[3] == 71) + else if (data[3].unicode() == 71) { @@ -153,12 +153,12 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[2] == 76) + else if (data[2].unicode() == 76) { - if(data[3] == 77) + if (data[3].unicode() == 77) return FFLM; @@ -178,7 +178,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) WithNamespace::Token WithNamespace::classifier14(const QChar *data) { - if (data[0] == 119) + if (data[0].unicode() == 119) { @@ -194,7 +194,7 @@ WithNamespace::Token WithNamespace::classifier3(const QChar *data) } - else if (data[0] == 99) + else if (data[0].unicode() == 99) { diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index 7942a84615..f93c8f825b 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -129,29 +129,14 @@ void tst_toolsupport::offsets_data() #endif { -#ifdef Q_OS_WIN QTest::newRow("QDateTimePrivate::m_msecs") - << pmm_to_offsetof(&QDateTimePrivate::m_msecs) << 8 << 8; - QTest::newRow("QDateTimePrivate::m_spec") - << pmm_to_offsetof(&QDateTimePrivate::m_spec) << 16 << 16; - QTest::newRow("QDateTimePrivate::m_offsetFromUtc") - << pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 20 << 20; - QTest::newRow("QDateTimePrivate::m_timeZone") - << pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 24 << 24; + << pmm_to_offsetof(&QDateTimePrivate::m_msecs) << 0 << 0; QTest::newRow("QDateTimePrivate::m_status") - << pmm_to_offsetof(&QDateTimePrivate::m_status) << 28 << 32; -#else - QTest::newRow("QDateTimePrivate::m_msecs") - << pmm_to_offsetof(&QDateTimePrivate::m_msecs) << 4 << 8; - QTest::newRow("QDateTimePrivate::m_spec") - << pmm_to_offsetof(&QDateTimePrivate::m_spec) << 12 << 16; + << pmm_to_offsetof(&QDateTimePrivate::m_status) << 8 << 8; QTest::newRow("QDateTimePrivate::m_offsetFromUtc") - << pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 16 << 20; + << pmm_to_offsetof(&QDateTimePrivate::m_offsetFromUtc) << 12 << 12; QTest::newRow("QDateTimePrivate::m_timeZone") << pmm_to_offsetof(&QDateTimePrivate::m_timeZone) << 20 << 24; - QTest::newRow("QDateTimePrivate::m_status") - << pmm_to_offsetof(&QDateTimePrivate::m_status) << 24 << 32; -#endif } #endif // RUN_MEMBER_OFFSET_TEST } diff --git a/tests/auto/other/windowsmobile/test/ddhelper.cpp b/tests/auto/other/windowsmobile/test/ddhelper.cpp deleted file mode 100644 index 3ce99a0ded..0000000000 --- a/tests/auto/other/windowsmobile/test/ddhelper.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifdef Q_OS_WINCE_WM - -#include <Ddraw.h> -#include <QDebug> - -static LPDIRECTDRAW g_pDD = NULL; // DirectDraw object -static LPDIRECTDRAWSURFACE g_pDDSSurface = NULL; // DirectDraw primary surface - -static DDSCAPS ddsCaps; -static DDSURFACEDESC ddsSurfaceDesc; -static void *buffer = NULL; - -static int width = 0; -static int height = 0; -static int pitch = 0; -static int bitCount = 0; -static int windowId = 0; - -static bool initialized = false; -static bool locked = false; - -void q_lock() -{ - if (locked) { - qWarning("Direct Painter already locked (QDirectPainter::lock())"); - return; - } - locked = true; - - - memset(&ddsSurfaceDesc, 0, sizeof(ddsSurfaceDesc)); - ddsSurfaceDesc.dwSize = sizeof(ddsSurfaceDesc); - - HRESULT h = g_pDDSSurface->Lock(0, &ddsSurfaceDesc, DDLOCK_WRITEONLY, 0); - if (h != DD_OK) - qDebug() << "GetSurfaceDesc failed!"; - - width = ddsSurfaceDesc.dwWidth; - height = ddsSurfaceDesc.dwHeight; - bitCount = ddsSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; - pitch = ddsSurfaceDesc.lPitch; - buffer = ddsSurfaceDesc.lpSurface; -} - -void q_unlock() -{ - if( !locked) { - qWarning("Direct Painter not locked (QDirectPainter::unlock()"); - return; - } - g_pDDSSurface->Unlock(0); - locked = false; -} - -void q_initDD() -{ - if (initialized) - return; - - DirectDrawCreate(NULL, &g_pDD, NULL); - - HRESULT h; - h = g_pDD->SetCooperativeLevel(0, DDSCL_NORMAL); - - if (h != DD_OK) - qDebug() << "cooperation level failed"; - - h = g_pDD->TestCooperativeLevel(); - if (h != DD_OK) - qDebug() << "cooperation level failed test"; - - DDSURFACEDESC ddsd; - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - - ddsd.dwFlags = DDSD_CAPS; - - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - h = g_pDD->CreateSurface(&ddsd, &g_pDDSSurface, NULL); - - if (h != DD_OK) - qDebug() << "CreateSurface failed!"; - - if (g_pDDSSurface->GetCaps(&ddsCaps) != DD_OK) - qDebug() << "GetCaps failed"; - - q_lock(); - q_unlock(); - initialized = true; -} - -uchar* q_frameBuffer() -{ - return (uchar*) buffer; -} - -int q_screenDepth() -{ - return bitCount; -} - -int q_screenWidth() -{ - return width; -} - -int q_screenHeight() -{ - return height; -} - -int q_linestep() -{ - return pitch; -} - -#endif //Q_OS_WINCE_WM - - diff --git a/tests/auto/other/windowsmobile/test/test.pro b/tests/auto/other/windowsmobile/test/test.pro deleted file mode 100644 index 36dd15f60e..0000000000 --- a/tests/auto/other/windowsmobile/test/test.pro +++ /dev/null @@ -1,23 +0,0 @@ - -CONFIG += testcase -QT += widgets testlib -HEADERS += ddhelper.h -SOURCES += tst_windowsmobile.cpp ddhelper.cpp -RESOURCES += windowsmobile.qrc - -TARGET = ../tst_windowsmobile - -wincewm*: { - addFiles.files = $$OUT_PWD/../testQMenuBar/*.exe - - - addFiles.path = "\\Program Files\\tst_windowsmobile" - DEPLOYMENT += addFiles -} - -wincewm*: { - LIBS += Ddraw.lib -} - - - diff --git a/tests/auto/other/windowsmobile/test/testQMenuBar_current.png b/tests/auto/other/windowsmobile/test/testQMenuBar_current.png Binary files differdeleted file mode 100644 index f0042b8fe0..0000000000 --- a/tests/auto/other/windowsmobile/test/testQMenuBar_current.png +++ /dev/null diff --git a/tests/auto/other/windowsmobile/test/testSimpleWidget_current.png b/tests/auto/other/windowsmobile/test/testSimpleWidget_current.png Binary files differdeleted file mode 100644 index 8086c41ce9..0000000000 --- a/tests/auto/other/windowsmobile/test/testSimpleWidget_current.png +++ /dev/null diff --git a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp deleted file mode 100644 index 8d0e468bd6..0000000000 --- a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QtCore/QDate> -#include <QtCore/QDebug> -#include <QtCore/QObject> -#include <QtGui> -#ifdef Q_OS_WINCE_WM -#include <windows.h> -#include "ddhelper.h" -#endif - - - -class tst_WindowsMobile : public QObject -{ - Q_OBJECT -public: - tst_WindowsMobile() - { - qApp->setCursorFlashTime (24 * 3600 * 1000); // once a day - // qApp->setCursorFlashTime (INT_MAX); -#ifdef Q_OS_WINCE_WM - q_initDD(); -#endif - } - -#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 - private slots: - void testMainWindowAndMenuBar(); - void testSimpleWidget(); -#endif -}; - -#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 - -bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} - -bool qt_wince_is_smartphone() { - return qt_wince_is_platform(QString::fromLatin1("Smartphone")); -} - -void openMenu() -{ - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,450,630,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,450,630,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); - QTest::qWait(2000); - ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); -} - -void compareScreenshots(const QString &image1, const QString &image2) -{ - QImage screenShot(image1); - QImage original(image2); - - // cut away the title bar before comparing - QDesktopWidget desktop; - QRect desktopFrameRect = desktop.frameGeometry(); - QRect desktopClientRect = desktop.availableGeometry(); - - QPainter p1(&screenShot); - QPainter p2(&original); - - //screenShot.save("scr1.png", "PNG"); - p1.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); - p2.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); - - //screenShot.save("scr2.png", "PNG"); - //original.save("orig1.png", "PNG"); - - QCOMPARE(original, screenShot); -} - -void takeScreenShot(const QString filename) -{ - q_lock(); - QImage image = QImage(( uchar *) q_frameBuffer(), q_screenWidth(), - q_screenHeight(), q_screenWidth() * q_screenDepth() / 8, QImage::Format_RGB16); - image.save(filename, "PNG"); - q_unlock(); -} - -void tst_WindowsMobile::testMainWindowAndMenuBar() -{ - if (qt_wince_is_smartphone()) - QSKIP("This test is only for Windows Mobile"); - - QProcess process; - process.start("testQMenuBar.exe"); - QCOMPARE(process.state(), QProcess::Running); - QTest::qWait(6000); - openMenu(); - QTest::qWait(1000); - takeScreenShot("testQMenuBar_current.png"); - process.close(); - compareScreenshots("testQMenuBar_current.png", ":/testQMenuBar_current.png"); -} - -void tst_WindowsMobile::testSimpleWidget() -{ - if (qt_wince_is_smartphone()) - QSKIP("This test is only for Windows Mobile"); - - QMenuBar menubar; - menubar.show(); - QWidget maximized; - QPalette pal = maximized.palette(); - pal.setColor(QPalette::Background, Qt::red); - maximized.setPalette(pal); - maximized.showMaximized(); - QWidget widget; - widget.setGeometry(100, 100, 200, 200); - widget.setWindowTitle("Widget"); - widget.show(); - qApp->processEvents(); - QTest::qWait(1000); - - QWidget widget2; - widget2.setGeometry(100, 380, 300, 200); - widget2.setWindowTitle("Widget 2"); - widget2.setWindowFlags(Qt::Popup); - widget2.show(); - - qApp->processEvents(); - QTest::qWait(1000); - takeScreenShot("testSimpleWidget_current.png"); - compareScreenshots("testSimpleWidget_current.png", ":/testSimpleWidget_current.png"); -} - - -#endif //Q_OS_WINCE_WM - - -QTEST_MAIN(tst_WindowsMobile) -#include "tst_windowsmobile.moc" - diff --git a/tests/auto/other/windowsmobile/test/windowsmobile.qrc b/tests/auto/other/windowsmobile/test/windowsmobile.qrc deleted file mode 100644 index 5d6f61459e..0000000000 --- a/tests/auto/other/windowsmobile/test/windowsmobile.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>testQMenuBar_current.png</file> - <file>testSimpleWidget_current.png</file> -</qresource> -</RCC> diff --git a/tests/auto/other/windowsmobile/testQMenuBar/main.cpp b/tests/auto/other/windowsmobile/testQMenuBar/main.cpp deleted file mode 100644 index 8d9071ff72..0000000000 --- a/tests/auto/other/windowsmobile/testQMenuBar/main.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QtCore/QDate> -#include <QtCore/QDebug> -#include <QtCore/QObject> -#include <QtGui> -#include <windows.h> - -int main(int argc, char * argv[]) -{ - QList<QWidget*> widgets; - QApplication app(argc, argv); - - QMainWindow mainWindow; - mainWindow.setWindowTitle("Test"); - QMenu *fileMenu = mainWindow.menuBar()->addMenu("File"); - QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit"); - QMenu *viewMenu = mainWindow.menuBar()->addMenu("View"); - QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools"); - QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options"); - QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help"); - - qApp->processEvents(); - - fileMenu->addAction("Open"); - QAction *close = fileMenu->addAction("Close"); - fileMenu->addSeparator(); - fileMenu->addAction("Exit"); - - close->setEnabled(false); - - editMenu->addAction("Cut"); - editMenu->addAction("Pase"); - editMenu->addAction("Copy"); - editMenu->addSeparator(); - editMenu->addAction("Find"); - - viewMenu->addAction("Hide"); - viewMenu->addAction("Show"); - viewMenu->addAction("Explore"); - QAction *visible = viewMenu->addAction("Visible"); - visible->setCheckable(true); - visible->setChecked(true); - - toolsMenu->addMenu("Hammer"); - toolsMenu->addMenu("Caliper"); - toolsMenu->addMenu("Helm"); - - optionsMenu->addMenu("Settings"); - optionsMenu->addMenu("Standard"); - optionsMenu->addMenu("Extended"); - - QMenu *subMenu = helpMenu->addMenu("Help"); - subMenu->addAction("Index"); - subMenu->addSeparator(); - subMenu->addAction("Vodoo Help"); - helpMenu->addAction("Contens"); - helpMenu->addSeparator(); - helpMenu->addAction("About"); - - QToolBar toolbar; - mainWindow.addToolBar(&toolbar); - toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction")); - - QTextEdit textEdit; - mainWindow.setCentralWidget(&textEdit); - - mainWindow.showMaximized(); - - app.exec(); -} diff --git a/tests/auto/other/windowsmobile/testQMenuBar/testQMenuBar.pro b/tests/auto/other/windowsmobile/testQMenuBar/testQMenuBar.pro deleted file mode 100644 index 12ef683c11..0000000000 --- a/tests/auto/other/windowsmobile/testQMenuBar/testQMenuBar.pro +++ /dev/null @@ -1,5 +0,0 @@ -SOURCES += main.cpp -QT += widgets -TARGET = ../testQMenuBar - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/windowsmobile/windowsmobile.pro b/tests/auto/other/windowsmobile/windowsmobile.pro deleted file mode 100644 index 2e6b444d7b..0000000000 --- a/tests/auto/other/windowsmobile/windowsmobile.pro +++ /dev/null @@ -1,9 +0,0 @@ - -TEMPLATE = subdirs - -wincewm* { - SUBDIRS = testQMenuBar -} - SUBDIRS += test - - diff --git a/tests/auto/qtest-config.h b/tests/auto/qtest-config.h deleted file mode 100644 index b3696a1456..0000000000 --- a/tests/auto/qtest-config.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTEST_CONFIG_H -#define QTEST_CONFIG_H - -#include <qglobal.h> - -#ifndef QTEST_NO_CURSOR -# if defined(QT_NO_CURSOR) || defined(Q_OS_WINCE) || defined(MEEGO_EDITION_HARMATTAN) -# define QTEST_NO_CURSOR -# endif -#endif // QTEST_NO_CURSOR - -#endif // QTEST_CONFIG_H diff --git a/tests/auto/sql/kernel/qsql/qsql.pro b/tests/auto/sql/kernel/qsql/qsql.pro index 71e2989572..1c7452cd73 100644 --- a/tests/auto/sql/kernel/qsql/qsql.pro +++ b/tests/auto/sql/kernel/qsql/qsql.pro @@ -3,9 +3,3 @@ TARGET = tst_qsql SOURCES += tst_qsql.cpp QT = core-private sql-private testlib - -wince { - DEPLOYMENT_PLUGIN += qsqlite -} -mingw: LIBS += -lws2_32 - diff --git a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro index 7da5b8bc8e..9ee414bf34 100644 --- a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro +++ b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro @@ -3,17 +3,3 @@ TARGET = tst_qsqldatabase SOURCES += tst_qsqldatabase.cpp QT = core sql testlib core-private sql-private - -win32: { - !wince: LIBS += -lws2_32 - else: LIBS += -lws2 -} - -wince { - DEPLOYMENT_PLUGIN += qsqlite - - testData.files = testdata - testData.path = . - - DEPLOYMENT += testData -} diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index 389d3abf85..701da7d346 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -43,20 +43,6 @@ #include <QtSql/private/qsqldriver_p.h> #include <QtTest/QtTest> -#if defined(Q_OS_WIN) -# include <qt_windows.h> -# if defined(Q_OS_WINCE) || defined(Q_OS_WINRT) -# include <winsock2.h> -# endif -#else -#include <unistd.h> -#endif -#if defined(Q_OS_WINRT) - static inline int qgethostname(char *name, int) { qstrcpy(name, "localhost"); return 9; } -#else -# define qgethostname gethostname -#endif - #define CHECK_DATABASE( db ) \ if ( !db.isValid() ) { qFatal( "db is Invalid" ); } @@ -71,16 +57,10 @@ static QString qGetHostName() { static QString hostname; - if ( !hostname.isEmpty() ) - return hostname; - - char hn[257]; - - if ( qgethostname( hn, 255 ) == 0 ) { - hn[256] = '\0'; - hostname = QString::fromLatin1( hn ); - hostname.replace( QLatin1Char( '.' ), QLatin1Char( '_' ) ); - hostname.replace( QLatin1Char( '-' ), QLatin1Char( '_' ) ); + if (hostname.isEmpty()) { + hostname = QSysInfo::machineHostName(); + hostname.replace(QLatin1Char( '.' ), QLatin1Char( '_' )); + hostname.replace(QLatin1Char( '-' ), QLatin1Char( '_' )); } return hostname; diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index bd8fbcca0e..8126e72ad2 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -100,6 +100,8 @@ private slots: void eventNotificationIBase(); void eventNotificationPSQL_data() { generic_data("QPSQL"); } void eventNotificationPSQL(); + void eventNotificationSQLite_data() { generic_data("QSQLITE"); } + void eventNotificationSQLite(); //database specific 64 bit integer test void bigIntField_data() { generic_data(); } @@ -2109,6 +2111,35 @@ void tst_QSqlDatabase::eventNotificationPSQL() QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } +void tst_QSqlDatabase::eventNotificationSQLite() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + if (db.driverName().compare(QLatin1String("QSQLITE"), Qt::CaseInsensitive)) { + QSKIP("QSQLITE specific test"); + } + const QString tableName(qTableName("sqlitnotifytest", __FILE__, db)); + tst_Databases::safeDropTable(db, tableName); + + QSignalSpy notificationSpy(db.driver(), SIGNAL(notification(QString))); + QSignalSpy notificationSpyExt(db.driver(), SIGNAL(notification(QString,QSqlDriver::NotificationSource,QVariant))); + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER, realVal REAL)")); + db.driver()->subscribeToNotification(tableName); + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)")); + QTRY_COMPARE(notificationSpy.count(), 1); + QTRY_COMPARE(notificationSpyExt.count(), 1); + QList<QVariant> arguments = notificationSpy.takeFirst(); + QCOMPARE(arguments.at(0).toString(), tableName); + arguments = notificationSpyExt.takeFirst(); + QCOMPARE(arguments.at(0).toString(), tableName); + db.driver()->unsubscribeFromNotification(tableName); + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)")); + QTRY_COMPARE(notificationSpy.count(), 0); + QTRY_COMPARE(notificationSpyExt.count(), 0); +} + void tst_QSqlDatabase::sqlite_bindAndFetchUInt() { QFETCH(QString, dbName); diff --git a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro index 8bfe1da1ce..772dc89177 100644 --- a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro +++ b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro @@ -3,16 +3,3 @@ TARGET = tst_qsqldriver SOURCES += tst_qsqldriver.cpp QT = core sql testlib core-private sql-private - -wince { - plugFiles.files = ../../../plugins/sqldrivers - plugFiles.path = . - DEPLOYMENT += plugFiles - LIBS += -lws2 -} else { - mingw { - LIBS += -lws2_32 - } else:win32 { - LIBS += ws2_32.lib - } -} diff --git a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro index a6be23892d..c7638f9c0b 100644 --- a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro +++ b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro @@ -4,12 +4,3 @@ CONFIG += testcase SOURCES += tst_qsqlquery.cpp QT = core sql testlib core-private sql-private - -win32:!wince: LIBS += -lws2_32 - -wince { - plugFiles.files = ../../../plugins/sqldrivers - plugFiles.path = . - DEPLOYMENT += plugFiles - LIBS += -lws2 -} diff --git a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro index 64d8c5ccfb..32e0f2228f 100644 --- a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro +++ b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro @@ -3,14 +3,3 @@ TARGET = tst_qsqlthread SOURCES += tst_qsqlthread.cpp QT = core sql testlib core-private sql-private - - -wince { - plugFiles.files = ../../../plugins/sqldrivers - plugFiles.path = . - DEPLOYMENT += plugFiles - LIBS += -lws2 -} else { - win32:LIBS += -lws2_32 -} - diff --git a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro index 2576fbad71..05eb871694 100644 --- a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro +++ b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro @@ -3,11 +3,3 @@ TARGET = tst_qsqlquerymodel SOURCES += tst_qsqlquerymodel.cpp QT += widgets sql testlib core-private sql-private - -wince { - DEPLOYMENT_PLUGIN += qsqlite - LIBS += -lws2 -} else { - win32:LIBS += -lws2_32 -} - diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro index cade7c171d..5695c06b29 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro @@ -3,16 +3,3 @@ TARGET = tst_qsqlrelationaltablemodel SOURCES += tst_qsqlrelationaltablemodel.cpp QT = core sql testlib core-private sql-private - -wince { - plugFiles.files = ../../../plugins/sqldrivers - plugFiles.path = . - DEPLOYMENT += plugFiles - LIBS += -lws2 -} else { - mingw { - LIBS += -lws2_32 - } else:win32 { - LIBS += ws2_32.lib - } -} diff --git a/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro b/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro index 2af39b341f..958f0507bf 100644 --- a/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro +++ b/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro @@ -3,13 +3,3 @@ TARGET = tst_qsqltablemodel SOURCES += tst_qsqltablemodel.cpp QT = core core-private sql sql-private testlib - -wince { - plugFiles.files = ../../../plugins/sqldrivers - plugFiles.path = . - DEPLOYMENT += plugFiles - LIBS += -lws2 -} else { - win32:LIBS += -lws2_32 -} - diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 3586b7f420..97eb19599b 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -128,6 +128,7 @@ private slots: void compare_registered_enums(); void compare_class_enums(); void compare_boolfuncs(); + void compare_to_nullptr(); void compare_pointerfuncs(); void compare_tostring(); void compare_tostring_data(); @@ -148,6 +149,7 @@ private slots: void verify2(); void tryVerify(); void tryVerify2(); + void verifyExplicitOperatorBool(); }; enum MyUnregisteredEnum { MyUnregisteredEnumValue1, MyUnregisteredEnumValue2 }; @@ -183,6 +185,24 @@ void tst_Cmptest::compare_boolfuncs() QCOMPARE(!boolfunc(), false); } +namespace { +template <typename T> +T *null() Q_DECL_NOTHROW { return nullptr; } +} + +void tst_Cmptest::compare_to_nullptr() +{ + QCOMPARE(null<int>(), nullptr); + QCOMPARE(null<const int>(), nullptr); + QCOMPARE(null<volatile int>(), nullptr); + QCOMPARE(null<const volatile int>(), nullptr); + + QCOMPARE(nullptr, null<int>()); + QCOMPARE(nullptr, null<const int>()); + QCOMPARE(nullptr, null<volatile int>()); + QCOMPARE(nullptr, null<const volatile int>()); +} + static int i = 0; static int *intptr() { return &i; } @@ -465,5 +485,21 @@ void tst_Cmptest::tryVerify2() QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1); } +void tst_Cmptest::verifyExplicitOperatorBool() +{ + struct ExplicitOperatorBool { + int m_i; + explicit ExplicitOperatorBool(int i) : m_i(i) {} + explicit operator bool() const { return m_i > 0; } + bool operator !() const { return !bool(*this); } + }; + + ExplicitOperatorBool val1(42); + QVERIFY(val1); + + ExplicitOperatorBool val2(-273); + QVERIFY(!val2); +} + QTEST_MAIN(tst_Cmptest) #include "tst_cmptest.moc" diff --git a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp index 6cfa023b7e..87b241f5e5 100644 --- a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp +++ b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp @@ -44,7 +44,7 @@ private slots: void tst_Crashes::crash() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //we avoid the error dialogbox to appear on windows SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); #endif diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index a66413dfa0..621aceb887 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -8,13 +8,13 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_unregistered_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="158"> +<Incident type="fail" file="tst_cmptest.cpp" line="160"> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_registered_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="165"> +<Incident type="fail" file="tst_cmptest.cpp" line="167"> <Description><![CDATA[Compared values are not the same Actual (Qt::Monday): Monday Expected (Qt::Sunday): Sunday]]></Description> @@ -22,7 +22,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_class_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="171"> +<Incident type="fail" file="tst_cmptest.cpp" line="173"> <Description><![CDATA[Compared values are not the same Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1 Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description> @@ -33,12 +33,16 @@ <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> </TestFunction> +<TestFunction name="compare_to_nullptr"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="compare_pointerfuncs"> <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_tostring"> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[int, string]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(int,123) @@ -47,19 +51,19 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both invalid]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[null hash, invalid]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant()]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[string, null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass)]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[both non-null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) @@ -74,31 +78,31 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal lists]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[second-last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[prefix]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[short list second]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[short list first]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 1 @@ -107,7 +111,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListInt"> -<Incident type="fail" file="tst_cmptest.cpp" line="343"> +<Incident type="fail" file="tst_cmptest.cpp" line="363"> <Description><![CDATA[Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4]]></Description> @@ -115,7 +119,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListDouble"> -<Incident type="fail" file="tst_cmptest.cpp" line="350"> +<Incident type="fail" file="tst_cmptest.cpp" line="370"> <Description><![CDATA[Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1]]></Description> @@ -123,7 +127,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQColor"> -<Incident type="fail" file="tst_cmptest.cpp" line="360"> +<Incident type="fail" file="tst_cmptest.cpp" line="380"> <Description><![CDATA[Compared values are not the same Actual (yellow): #ffff00 Expected (green) : #00ff00]]></Description> @@ -134,13 +138,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 0 @@ -149,13 +153,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> @@ -165,13 +169,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 0 @@ -180,19 +184,19 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different format]]></DataTag> <Description><![CDATA[Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> @@ -202,7 +206,7 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal-empty]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="435"> +<Incident type="fail" file="tst_cmptest.cpp" line="455"> <DataTag><![CDATA[1-empty]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (rA): QRegion(200x50+10+10) @@ -211,7 +215,7 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="435"> +<Incident type="fail" file="tst_cmptest.cpp" line="455"> <DataTag><![CDATA[different lists]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (rA): QRegion(200x50+10+10) @@ -220,29 +224,33 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="verify"> -<Incident type="fail" file="tst_cmptest.cpp" line="447"> +<Incident type="fail" file="tst_cmptest.cpp" line="467"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="verify2"> -<Incident type="fail" file="tst_cmptest.cpp" line="453"> +<Incident type="fail" file="tst_cmptest.cpp" line="473"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify"> -<Incident type="fail" file="tst_cmptest.cpp" line="459"> +<Incident type="fail" file="tst_cmptest.cpp" line="479"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify2"> -<Incident type="fail" file="tst_cmptest.cpp" line="465"> +<Incident type="fail" file="tst_cmptest.cpp" line="485"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="verifyExplicitOperatorBool"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="cleanupTestCase"> <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity index 925acb37fe..8801e05e6e 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.teamcity +++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity @@ -2,117 +2,121 @@ ##teamcity[testStarted name='initTestCase()'] ##teamcity[testFinished name='initTestCase()'] ##teamcity[testStarted name='compare_unregistered_enums()'] -##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(158)|]' details='Compared values are not the same'] +##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(160)|]' details='Compared values are not the same'] ##teamcity[testFinished name='compare_unregistered_enums()'] ##teamcity[testStarted name='compare_registered_enums()'] -##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(165)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday'] +##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(167)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday'] ##teamcity[testFinished name='compare_registered_enums()'] ##teamcity[testStarted name='compare_class_enums()'] -##teamcity[testFailed name='compare_class_enums()' message='Failure! |[Loc: tst_cmptest.cpp(171)|]' details='Compared values are not the same|n Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1|n Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2'] +##teamcity[testFailed name='compare_class_enums()' message='Failure! |[Loc: tst_cmptest.cpp(173)|]' details='Compared values are not the same|n Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1|n Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2'] ##teamcity[testFinished name='compare_class_enums()'] ##teamcity[testStarted name='compare_boolfuncs()'] ##teamcity[testFinished name='compare_boolfuncs()'] +##teamcity[testStarted name='compare_to_nullptr()'] +##teamcity[testFinished name='compare_to_nullptr()'] ##teamcity[testStarted name='compare_pointerfuncs()'] ##teamcity[testFinished name='compare_pointerfuncs()'] ##teamcity[testStarted name='compare_tostring(int, string)'] -##teamcity[testFailed name='compare_tostring(int, string)' message='Failure! |[Loc: tst_cmptest.cpp(242)|]' details='Compared values are not the same|n Actual (actual) : QVariant(int,123)|n Expected (expected): QVariant(QString,hi)'] +##teamcity[testFailed name='compare_tostring(int, string)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(int,123)|n Expected (expected): QVariant(QString,hi)'] ##teamcity[testFinished name='compare_tostring(int, string)'] ##teamcity[testStarted name='compare_tostring(both invalid)'] ##teamcity[testFinished name='compare_tostring(both invalid)'] ##teamcity[testStarted name='compare_tostring(null hash, invalid)'] -##teamcity[testFailed name='compare_tostring(null hash, invalid)' message='Failure! |[Loc: tst_cmptest.cpp(242)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QVariantHash)|n Expected (expected): QVariant()'] +##teamcity[testFailed name='compare_tostring(null hash, invalid)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QVariantHash)|n Expected (expected): QVariant()'] ##teamcity[testFinished name='compare_tostring(null hash, invalid)'] ##teamcity[testStarted name='compare_tostring(string, null user type)'] -##teamcity[testFailed name='compare_tostring(string, null user type)' message='Failure! |[Loc: tst_cmptest.cpp(242)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QString,A simple string)|n Expected (expected): QVariant(PhonyClass)'] +##teamcity[testFailed name='compare_tostring(string, null user type)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QString,A simple string)|n Expected (expected): QVariant(PhonyClass)'] ##teamcity[testFinished name='compare_tostring(string, null user type)'] ##teamcity[testStarted name='compare_tostring(both non-null user type)'] -##teamcity[testFailed name='compare_tostring(both non-null user type)' message='Failure! |[Loc: tst_cmptest.cpp(242)|]' details='Compared values are not the same|n Actual (actual) : QVariant(PhonyClass,<value not representable as string>)|n Expected (expected): QVariant(PhonyClass,<value not representable as string>)'] +##teamcity[testFailed name='compare_tostring(both non-null user type)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(PhonyClass,<value not representable as string>)|n Expected (expected): QVariant(PhonyClass,<value not representable as string>)'] ##teamcity[testFinished name='compare_tostring(both non-null user type)'] ##teamcity[testStarted name='compareQStringLists(empty lists)'] ##teamcity[testFinished name='compareQStringLists(empty lists)'] ##teamcity[testStarted name='compareQStringLists(equal lists)'] ##teamcity[testFinished name='compareQStringLists(equal lists)'] ##teamcity[testStarted name='compareQStringLists(last item different)'] -##teamcity[testFailed name='compareQStringLists(last item different)' message='Failure! |[Loc: tst_cmptest.cpp(336)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"'] +##teamcity[testFailed name='compareQStringLists(last item different)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"'] ##teamcity[testFinished name='compareQStringLists(last item different)'] ##teamcity[testStarted name='compareQStringLists(second-last item different)'] -##teamcity[testFailed name='compareQStringLists(second-last item different)' message='Failure! |[Loc: tst_cmptest.cpp(336)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"'] +##teamcity[testFailed name='compareQStringLists(second-last item different)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"'] ##teamcity[testFinished name='compareQStringLists(second-last item different)'] ##teamcity[testStarted name='compareQStringLists(prefix)'] -##teamcity[testFailed name='compareQStringLists(prefix)' message='Failure! |[Loc: tst_cmptest.cpp(336)|]' details='Compared lists have different sizes.|n Actual (opA) size: 2|n Expected (opB) size: 1'] +##teamcity[testFailed name='compareQStringLists(prefix)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 2|n Expected (opB) size: 1'] ##teamcity[testFinished name='compareQStringLists(prefix)'] ##teamcity[testStarted name='compareQStringLists(short list second)'] -##teamcity[testFailed name='compareQStringLists(short list second)' message='Failure! |[Loc: tst_cmptest.cpp(336)|]' details='Compared lists have different sizes.|n Actual (opA) size: 12|n Expected (opB) size: 1'] +##teamcity[testFailed name='compareQStringLists(short list second)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 12|n Expected (opB) size: 1'] ##teamcity[testFinished name='compareQStringLists(short list second)'] ##teamcity[testStarted name='compareQStringLists(short list first)'] -##teamcity[testFailed name='compareQStringLists(short list first)' message='Failure! |[Loc: tst_cmptest.cpp(336)|]' details='Compared lists have different sizes.|n Actual (opA) size: 1|n Expected (opB) size: 12'] +##teamcity[testFailed name='compareQStringLists(short list first)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 1|n Expected (opB) size: 12'] ##teamcity[testFinished name='compareQStringLists(short list first)'] ##teamcity[testStarted name='compareQListInt()'] -##teamcity[testFailed name='compareQListInt()' message='Failure! |[Loc: tst_cmptest.cpp(343)|]' details='Compared lists differ at index 2.|n Actual (int1): 3|n Expected (int2): 4'] +##teamcity[testFailed name='compareQListInt()' message='Failure! |[Loc: tst_cmptest.cpp(363)|]' details='Compared lists differ at index 2.|n Actual (int1): 3|n Expected (int2): 4'] ##teamcity[testFinished name='compareQListInt()'] ##teamcity[testStarted name='compareQListDouble()'] -##teamcity[testFailed name='compareQListDouble()' message='Failure! |[Loc: tst_cmptest.cpp(350)|]' details='Compared lists differ at index 0.|n Actual (double1): 1.5|n Expected (double2): 1'] +##teamcity[testFailed name='compareQListDouble()' message='Failure! |[Loc: tst_cmptest.cpp(370)|]' details='Compared lists differ at index 0.|n Actual (double1): 1.5|n Expected (double2): 1'] ##teamcity[testFinished name='compareQListDouble()'] ##teamcity[testStarted name='compareQColor()'] -##teamcity[testFailed name='compareQColor()' message='Failure! |[Loc: tst_cmptest.cpp(360)|]' details='Compared values are not the same|n Actual (yellow): #ffff00|n Expected (green) : #00ff00'] +##teamcity[testFailed name='compareQColor()' message='Failure! |[Loc: tst_cmptest.cpp(380)|]' details='Compared values are not the same|n Actual (yellow): #ffff00|n Expected (green) : #00ff00'] ##teamcity[testFinished name='compareQColor()'] ##teamcity[testStarted name='compareQPixmaps(both null)'] ##teamcity[testFinished name='compareQPixmaps(both null)'] ##teamcity[testStarted name='compareQPixmaps(one null)'] -##teamcity[testFailed name='compareQPixmaps(one null)' message='Failure! |[Loc: tst_cmptest.cpp(385)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0'] +##teamcity[testFailed name='compareQPixmaps(one null)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0'] ##teamcity[testFinished name='compareQPixmaps(one null)'] ##teamcity[testStarted name='compareQPixmaps(other null)'] -##teamcity[testFailed name='compareQPixmaps(other null)' message='Failure! |[Loc: tst_cmptest.cpp(385)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1'] +##teamcity[testFailed name='compareQPixmaps(other null)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1'] ##teamcity[testFinished name='compareQPixmaps(other null)'] ##teamcity[testStarted name='compareQPixmaps(equal)'] ##teamcity[testFinished name='compareQPixmaps(equal)'] ##teamcity[testStarted name='compareQPixmaps(different size)'] -##teamcity[testFailed name='compareQPixmaps(different size)' message='Failure! |[Loc: tst_cmptest.cpp(385)|]' details='Compared QPixmaps differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20'] +##teamcity[testFailed name='compareQPixmaps(different size)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20'] ##teamcity[testFinished name='compareQPixmaps(different size)'] ##teamcity[testStarted name='compareQPixmaps(different pixels)'] -##teamcity[testFailed name='compareQPixmaps(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(385)|]' details='Compared values are not the same'] +##teamcity[testFailed name='compareQPixmaps(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared values are not the same'] ##teamcity[testFinished name='compareQPixmaps(different pixels)'] ##teamcity[testStarted name='compareQImages(both null)'] ##teamcity[testFinished name='compareQImages(both null)'] ##teamcity[testStarted name='compareQImages(one null)'] -##teamcity[testFailed name='compareQImages(one null)' message='Failure! |[Loc: tst_cmptest.cpp(412)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0'] +##teamcity[testFailed name='compareQImages(one null)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0'] ##teamcity[testFinished name='compareQImages(one null)'] ##teamcity[testStarted name='compareQImages(other null)'] -##teamcity[testFailed name='compareQImages(other null)' message='Failure! |[Loc: tst_cmptest.cpp(412)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1'] +##teamcity[testFailed name='compareQImages(other null)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1'] ##teamcity[testFinished name='compareQImages(other null)'] ##teamcity[testStarted name='compareQImages(equal)'] ##teamcity[testFinished name='compareQImages(equal)'] ##teamcity[testStarted name='compareQImages(different size)'] -##teamcity[testFailed name='compareQImages(different size)' message='Failure! |[Loc: tst_cmptest.cpp(412)|]' details='Compared QImages differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20'] +##teamcity[testFailed name='compareQImages(different size)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20'] ##teamcity[testFinished name='compareQImages(different size)'] ##teamcity[testStarted name='compareQImages(different format)'] -##teamcity[testFailed name='compareQImages(different format)' message='Failure! |[Loc: tst_cmptest.cpp(412)|]' details='Compared QImages differ in format.|n Actual (opA): 6|n Expected (opB): 3'] +##teamcity[testFailed name='compareQImages(different format)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ in format.|n Actual (opA): 6|n Expected (opB): 3'] ##teamcity[testFinished name='compareQImages(different format)'] ##teamcity[testStarted name='compareQImages(different pixels)'] -##teamcity[testFailed name='compareQImages(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(412)|]' details='Compared values are not the same'] +##teamcity[testFailed name='compareQImages(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared values are not the same'] ##teamcity[testFinished name='compareQImages(different pixels)'] ##teamcity[testStarted name='compareQRegion(equal-empty)'] ##teamcity[testFinished name='compareQRegion(equal-empty)'] ##teamcity[testStarted name='compareQRegion(1-empty)'] -##teamcity[testFailed name='compareQRegion(1-empty)' message='Failure! |[Loc: tst_cmptest.cpp(435)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(null)'] +##teamcity[testFailed name='compareQRegion(1-empty)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(null)'] ##teamcity[testFinished name='compareQRegion(1-empty)'] ##teamcity[testStarted name='compareQRegion(equal)'] ##teamcity[testFinished name='compareQRegion(equal)'] ##teamcity[testStarted name='compareQRegion(different lists)'] -##teamcity[testFailed name='compareQRegion(different lists)' message='Failure! |[Loc: tst_cmptest.cpp(435)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)'] +##teamcity[testFailed name='compareQRegion(different lists)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)'] ##teamcity[testFinished name='compareQRegion(different lists)'] ##teamcity[testStarted name='verify()'] -##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(447)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()'] +##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(467)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()'] ##teamcity[testFinished name='verify()'] ##teamcity[testStarted name='verify2()'] -##teamcity[testFailed name='verify2()' message='Failure! |[Loc: tst_cmptest.cpp(453)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)'] +##teamcity[testFailed name='verify2()' message='Failure! |[Loc: tst_cmptest.cpp(473)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)'] ##teamcity[testFinished name='verify2()'] ##teamcity[testStarted name='tryVerify()'] -##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: tst_cmptest.cpp(459)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()'] +##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: tst_cmptest.cpp(479)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()'] ##teamcity[testFinished name='tryVerify()'] ##teamcity[testStarted name='tryVerify2()'] -##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: tst_cmptest.cpp(465)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)'] +##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: tst_cmptest.cpp(485)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)'] ##teamcity[testFinished name='tryVerify2()'] +##teamcity[testStarted name='verifyExplicitOperatorBool()'] +##teamcity[testFinished name='verifyExplicitOperatorBool()'] ##teamcity[testStarted name='cleanupTestCase()'] ##teamcity[testFinished name='cleanupTestCase()'] ##teamcity[testSuiteFinished name='tst_Cmptest'] diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index c7094a4113..9c7f56e6c3 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -2,122 +2,124 @@ Config: Using QtTest library PASS : tst_Cmptest::initTestCase() FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same - Loc: [tst_cmptest.cpp(158)] + Loc: [tst_cmptest.cpp(160)] FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same Actual (Qt::Monday): Monday Expected (Qt::Sunday): Sunday - Loc: [tst_cmptest.cpp(165)] + Loc: [tst_cmptest.cpp(167)] FAIL! : tst_Cmptest::compare_class_enums() Compared values are not the same Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1 Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2 - Loc: [tst_cmptest.cpp(171)] + Loc: [tst_cmptest.cpp(173)] PASS : tst_Cmptest::compare_boolfuncs() +PASS : tst_Cmptest::compare_to_nullptr() PASS : tst_Cmptest::compare_pointerfuncs() FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same Actual (actual) : QVariant(int,123) Expected (expected): QVariant(QString,hi) - Loc: [tst_cmptest.cpp(242)] + Loc: [tst_cmptest.cpp(262)] PASS : tst_Cmptest::compare_tostring(both invalid) FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant() - Loc: [tst_cmptest.cpp(242)] + Loc: [tst_cmptest.cpp(262)] FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass) - Loc: [tst_cmptest.cpp(242)] + Loc: [tst_cmptest.cpp(262)] FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>) - Loc: [tst_cmptest.cpp(242)] + Loc: [tst_cmptest.cpp(262)] PASS : tst_Cmptest::compareQStringLists(empty lists) PASS : tst_Cmptest::compareQStringLists(equal lists) FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS" - Loc: [tst_cmptest.cpp(336)] + Loc: [tst_cmptest.cpp(356)] FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS" - Loc: [tst_cmptest.cpp(336)] + Loc: [tst_cmptest.cpp(356)] FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1 - Loc: [tst_cmptest.cpp(336)] + Loc: [tst_cmptest.cpp(356)] FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1 - Loc: [tst_cmptest.cpp(336)] + Loc: [tst_cmptest.cpp(356)] FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes. Actual (opA) size: 1 Expected (opB) size: 12 - Loc: [tst_cmptest.cpp(336)] + Loc: [tst_cmptest.cpp(356)] FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4 - Loc: [tst_cmptest.cpp(343)] + Loc: [tst_cmptest.cpp(363)] FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1 - Loc: [tst_cmptest.cpp(350)] + Loc: [tst_cmptest.cpp(370)] FAIL! : tst_Cmptest::compareQColor() Compared values are not the same Actual (yellow): #ffff00 Expected (green) : #00ff00 - Loc: [tst_cmptest.cpp(360)] + Loc: [tst_cmptest.cpp(380)] PASS : tst_Cmptest::compareQPixmaps(both null) FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 - Loc: [tst_cmptest.cpp(385)] + Loc: [tst_cmptest.cpp(405)] FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ. Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 - Loc: [tst_cmptest.cpp(385)] + Loc: [tst_cmptest.cpp(405)] PASS : tst_Cmptest::compareQPixmaps(equal) FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20 - Loc: [tst_cmptest.cpp(385)] + Loc: [tst_cmptest.cpp(405)] FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same - Loc: [tst_cmptest.cpp(385)] + Loc: [tst_cmptest.cpp(405)] PASS : tst_Cmptest::compareQImages(both null) FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 - Loc: [tst_cmptest.cpp(412)] + Loc: [tst_cmptest.cpp(432)] FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ. Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 - Loc: [tst_cmptest.cpp(412)] + Loc: [tst_cmptest.cpp(432)] PASS : tst_Cmptest::compareQImages(equal) FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20 - Loc: [tst_cmptest.cpp(412)] + Loc: [tst_cmptest.cpp(432)] FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3 - Loc: [tst_cmptest.cpp(412)] + Loc: [tst_cmptest.cpp(432)] FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same - Loc: [tst_cmptest.cpp(412)] + Loc: [tst_cmptest.cpp(432)] PASS : tst_Cmptest::compareQRegion(equal-empty) FAIL! : tst_Cmptest::compareQRegion(1-empty) Compared values are not the same Actual (rA): QRegion(200x50+10+10) Expected (rB): QRegion(null) - Loc: [tst_cmptest.cpp(435)] + Loc: [tst_cmptest.cpp(455)] PASS : tst_Cmptest::compareQRegion(equal) FAIL! : tst_Cmptest::compareQRegion(different lists) Compared values are not the same Actual (rA): QRegion(200x50+10+10) Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10) - Loc: [tst_cmptest.cpp(435)] + Loc: [tst_cmptest.cpp(455)] FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. () - Loc: [tst_cmptest.cpp(447)] + Loc: [tst_cmptest.cpp(467)] FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42) - Loc: [tst_cmptest.cpp(453)] + Loc: [tst_cmptest.cpp(473)] FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. () - Loc: [tst_cmptest.cpp(459)] + Loc: [tst_cmptest.cpp(479)] FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42) - Loc: [tst_cmptest.cpp(465)] + Loc: [tst_cmptest.cpp(485)] +PASS : tst_Cmptest::verifyExplicitOperatorBool() PASS : tst_Cmptest::cleanupTestCase() -Totals: 13 passed, 30 failed, 0 skipped, 0 blacklisted, 246ms +Totals: 15 passed, 30 failed, 0 skipped, 0 blacklisted, 244ms ********* Finished testing of tst_Cmptest ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index d472840e98..f64ffe3792 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -10,13 +10,13 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_unregistered_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="158"> +<Incident type="fail" file="tst_cmptest.cpp" line="160"> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_registered_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="165"> +<Incident type="fail" file="tst_cmptest.cpp" line="167"> <Description><![CDATA[Compared values are not the same Actual (Qt::Monday): Monday Expected (Qt::Sunday): Sunday]]></Description> @@ -24,7 +24,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_class_enums"> -<Incident type="fail" file="tst_cmptest.cpp" line="171"> +<Incident type="fail" file="tst_cmptest.cpp" line="173"> <Description><![CDATA[Compared values are not the same Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1 Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description> @@ -35,12 +35,16 @@ <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> </TestFunction> +<TestFunction name="compare_to_nullptr"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="compare_pointerfuncs"> <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_tostring"> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[int, string]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(int,123) @@ -49,19 +53,19 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both invalid]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[null hash, invalid]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant()]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[string, null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass)]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="242"> +<Incident type="fail" file="tst_cmptest.cpp" line="262"> <DataTag><![CDATA[both non-null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) @@ -76,31 +80,31 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal lists]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[second-last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[prefix]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[short list second]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="336"> +<Incident type="fail" file="tst_cmptest.cpp" line="356"> <DataTag><![CDATA[short list first]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 1 @@ -109,7 +113,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListInt"> -<Incident type="fail" file="tst_cmptest.cpp" line="343"> +<Incident type="fail" file="tst_cmptest.cpp" line="363"> <Description><![CDATA[Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4]]></Description> @@ -117,7 +121,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListDouble"> -<Incident type="fail" file="tst_cmptest.cpp" line="350"> +<Incident type="fail" file="tst_cmptest.cpp" line="370"> <Description><![CDATA[Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1]]></Description> @@ -125,7 +129,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQColor"> -<Incident type="fail" file="tst_cmptest.cpp" line="360"> +<Incident type="fail" file="tst_cmptest.cpp" line="380"> <Description><![CDATA[Compared values are not the same Actual (yellow): #ffff00 Expected (green) : #00ff00]]></Description> @@ -136,13 +140,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 0 @@ -151,13 +155,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="385"> +<Incident type="fail" file="tst_cmptest.cpp" line="405"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> @@ -167,13 +171,13 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 0 @@ -182,19 +186,19 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different format]]></DataTag> <Description><![CDATA[Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="412"> +<Incident type="fail" file="tst_cmptest.cpp" line="432"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> @@ -204,7 +208,7 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal-empty]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="435"> +<Incident type="fail" file="tst_cmptest.cpp" line="455"> <DataTag><![CDATA[1-empty]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (rA): QRegion(200x50+10+10) @@ -213,7 +217,7 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="435"> +<Incident type="fail" file="tst_cmptest.cpp" line="455"> <DataTag><![CDATA[different lists]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (rA): QRegion(200x50+10+10) @@ -222,29 +226,33 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="verify"> -<Incident type="fail" file="tst_cmptest.cpp" line="447"> +<Incident type="fail" file="tst_cmptest.cpp" line="467"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="verify2"> -<Incident type="fail" file="tst_cmptest.cpp" line="453"> +<Incident type="fail" file="tst_cmptest.cpp" line="473"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify"> -<Incident type="fail" file="tst_cmptest.cpp" line="459"> +<Incident type="fail" file="tst_cmptest.cpp" line="479"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify2"> -<Incident type="fail" file="tst_cmptest.cpp" line="465"> +<Incident type="fail" file="tst_cmptest.cpp" line="485"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="verifyExplicitOperatorBool"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="cleanupTestCase"> <Incident type="pass" file="" line="0" /> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 9f1726b0d6..de47ac97f5 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="0" failures="30" tests="19" name="tst_Cmptest"> +<testsuite errors="0" failures="30" tests="21" name="tst_Cmptest"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -20,6 +20,7 @@ Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2" result="fail"/> </testcase> <testcase result="pass" name="compare_boolfuncs"/> + <testcase result="pass" name="compare_to_nullptr"/> <testcase result="pass" name="compare_pointerfuncs"/> <testcase result="fail" name="compare_tostring"> <failure tag="int, string" message="Compared values are not the same @@ -114,6 +115,7 @@ <testcase result="fail" name="tryVerify2"> <failure message="'opaqueFunc() < 2' returned FALSE. (42)" result="fail"/> </testcase> + <testcase result="pass" name="verifyExplicitOperatorBool"/> <testcase result="pass" name="cleanupTestCase"/> <system-err/> </testsuite> diff --git a/tests/auto/tools/moc/subdir/extradefines.h b/tests/auto/tools/moc/subdir/extradefines.h new file mode 100644 index 0000000000..e7888ce80d --- /dev/null +++ b/tests/auto/tools/moc/subdir/extradefines.h @@ -0,0 +1 @@ +#define FOO 1 diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index b49d7bc477..714ae19a10 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -70,8 +70,81 @@ #include "non-gadget-parent-class.h" #include "grand-parent-gadget-class.h" +#ifdef Q_MOC_RUN +// check that moc can parse these constructs, they are being used in Windows winsock2.h header +#define STRING_HASH_HASH(x) ("foo" ## x ## "bar") +const char *string_hash_hash = STRING_HASH_HASH("baz"); +#endif + Q_DECLARE_METATYPE(const QMetaObject*); +namespace TestNonQNamespace { + +struct TestGadget { + Q_GADGET + Q_CLASSINFO("key", "value") +public: + enum class TestGEnum1 { + Key1 = 11, + Key2 + }; + Q_ENUM(TestGEnum1) + + enum class TestGEnum2 { + Key1 = 17, + Key2 + }; + Q_ENUM(TestGEnum2) +}; + +} + +namespace TestQNamespace { + Q_NAMESPACE + enum class TestEnum1 { + Key1 = 11, + Key2 + }; + Q_ENUM_NS(TestEnum1) + + enum class TestEnum2 { + Key1 = 17, + Key2 + }; + Q_ENUM_NS(TestEnum2) + + // try to dizzy moc by adding a struct in between + struct TestGadget { + Q_GADGET + public: + enum class TestGEnum1 { + Key1 = 13, + Key2 + }; + enum class TestGEnum2 { + Key1 = 23, + Key2 + }; + Q_ENUM(TestGEnum1) + Q_ENUM(TestGEnum2) + }; + + enum class TestFlag1 { + None = 0, + Flag1 = 1, + Flag2 = 2, + Any = Flag1 | Flag2 + }; + Q_FLAG_NS(TestFlag1) + + enum class TestFlag2 { + None = 0, + Flag1 = 4, + Flag2 = 8, + Any = Flag1 | Flag2 + }; + Q_FLAG_NS(TestFlag2) +} QT_USE_NAMESPACE @@ -489,13 +562,6 @@ public: Q_ENUMS(EnumSourceClass::TestEnum) }; -#if defined(Q_MOC_RUN) -// Task #119503 -#define _TASK_119503 -#if !_TASK_119503 -#endif -#endif - class CtorTestClass : public QObject { Q_OBJECT @@ -576,6 +642,10 @@ private slots: void frameworkSearchPath(); void cstyleEnums(); void defineMacroViaCmdline(); + void defineMacroViaForcedInclude(); + void defineMacroViaForcedIncludeRelative(); + void environmentIncludePaths_data(); + void environmentIncludePaths(); void specifyMetaTagsFromCmdline(); void invokable(); void singleFunctionKeywordSignalAndSlot(); @@ -624,6 +694,7 @@ private slots: void gadgetHierarchy(); void optionsFileError_data(); void optionsFileError(); + void testQNamespace(); signals: void sigWithUnsignedArg(unsigned foo); @@ -1254,6 +1325,92 @@ void tst_Moc::defineMacroViaCmdline() #endif } +void tst_Moc::defineMacroViaForcedInclude() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QProcess proc; + + QStringList args; + args << "--include" << m_sourceDirectory + QLatin1String("/subdir/extradefines.h"); + args << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + +void tst_Moc::defineMacroViaForcedIncludeRelative() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QProcess proc; + + QStringList args; + args << "--include" << QStringLiteral("extradefines.h") << "-I" + m_sourceDirectory + "/subdir"; + args << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + + +void tst_Moc::environmentIncludePaths_data() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QTest::addColumn<QString>("cmdline"); + QTest::addColumn<QString>("varname"); + + QTest::newRow("INCLUDE") << "--compiler-flavor=msvc" << "INCLUDE"; + QTest::newRow("CPATH1") << QString() << "CPATH"; + QTest::newRow("CPATH2") << "--compiler-flavor=unix" << "CPATH"; + QTest::newRow("CPLUS_INCLUDE_PATH1") << QString() << "CPLUS_INCLUDE_PATH"; + QTest::newRow("CPLUS_INCLUDE_PATH2") << "--compiler-flavor=unix" << "CPLUS_INCLUDE_PATH"; +#endif +} + +void tst_Moc::environmentIncludePaths() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QFETCH(QString, cmdline); + QFETCH(QString, varname); + + QStringList args; + if (!cmdline.isEmpty()) + args << cmdline; + args << "--include" << QStringLiteral("extradefines.h") + << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.remove("INCLUDE"); + env.remove("CPATH"); + env.remove("CPLUS_INCLUDE_PATH"); + env.insert(varname, m_sourceDirectory + "/subdir"); + + QProcess proc; + proc.setProcessEnvironment(env); + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + // tst_Moc::specifyMetaTagsFromCmdline() // plugin_metadata.h contains a plugin which we register here. Since we're not building this // application as a plugin, we need top copy some of the initializer code found in qplugin.h: @@ -1918,6 +2075,13 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); + QTest::newRow("Namespace declaration lacks Q_NAMESPACE macro.") + << QByteArray("namespace X {\nQ_CLASSINFO(\"key\",\"value\")\nenum class MyEnum {Key1 = 1}\nQ_ENUMS(MyEnum)\n}\n") + << QStringList() + << 1 + << QString() + << QString("standard input:1: Error: Namespace declaration lacks Q_NAMESPACE macro."); + QTest::newRow("Invalid macro definition") << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45, 42, 39);") << QStringList() @@ -1939,6 +2103,13 @@ void tst_Moc::warnings_data() << QString("IGNORE_ALL_STDOUT") << QString(":-1: Error: Unexpected character in macro argument list."); + QTest::newRow("Missing header warning") + << QByteArray("class X : public QObject { Q_OBJECT };") + << (QStringList() << QStringLiteral("--include") << QStringLiteral("doesnotexist.h")) + << 0 + << QString("IGNORE_ALL_STDOUT") + << QStringLiteral("Warning: Failed to resolve include \"doesnotexist.h\" for moc file <standard input>"); + QTest::newRow("QTBUG-54815: Crash on invalid input") << QByteArray("class M{(})F<{}d000000000000000#0") << QStringList() @@ -2012,18 +2183,19 @@ void tst_Moc::cxx11Enums_data() QTest::addColumn<const QMetaObject *>("meta"); QTest::addColumn<QByteArray>("enumName"); QTest::addColumn<char>("prefix"); + QTest::addColumn<bool>("isScoped"); const QMetaObject *meta1 = &CXX11Enums::staticMetaObject; const QMetaObject *meta2 = &CXX11Enums2::staticMetaObject; - QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << 'A'; - QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << 'A'; - QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << 'B'; - QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << 'B'; - QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << 'C'; - QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << 'C'; - QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << 'D'; - QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << 'D'; + QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << 'A' << true; + QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << 'A' << true; + QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << 'B' << false; + QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << 'B' << false; + QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << 'C' << true; + QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << 'C' << true; + QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << 'D' << false; + QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << 'D' << false; } void tst_Moc::cxx11Enums() @@ -2033,6 +2205,7 @@ void tst_Moc::cxx11Enums() QFETCH(QByteArray, enumName); QFETCH(char, prefix); + QFETCH(bool, isScoped); int idx; idx = meta->indexOfEnumerator(enumName); @@ -2046,6 +2219,7 @@ void tst_Moc::cxx11Enums() QCOMPARE(meta->enumerator(idx).keyToValue(v), i); QCOMPARE(meta->enumerator(idx).valueToKey(i), v.constData()); } + QCOMPARE(meta->enumerator(idx).isScoped(), isScoped); } void tst_Moc::returnRefs() @@ -3538,6 +3712,41 @@ void tst_Moc::optionsFileError() #endif } +static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, const QVector<QPair<QByteArray, int >> &keys) +{ + QCOMPARE(name, QByteArray{enumerator.name()}); + QCOMPARE(keys.size(), enumerator.keyCount()); + for (int i = 0; i < enumerator.keyCount(); ++i) { + QCOMPARE(keys[i].first, QByteArray{enumerator.key(i)}); + QCOMPARE(keys[i].second, enumerator.value(i)); + } +} + +void tst_Moc::testQNamespace() +{ + QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); + checkEnum(TestQNamespace::staticMetaObject.enumerator(0), "TestEnum1", + {{"Key1", 11}, {"Key2", 12}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(1), "TestEnum2", + {{"Key1", 17}, {"Key2", 18}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(2), "TestFlag1", + {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Any", 1 | 2}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(3), "TestFlag2", + {{"None", 0}, {"Flag1", 4}, {"Flag2", 8}, {"Any", 4 | 8}}); + + QCOMPARE(TestQNamespace::TestGadget::staticMetaObject.enumeratorCount(), 2); + checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1", + {{"Key1", 13}, {"Key2", 14}}); + checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(1), "TestGEnum2", + {{"Key1", 23}, {"Key2", 24}}); + + QMetaEnum meta = QMetaEnum::fromType<TestQNamespace::TestEnum1>(); + QVERIFY(meta.isValid()); + QCOMPARE(meta.name(), "TestEnum1"); + QCOMPARE(meta.enclosingMetaObject(), &TestQNamespace::staticMetaObject); + QCOMPARE(meta.keyCount(), 2); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS diff --git a/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro b/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro index 4bfa89a44e..fa232b323b 100644 --- a/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro +++ b/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro @@ -2,7 +2,7 @@ CONFIG += testcase QT = core testlib dbus TARGET = tst_qdbuscpp2xml -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_DBUS SOURCES += tst_qdbuscpp2xml.cpp \ diff --git a/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro index 8c29ff47c4..02910b0267 100644 --- a/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro +++ b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro @@ -2,4 +2,4 @@ CONFIG += testcase QT = core testlib TARGET = tst_qdbusxml2cpp SOURCES += tst_qdbusxml2cpp.cpp -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_DBUS diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 4cd335d732..62fcedddb9 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -815,6 +815,49 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:2: member() argument 2 (start) '4..foo' invalid." << true; + // The argument processing is shared with $$member(), so some tests are skipped. + QTest::newRow("$$str_member(): empty") + << "VAR = $$str_member()" + << "VAR =" + << "" + << true; + + QTest::newRow("$$str_member(): too short") + << "VAR = $$str_member(string_value, 7, 12)" + << "VAR =" // this is actually kinda stupid + << "" + << true; + + QTest::newRow("$$str_member(): ok") + << "VAR = $$str_member(string_value, 7, 11)" + << "VAR = value" + << "" + << true; + + QTest::newRow("$$str_member(): ok (default start)") + << "VAR = $$str_member(string_value)" + << "VAR = s" + << "" + << true; + + QTest::newRow("$$str_member(): ok (default end)") + << "VAR = $$str_member(string_value, 7)" + << "VAR = v" + << "" + << true; + + QTest::newRow("$$str_member(): negative") + << "VAR = $$str_member(string_value, -5, -3)" + << "VAR = val" + << "" + << true; + + QTest::newRow("$$str_member(): inverse") + << "VAR = $$str_member(string_value, -2, 1)" + << "VAR = ulav_gnirt" + << "" + << true; + QTest::newRow("$$first(): empty") << "IN = \nVAR = $$first(IN)" << "VAR =" @@ -839,6 +882,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: first(var) requires one argument." << true; + QTest::newRow("$$take_first(): empty") + << "IN = \nVAR = $$take_first(IN)" + << "VAR =\nIN =" + << "" + << true; + + QTest::newRow("$$take_first(): one") + << "IN = one\nVAR = $$take_first(IN)" + << "VAR = one\nIN =" + << "" + << true; + + QTest::newRow("$$take_first(): multiple") + << "IN = one two three\nVAR = $$take_first(IN)" + << "VAR = one\nIN = two three" + << "" + << true; + + QTest::newRow("$$take_first(): bad number of arguments") + << "VAR = $$take_first(1, 2)" + << "VAR =" + << "##:1: take_first(var) requires one argument." + << true; + QTest::newRow("$$last(): empty") << "IN = \nVAR = $$last(IN)" << "VAR =" @@ -863,6 +930,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: last(var) requires one argument." << true; + QTest::newRow("$$take_last(): empty") + << "IN = \nVAR = $$take_last(IN)" + << "VAR =\nIN =" + << "" + << true; + + QTest::newRow("$$take_last(): one") + << "IN = one\nVAR = $$take_last(IN)" + << "VAR = one\nIN =" + << "" + << true; + + QTest::newRow("$$take_last(): multiple") + << "IN = one two three\nVAR = $$take_last(IN)" + << "VAR = three\nIN = one two" + << "" + << true; + + QTest::newRow("$$take_last(): bad number of arguments") + << "VAR = $$take_last(1, 2)" + << "VAR =" + << "##:1: take_last(var) requires one argument." + << true; + QTest::newRow("$$size()") << "IN = one two three\nVAR = $$size(IN)" << "VAR = 3" @@ -875,6 +966,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: size(var) requires one argument." << true; + QTest::newRow("$$str_size()") + << "VAR = $$str_size(one two three)" + << "VAR = 13" + << "" + << true; + + QTest::newRow("$$str_size(): bad number of arguments") + << "VAR = $$str_size(1, 2)" + << "VAR =" + << "##:1: str_size(str) requires one argument." + << true; + QTest::newRow("$$fromfile(): right var") << "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, DEFINES)" << "VAR = QT_DLL" @@ -1003,6 +1106,48 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: format_number(): invalid format option foo=bar." << true; + QTest::newRow("$$num_add(): one") + << "VAR = $$num_add(10)" + << "VAR = 10" + << "" + << true; + + QTest::newRow("$$num_add(): two") + << "VAR = $$num_add(1, 2)" + << "VAR = 3" + << "" + << true; + + QTest::newRow("$$num_add(): three") + << "VAR = $$num_add(1, 3, 5)" + << "VAR = 9" + << "" + << true; + + QTest::newRow("$$num_add(): negative") + << "VAR = $$num_add(7, -13)" + << "VAR = -6" + << "" + << true; + + QTest::newRow("$$num_add(): bad number of arguments") + << "VAR = $$num_add()" + << "VAR = " + << "##:1: num_add(num, ...) requires at least one argument." + << true; + + QTest::newRow("$$num_add(): bad number: float") + << "VAR = $$num_add(1.1)" + << "VAR =" + << "##:1: num_add(): floats are currently not supported." + << true; + + QTest::newRow("$$num_add(): bad number: malformed") + << "VAR = $$num_add(fail)" + << "VAR =" + << "##:1: num_add(): malformed number fail." + << true; + QTest::newRow("$$join(): empty") << "IN = \nVAR = $$join(IN, //)" << "VAR =" @@ -1181,9 +1326,9 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << true; QTest::newRow("$$system(): bad number of arguments") - << "VAR = $$system(1, 2, 3)" + << "VAR = $$system(1, 2, 3, 4)" << "VAR =" - << "##:1: system(execute) requires one or two arguments." + << "##:1: system(command, [mode], [stsvar]) requires one to three arguments." << true; QTest::newRow("$$unique()") @@ -1198,6 +1343,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: unique(var) requires one argument." << true; + QTest::newRow("$$sorted()") + << "IN = one two three\nVAR = $$sorted(IN)" + << "VAR = one three two" + << "" + << true; + + QTest::newRow("$$sorted(): bad number of arguments") + << "VAR = $$sorted(1, 2)" + << "VAR =" + << "##:1: sorted(var) requires one argument." + << true; + QTest::newRow("$$reverse()") << "IN = one two three\nVAR = $$reverse(IN)" << "VAR = three two one" @@ -2102,7 +2259,7 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "jsontext = not good\n" "parseJson(jsontext, json): OK = 1" << "OK = UNDEF" - << "" + << "##:2: Error parsing json at offset 1: illegal value" << true; QTest::newRow("parseJson(): bad number of arguments") @@ -2168,6 +2325,18 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "##:1: load(feature) requires one or two arguments." << true; + QTest::newRow("discard_from()") + << "HERE = 1\nPLUS = one\ninclude(include/inc.pri)\ndiscard_from(include/inc.pri): OK = 1" + << "OK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF" + << "" + << true; + + QTest::newRow("discard_from(): bad number of arguments") + << "discard_from(1, 2): OK = 1" + << "OK = UNDEF" + << "##:1: discard_from(file) requires one argument." + << true; + // We don't test debug() and log(), because they print directly to stderr. QTest::newRow("message()") @@ -2189,12 +2358,18 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "Project WARNING: World, be warned!" << true; - QTest::newRow("error()") + QTest::newRow("error(message)") << "error('World, you FAIL!'): OK = 1\nOKE = 1" << "OK = UNDEF\nOKE = UNDEF" << "Project ERROR: World, you FAIL!" << false; + QTest::newRow("error(empty)") + << "error(): OK = 1\nOKE = 1" + << "OK = UNDEF\nOKE = UNDEF" + << "" + << false; + QTest::newRow("if(error())") << "if(error(\\'World, you FAIL!\\')): OK = 1\nOKE = 1" << "OK = UNDEF\nOKE = UNDEF" @@ -2581,19 +2756,20 @@ void tst_qmakelib::proEval() QMakeTestHandler handler; handler.setExpectedMessages(msgs.replace("##:", infile + ':').split('\n', QString::SkipEmptyParts)); QMakeVfs vfs; - QMakeParser parser(0, &vfs, &handler); + ProFileCache cache; + QMakeParser parser(&cache, &vfs, &handler); QMakeGlobals globals; globals.do_cache = false; globals.xqmakespec = "fake-g++"; globals.environment = m_env; globals.setProperties(m_prop); globals.setDirectories(m_indir, m_outdir); - ProFile *outPro = parser.parsedProBlock(out, "out", 1, QMakeParser::FullGrammar); + ProFile *outPro = parser.parsedProBlock(QStringRef(&out), "out", 1, QMakeParser::FullGrammar); if (!outPro->isOk()) { qWarning("Expected output is malformed"); verified = false; } - ProFile *pro = parser.parsedProBlock(in, infile, 1, QMakeParser::FullGrammar); + ProFile *pro = parser.parsedProBlock(QStringRef(&in), infile, 1, QMakeParser::FullGrammar); QMakeEvaluator visitor(&globals, &parser, &vfs, &handler); visitor.setOutputDir(m_outdir); #ifdef Q_OS_WIN diff --git a/tests/auto/tools/qmakelib/parsertest.cpp b/tests/auto/tools/qmakelib/parsertest.cpp index 5e12d930f8..dc92f98f45 100644 --- a/tests/auto/tools/qmakelib/parsertest.cpp +++ b/tests/auto/tools/qmakelib/parsertest.cpp @@ -1962,7 +1962,7 @@ void tst_qmakelib::proParser() handler.setExpectedMessages(msgs.split('\n', QString::SkipEmptyParts)); QMakeVfs vfs; QMakeParser parser(0, &vfs, &handler); - ProFile *pro = parser.parsedProBlock(in, "in", 1, QMakeParser::FullGrammar); + ProFile *pro = parser.parsedProBlock(QStringRef(&in), "in", 1, QMakeParser::FullGrammar); if (handler.printedMessages()) { qWarning("Got unexpected message(s)"); verified = false; diff --git a/tests/auto/tools/qmakelib/testdata/include/inc.pri b/tests/auto/tools/qmakelib/testdata/include/inc.pri index 1f1b3a287f..f9a4ec1bfa 100644 --- a/tests/auto/tools/qmakelib/testdata/include/inc.pri +++ b/tests/auto/tools/qmakelib/testdata/include/inc.pri @@ -1,6 +1,8 @@ VAR = val .VAR = nope +PLUS += more + fake-*: MATCH = 1 defineTest(func) { diff --git a/tests/auto/widgets/dialogs/dialogs.pro b/tests/auto/widgets/dialogs/dialogs.pro index c6667824d9..cf548f2dea 100644 --- a/tests/auto/widgets/dialogs/dialogs.pro +++ b/tests/auto/widgets/dialogs/dialogs.pro @@ -13,7 +13,7 @@ SUBDIRS=\ qsidebar \ qwizard \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qsidebar \ mac:qinputdialog.CONFIG += no_check_target # QTBUG-25496 diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index e6a0c5e86b..ac7ba02700 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -69,10 +69,8 @@ private slots: void showMaximized(); void showMinimized(); void showFullScreen(); -#ifndef Q_OS_WINCE void showAsTool(); void toolDialogPosition(); -#endif void deleteMainDefault(); void deleteInExec(); #ifndef QT_NO_SIZEGRIP @@ -358,8 +356,6 @@ void tst_QDialog::showFullScreen() QVERIFY(!dialog.isVisible()); } -// No real support for Qt::Tool on WinCE -#ifndef Q_OS_WINCE void tst_QDialog::showAsTool() { #if defined(Q_OS_UNIX) @@ -379,10 +375,7 @@ void tst_QDialog::showAsTool() QCOMPARE(dialog.wasActive(), false); } } -#endif -// No real support for Qt::Tool on WinCE -#ifndef Q_OS_WINCE // Verify that pos() returns the same before and after show() // for a dialog with the Tool window type. void tst_QDialog::toolDialogPosition() @@ -394,7 +387,6 @@ void tst_QDialog::toolDialogPosition() const QPoint afterShowPosition = dialog.pos(); QCOMPARE(afterShowPosition, beforeShowPosition); } -#endif class Dialog : public QDialog { diff --git a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro index 2a11a29420..4ea23a896f 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro +++ b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro @@ -8,18 +8,6 @@ QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qfiledialog.cpp -wince* { - addFiles.files = *.cpp - addFiles.path = . - filesInDir.files = *.pro - filesInDir.path = someDir - DEPLOYMENT += addFiles filesInDir -} - -wince* { - DEFINES += SRCDIR=\\\"./\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} +DEFINES += SRCDIR=\\\"$$PWD/\\\" linux*: CONFIG += insignificant_test # Crashes on different Linux distros diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index e61c61ddfd..e13e0201bc 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -186,9 +186,6 @@ void tst_QFiledialog::init() QFileDialogPrivate::setLastVisitedDirectory(QUrl()); // populate the sidebar with some default settings QFileDialog fd; -#if defined(Q_OS_WINCE) - QTest::qWait(1000); -#endif } void tst_QFiledialog::cleanup() diff --git a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro index fb432a7d21..1b35b2e4ac 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro +++ b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro @@ -6,17 +6,4 @@ QT += core-private gui-private SOURCES += tst_qfiledialog2.cpp -wince* { - addFiles.files = *.cpp - addFiles.path = . - filesInDir.files = *.pro - filesInDir.path = someDir - DEPLOYMENT += addFiles filesInDir -} - -wince* { - DEFINES += SRCDIR=\\\"./\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 82934982c4..a16bd1a787 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -54,7 +54,7 @@ #include <qpa/qplatformdialoghelper.h> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) #include "../../../network-settings.h" #endif @@ -107,7 +107,7 @@ private slots: #ifndef Q_OS_MAC void task227930_correctNavigationKeyboardBehavior(); #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) void task226366_lowerCaseHardDriveWindows(); #endif void completionOnLevelAfterRoot(); @@ -138,9 +138,6 @@ tst_QFileDialog2::tst_QFileDialog2() : tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX") { QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs); -#if defined(Q_OS_WINCE) - qApp->setAutoMaximizeThreshold(-1); -#endif } void tst_QFileDialog2::cleanupSettingsFile() @@ -167,9 +164,6 @@ void tst_QFileDialog2::init() QFileDialogPrivate::setLastVisitedDirectory(QUrl()); // populate the sidebar with some default settings QFileDialog fd; -#if defined(Q_OS_WINCE) - QTest::qWait(1000); -#endif } void tst_QFileDialog2::cleanup() @@ -189,11 +183,7 @@ void tst_QFileDialog2::listRoot() fd.show(); QCOMPARE(qt_test_isFetchedRoot(),false); fd.setDirectory(""); -#ifdef Q_OS_WINCE - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QCOMPARE(qt_test_isFetchedRoot(),true); } #endif @@ -286,7 +276,7 @@ void tst_QFileDialog2::showNameFilterDetails() void tst_QFileDialog2::unc() { -#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./ QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable"); #else @@ -634,7 +624,7 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() } #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() { QFileDialog fd; @@ -664,7 +654,7 @@ void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() void tst_QFileDialog2::completionOnLevelAfterRoot() { QFileDialog fd; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) fd.setDirectory("C:/"); QDir current = fd.directory(); QStringList entryList = current.entryList(QStringList(), QDir::Dirs); @@ -708,7 +698,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() fd.show(); QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); QTest::qWait(2000); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) //I love testlib :D for (int i = 0; i < 5; i++) QTest::keyClick(edit, testDir.at(i).toLower().toLatin1() - 'a' + Qt::Key_A); @@ -719,7 +709,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() QTest::qWait(200); QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); QTest::qWait(200); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) QCOMPARE(edit->text(), testDir); #else QTRY_COMPARE(edit->text(), QString("etc")); @@ -853,33 +843,21 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() fd.setDirectory(current.absolutePath()); fd.setViewMode(QFileDialog::Detail); fd.show(); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QTreeView *tree = fd.findChild<QTreeView*>("treeView"); tree->header()->setSortIndicator(3,Qt::DescendingOrder); QTest::qWait(200); QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QTest::mouseClick(button, Qt::LeftButton); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QFileDialog fd2; fd2.setFileMode(QFileDialog::Directory); fd2.restoreState(fd.saveState()); current.cd("aaaaaaaaaaaaaaaaaa"); fd2.setDirectory(current.absolutePath()); fd2.show(); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView"); tree2->setFocus(); @@ -889,22 +867,14 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open); fd2.selectFile("g"); QTest::mouseClick(button2, Qt::LeftButton); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g")); QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName()); fd3.restoreState(fd.saveState()); fd3.setFileMode(QFileDialog::Directory); fd3.show(); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView"); tree3->setFocus(); @@ -913,11 +883,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open); QTest::mouseClick(button3, Qt::LeftButton); -#if defined(Q_OS_WINCE) - QTest::qWait(1500); -#else QTest::qWait(500); -#endif QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName()); current.cd("aaaaaaaaaaaaaaaaaa"); @@ -999,11 +965,7 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries() sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath())); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); // give the background processes more time on windows mobile -#ifdef Q_OS_WINCE - QTest::qWait(1000); -#else QTest::qWait(250); -#endif QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index ad7600c784..00693ba6f7 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -40,7 +40,7 @@ #include <QStyle> #include <QtGlobal> #include <QTemporaryDir> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) # include <qt_windows.h> // for SetFileAttributes #endif @@ -332,7 +332,7 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi return false; } file.close(); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) if (initial_files.at(i)[0] == '.') { QString hiddenFile = QDir::toNativeSeparators(file.fileName()); wchar_t nativeHiddenFile[MAX_PATH]; @@ -369,14 +369,9 @@ void tst_QFileSystemModel::rowCount() QSignalSpy spy2(model, SIGNAL(rowsInserted(QModelIndex,int,int))); QSignalSpy spy3(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); -#if !defined(Q_OS_WINCE) QStringList files = QStringList() << "b" << "d" << "f" << "h" << "j" << ".a" << ".c" << ".e" << ".g"; QString l = "b,d,f,h,j,.a,.c,.e,.g"; -#else - // Cannot hide them on CE - QStringList files = QStringList() << "b" << "d" << "f" << "h" << "j"; - QString l = "b,d,f,h,j"; -#endif + QVERIFY(createFiles(tmp, files)); QModelIndex root = model->setRootPath(tmp); @@ -404,9 +399,6 @@ static inline QString lastEntry(const QModelIndex &root) void tst_QFileSystemModel::rowsInserted() { -#if defined(Q_OS_WINCE) - QSKIP("Watching directories does not work on CE(see #137910)"); -#endif QString tmp = flatDirTestPath; rowCount(); QModelIndex root = model->index(model->rootPath()); @@ -461,9 +453,6 @@ void tst_QFileSystemModel::rowsRemoved_data() void tst_QFileSystemModel::rowsRemoved() { -#if defined(Q_OS_WINCE) - QSKIP("Watching directories does not work on CE(see #137910)"); -#endif QString tmp = flatDirTestPath; rowCount(); QModelIndex root = model->index(model->rootPath()); @@ -552,7 +541,6 @@ void tst_QFileSystemModel::filters_data() QTest::addColumn<int>("dirFilters"); QTest::addColumn<QStringList>("nameFilters"); QTest::addColumn<int>("rowCount"); -#if !defined(Q_OS_WINCE) QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 2; QTest::newRow("no dirs - dot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 1; QTest::newRow("no dirs - dotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 1; @@ -574,30 +562,6 @@ void tst_QFileSystemModel::filters_data() (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive) << (QStringList() << "a") << 1; QTest::newRow("dir+files+hid+dot+cas+alldir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive | QDir::AllDirs) << (QStringList() << "Z") << 1; -#else - QTest::qWait(3000); // We need to calm down a bit... - QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 0; - QTest::newRow("no dirs - dot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 1; - QTest::newRow("no dirs - dotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 1; - QTest::newRow("no dirs - dotanddotdot") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 0; - QTest::newRow("one dir - dot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDot) << QStringList() << 2; - QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotDot) << QStringList() << 2; - QTest::newRow("one dir - dotanddotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1; - QTest::newRow("one dir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs) << QStringList() << 1; - QTest::newRow("no dir + hidden") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Hidden) << QStringList() << 0; - QTest::newRow("dir+hid+files") << (QStringList() << "a" << "b" << "c") << QStringList() << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden) << QStringList() << 3; - QTest::newRow("dir+file+hid-dot .A") << (QStringList() << "a" << "b" << "c") << (QStringList() << ".A") << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << QStringList() << 4; - QTest::newRow("dir+files+hid+dot A") << (QStringList() << "a" << "b" << "c") << (QStringList() << "AFolder") << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << (QStringList() << "A*") << 2; - QTest::newRow("dir+files+hid+dot+cas1") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive) << (QStringList() << "Z") << 1; - QTest::newRow("dir+files+hid+dot+cas2") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive) << (QStringList() << "a") << 1; - QTest::newRow("dir+files+hid+dot+cas+alldir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << - (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive | QDir::AllDirs) << (QStringList() << "Z") << 1; -#endif QTest::newRow("case sensitive") << (QStringList() << "Antiguagdb" << "Antiguamtd" << "Antiguamtp" << "afghanistangdb" << "afghanistanmtd") diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST index b62f3e3344..07f3a41df3 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST +++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST @@ -1,4 +1,5 @@ [task256466_wrongStyle] opensuse-13.1 +opensuse-42.1 rhel-7.1 rhel-7.2 diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index d6b3ce07e8..d6c4841b22 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -395,11 +395,8 @@ void tst_QMessageBox::about() QVERIFY(closeHelper.done()); #endif -#if !defined(Q_OS_WINCE) const int keyToSend = Qt::Key_Enter; -#else - const keyToSend = Qt::Key_Escape; -#endif + closeHelper.start(keyToSend); QMessageBox::aboutQt(0, "Caption"); #ifdef Q_OS_MAC diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 2635a2ed82..016835f142 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -51,9 +51,6 @@ class tst_QWizard : public QObject { Q_OBJECT -public: - tst_QWizard(); - private slots: void cleanup(); void buttonText(); @@ -128,13 +125,6 @@ private slots: */ }; -tst_QWizard::tst_QWizard() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QWizard::cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); @@ -962,9 +952,6 @@ void tst_QWizard::setOption_IndependentPages() void tst_QWizard::setOption_IgnoreSubTitles() { -#if defined(Q_OS_WINCE) - QSKIP("Skipped because of limited resources and potential crash. (Task: 166824)"); -#endif const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); const int kPixels = (availableGeometry.width() + 500) / 1000; const int frame = 50 * kPixels; @@ -1073,9 +1060,6 @@ void tst_QWizard::setOption_IgnoreSubTitles() void tst_QWizard::setOption_ExtendedWatermarkPixmap() { -#if defined(Q_OS_WINCE) - QSKIP("Skipped because of limited resources and potential crash. (Task: 166824)"); -#endif QPixmap watermarkPixmap(200, 400); watermarkPixmap.fill(Qt::black); @@ -2062,10 +2046,6 @@ void tst_QWizard::combinations_data() void tst_QWizard::combinations() { -#ifdef Q_OS_WINCE - QSKIP("Too much memory usage for testing on CE emulator"); -#endif - QFETCH(bool, ref); QFETCH(bool, testEquality); QFETCH(QList<Operation *>, operations); diff --git a/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro b/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro index bf0f99598b..4fbe13cce7 100644 --- a/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro +++ b/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro @@ -5,10 +5,3 @@ QT += widgets widgets-private testlib QT += gui-private SOURCES += tst_qpixmapfilter.cpp - -wince { - addFiles.files = noise.png - addFiles.path = . - DEPLOYMENT += addFiles -} - diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp index 6b0c1ecf57..c3ebb838bb 100644 --- a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -38,8 +38,6 @@ #include <QtCore/QHash> #include <QtCore/QDebug> -#include <qpa/qwindowsysteminterface.h> - class tst_QGestureRecognizer : public QObject { Q_OBJECT @@ -64,15 +62,13 @@ private: tst_QGestureRecognizer::tst_QGestureRecognizer() : m_fingerDistance(qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch() / 2.0)) - , m_touchDevice(new QTouchDevice) + , m_touchDevice(QTest::createTouchDevice()) { qputenv("QT_PAN_TOUCHPOINTS", "2"); // Prevent device detection of pan touch point count. } void tst_QGestureRecognizer::initTestCase() { - m_touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(m_touchDevice); } #ifndef QT_NO_GESTURES diff --git a/tests/auto/widgets/graphicsview/graphicsview.pro b/tests/auto/widgets/graphicsview/graphicsview.pro index dce3c6dda9..e99897a4f6 100644 --- a/tests/auto/widgets/graphicsview/graphicsview.pro +++ b/tests/auto/widgets/graphicsview/graphicsview.pro @@ -19,7 +19,7 @@ SUBDIRS=\ qgraphicsview \ qgraphicswidget \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qgraphicsanchorlayout \ qgraphicsanchorlayout1 \ qgraphicsitem \ diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 90ea2cb58b..f5b2269297 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -38,7 +38,6 @@ class tst_QGraphicsGridLayout : public QObject Q_OBJECT private slots: - void initTestCase(); void qgraphicsgridlayout_data(); void qgraphicsgridlayout(); void addItem_data(); @@ -294,16 +293,6 @@ Q_DECLARE_METATYPE(ItemList); typedef QList<QSizeF> SizeList; - -// This will be called before the first test function is executed. -// It is only called once. -void tst_QGraphicsGridLayout::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QGraphicsGridLayout::qgraphicsgridlayout_data() { } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro index 5bfa15db16..88526144fc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -5,4 +5,4 @@ QT += core-private gui-private SOURCES += tst_qgraphicsitem.cpp DEFINES += QT_NO_CAST_TO_ASCII -win32:!wince:!winrt: LIBS += -luser32 +win32:!winrt: LIBS += -luser32 diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index fc192560b4..46d0b18990 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -57,9 +57,7 @@ Q_DECLARE_METATYPE(QPainterPath) -#include "../../../qtest-config.h" - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #include <windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ @@ -279,9 +277,6 @@ class tst_QGraphicsItem : public QObject { Q_OBJECT -public slots: - void init(); - private slots: void construction(); void constructionWithParent(); @@ -355,7 +350,7 @@ private slots: void filtersChildEvents(); void filtersChildEvents2(); void ensureVisible(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void cursor(); #endif //void textControlGetterSetter(); @@ -481,13 +476,6 @@ private: QList<QGraphicsItem *> paintedItems; }; -void tst_QGraphicsItem::init() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QGraphicsItem::construction() { for (int i = 0; i < 7; ++i) { @@ -4187,7 +4175,7 @@ void tst_QGraphicsItem::ensureVisible() QTest::qWait(25); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsItem::cursor() { QGraphicsScene scene; @@ -4535,7 +4523,7 @@ protected: case QGraphicsItem::ItemSceneHasChanged: break; case QGraphicsItem::ItemCursorChange: -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR oldValues << cursor(); #endif break; @@ -5098,10 +5086,6 @@ public: void tst_QGraphicsItem::paint() { -#ifdef Q_OS_MACX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_7) - QSKIP("QTBUG-31454 - Unstable auto-test"); -#endif QGraphicsScene scene; PaintTester paintTester; @@ -6586,12 +6570,6 @@ public: void tst_QGraphicsItem::ensureUpdateOnTextItem() { -#ifdef Q_OS_MAC - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_7) { - QSKIP("This test is unstable on 10.7 in CI"); - } -#endif - QGraphicsScene scene; QGraphicsView view(&scene); view.show(); @@ -11039,9 +11017,7 @@ void tst_QGraphicsItem::touchEventPropagation() touchPoints << tp; sendMousePress(&scene, tp.scenePos()); - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + QTouchDevice *device = QTest::createTouchDevice(); QTouchEvent touchBegin(QEvent::TouchBegin, device, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); qApp->sendEvent(&scene, &touchBegin); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 491dda9f9e..01708d526c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -33,8 +33,6 @@ #include <private/qgraphicsproxywidget_p.h> #include <private/qlayoutengine_p.h> // qSmartMin functions... -#include "../../../qtest-config.h" - static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton) { QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, button, 0); @@ -97,7 +95,7 @@ private slots: void focusNextPrevChild(); void focusOutEvent_data(); void focusOutEvent(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void hoverEnterLeaveEvent_data(); void hoverEnterLeaveEvent(); #endif @@ -140,7 +138,7 @@ private slots: void setFocus_complexTwoWidgets(); void popup_basic(); void popup_subwidget(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void changingCursor_basic(); #endif void tooltip_basic(); @@ -272,9 +270,6 @@ public: // It is only called once. void tst_QGraphicsProxyWidget::initTestCase() { -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif // Disable menu animations to prevent the alpha widget from getting in the way // in actionsContextMenu(). QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); @@ -416,7 +411,7 @@ void tst_QGraphicsProxyWidget::setWidget() } QWidget *widget = new QWidget; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR widget->setCursor(Qt::IBeamCursor); #endif widget->setPalette(QPalette(Qt::magenta)); @@ -453,7 +448,7 @@ void tst_QGraphicsProxyWidget::setWidget() QVERIFY(subWidget->testAttribute(Qt::WA_DontShowOnScreen)); QVERIFY(!subWidget->testAttribute(Qt::WA_QuitOnClose)); QCOMPARE(proxy->acceptHoverEvents(), true); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QVERIFY(proxy->hasCursor()); // These should match @@ -936,7 +931,7 @@ protected: } }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent_data() { QTest::addColumn<bool>("hasWidget"); @@ -1524,7 +1519,7 @@ void tst_QGraphicsProxyWidget::setWidget_simple() // Properties // QCOMPARE(proxy.focusPolicy(), lineEdit->focusPolicy()); // QCOMPARE(proxy.palette(), lineEdit->palette()); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QCOMPARE(proxy.cursor().shape(), lineEdit->cursor().shape()); #endif QCOMPARE(proxy.layoutDirection(), lineEdit->layoutDirection()); @@ -1573,7 +1568,7 @@ void tst_QGraphicsProxyWidget::resize_simple_data() QTest::addColumn<QSizeF>("size"); QTest::newRow("200, 200") << QSizeF(200, 200); -#if !defined(Q_PROCESSOR_ARM) && !defined(Q_OS_WINCE) +#if !defined(Q_PROCESSOR_ARM) QTest::newRow("1000, 1000") << QSizeF(1000, 1000); // Since 4.5, 10000x10000 runs out of memory. // QTest::newRow("10000, 10000") << QSizeF(10000, 10000); @@ -2541,7 +2536,7 @@ void tst_QGraphicsProxyWidget::popup_subwidget() QCOMPARE(popup->size(), child->size().toSize()); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsProxyWidget::changingCursor_basic() { // Confirm that mouse events are working properly by checking that @@ -3647,7 +3642,7 @@ public slots: void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget() { -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(QTEST_NO_CURSOR) +#if defined(Q_OS_DARWIN) || defined(Q_OS_WIN) || defined(QT_NO_CURSOR) QSKIP("Test case unstable on this platform"); #endif QGraphicsView view; @@ -3804,9 +3799,7 @@ void tst_QGraphicsProxyWidget::forwardTouchEvent() EventSpy eventSpy(widget); - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + QTouchDevice *device = QTest::createTouchDevice(); QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 0); QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 0); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro index 986ba019b4..351cecd92e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -4,18 +4,9 @@ QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qgraphicsscene.cpp RESOURCES += images.qrc -win32:!wince:!winrt: LIBS += -luser32 +win32:!winrt: LIBS += -luser32 -!wince: DEFINES += SRCDIR=\\\"$$PWD\\\" +DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_NO_CAST_TO_ASCII -wince* { - rootFiles.files = Ash_European.jpg graphicsScene_selection.data - rootFiles.path = . - renderFiles.files = testData\\render\\* - renderFiles.path = testData\\render - DEPLOYMENT += rootFiles renderFiles - DEFINES += SRCDIR=\\\".\\\" -} - RESOURCES += testdata.qrc diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index a346bb9d1f..d95f6e408e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -28,9 +28,6 @@ #include <QtTest/QtTest> -#if defined(Q_OS_WINCE) -#include <ceconfig.h> -#endif #include <QtGui> #include <QtWidgets> @@ -41,7 +38,7 @@ #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #include <windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ @@ -170,7 +167,6 @@ class tst_QGraphicsScene : public QObject { Q_OBJECT public slots: - void initTestCase(); void cleanup(); private slots: @@ -271,15 +267,9 @@ private slots: void taskQT_3674_doNotCrash(); void taskQTBUG_15977_renderWithDeviceCoordinateCache(); void taskQTBUG_16401_focusItem(); + void taskQTBUG_42915_focusNextPrevChild(); }; -void tst_QGraphicsScene::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QGraphicsScene::cleanup() { // ensure not even skipped tests with custom input context leave it dangling @@ -1250,7 +1240,7 @@ void tst_QGraphicsScene::addText() void tst_QGraphicsScene::removeItem() { -#if (defined(Q_OS_WINCE) && !defined(GWES_ICONCURS)) || defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) QSKIP("No mouse cursor support"); #endif QGraphicsScene scene; @@ -1587,11 +1577,7 @@ void tst_QGraphicsScene::hoverEvents_siblings() QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing, true); -#if defined(Q_OS_WINCE) - view.setMinimumSize(230, 200); -#else view.setMinimumSize(400, 300); -#endif view.rotate(10); view.scale(1.7, 1.7); view.show(); @@ -1660,11 +1646,7 @@ void tst_QGraphicsScene::hoverEvents_parentChild() QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing, true); -#if defined(Q_OS_WINCE) - view.setMinimumSize(230, 200); -#else view.setMinimumSize(400, 300); -#endif view.rotate(10); view.scale(1.7, 1.7); view.show(); @@ -4834,5 +4816,29 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem() QVERIFY(!scene.focusItem()); } +void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + scene.setSceneRect(1, 1, 198, 198); + view.setFocus(); + + QGraphicsWidget *widget1 = new QGraphicsWidget(); + QGraphicsRectItem *rect1 = new QGraphicsRectItem(-50, -50, 100, 100, widget1); + rect1->setBrush(Qt::blue); + scene.addItem(widget1); + widget1->setPos(100, 100); + widget1->setFlags(QGraphicsItem::ItemIsPanel); + + QGraphicsWidget *widget2 = new QGraphicsWidget(widget1); + widget2->setFocusPolicy(Qt::NoFocus); + + view.show(); + QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QTest::keyEvent(QTest::Click, &view, Qt::Key_Tab); +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/qgraphicssceneindex.pro b/tests/auto/widgets/graphicsview/qgraphicssceneindex/qgraphicssceneindex.pro index 3b74ab0c75..42c260d480 100644 --- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/qgraphicssceneindex.pro +++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/qgraphicssceneindex.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qgraphicssceneindex -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qgraphicssceneindex.cpp diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 1df9a9434c..2ecc1120b9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -57,7 +57,6 @@ #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> -#include "../../../qtest-config.h" #include "tst_qgraphicsview.h" Q_DECLARE_METATYPE(ExpectedValueDescription) @@ -146,7 +145,6 @@ public: : platformName(QGuiApplication::platformName().toLower()) { } private slots: - void initTestCase(); void cleanup(); void construction(); void renderHints(); @@ -202,7 +200,7 @@ private slots: #ifndef QT_NO_WHEELEVENT void wheelEvent(); #endif -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void cursor(); void cursor2(); #endif @@ -266,7 +264,7 @@ private slots: void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void QTBUG_7438_cursor(); #endif void hoverLeave(); @@ -279,13 +277,6 @@ private: QString platformName; }; -void tst_QGraphicsView::initTestCase() -{ -#ifdef Q_OS_WINCE_WM - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QGraphicsView::cleanup() { // ensure not even skipped tests with custom input context leave it dangling @@ -739,7 +730,7 @@ void tst_QGraphicsView::dragMode_scrollHand() for (int i = 0; i < 2; ++i) { // ScrollHandDrag -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR Qt::CursorShape cursorShape = view.viewport()->cursor().shape(); #endif int horizontalScrollBarValue = view.horizontalScrollBar()->value(); @@ -758,7 +749,7 @@ void tst_QGraphicsView::dragMode_scrollHand() QTRY_VERIFY(item->isSelected()); for (int k = 0; k < 4; ++k) { -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), Qt::ClosedHandCursor); #endif { @@ -801,7 +792,7 @@ void tst_QGraphicsView::dragMode_scrollHand() QTRY_VERIFY(item->isSelected()); QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue - 10); QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue - 10); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -861,7 +852,7 @@ void tst_QGraphicsView::dragMode_rubberBand() for (int i = 0; i < 2; ++i) { // RubberBandDrag -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR Qt::CursorShape cursorShape = view.viewport()->cursor().shape(); #endif int horizontalScrollBarValue = view.horizontalScrollBar()->value(); @@ -875,7 +866,7 @@ void tst_QGraphicsView::dragMode_rubberBand() QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -923,7 +914,7 @@ void tst_QGraphicsView::dragMode_rubberBand() } QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue); QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -1428,20 +1419,9 @@ void tst_QGraphicsView::fitInView() items[0]->setTransform(QTransform().rotate(30), true); items[1]->setTransform(QTransform().rotate(-30), true); -#if defined(Q_OS_WINCE) - //Is the standard scrollbar size - int scrollbarSize = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent) - 13; -#endif - QGraphicsView view(&scene); view.setSceneRect(-400, -400, 800, 800); - -#if defined(Q_OS_WINCE) - //We need to take in account the scrollbar size for the WindowsMobilStyle - view.setFixedSize(400 + scrollbarSize, 200 + scrollbarSize); -#else view.setFixedSize(400, 200); -#endif view.showNormal(); view.fitInView(scene.itemsBoundingRect(), Qt::IgnoreAspectRatio); @@ -1855,11 +1835,7 @@ void tst_QGraphicsView::mapToScene() QGraphicsView view(&topLevel); view.setScene(&scene); view.setSceneRect(-500, -500, 1000, 1000); -#if defined(Q_OS_WINCE) - QSize viewSize(200,200); -#else QSize viewSize(300,300); -#endif view.setFixedSize(viewSize); topLevel.show(); @@ -2266,7 +2242,7 @@ void tst_QGraphicsView::wheelEvent() } #endif // !QT_NO_WHEELEVENT -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsView::cursor() { QGraphicsScene scene; @@ -2290,7 +2266,7 @@ void tst_QGraphicsView::cursor() } #endif -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsView::cursor2() { QGraphicsScene scene; @@ -3785,7 +3761,7 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -3795,7 +3771,7 @@ void tst_QGraphicsView::mouseTracking() // Adding an item to the scene before the scene is set on the view. QGraphicsScene scene(-10000, -10000, 20000, 20000); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -3812,7 +3788,7 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view3(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -4573,9 +4549,6 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() { -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE does not implement mouse tracking at this point"); -#endif QGraphicsScene scene(-100, -100, 200, 200); scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue)); @@ -4767,7 +4740,7 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QGraphicsView::QTBUG_7438_cursor() { QGraphicsScene scene; diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index ca9f866e81..9e390e45a6 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -42,8 +42,6 @@ #include <qstylefactory.h> #include <qscreen.h> -#include "../../../qtest-config.h" - typedef QList<QGraphicsItem *> QGraphicsItemList; class EventSpy : public QObject @@ -1112,9 +1110,7 @@ void tst_QGraphicsWidget::initStyleOption() bool hasFocus = option.state & QStyle::State_HasFocus; QCOMPARE(hasFocus, focus); bool isUnderMouse = option.state & QStyle::State_MouseOver; -#ifndef Q_OS_WINCE QCOMPARE(isUnderMouse, underMouse); -#endif // if (layoutDirection != Qt::LeftToRight) //QEXPECT_FAIL("", "QApplicaiton::layoutDirection doesn't propagate to QGraphicsWidget", Continue); //QCOMPARE(option.direction, layoutDirection); @@ -2938,8 +2934,8 @@ protected: void tst_QGraphicsWidget::respectHFW() { -#if defined(Q_OS_WINCE) || defined(Q_OS_MAC) - QSKIP("This test is platform dependent, it fails on wince and mac. Please fix."); +#if defined(Q_OS_DARWIN) + QSKIP("This test is platform dependent, it fails on Apple platforms. Please fix."); #else QGraphicsScene scene; HFWWidget *window = new HFWWidget; @@ -3184,7 +3180,7 @@ void tst_QGraphicsWidget::itemChangeEvents() valueDuringEvents.insert(QEvent::ParentChange, QVariant::fromValue(parentItem())); break; } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR case QEvent::CursorChange: { valueDuringEvents.insert(QEvent::CursorChange, int(cursor().shape())); break; @@ -3235,7 +3231,7 @@ void tst_QGraphicsWidget::itemChangeEvents() QVERIFY(!item->isVisible()); QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::Hide).toBool()); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR // CursorChange should be triggered after the cursor has changed item->setCursor(Qt::PointingHandCursor); QTRY_COMPARE(item->valueDuringEvents.value(QEvent::CursorChange).toInt(), int(item->cursor().shape())); diff --git a/tests/auto/widgets/itemviews/itemviews.pro b/tests/auto/widgets/itemviews/itemviews.pro index 2bd8ec43d3..af0b6aeef0 100644 --- a/tests/auto/widgets/itemviews/itemviews.pro +++ b/tests/auto/widgets/itemviews/itemviews.pro @@ -17,7 +17,7 @@ SUBDIRS=\ qtreewidget \ qtreewidgetitemiterator \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qcolumnview \ qlistwidget \ diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 8cb95c867c..7412637354 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -95,7 +95,6 @@ public: void basic_tests(QAbstractItemView *view); private slots: - void initTestCase(); void cleanup(); void getSetCheck(); void emptyModels_data(); @@ -254,13 +253,6 @@ void tst_QAbstractItemView::getSetCheck() QCOMPARE(16, obj1->autoScrollMargin()); } -void tst_QAbstractItemView::initTestCase() -{ -#ifdef Q_OS_WINCE_WM - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QAbstractItemView::cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); @@ -1205,9 +1197,6 @@ void tst_QAbstractItemView::task250754_fontChange() void tst_QAbstractItemView::task200665_itemEntered() { -#ifdef Q_OS_WINCE_WM - QSKIP("On Windows Mobile the mouse tracking is unavailable at the moment"); -#endif //we test that view will emit entered //when the scrollbar move but not the mouse itself QStandardItemModel model(1000,1); diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index d717278be9..e6c4ab44f8 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -183,9 +183,6 @@ void tst_QColumnView::initTestCase() void tst_QColumnView::init() { qApp->setLayoutDirection(Qt::LeftToRight); -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif } void tst_QColumnView::rootIndex() diff --git a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro index 5190598701..ea4e9d4620 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro +++ b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro @@ -13,7 +13,7 @@ wince* { DEPLOYMENT += addit tests sourceFile } -android|wince { +android { DEFINES += SRCDIR=\\\"./\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp index 06019d4555..30109952c7 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp @@ -575,7 +575,7 @@ void tst_QDirModel::filePath() model.setResolveSymlinks(false); QModelIndex index = model.index(SRCDIR "test.lnk"); QVERIFY(index.isValid()); -#if !defined(Q_OS_WINCE) && !defined(Q_OS_ANDROID) +#if !defined(Q_OS_ANDROID) QString path = SRCDIR; #else QString path = QFileInfo(SRCDIR).absoluteFilePath(); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index ea065a4db4..32a324b888 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -381,9 +381,6 @@ tst_QHeaderView::tst_QHeaderView() void tst_QHeaderView::initTestCase() { -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif m_tableview = new QTableView(); } @@ -554,11 +551,7 @@ void tst_QHeaderView::hidden() void tst_QHeaderView::stretch() { // Show before resize and setStretchLastSection -#if defined(Q_OS_WINCE) - QSize viewSize(200,300); -#else QSize viewSize(500, 500); -#endif view->resize(viewSize); view->setStretchLastSection(true); QCOMPARE(view->stretchLastSection(), true); @@ -618,12 +611,6 @@ void tst_QHeaderView::sectionSize() QFETCH(int, lastVisibleSectionSize); QFETCH(int, persistentSectionSize); -#ifdef Q_OS_WINCE - // We test on a device with doubled pixels. Therefore we need to specify - // different boundaries. - initialDefaultSize = qMax(view->minimumSectionSize(), 30); -#endif - // bounds check foreach (int val, boundsCheck) view->sectionSize(val); @@ -693,13 +680,7 @@ void tst_QHeaderView::visualIndexAt_data() QTest::addColumn<QList<int> >("visual"); QList<int> coordinateList; -#ifndef Q_OS_WINCE coordinateList << -1 << 0 << 31 << 91 << 99999; -#else - // We test on a device with doubled pixels. Therefore we need to specify - // different boundaries. - coordinateList << -1 << 0 << 33 << 97 << 99999; -#endif QTest::newRow("no hidden, no moved sections") << QList<int>() @@ -752,10 +733,6 @@ void tst_QHeaderView::visualIndexAt() void tst_QHeaderView::length() { -#if defined(Q_OS_WINCE) - QFont font(QLatin1String("Tahoma"), 7); - view->setFont(font); -#endif view->setStretchLastSection(true); topLevel->show(); QVERIFY(QTest::qWaitForWindowExposed(topLevel)); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro index 02a71f8101..10cd1dcc54 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro +++ b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro @@ -3,4 +3,4 @@ TARGET = tst_qitemdelegate QT += widgets widgets-private testlib SOURCES += tst_qitemdelegate.cpp -win32:!wince:!winrt: LIBS += -luser32 +win32:!winrt: LIBS += -luser32 diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 972dabdcb8..0720a4f766 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -55,7 +55,7 @@ Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) -#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT) #include <windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index d3211eada8..1fd7b31e22 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -32,42 +32,13 @@ #include "viewstotest.cpp" #include <stdlib.h> -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) || defined(Q_OS_WIN) #include <time.h> #endif -#if defined(Q_OS_WIN) -#include <time.h> -#if defined(Q_OS_WINCE) -#include <aygshell.h> -#endif -#define random rand -#define srandom srand - -#if defined(Q_OS_WINCE) -#ifndef SPI_GETPLATFORMTYPE -#define SPI_GETPLATFORMTYPE 257 -#endif - -bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} - -bool qt_wince_is_pocket_pc() { - return qt_wince_is_platform(QString::fromLatin1("PocketPC")); -} -bool qt_wince_is_smartphone() { - return qt_wince_is_platform(QString::fromLatin1("Smartphone")); -} -bool qt_wince_is_mobile() { - return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()); -} -#endif +#if defined(Q_OS_WIN) +# define random rand +# define srandom srand #endif /*! @@ -305,10 +276,6 @@ void tst_QItemView::nonDestructiveBasicTest_data() */ void tst_QItemView::nonDestructiveBasicTest() { -#ifdef Q_OS_WINCE - QTest::qWait(400); -#endif - QFETCH(QString, viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); @@ -476,11 +443,7 @@ void tst_QItemView::spider() view->setModel(treeModel); view->show(); QVERIFY(QTest::qWaitForWindowActive(view)); -#if defined(Q_OS_WINCE) - srandom(0); -#else srandom(time(0)); -#endif touch(view->viewport(), Qt::NoModifier, Qt::Key_Left); touch(view->viewport(), Qt::ShiftModifier, Qt::Key_Enter); touch(view->viewport(), Qt::ControlModifier, Qt::Key_Backspace); diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro index 509303b62e..44e25ded66 100644 --- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro +++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro @@ -2,5 +2,5 @@ CONFIG += testcase TARGET = tst_qlistview QT += widgets gui-private widgets-private core-private testlib SOURCES += tst_qlistview.cpp -win32:!wince:!winrt: LIBS += -luser32 +win32:!winrt: LIBS += -luser32 linux*: CONFIG += insignificant_test # Crashes diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 98cc9b29ed..0f1c5723d5 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -46,13 +46,13 @@ #include <QtWidgets/QStyleFactory> #include <QtWidgets/QVBoxLayout> -#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) # include <windows.h> # include <QtGui/QGuiApplication> #include <qpa/qplatformnativeinterface.h> #endif // Q_OS_WIN -#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) static inline HWND getHWNDForWidget(const QWidget *widget) { QWindow *window = widget->windowHandle(); @@ -84,7 +84,6 @@ class tst_QListView : public QObject Q_OBJECT private slots: - void initTestCase(); void cleanup(); void getSetCheck(); void noDelegate(); @@ -112,7 +111,7 @@ private slots: void scrollBarAsNeeded(); void moveItems(); void wordWrap(); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void setCurrentIndexAfterAppendRowCrash(); #endif void emptyItemSize(); @@ -293,13 +292,6 @@ public: } }; -void tst_QListView::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QListView::cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); @@ -984,25 +976,6 @@ void tst_QListView::selection_data() << QRect(300, 0, 1, 300) // selection rectangle << IntList(); // expected items -#if defined(Q_OS_WINCE) - // depending on whether the display is double-pixeld, we need - // to click at a different position - bool doubledSize = false; - int dpi = GetDeviceCaps(GetDC(0), LOGPIXELSX); - if ((dpi < 1000) && (dpi > 0)) { - doubledSize = true; - } - QTest::newRow("select inside contents, (on viewport)") - << 35 // itemCount - << int(QListView::ListMode) - << int(QListView::TopToBottom) - << true // wrapping - << 0 // spacing - << QSize() // gridSize - << IntList() // hiddenRows - << QRect(doubledSize?350:175,doubledSize?550:275, 1, 1)// selection rectangle - << IntList(); // expected items -#else QTest::newRow("select inside contents, (on viewport)") << 35 // itemCount << int(QListView::ListMode) @@ -1013,7 +986,6 @@ void tst_QListView::selection_data() << IntList() // hiddenRows << QRect(175, 275, 1, 1) // selection rectangle << IntList(); // expected items -#endif QTest::newRow("select a tall rect in LeftToRight flow, wrap items") << 70 // itemCount @@ -1138,17 +1110,7 @@ void tst_QListView::selection() v.setRowHidden(hiddenRows.at(j), true); } -#if defined(Q_OS_WINCE) - // If the device is double-pixeled then the scrollbars become - // 10 pixels wider than normal (Windows Style: 16, Windows Mobile Style: 26). - // So we have to make the window slightly bigger to have the same count of - // items in each row of the list view like in the other styles. - static const int dpi = ::GetDeviceCaps(GetDC(0), LOGPIXELSX); - if ((dpi < 1000) && (dpi > 0)) - v.resize(535,535); -#else v.resize(525,525); -#endif topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); @@ -1450,7 +1412,7 @@ void tst_QListView::wordWrap() QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), true); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) class SetCurrentIndexAfterAppendRowCrashDialog : public QDialog { Q_OBJECT @@ -1501,7 +1463,7 @@ void tst_QListView::setCurrentIndexAfterAppendRowCrash() SetCurrentIndexAfterAppendRowCrashDialog w; w.exec(); } -#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT +#endif // Q_OS_WIN && !Q_OS_WINRT void tst_QListView::emptyItemSize() { diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 7258044804..cf8ee310d3 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -61,8 +61,6 @@ class tst_QTableView : public QObject Q_OBJECT private slots: - void initTestCase(); - void getSetCheck(); void noDelegate(); @@ -520,13 +518,6 @@ public: QSize hint; }; -void tst_QTableView::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QTableView::noDelegate() { QtTestTableModel model(3, 3); @@ -3996,10 +3987,6 @@ void tst_QTableView::mouseWheel_data() void tst_QTableView::mouseWheel() { -#ifdef Q_OS_WINCE - QSKIP("Since different Windows CE versions sport different taskbars, we skip this test"); -#endif - QFETCH(int, scrollMode); QFETCH(int, delta); QFETCH(int, horizontalPositon); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 611aaa92e6..c7b7ffaf95 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -75,8 +75,6 @@ public slots: void selectionOrderTest(); private slots: - void initTestCase(); - void getSetCheck(); // one test per QTreeView property @@ -347,13 +345,6 @@ public: mutable QMap<QModelIndex,QModelIndex> parentHash; }; -void tst_QTreeView::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - // Testing get/set functions void tst_QTreeView::getSetCheck() { diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 205067d89c..7796627bd9 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -42,15 +42,12 @@ class tst_QAction : public QObject public: tst_QAction(); - virtual ~tst_QAction(); - void updateState(QActionEvent *e); -public slots: - void initTestCase(); - void cleanupTestCase(); private slots: + void init(); + void cleanup(); void getSetCheck(); void setText_data(); void setText(); @@ -68,11 +65,26 @@ private slots: private: int m_lastEventType; - int m_keyboardScheme; + const int m_keyboardScheme; QAction *m_lastAction; - QWidget *m_tstWidget; }; +tst_QAction::tst_QAction() + : m_keyboardScheme(QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt()) +{ +} + +void tst_QAction::init() +{ + m_lastEventType = 0; + m_lastAction = nullptr; +} + +void tst_QAction::cleanup() +{ + QVERIFY(QApplication::topLevelWidgets().isEmpty()); +} + // Testing get/set functions void tst_QAction::getSetCheck() { @@ -104,46 +116,16 @@ class MyWidget : public QWidget { Q_OBJECT public: - MyWidget(tst_QAction *tst, QWidget *parent = 0) : QWidget(parent) { this->tst = tst; } + explicit MyWidget(tst_QAction *tst, QWidget *parent = nullptr) : QWidget(parent), m_test(tst) + { setWindowTitle(QTest::currentTestFunction()); } protected: - virtual void actionEvent(QActionEvent *e) { tst->updateState(e); } + void actionEvent(QActionEvent *e) override { m_test->updateState(e); } private: - tst_QAction *tst; + tst_QAction *m_test; }; -tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) -{ - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) - m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); -} - -tst_QAction::~tst_QAction() -{ - -} - -void tst_QAction::initTestCase() -{ - m_lastEventType = 0; - m_lastAction = 0; - - MyWidget *mw = new MyWidget(this); - m_tstWidget = mw; - mw->show(); - qApp->setActiveWindow(mw); -} - -void tst_QAction::cleanupTestCase() -{ - QWidget *testWidget = m_tstWidget; - if (testWidget) { - testWidget->hide(); - delete testWidget; - } -} - void tst_QAction::setText_data() { QTest::addColumn<QString>("text"); @@ -208,7 +190,10 @@ void tst_QAction::actionEvent() a.setText("action text"); // add action - m_tstWidget->addAction(&a); + MyWidget testWidget(this); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); + testWidget.addAction(&a); qApp->processEvents(); QCOMPARE(m_lastEventType, (int)QEvent::ActionAdded); @@ -222,7 +207,7 @@ void tst_QAction::actionEvent() QCOMPARE(m_lastAction, &a); // remove action - m_tstWidget->removeAction(&a); + testWidget.removeAction(&a); qApp->processEvents(); QCOMPARE(m_lastEventType, (int)QEvent::ActionRemoved); @@ -262,22 +247,24 @@ void tst_QAction::alternateShortcuts() { //test the alternate shortcuts (by adding more than 1 shortcut) - QWidget *wid = m_tstWidget; + MyWidget testWidget(this); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); { - QAction act(wid); - wid->addAction(&act); + QAction act(&testWidget); + testWidget.addAction(&act); QList<QKeySequence> shlist = QList<QKeySequence>() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A"); act.setShortcuts(shlist); QSignalSpy spy(&act, SIGNAL(triggered())); act.setAutoRepeat(true); - QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); QCOMPARE(spy.count(), 1); //act should have been triggered act.setAutoRepeat(false); - QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time //end of the scope of the action, it will be destroyed and removed from wid @@ -286,11 +273,15 @@ void tst_QAction::alternateShortcuts() //this tests a crash (if the action did not unregister its alternate shortcuts) - QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); } void tst_QAction::enabledVisibleInteraction() { + MyWidget testWidget(this); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); + QAction act(0); // check defaults QVERIFY(act.isEnabled()); @@ -305,20 +296,20 @@ void tst_QAction::enabledVisibleInteraction() QVERIFY(act.isVisible()); // check if shortcut is disabled if not visible - m_tstWidget->addAction(&act); + testWidget.addAction(&act); act.setShortcut(QKeySequence("Ctrl+T")); QSignalSpy spy(&act, SIGNAL(triggered())); act.setEnabled(true); act.setVisible(false); - QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger act.setVisible(false); act.setEnabled(true); - QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger act.setVisible(true); act.setEnabled(true); - QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier); + QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger } @@ -378,38 +369,42 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() void tst_QAction::repeat() { - QWidget *wid = m_tstWidget; - QAction act(wid); - wid->addAction(&act); + MyWidget testWidget(this); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); + QVERIFY(QTest::qWaitForWindowActive(&testWidget)); + + QAction act(&testWidget); + testWidget.addAction(&act); act.setShortcut(QKeySequence(Qt::Key_F)); QSignalSpy spy(&act, SIGNAL(triggered())); act.setAutoRepeat(true); - QTest::keyPress(wid, Qt::Key_F); - QTest::keyRelease(wid, Qt::Key_F); + QTest::keyPress(&testWidget, Qt::Key_F); + QTest::keyRelease(&testWidget, Qt::Key_F); QCOMPARE(spy.count(), 1); spy.clear(); - QTest::keyPress(wid, Qt::Key_F); + QTest::keyPress(&testWidget, Qt::Key_F); // repeat event - QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); - QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); - QTest::keyRelease(wid, Qt::Key_F); + QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); + QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); + QTest::keyRelease(&testWidget, Qt::Key_F); QCOMPARE(spy.count(), 3); spy.clear(); act.setAutoRepeat(false); - QTest::keyPress(wid, Qt::Key_F); - QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); - QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); - QTest::keyRelease(wid, Qt::Key_F); + QTest::keyPress(&testWidget, Qt::Key_F); + QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); + QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); + QTest::keyRelease(&testWidget, Qt::Key_F); QCOMPARE(spy.count(), 1); spy.clear(); act.setAutoRepeat(true); - QTest::keyPress(wid, Qt::Key_F); - QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); - QTest::keyRelease(wid, Qt::Key_F); + QTest::keyPress(&testWidget, Qt::Key_F); + QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); + QTest::keyRelease(&testWidget, Qt::Key_F); QCOMPARE(spy.count(), 2); } diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro index 908aa846c0..92409e4bfe 100644 --- a/tests/auto/widgets/kernel/qapplication/test/test.pro +++ b/tests/auto/widgets/kernel/qapplication/test/test.pro @@ -11,7 +11,7 @@ TESTDATA = ../test/test.pro ../tmp/README !winrt { SUBPROGRAMS = desktopsettingsaware modal - win32:!wince: SUBPROGRAMS += wincmdline + win32:SUBPROGRAMS += wincmdline for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" } diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index b7e8cded7a..eda51e31a9 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -52,15 +52,9 @@ #include <QtWidgets/private/qapplication_p.h> #include <QtWidgets/QStyle> -#ifdef Q_OS_WINCE -#include <windows.h> -#endif - #include <qpa/qwindowsysteminterface.h> #include <private/qhighdpiscaling_p.h> -#include "../../../qtest-config.h" - QT_BEGIN_NAMESPACE static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt) { @@ -235,10 +229,6 @@ static char *argv0; tst_QApplication::tst_QApplication() : quitApplicationTriggered(false) { -#ifdef Q_OS_WINCE - // Clean up environment previously to launching test - qputenv("QT_PLUGIN_PATH", QByteArray()); -#endif } void tst_QApplication::cleanup() @@ -897,19 +887,8 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r) #define QT_TST_QAPP_DEBUG void tst_QApplication::libraryPaths() { -#ifndef Q_OS_WINCE const QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath(); QVERIFY(!testDir.isEmpty()); -#else // !Q_OS_WINCE - // On Windows CE we need QApplication object to have valid - // current Path. Therefore we need to identify it ourselves - // here for the test. - QFileInfo filePath; - wchar_t module_name[MAX_PATH]; - GetModuleFileName(0, module_name, MAX_PATH); - filePath = QString::fromWCharArray(module_name); - const QString testDir = filePath.path() + "/test"; -#endif // Q_OS_WINCE { QApplication::setLibraryPaths(QStringList() << testDir); QCOMPARE(QApplication::libraryPaths(), (QStringList() << testDir)); @@ -1000,11 +979,7 @@ void tst_QApplication::libraryPaths() QString appDirPath = app.applicationDirPath(); app.addLibraryPath(appDirPath); -#ifdef Q_OS_WINCE - app.addLibraryPath(appDirPath + "/../.."); -#else app.addLibraryPath(appDirPath + "/.."); -#endif #ifdef QT_TST_QAPP_DEBUG qDebug() << "appDirPath" << appDirPath; qDebug() << "After adding appDirPath && appDirPath + /..:" << app.libraryPaths(); @@ -1044,15 +1019,9 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() QByteArray nonExistentPath = "/nonexistent"; QByteArray pluginPath = validPath + ':' + nonExistentPath; #elif defined(Q_OS_WIN) -# ifdef Q_OS_WINCE - QByteArray validPath = "/Temp"; - QByteArray nonExistentPath = "/nonexistent"; - QByteArray pluginPath = validPath + ';' + nonExistentPath; -# else QByteArray validPath = "C:\\windows"; QByteArray nonExistentPath = "Z:\\nonexistent"; QByteArray pluginPath = validPath + ';' + nonExistentPath; -# endif #endif { @@ -1069,9 +1038,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() << QLibraryInfo::location(QLibraryInfo::PluginsPath) << QDir(app.applicationDirPath()).canonicalPath() << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath(); -# ifdef Q_OS_WINCE - expected = QSet<QString>::fromList(expected).toList(); -# endif + QVERIFY2(isPathListIncluded(app.libraryPaths(), expected), qPrintable("actual:\n - " + app.libraryPaths().join("\n - ") + "\nexpected:\n - " + expected.join("\n - "))); @@ -1091,9 +1058,6 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() QStringList() << QLibraryInfo::location(QLibraryInfo::PluginsPath) << app.applicationDirPath(); -# ifdef Q_OS_WINCE - expected = QSet<QString>::fromList(expected).toList(); -# endif QVERIFY(isPathListIncluded(app.libraryPaths(), expected)); qputenv("QT_PLUGIN_PATH", QByteArray()); @@ -1479,10 +1443,6 @@ void tst_QApplication::desktopSettingsAware() } QVERIFY2(!path.isEmpty(), "Cannot locate desktopsettingsaware helper application"); path += "desktopsettingsaware"; -#ifdef Q_OS_WINCE - int argc = 0; - QApplication tmpApp(argc, 0); -#endif QProcess testProcess; testProcess.start(path); QVERIFY2(testProcess.waitForStarted(), @@ -1974,9 +1934,7 @@ void tst_QApplication::touchEventPropagation() release.setState(Qt::TouchPointReleased); releasedTouchPoints << release; - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); + QTouchDevice *device = QTest::createTouchDevice(); { // touch event behavior on a window @@ -2331,7 +2289,7 @@ Q_GLOBAL_STATIC(QPixmap, tst_qapp_pixmap); Q_GLOBAL_STATIC(QFont, tst_qapp_font); Q_GLOBAL_STATIC(QRegion, tst_qapp_region); Q_GLOBAL_STATIC(QFontDatabase, tst_qapp_fontDatabase); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR Q_GLOBAL_STATIC(QCursor, tst_qapp_cursor); #endif @@ -2356,7 +2314,7 @@ void tst_QApplication::globalStaticObjectDestruction() QVERIFY(tst_qapp_font()); QVERIFY(tst_qapp_region()); QVERIFY(tst_qapp_fontDatabase()); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QVERIFY(tst_qapp_cursor()); #endif } diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index a19f4aea56..b7ca5d21c7 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -84,6 +84,12 @@ private slots: void insertRow_QString_QLayout(); void insertRow_QWidget(); void insertRow_QLayout(); + void removeRow(); + void removeRow_QWidget(); + void removeRow_QLayout(); + void takeRow(); + void takeRow_QWidget(); + void takeRow_QLayout(); void setWidget(); void setLayout(); @@ -687,6 +693,237 @@ void tst_QFormLayout::insertRow_QLayout() // ### come back to this later } +void tst_QFormLayout::removeRow() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QWidget> w1 = new QWidget; + QPointer<QWidget> w2 = new QWidget; + + layout->addRow("test1", w1); + layout->addRow(w2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + layout->removeRow(1); + + QVERIFY(!w1); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + layout->removeRow(0); + + QVERIFY(!w2); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); +} + +void tst_QFormLayout::removeRow_QWidget() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QWidget> w1 = new QWidget; + QPointer<QWidget> w2 = new QWidget; + + layout->addRow("test1", w1); + layout->addRow(w2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + layout->removeRow(w1); + + QVERIFY(!w1); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + layout->removeRow(w2); + + QVERIFY(!w2); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QWidget *w3 = new QWidget; + layout->removeRow(w3); + delete w3; +} + +void tst_QFormLayout::removeRow_QLayout() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QHBoxLayout> l1 = new QHBoxLayout; + QPointer<QWidget> w1 = new QWidget; + l1->addWidget(w1); + QPointer<QHBoxLayout> l2 = new QHBoxLayout; + QPointer<QWidget> w2 = new QWidget; + l2->addWidget(w2); + + layout->addRow("test1", l1); + layout->addRow(l2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + layout->removeRow(l1); + + QVERIFY(!l1); + QVERIFY(!w1); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + layout->removeRow(l2); + + QVERIFY(!l2); + QVERIFY(!w2); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QHBoxLayout *l3 = new QHBoxLayout; + layout->removeRow(l3); + delete l3; +} + +void tst_QFormLayout::takeRow() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QWidget> w1 = new QWidget; + QPointer<QWidget> w2 = new QWidget; + + layout->addRow("test1", w1); + layout->addRow(w2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + QFormLayout::TakeRowResult result = layout->takeRow(1); + + QVERIFY(w2); + QVERIFY(result.fieldItem); + QVERIFY(result.labelItem); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + result = layout->takeRow(0); + + QVERIFY(w1); + QVERIFY(result.fieldItem); + QVERIFY(!result.labelItem); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + result = layout->takeRow(0); + + QVERIFY(!result.fieldItem); + QVERIFY(!result.labelItem); +} + +void tst_QFormLayout::takeRow_QWidget() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QWidget> w1 = new QWidget; + QPointer<QWidget> w2 = new QWidget; + + layout->addRow("test1", w1); + layout->addRow(w2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + QFormLayout::TakeRowResult result = layout->takeRow(w1); + + QVERIFY(w1); + QVERIFY(result.fieldItem); + QVERIFY(result.labelItem); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + result = layout->takeRow(w2); + + QVERIFY(w2); + QVERIFY(result.fieldItem); + QVERIFY(!result.labelItem); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QWidget *w3 = new QWidget; + result = layout->takeRow(w3); + delete w3; + + QVERIFY(!result.fieldItem); + QVERIFY(!result.labelItem); +} + +void tst_QFormLayout::takeRow_QLayout() +{ + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QPointer<QHBoxLayout> l1 = new QHBoxLayout; + QPointer<QWidget> w1 = new QWidget; + l1->addWidget(w1); + QPointer<QHBoxLayout> l2 = new QHBoxLayout; + QPointer<QWidget> w2 = new QWidget; + l2->addWidget(w2); + + layout->addRow("test1", l1); + layout->addRow(l2); + + QCOMPARE(layout->count(), 3); + QCOMPARE(layout->rowCount(), 2); + + QFormLayout::TakeRowResult result = layout->takeRow(l1); + + QVERIFY(l1); + QVERIFY(w1); + QVERIFY(result.fieldItem); + QVERIFY(result.labelItem); + QCOMPARE(layout->count(), 1); + QCOMPARE(layout->rowCount(), 1); + + result = layout->takeRow(l2); + + QVERIFY(l2); + QVERIFY(w2); + QVERIFY(result.fieldItem); + QVERIFY(!result.labelItem); + QCOMPARE(layout->count(), 0); + QCOMPARE(layout->rowCount(), 0); + + QHBoxLayout *l3 = new QHBoxLayout; + result = layout->takeRow(l3); + delete l3; + + QVERIFY(!result.fieldItem); + QVERIFY(!result.labelItem); +} + void tst_QFormLayout::setWidget() { QFormLayout layout; diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 07dcfca28f..3c4c1a1d41 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -56,7 +56,6 @@ class tst_QGridLayout : public QObject Q_OBJECT private slots: - void initTestCase(); void cleanup(); void getItemPosition(); void itemAtPosition(); @@ -81,17 +80,11 @@ private slots: void taskQTBUG_27420_takeAtShouldUnparentLayout(); void taskQTBUG_40609_addingWidgetToItsOwnLayout(); void taskQTBUG_40609_addingLayoutToItself(); + void taskQTBUG_52357_spacingWhenItemIsHidden(); void replaceWidget(); void dontCrashWhenExtendsToEnd(); }; -void tst_QGridLayout::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - static inline int visibleTopLevelWidgetCount() { int result= 0; @@ -603,19 +596,6 @@ void tst_QGridLayout::spacingsAndMargins_data() << QPoint( 20, child_offset_y) << QPoint( 20, child_offset_y + 100 + 6) ); -#if defined (Q_OS_WINCE) //There is not enough screenspace to run the test in original size on Windows CE. We use smaller widgets. - child_offset_y = 11 + 9 + 50 + 6 + 50 + 6 + 50 + 6; - QTest::newRow("1x3 grid") << 1 << 3 << QSize(50, 50) - << (PointList() // toplevel - << QPoint( 11, 11) - << QPoint( 11, 11 + 50 + 6) - << QPoint( 11, 11 + 50 + 6 + 50 + 6) - // children - << QPoint( 20, child_offset_y) - << QPoint( 20, child_offset_y + 50 + 6) - << QPoint( 20, child_offset_y + 50 + 6 + 50 + 6) - ); -#else child_offset_y = 11 + 9 + 100 + 6 + 100 + 6 + 100 + 6; QTest::newRow("1x3 grid") << 1 << 3 << QSize(100, 100) << (PointList() // toplevel @@ -627,7 +607,6 @@ void tst_QGridLayout::spacingsAndMargins_data() << QPoint( 20, child_offset_y + 100 + 6) << QPoint( 20, child_offset_y + 100 + 6 + 100 + 6) ); -#endif child_offset_y = 11 + 9 + 100 + 6 + 100 + 6; QTest::newRow("2x2 grid") << 2 << 2 << QSize(100, 100) @@ -1672,6 +1651,26 @@ void tst_QGridLayout::taskQTBUG_40609_addingLayoutToItself(){ QCOMPARE(layout.count(), 0); } +void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden() +{ + QWidget widget; + setFrameless(&widget); + QGridLayout layout(&widget); + layout.setMargin(0); + layout.setSpacing(5); + QPushButton button1; + layout.addWidget(&button1, 0, 0); + QPushButton button2; + layout.addWidget(&button2, 0, 1); + QPushButton button3; + layout.addWidget(&button3, 0, 2); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + int tempWidth = button1.width() + button2.width() + button3.width() + 2 * layout.spacing(); + button2.hide(); + QTRY_COMPARE_WITH_TIMEOUT(tempWidth, button1.width() + button3.width() + layout.spacing(), 1000); +} + void tst_QGridLayout::replaceWidget() { QWidget wdg; diff --git a/tests/auto/widgets/kernel/qlayout/qlayout.pro b/tests/auto/widgets/kernel/qlayout/qlayout.pro index 2213767950..d460785158 100644 --- a/tests/auto/widgets/kernel/qlayout/qlayout.pro +++ b/tests/auto/widgets/kernel/qlayout/qlayout.pro @@ -4,13 +4,7 @@ TARGET = tst_qlayout QT += widgets widgets-private testlib SOURCES += tst_qlayout.cpp -wince* { - addFiles.files = baseline - addFiles.path = . - DEPLOYMENT += addFiles -} else { - TESTDATA += baseline/* -} +TESTDATA += baseline/* android { RESOURCES += \ diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 98a4caf49e..6fe6bd2f67 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -3,6 +3,7 @@ ubuntu-14.04 [saveRestoreGeometry] ubuntu-14.04 +ubuntu-16.04 [restoreVersion1Geometry] ubuntu-14.04 osx @@ -53,6 +54,7 @@ osx osx [maskedUpdate] osx +opensuse-42.1 [hideWhenFocusWidgetIsChild] osx-10.10 [hideOpaqueChildWhileHidden] diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index a3fd622896..499ca65516 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -16,8 +16,4 @@ mac { OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } -x11 { - LIBS += $$QMAKE_LIBS_X11 -} - -win32:!wince:!winrt: LIBS += -luser32 -lgdi32 +win32:!winrt: LIBS += -luser32 -lgdi32 diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 98b630b49d..e19e9e5bf1 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -67,15 +67,13 @@ #include <QtGui/qwindow.h> #include <qtimer.h> -#include "../../../qtest-config.h" - #if defined(Q_OS_OSX) #include "tst_qwidget_mac_helpers.h" // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile. #endif #include <QtTest/QTest> -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) # include <QtCore/qt_windows.h> # include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformnativeinterface.h> @@ -91,49 +89,12 @@ static HWND winHandleOf(const QWidget *w) return 0; } -# ifdef Q_OS_WINCE -# define Q_CHECK_PAINTEVENTS -# ifdef Q_OS_WINCE_WM -# include <qguifunctions_wince.h> -// taken from qguifunctions_wce.cpp -# define SPI_GETPLATFORMTYPE 257 -static bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} -static inline bool qt_wince_is_smartphone() { return qt_wince_is_platform(QString::fromLatin1("Smartphone")); } -# endif // Q_OS_WINCE_WM -# elif !defined(Q_OS_WINRT) // Q_OS_WINCE -# define Q_CHECK_PAINTEVENTS \ +# define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ QSKIP("desktop is not visible, this test would fail"); -# else // !Q_OS_WINCE && !Q_OS_WINRT -# define Q_CHECK_PAINTEVENTS -# endif // Q_OS_WINRT -#else // Q_OS_WIN + +#else // Q_OS_WIN && !Q_OS_WINRT # define Q_CHECK_PAINTEVENTS -#endif // else Q_OS_WIN - - -#if defined(Q_OS_WINCE_WM) -#include <qguifunctions_wince.h> -// taken from qguifunctions_wce.cpp -#define SPI_GETPLATFORMTYPE 257 -bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} -bool qt_wince_is_smartphone() { - return qt_wince_is_platform(QString::fromLatin1("Smartphone")); -} #endif #ifdef Q_OS_OSX @@ -163,7 +124,7 @@ static inline void centerOnScreen(QWidget *w) w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) static inline void setWindowsAnimationsEnabled(bool enabled) { ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled }; @@ -176,10 +137,10 @@ static inline bool windowsAnimationsEnabled() SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0); return animation.iMinAnimate; } -#else // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT +#else // Q_OS_WIN && !Q_OS_WINRT inline void setWindowsAnimationsEnabled(bool) {} static inline bool windowsAnimationsEnabled() { return false; } -#endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT +#endif // !Q_OS_WIN || Q_OS_WINRT template <class T> static QByteArray msgComparisonFailed(T v1, const char *op, T v2) @@ -212,8 +173,6 @@ public: public slots: void initTestCase(); - void cleanupTestCase(); - void init(); void cleanup(); private slots: void getSetCheck(); @@ -251,9 +210,7 @@ private slots: void hideWhenFocusWidgetIsChild(); void normalGeometry(); void setGeometry(); -#ifndef Q_OS_WINCE void windowOpacity(); -#endif void raise(); void lower(); void stackUnder(); @@ -314,7 +271,7 @@ private slots: void subtractOpaqueSiblings(); -#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT) void setGeometry_win(); #endif @@ -322,7 +279,7 @@ private slots: void deleteStyle(); void multipleToplevelFocusCheck(); void setFocus(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void setCursor(); #endif void setToolTip(); @@ -339,9 +296,7 @@ private slots: void render_task188133(); void render_task211796(); void render_task217815(); -#ifndef Q_OS_WINCE void render_windowOpacity(); -#endif void render_systemClip(); void render_systemClip2_data(); void render_systemClip2(); @@ -357,9 +312,7 @@ private slots: void repaintWhenChildDeleted(); void hideOpaqueChildWhileHidden(); -#if !defined(Q_OS_WINCE) void updateWhileMinimized(); -#endif void alienWidgets(); void adjustSize(); void adjustSize_data(); @@ -394,7 +347,7 @@ private slots: void setClearAndResizeMask(); void maskedUpdate(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void syntheticEnterLeave(); void taskQTBUG_4055_sendSyntheticEnterLeave(); void underMouse(); @@ -406,9 +359,7 @@ private slots: void toplevelLineEditFocus(); void focusWidget_task254563(); -#ifndef Q_OS_WINCE_WM void rectOutsideCoordinatesLimit_task144779(); -#endif void setGraphicsEffect(); #ifdef QT_BUILD_INTERNAL @@ -457,13 +408,13 @@ private slots: private: bool ensureScreenSize(int width, int height); - QWidget *testWidget; const QString m_platform; QSize m_testWidgetSize; QPoint m_availableTopLeft; QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; + QTouchDevice *m_touchScreen; }; bool tst_QWidget::ensureScreenSize(int width, int height) @@ -611,7 +562,7 @@ void tst_QWidget::getSetCheck() QCOMPARE(true, obj1.autoFillBackground()); var1.reset(); -#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT) obj1.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); const HWND handle = reinterpret_cast<HWND>(obj1.winId()); // explicitly create window handle QVERIFY(GetWindowLong(handle, GWL_STYLE) & WS_POPUP); @@ -622,6 +573,7 @@ tst_QWidget::tst_QWidget() : m_platform(QGuiApplication::platformName().toLower()) , m_safeCursorPos(0, 0) , m_windowsAnimationsEnabled(windowsAnimationsEnabled()) + , m_touchScreen(QTest::createTouchDevice()) { if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild() setWindowsAnimationsEnabled(false); @@ -634,8 +586,6 @@ tst_QWidget::tst_QWidget() palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14)); palette.setColor(QPalette::Text, QColor(21, 22, 23)); qApp->setPalette(palette, "QPropagationTestWidget"); - - testWidget = 0; } tst_QWidget::~tst_QWidget() @@ -656,9 +606,6 @@ private: void tst_QWidget::initTestCase() { -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif // Size of reference widget, 200 for < 2000, scale up for larger screens // to avoid Windows warnings about minimum size for decorated windows. int width = 200; @@ -674,122 +621,23 @@ void tst_QWidget::initTestCase() if (screenWidth > 2000) width = 100 * ((screenWidth + 500) / 1000); m_testWidgetSize = QSize(width, width); - // Create the test class - testWidget = new BezierViewer; - testWidget->setWindowTitle(QStringLiteral("BezierViewer")); - testWidget->move(m_availableTopLeft + QPoint(screenWidth / 3, 50)); - testWidget->resize(m_testWidgetSize); - testWidget->show(); - QVERIFY(QTest::qWaitForWindowExposed(testWidget)); -} - -void tst_QWidget::cleanupTestCase() -{ - delete testWidget; - testWidget = 0; -} - -void tst_QWidget::init() -{ -// TODO: Add initialization code here. -// This will be executed immediately before each test is run. - testWidget->setFont(QFont()); - testWidget->setPalette(QPalette()); } void tst_QWidget::cleanup() { - // Only 'testwidget', do not leak any other widgets. - QCOMPARE(QApplication::topLevelWidgets().size(), 1); -} - -// Helper class... - -BezierViewer::BezierViewer( QWidget* parent) - : QWidget(parent) -{ - setObjectName(QLatin1String("TestWidget")); - setWindowTitle(objectName()); - QPalette pal; - pal.setColor(backgroundRole(), Qt::white); - setPalette(pal); -} - - -void BezierViewer::setPoints( const QPolygonF& a ) -{ - points = a; -} - -#include "private/qbezier_p.h" -void BezierViewer::paintEvent( QPaintEvent* ) -{ - if ( points.size() != 4 ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QPolygon::bezier: The array must have 4 control points" ); -#endif - return; - } - - /* Calculate Bezier curve */ - QPolygonF bezier = QBezier::fromPoints(points.at(0),points.at(1),points.at(2),points.at(3)).toPolygon(); - - QPainter painter( this ); - - /* Calculate scale to fit in window */ - QRectF br = bezier.boundingRect() | points.boundingRect(); - QRectF pr = rect(); - int scl = qMax( qMin(pr.width()/br.width(), pr.height()/br.height()), qreal(1.) ); - int border = scl-1; - - /* Scale Bezier curve vertices */ - for ( QPolygonF::Iterator it = bezier.begin(); it != bezier.end(); ++it ) { - it->setX( (it->x()-br.x()) * scl + border ); - it->setY( (it->y()-br.y()) * scl + border ); - } - - /* Draw grid */ - painter.setPen( Qt::lightGray ); - int i; - for ( i = border; i <= pr.width(); i += scl ) { - painter.drawLine( i, 0, i, pr.height() ); - } - for ( int j = border; j <= pr.height(); j += scl ) { - painter.drawLine( 0, j, pr.width(), j ); - } - - /* Write number of vertices */ - painter.setPen( Qt::red ); - painter.setFont( QFont("Helvetica", 14, QFont::DemiBold, true ) ); - QString caption; - caption.setNum( bezier.size() ); - caption += QString::fromLatin1( " vertices" ); - painter.drawText( 10, pr.height()-10, caption ); - - /* Draw Bezier curve */ - painter.setPen( Qt::black ); - painter.drawPolyline( bezier ); - - /* Scale and draw control points */ - painter.setPen( Qt::darkGreen ); - for ( QPolygonF::Iterator p1 = points.begin(); p1 != points.end(); ++p1 ) { - int x = (p1->x()-br.x()) * scl + border; - int y = (p1->y()-br.y()) * scl + border; - painter.drawLine( x-4, y-4, x+4, y+4 ); - painter.drawLine( x+4, y-4, x-4, y+4 ); - } - - /* Draw vertices */ - painter.setPen( Qt::red ); - painter.setBrush( Qt::red ); - for ( QPolygonF::Iterator p2 = bezier.begin(); p2 != bezier.end(); ++p2 ) - painter.drawEllipse( p2->x()-1, p2->y()-1, 3, 3 ); + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QWidget::fontPropagation() { + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); QFont font = testWidget->font(); - QWidget* childWidget = new QWidget( testWidget ); + QWidget* childWidget = new QWidget( testWidget.data() ); childWidget->show(); QCOMPARE( font, childWidget->font() ); @@ -820,7 +668,7 @@ void tst_QWidget::fontPropagation() font.setPointSize(font.pointSize() + 2); testWidget->setFont(font); - QWidget *one = new QWidget(testWidget); + QWidget *one = new QWidget(testWidget.data()); QWidget *two = new QWidget(one); QWidget *three = new QWidget(two); QWidget *four = new QWidget(two); @@ -976,8 +824,15 @@ void tst_QWidget::fontPropagation2() void tst_QWidget::palettePropagation() { + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); + QPalette palette = testWidget->palette(); - QWidget* childWidget = new QWidget( testWidget ); + QWidget* childWidget = new QWidget( testWidget.data() ); childWidget->show(); QCOMPARE( palette, childWidget->palette() ); @@ -1110,7 +965,13 @@ void tst_QWidget::palettePropagation2() void tst_QWidget::enabledPropagation() { - QWidget* childWidget = new QWidget( testWidget ); + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); + QWidget* childWidget = new QWidget( testWidget.data() ); childWidget->show(); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); @@ -1193,7 +1054,13 @@ void tst_QWidget::properTabHandlingWhenDisabled_QTBUG27417() #ifndef QT_NO_DRAGANDDROP void tst_QWidget::acceptDropsPropagation() { - QWidget *childWidget = new QWidget(testWidget); + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); + QWidget *childWidget = new QWidget(testWidget.data()); childWidget->show(); QVERIFY(!testWidget->acceptDrops()); QVERIFY(!childWidget->acceptDrops()); @@ -1240,32 +1107,38 @@ void tst_QWidget::acceptDropsPropagation() void tst_QWidget::isEnabledTo() { - QWidget* childWidget = new QWidget( testWidget ); + QWidget testWidget; + testWidget.resize(m_testWidgetSize); + testWidget.setWindowTitle(__FUNCTION__); + centerOnScreen(&testWidget); + testWidget.show(); + QWidget* childWidget = new QWidget( &testWidget ); QWidget* grandChildWidget = new QWidget( childWidget ); - QVERIFY( childWidget->isEnabledTo( testWidget ) ); - QVERIFY( grandChildWidget->isEnabledTo( testWidget ) ); + QVERIFY( childWidget->isEnabledTo( &testWidget ) ); + QVERIFY( grandChildWidget->isEnabledTo( &testWidget ) ); childWidget->setEnabled( false ); - QVERIFY( !childWidget->isEnabledTo( testWidget ) ); + QVERIFY( !childWidget->isEnabledTo( &testWidget ) ); QVERIFY( grandChildWidget->isEnabledTo( childWidget ) ); - QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) ); + QVERIFY( !grandChildWidget->isEnabledTo( &testWidget ) ); - QScopedPointer<QMainWindow> childDialog(new QMainWindow(testWidget)); - testWidget->setEnabled(false); + QScopedPointer<QMainWindow> childDialog(new QMainWindow(&testWidget)); + testWidget.setEnabled(false); QVERIFY(!childDialog->isEnabled()); QVERIFY(childDialog->isEnabledTo(0)); - testWidget->setEnabled(true); } void tst_QWidget::visible() { // Ensure that the testWidget is hidden for this test at the // start - - testWidget->hide(); + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); QVERIFY( !testWidget->isVisible() ); - QWidget* childWidget = new QWidget( testWidget ); + QWidget* childWidget = new QWidget( testWidget.data() ); QVERIFY( !childWidget->isVisible() ); testWidget->show(); @@ -1331,11 +1204,16 @@ void tst_QWidget::setLocale() void tst_QWidget::visible_setWindowOpacity() { - testWidget->hide(); + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->winId(); + QVERIFY( !testWidget->isVisible() ); testWidget->setWindowOpacity(0.5); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - QVERIFY(!::IsWindowVisible(winHandleOf(testWidget))); + QVERIFY(!::IsWindowVisible(winHandleOf(testWidget.data()))); #endif testWidget->setWindowOpacity(1.0); } @@ -1344,35 +1222,40 @@ void tst_QWidget::isVisibleTo() { // Ensure that the testWidget is hidden for this test at the // start + QWidget testWidget; + testWidget.resize(m_testWidgetSize); + testWidget.setWindowTitle(__FUNCTION__); + centerOnScreen(&testWidget); - testWidget->hide(); - QWidget* childWidget = new QWidget( testWidget ); - QVERIFY( childWidget->isVisibleTo( testWidget ) ); + QWidget* childWidget = new QWidget( &testWidget ); + QVERIFY( childWidget->isVisibleTo( &testWidget ) ); childWidget->hide(); - QVERIFY( !childWidget->isVisibleTo( testWidget ) ); + QVERIFY( !childWidget->isVisibleTo( &testWidget ) ); QWidget* grandChildWidget = new QWidget( childWidget ); - QVERIFY( !grandChildWidget->isVisibleTo( testWidget ) ); + QVERIFY( !grandChildWidget->isVisibleTo( &testWidget ) ); QVERIFY( grandChildWidget->isVisibleTo( childWidget ) ); - testWidget->show(); + testWidget.show(); childWidget->show(); - QVERIFY( childWidget->isVisibleTo( testWidget ) ); + QVERIFY( childWidget->isVisibleTo( &testWidget ) ); grandChildWidget->hide(); QVERIFY( !grandChildWidget->isVisibleTo( childWidget ) ); - QVERIFY( !grandChildWidget->isVisibleTo( testWidget ) ); - + QVERIFY( !grandChildWidget->isVisibleTo( &testWidget ) ); } void tst_QWidget::isHidden() { // Ensure that the testWidget is hidden for this test at the // start + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); - testWidget->hide(); QVERIFY( testWidget->isHidden() ); - QWidget* childWidget = new QWidget( testWidget ); + QWidget* childWidget = new QWidget( testWidget.data() ); QVERIFY( !childWidget->isHidden() ); testWidget->show(); @@ -1405,8 +1288,15 @@ void tst_QWidget::isHidden() void tst_QWidget::fonts() { + QWidget testWidget; + testWidget.resize(m_testWidgetSize); + testWidget.setWindowTitle(__FUNCTION__); + centerOnScreen(&testWidget); + testWidget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); + // Tests setFont(), ownFont() and unsetFont() - QWidget* cleanTestWidget = new QWidget( testWidget ); + QWidget* cleanTestWidget = new QWidget( &testWidget ); QFont originalFont = cleanTestWidget->font(); QVERIFY( !cleanTestWidget->testAttribute(Qt::WA_SetFont) ); @@ -1415,7 +1305,7 @@ void tst_QWidget::fonts() QFont newFont( "times", 18 ); cleanTestWidget->setFont( newFont ); - newFont = newFont.resolve( testWidget->font() ); + newFont = newFont.resolve( testWidget.font() ); QVERIFY( cleanTestWidget->testAttribute(Qt::WA_SetFont) ); QVERIFY2( cleanTestWidget->font() == newFont, @@ -1512,7 +1402,7 @@ void tst_QWidget::mapFromAndTo() subWindow2->setGeometry(75, 75, 100, 100); subSubWindow->setGeometry(10, 10, 10, 10); -#if !defined(Q_OS_WINCE) && !defined(Q_OS_QNX) +#if !defined(Q_OS_QNX) //update visibility if (windowMinimized) { if (!windowHidden) { @@ -1692,7 +1582,6 @@ void tst_QWidget::focusChainOnReparent() void tst_QWidget::focusChainOnHide() { - testWidget->hide(); // We do not want to get disturbed by other widgets // focus should move to the next widget in the focus chain when we hide it. QScopedPointer<QWidget> parent(new QWidget()); parent->setObjectName(QLatin1String("focusChainOnHide")); @@ -1716,8 +1605,6 @@ void tst_QWidget::focusChainOnHide() QTRY_COMPARE(parent->hasFocus(), true); QCOMPARE(parent.data(), qApp->focusWidget()); - - testWidget->show(); //don't disturb later tests } class Container : public QWidget @@ -1825,15 +1712,8 @@ void tst_QWidget::activation() { Q_CHECK_PAINTEVENTS -#if defined(Q_OS_WINCE) - int waitTime = 1000; -#else int waitTime = 100; -#endif -#ifdef Q_OS_WINCE - qApp->processEvents(); -#endif QWidget widget1; widget1.setObjectName("activation-Widget1"); widget1.setWindowTitle(widget1.objectName()); @@ -1885,10 +1765,6 @@ void tst_QWidget::windowState() size = QGuiApplication::primaryScreen()->size(); } else { pos = QPoint(10, 10); -#ifdef Q_OS_WINCE_WM - if (qt_wince_is_smartphone()) { //small screen - size = QSize(100,100); -#endif } QWidget widget1; @@ -2420,11 +2296,7 @@ void tst_QWidget::reparent() childTLW.show(); QVERIFY(QTest::qWaitForWindowExposed(&parent)); -#ifdef Q_OS_WINCE - parent.move(50, 50); -#else parent.move(parentPosition); -#endif QPoint childPos = parent.mapToGlobal(child.pos()); QPoint tlwPos = childTLW.pos(); @@ -2453,6 +2325,12 @@ void tst_QWidget::icon() QPixmap p(20,20); p.fill(Qt::red); + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); testWidget->setWindowIcon(p); QVERIFY(!testWidget->windowIcon().isNull()); @@ -2468,22 +2346,27 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() { if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); - testWidget->activateWindow(); - QScopedPointer<QWidget> parentWidget(new QWidget(testWidget)); + + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->setWindowTitle(__FUNCTION__); + testWidget->resize(m_testWidgetSize); + centerOnScreen(testWidget.data()); + QWidget *parentWidget(new QWidget(testWidget.data())); parentWidget->setObjectName("parentWidget"); parentWidget->setGeometry(0, 0, 100, 100); - QLineEdit *edit = new QLineEdit(parentWidget.data()); + QLineEdit *edit = new QLineEdit(parentWidget); edit->setObjectName("edit1"); - QLineEdit *edit3 = new QLineEdit(parentWidget.data()); + QLineEdit *edit3 = new QLineEdit(parentWidget); edit3->setObjectName("edit3"); edit3->move(0,50); - parentWidget->show(); - QLineEdit *edit2 = new QLineEdit(testWidget); + QLineEdit *edit2 = new QLineEdit(testWidget.data()); edit2->setObjectName("edit2"); - edit2->show(); edit2->move(110, 100); edit->setFocus(); - qApp->processEvents(); + testWidget->show(); + testWidget->activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(testWidget.data())); + QString actualFocusWidget, expectedFocusWidget; if (!qApp->focusWidget() && m_platform == QStringLiteral("xcb")) QSKIP("X11: Your window manager is too broken for this test"); @@ -2639,8 +2522,6 @@ void tst_QWidget::setGeometry() QCOMPARE(tlw.geometry(), tr); } -// Windows CE does not support windowOpacity. -#ifndef Q_OS_WINCE void tst_QWidget::windowOpacity() { QWidget widget; @@ -2671,7 +2552,6 @@ void tst_QWidget::windowOpacity() child.setWindowOpacity(-1.0); QCOMPARE(child.windowOpacity(), 1.0); } -#endif class UpdateWidget : public QWidget { @@ -2990,9 +2870,6 @@ void tst_QWidget::stackUnder() foreach (UpdateWidget *child, allChildren) { int expectedZOrderChangeEvents = child == child1 ? 1 : 0; if (child == child3) { -#ifdef Q_OS_WINCE - qApp->processEvents(); -#endif #ifndef Q_OS_OSX QEXPECT_FAIL(0, "See QTBUG-493", Continue); #endif @@ -3384,9 +3261,6 @@ void tst_QWidget::widgetAt() w2->setMask(rgn); qApp->processEvents(); QTest::qWait(10); -#if defined(Q_OS_WINCE) - QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 -#endif QTRY_VERIFY((wr = QApplication::widgetAt(testPos))); QTRY_COMPARE(wr->objectName(), w1->objectName()); @@ -3402,9 +3276,6 @@ void tst_QWidget::widgetAt() w2->setMask(bitmap); qApp->processEvents(); QTest::qWait(10); -#if defined(Q_OS_WINCE) - QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 -#endif QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data()); QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data()); } @@ -3572,8 +3443,6 @@ bool verifyWidgetMask(QWidget *widget, QRect mask) void tst_QWidget::setMask() { - testWidget->hide(); // get this out of the way. - { MaskedPainter w; w.resize(200, 200); @@ -3729,7 +3598,7 @@ void tst_QWidget::optimizedResize_topLevel() topLevel.partial = false; topLevel.paintedRegion = QRegion(); -#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_WIN32) topLevel.resize(topLevel.size() + QSize(10, 10)); #else // Static contents does not work when programmatically resizing @@ -3800,7 +3669,6 @@ void tst_QWidget::setMinimumSize() // Setting a minimum size larger than the desktop does not work on WinCE, // so skip this part of the test. -#ifndef Q_OS_WINCE QSize nonDefaultSize = defaultSize + QSize(5,5); w.setMinimumSize(nonDefaultSize); w.showNormal(); @@ -3809,7 +3677,6 @@ void tst_QWidget::setMinimumSize() msgComparisonFailed(w.height(), ">=", nonDefaultSize.height())); QVERIFY2(w.width() >= nonDefaultSize.width(), msgComparisonFailed(w.width(), ">=", nonDefaultSize.width())); -#endif } void tst_QWidget::setMaximumSize() @@ -4749,7 +4616,7 @@ void tst_QWidget::setWindowGeometry() } } -#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT) void tst_QWidget::setGeometry_win() { QWidget widget; @@ -4770,7 +4637,7 @@ void tst_QWidget::setGeometry_win() QVERIFY2(rt.top <= m_availableTopLeft.y(), msgComparisonFailed(int(rt.top), "<=", m_availableTopLeft.y())); } -#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINRT) // Since X11 WindowManager operation are all async, and we have no way to know if the window // manager has finished playing with the window geometry, this test can't be reliable on X11. @@ -5095,12 +4962,8 @@ void tst_QWidget::moveChild() parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); ColorWidget child(&parent, Qt::Widget, Qt::blue); -#ifndef Q_OS_WINCE parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50), QSize(200, 200))); -#else - parent.setGeometry(60, 60, 150, 150); -#endif child.setGeometry(25, 25, 50, 50); #ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting QCursor::setPos(parent.geometry().topRight() + QPoint(50 , 50)); @@ -5325,11 +5188,18 @@ public: void tst_QWidget::setFocus() { + QScopedPointer<QWidget> testWidget(new QWidget); + testWidget->resize(m_testWidgetSize); + testWidget->setWindowTitle(__FUNCTION__); + centerOnScreen(testWidget.data()); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget.data())); + const QPoint windowPos = testWidget->geometry().topRight() + QPoint(50, 0); { // move focus to another window testWidget->activateWindow(); - QApplication::setActiveWindow(testWidget); + QApplication::setActiveWindow(testWidget.data()); if (testWidget->focusWidget()) testWidget->focusWidget()->clearFocus(); else @@ -5375,7 +5245,7 @@ void tst_QWidget::setFocus() // note: window may be active, but we don't want it to be testWidget->activateWindow(); - QApplication::setActiveWindow(testWidget); + QApplication::setActiveWindow(testWidget.data()); if (testWidget->focusWidget()) testWidget->focusWidget()->clearFocus(); else @@ -5544,7 +5414,7 @@ private: int m_count; }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QWidget::setCursor() { { @@ -5687,8 +5557,6 @@ void tst_QWidget::setToolTip() QCOMPARE(widget.toolTip(), QString()); QCOMPARE(spy.count(), 2); - // Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform. -#ifndef Q_OS_WINCE_WM for (int pass = 0; pass < 2; ++pass) { QCursor::setPos(m_safeCursorPos); QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup)); @@ -5716,7 +5584,6 @@ void tst_QWidget::setToolTip() QTest::qWait(2200); // delay is 2000 QTest::mouseMove(popupWindow); } -#endif } void tst_QWidget::testWindowIconChangeEventPropagation() @@ -6795,7 +6662,6 @@ void tst_QWidget::render_task217815() } // Window Opacity is not supported on Windows CE. -#ifndef Q_OS_WINCE void tst_QWidget::render_windowOpacity() { const qreal opacity = 0.5; @@ -6868,7 +6734,6 @@ void tst_QWidget::render_windowOpacity() QCOMPARE(result, expected); } } -#endif void tst_QWidget::render_systemClip() { @@ -7326,14 +7191,10 @@ void tst_QWidget::repaintWhenChildDeleted() } #endif ColorWidget w(0, Qt::FramelessWindowHint, Qt::red); -#if !defined(Q_OS_WINCE) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; w.setGeometry(QRect(startPoint, QSize(100, 100))); -#else - w.setGeometry(60, 60, 110, 110); -#endif w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); QTest::qWait(10); @@ -7357,14 +7218,10 @@ void tst_QWidget::repaintWhenChildDeleted() void tst_QWidget::hideOpaqueChildWhileHidden() { ColorWidget w(0, Qt::FramelessWindowHint, Qt::red); -#if !defined(Q_OS_WINCE) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; w.setGeometry(QRect(startPoint, QSize(100, 100))); -#else - w.setGeometry(60, 60, 110, 110); -#endif ColorWidget child(&w, Qt::Widget, Qt::blue); child.setGeometry(10, 10, 80, 80); @@ -7393,7 +7250,6 @@ void tst_QWidget::hideOpaqueChildWhileHidden() } // This test doesn't make sense without support for showMinimized(). -#if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { if (m_platform == QStringLiteral("wayland")) @@ -7431,7 +7287,6 @@ void tst_QWidget::updateWhileMinimized() QTRY_COMPARE(widget.numPaintEvents, 1); QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50)); } -#endif class PaintOnScreenWidget: public QWidget { @@ -7798,13 +7653,6 @@ void tst_QWidget::adjustSize() QVERIFY2(child->size().height() < sizeHint.height(), msgComparisonFailed(child->size().height(), "<", sizeHint.height())); } else { -#if defined (Q_OS_WINCE) - if (!haveParent) { - const QRect& desktopRect = qApp->desktop()->availableGeometry(); - expectedSize.setWidth(qMin(expectedSize.width(), desktopRect.width())); - expectedSize.setHeight(qMin(expectedSize.height(), desktopRect.height())); - } -#endif QCOMPARE(child->size(), expectedSize); } if (!haveParent) @@ -8874,7 +8722,7 @@ void tst_QWidget::maskedUpdate() QTRY_COMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QWidget::syntheticEnterLeave() { if (m_platform == QStringLiteral("wayland")) @@ -8980,7 +8828,7 @@ void tst_QWidget::syntheticEnterLeave() } #endif -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() { if (m_platform == QStringLiteral("wayland")) @@ -9128,8 +8976,6 @@ void tst_QWidget::updateOnDestroyedSignal() void tst_QWidget::toplevelLineEditFocus() { - testWidget->hide(); - QLineEdit w; w.setMinimumWidth(m_testWidgetSize.width()); w.show(); @@ -9195,10 +9041,9 @@ QWidgetBackingStore* backingStore(QWidget &widget) } // Tables of 5000 elements do not make sense on Windows Mobile. -#ifndef Q_OS_WINCE_WM void tst_QWidget::rectOutsideCoordinatesLimit_task144779() { -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs #endif QWidget main(0,Qt::FramelessWindowHint); //don't get confused by the size of the window frame @@ -9233,11 +9078,10 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32), correct.toImage().convertToFormat(QImage::Format_RGB32)); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif } -#endif void tst_QWidget::setGraphicsEffect() { @@ -9850,25 +9694,21 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() { // Simple case, we ignore the touch events, we get mouse events instead - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget widget; widget.show(); QVERIFY(QTest::qWaitForWindowExposed(widget.windowHandle())); QCOMPARE(widget.m_touchEventCount, 0); QCOMPARE(widget.m_mouseEventCount, 0); - QTest::touchEvent(&widget, device).press(0, QPoint(10, 10), &widget); + QTest::touchEvent(&widget, m_touchScreen).press(0, QPoint(10, 10), &widget); QCOMPARE(widget.m_touchEventCount, 0); QCOMPARE(widget.m_mouseEventCount, 1); QCOMPARE(widget.m_lastMouseEventPos, QPointF(10, 10)); - QTest::touchEvent(&widget, device).move(0, QPoint(15, 15), &widget); + QTest::touchEvent(&widget, m_touchScreen).move(0, QPoint(15, 15), &widget); QCOMPARE(widget.m_touchEventCount, 0); QCOMPARE(widget.m_mouseEventCount, 2); QCOMPARE(widget.m_lastMouseEventPos, QPointF(15, 15)); - QTest::touchEvent(&widget, device).release(0, QPoint(20, 20), &widget); + QTest::touchEvent(&widget, m_touchScreen).release(0, QPoint(20, 20), &widget); QCOMPARE(widget.m_touchEventCount, 0); QCOMPARE(widget.m_mouseEventCount, 4); // we receive extra mouse move event QCOMPARE(widget.m_lastMouseEventPos, QPointF(20, 20)); @@ -9876,10 +9716,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() { // We accept the touch events, no mouse event is generated - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget widget; widget.setAcceptTouch(true); widget.show(); @@ -9887,13 +9723,13 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() QCOMPARE(widget.m_touchEventCount, 0); QCOMPARE(widget.m_mouseEventCount, 0); - QTest::touchEvent(&widget, device).press(0, QPoint(10, 10), &widget); + QTest::touchEvent(&widget, m_touchScreen).press(0, QPoint(10, 10), &widget); QCOMPARE(widget.m_touchEventCount, 1); QCOMPARE(widget.m_mouseEventCount, 0); - QTest::touchEvent(&widget, device).move(0, QPoint(15, 15), &widget); + QTest::touchEvent(&widget, m_touchScreen).move(0, QPoint(15, 15), &widget); QCOMPARE(widget.m_touchEventCount, 2); QCOMPARE(widget.m_mouseEventCount, 0); - QTest::touchEvent(&widget, device).release(0, QPoint(20, 20), &widget); + QTest::touchEvent(&widget, m_touchScreen).release(0, QPoint(20, 20), &widget); QCOMPARE(widget.m_touchEventCount, 3); QCOMPARE(widget.m_mouseEventCount, 0); } @@ -9901,10 +9737,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() { // Parent accepts touch events, child ignore both mouse and touch // We should see propagation of the TouchBegin - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget parent; parent.setAcceptTouch(true); TouchMouseWidget child(&parent); @@ -9917,7 +9749,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() QCOMPARE(child.m_touchEventCount, 0); QCOMPARE(child.m_mouseEventCount, 0); - QTest::touchEvent(parent.window(), device).press(0, QPoint(10, 10), &child); + QTest::touchEvent(parent.window(), m_touchScreen).press(0, QPoint(10, 10), &child); QCOMPARE(parent.m_touchEventCount, 1); QCOMPARE(parent.m_mouseEventCount, 0); QCOMPARE(child.m_touchEventCount, 0); @@ -9927,10 +9759,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() { // Parent accepts mouse events, child ignore both mouse and touch // We should see propagation of the TouchBegin into a MouseButtonPress - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget parent; TouchMouseWidget child(&parent); child.move(5, 5); @@ -9942,7 +9770,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() QCOMPARE(child.m_touchEventCount, 0); QCOMPARE(child.m_mouseEventCount, 0); - QTest::touchEvent(parent.window(), device).press(0, QPoint(10, 10), &child); + QTest::touchEvent(parent.window(), m_touchScreen).press(0, QPoint(10, 10), &child); QCOMPARE(parent.m_touchEventCount, 0); QCOMPARE(parent.m_mouseEventCount, 1); QCOMPARE(parent.m_lastMouseEventPos, QPointF(15, 15)); @@ -9954,10 +9782,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent() void tst_QWidget::touchUpdateOnNewTouch() { - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget widget; widget.setAcceptTouch(true); QVBoxLayout *layout = new QVBoxLayout; @@ -9970,23 +9794,23 @@ void tst_QWidget::touchUpdateOnNewTouch() QCOMPARE(widget.m_touchBeginCount, 0); QCOMPARE(widget.m_touchUpdateCount, 0); QCOMPARE(widget.m_touchEndCount, 0); - QTest::touchEvent(window, device).press(0, QPoint(20, 20), window); + QTest::touchEvent(window, m_touchScreen).press(0, QPoint(20, 20), window); QCOMPARE(widget.m_touchBeginCount, 1); QCOMPARE(widget.m_touchUpdateCount, 0); QCOMPARE(widget.m_touchEndCount, 0); - QTest::touchEvent(window, device).move(0, QPoint(25, 25), window); + QTest::touchEvent(window, m_touchScreen).move(0, QPoint(25, 25), window); QCOMPARE(widget.m_touchBeginCount, 1); QCOMPARE(widget.m_touchUpdateCount, 1); QCOMPARE(widget.m_touchEndCount, 0); - QTest::touchEvent(window, device).stationary(0).press(1, QPoint(40, 40), window); + QTest::touchEvent(window, m_touchScreen).stationary(0).press(1, QPoint(40, 40), window); QCOMPARE(widget.m_touchBeginCount, 1); QCOMPARE(widget.m_touchUpdateCount, 2); QCOMPARE(widget.m_touchEndCount, 0); - QTest::touchEvent(window, device).stationary(1).release(0, QPoint(25, 25), window); + QTest::touchEvent(window, m_touchScreen).stationary(1).release(0, QPoint(25, 25), window); QCOMPARE(widget.m_touchBeginCount, 1); QCOMPARE(widget.m_touchUpdateCount, 3); QCOMPARE(widget.m_touchEndCount, 0); - QTest::touchEvent(window, device).release(1, QPoint(40, 40), window); + QTest::touchEvent(window, m_touchScreen).release(1, QPoint(40, 40), window); QCOMPARE(widget.m_touchBeginCount, 1); QCOMPARE(widget.m_touchUpdateCount, 3); QCOMPARE(widget.m_touchEndCount, 1); @@ -9994,10 +9818,6 @@ void tst_QWidget::touchUpdateOnNewTouch() void tst_QWidget::touchEventsForGesturePendingWidgets() { - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - TouchMouseWidget parent; TouchMouseWidget child(&parent); parent.grabGesture(Qt::TapAndHoldGesture); @@ -10010,14 +9830,14 @@ void tst_QWidget::touchEventsForGesturePendingWidgets() QCOMPARE(child.m_gestureEventCount, 0); QCOMPARE(parent.m_touchEventCount, 0); QCOMPARE(parent.m_gestureEventCount, 0); - QTest::touchEvent(window, device).press(0, QPoint(20, 20), window); + QTest::touchEvent(window, m_touchScreen).press(0, QPoint(20, 20), window); QCOMPARE(child.m_touchEventCount, 0); QCOMPARE(child.m_gestureEventCount, 0); QCOMPARE(parent.m_touchBeginCount, 1); // QTapAndHoldGestureRecognizer::create() sets Qt::WA_AcceptTouchEvents QCOMPARE(parent.m_touchUpdateCount, 0); QCOMPARE(parent.m_touchEndCount, 0); QCOMPARE(parent.m_gestureEventCount, 0); - QTest::touchEvent(window, device).move(0, QPoint(25, 25), window); + QTest::touchEvent(window, m_touchScreen).move(0, QPoint(25, 25), window); QCOMPARE(child.m_touchEventCount, 0); QCOMPARE(child.m_gestureEventCount, 0); QCOMPARE(parent.m_touchBeginCount, 1); @@ -10025,7 +9845,7 @@ void tst_QWidget::touchEventsForGesturePendingWidgets() QCOMPARE(parent.m_touchEndCount, 0); QCOMPARE(parent.m_gestureEventCount, 0); QTest::qWait(1000); - QTest::touchEvent(window, device).release(0, QPoint(25, 25), window); + QTest::touchEvent(window, m_touchScreen).release(0, QPoint(25, 25), window); QCOMPARE(child.m_touchEventCount, 0); QCOMPARE(child.m_gestureEventCount, 0); QCOMPARE(parent.m_touchBeginCount, 1); @@ -10142,7 +9962,7 @@ void tst_QWidget::destroyedSignal() } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QWidget::underMouse() { // Move the mouse cursor to a safe location @@ -10429,7 +10249,7 @@ void tst_QWidget::taskQTBUG_27643_enterEvents() // Must only register only single enter on modal dialog's button after all said and done QCOMPARE(dialog.enters, 1); } -#endif // QTEST_NO_CURSOR +#endif // QT_NO_CURSOR class KeyboardWidget : public QWidget { diff --git a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro index 8672c363a2..a6248dfd16 100644 --- a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro +++ b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro @@ -2,8 +2,3 @@ CONFIG += testcase TARGET = tst_qwidget_window QT += widgets testlib core-private gui-private SOURCES += tst_qwidget_window.cpp - -x11 { - LIBS += $$QMAKE_LIBS_X11 -} - diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 35b1596003..6aaac6d135 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -331,8 +331,10 @@ void tst_QWidget_window::tst_showWithoutActivating() QSKIP("Cocoa: This fails. Figure out why."); else if (platformName != QStringLiteral("xcb") && platformName != QStringLiteral("windows") - && platformName != QStringLiteral("ios")) - QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios platforms."); + && platformName != QStringLiteral("ios") + && platformName != QStringLiteral("tvos") + && platformName != QStringLiteral("watchos")) + QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios/tvos/watchos platforms."); QWidget w1; w1.setAttribute(Qt::WA_ShowWithoutActivating); diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 50445b9a45..a1e5a70a08 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -3,12 +3,6 @@ TARGET = tst_qstyle QT += widgets testlib SOURCES += tst_qstyle.cpp -wince* { - addPixmap.files = task_25863.png - addPixmap.path = . - DEPLOYMENT += addPixmap -} - android { RESOURCES += \ testdata.qrc diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 5c213fea04..5925b764dd 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -56,20 +56,6 @@ #include <qlineedit.h> #include <qmdiarea.h> #include <qscrollarea.h> - -#ifdef Q_OS_WINCE_WM -#include <windows.h> - -static bool qt_wince_is_smartphone() { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (QString::fromLatin1("Smartphone").utf16()), tszPlatform)) - return true; - return false; -} -#endif - #include <qwidget.h> // Make a widget frameless to prevent size constraints of title bars @@ -90,7 +76,7 @@ public: private: bool testAllFunctions(QStyle *); - bool testScrollBarSubControls(QStyle *); + bool testScrollBarSubControls(); void testPainting(QStyle *style, const QString &platform); private slots: void drawItemPixmap(); @@ -109,12 +95,6 @@ private slots: #ifdef Q_OS_MAC void testMacStyle(); #endif -#ifdef Q_OS_WINCE - void testWindowsCEStyle(); -#endif -#ifdef Q_OS_WINCE_WM - void testWindowsMobileStyle(); -#endif void testStyleFactory(); void testProxyStyle(); void pixelMetric(); @@ -315,19 +295,11 @@ bool tst_QStyle::testAllFunctions(QStyle *style) style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200)); style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test")); - return testScrollBarSubControls(style); + return testScrollBarSubControls(); } -bool tst_QStyle::testScrollBarSubControls(QStyle* style) +bool tst_QStyle::testScrollBarSubControls() { - // WinCE SmartPhone doesn't have scrollbar subcontrols, so skip the rest of the test. -#ifdef Q_OS_WINCE_WM - if (style->inherits("QWindowsMobileStyle") && qt_wince_is_smartphone()) - return true; -#else - Q_UNUSED(style); -#endif - QScrollBar scrollBar; setFrameless(&scrollBar); scrollBar.show(); @@ -522,26 +494,6 @@ void tst_QStyle::testMacStyle() } #endif -#ifdef Q_OS_WINCE -// WindowsCEStyle style -void tst_QStyle::testWindowsCEStyle() -{ - QStyle *cstyle = QStyleFactory::create("WindowsCE"); - QVERIFY(testAllFunctions(cstyle)); - delete cstyle; -} -#endif - -#ifdef Q_OS_WINCE_WM -// WindowsMobileStyle style -void tst_QStyle::testWindowsMobileStyle() -{ - QStyle *cstyle = QStyleFactory::create("WindowsMobile"); - QVERIFY(testAllFunctions(cstyle)); - delete cstyle; -} -#endif - // Helper class... MyWidget::MyWidget( QWidget* parent, const char* name ) diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST index cf78fb47c2..61966e684f 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST +++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST @@ -1,2 +1,4 @@ [hoverColors] ubuntu-14.04 +opensuse-13.1 +opensuse-42.1 diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index c96004bd5d..7d9a8576d3 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -5,4 +5,4 @@ QT += widgets widgets-private gui-private testlib SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc -requires(contains(QT_CONFIG,private_tests)) +requires(qtConfig(private_tests)) diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index a107260d23..b95a17bd4e 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -34,8 +34,6 @@ #include <private/qstylesheetstyle_p.h> -#include "../../../qtest-config.h" - static inline void centerOnScreen(QWidget *w) { const QPoint offset = QPoint(w->width() / 2, w->height() / 2); @@ -76,7 +74,7 @@ private slots: void onWidgetDestroyed(); void fontPrecedence(); void focusColors(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void hoverColors(); #endif void background(); @@ -819,6 +817,24 @@ static bool testForColors(const QImage& image, const QColor& color, bool ensureP return false; } +static const QList<QWidget*> sample_widgets() // returning const to avoid detaching when passing to range-for +{ + QList<QWidget *> widgets; + widgets << new QPushButton("TESTING TESTING"); + widgets << new QLineEdit("TESTING TESTING"); + widgets << new QLabel("TESTING TESTING"); + QSpinBox *spinbox = new QSpinBox; + spinbox->setMaximum(1000000000); + spinbox->setValue(123456789); + widgets << spinbox; + QComboBox *combobox = new QComboBox; + combobox->setEditable(true); + combobox->addItems(QStringList() << "TESTING TESTING"); + widgets << combobox; + widgets << new QLabel("<b>TESTING TESTING</b>"); + return widgets; +} + void tst_QStyleSheetStyle::focusColors() { // Tests if colors can be changed by altering the focus of the widget. @@ -835,22 +851,9 @@ void tst_QStyleSheetStyle::focusColors() " (for example, QTBUG-33959)." "That doesn't mean that the feature doesn't work in practice."); #endif - QList<QWidget *> widgets; - widgets << new QPushButton("TESTING TESTING"); - widgets << new QLineEdit("TESTING TESTING"); - widgets << new QLabel("TESTING TESTING"); - QSpinBox *spinbox = new QSpinBox; - spinbox->setMaximum(1000000000); - spinbox->setValue(123456789); - widgets << spinbox; - QComboBox *combobox = new QComboBox; - combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING TESTING"); - widgets << combobox; - widgets << new QLabel("TESTING TESTING"); - foreach (QWidget *widget, widgets) { + for (QWidget *widget : sample_widgets()) { QDialog frame; QLayout* layout = new QGridLayout; @@ -887,27 +890,14 @@ void tst_QStyleSheetStyle::focusColors() } } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QStyleSheetStyle::hoverColors() { #ifdef Q_OS_OSX QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959."); #endif - QList<QWidget *> widgets; - widgets << new QPushButton("TESTING TESTING"); - widgets << new QLineEdit("TESTING TESTING"); - widgets << new QLabel("TESTING TESTING"); - QSpinBox *spinbox = new QSpinBox; - spinbox->setMaximum(1000000000); - spinbox->setValue(123456789); - widgets << spinbox; - QComboBox *combobox = new QComboBox; - combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING TESTING"); - widgets << combobox; - widgets << new QLabel("<b>TESTING TESTING</b>"); - foreach (QWidget *widget, widgets) { + for (QWidget *widget : sample_widgets()) { //without Qt::X11BypassWindowManagerHint the window manager may move the window after we moved the cursor QDialog frame(0, Qt::X11BypassWindowManagerHint); QLayout* layout = new QGridLayout; diff --git a/tests/auto/widgets/styles/styles.pro b/tests/auto/widgets/styles/styles.pro index 0de9dfcdab..9d7464cb5b 100644 --- a/tests/auto/widgets/styles/styles.pro +++ b/tests/auto/widgets/styles/styles.pro @@ -5,12 +5,12 @@ SUBDIRS=\ qstyleoption \ qstylesheetstyle \ -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qstylesheetstyle \ # This test can only be run on Mac OS: !mac:SUBDIRS -= \ qmacstyle \ -ios|android|qnx|wince: SUBDIRS -= \ +uikit|android|qnx: SUBDIRS -= \ qstylesheetstyle \ diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index ff71a6d56b..0098c5d884 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -600,10 +600,7 @@ void tst_QCompleter::directoryModel_data() if (i == 1) QTest::newRow("FILTERING_OFF") << "FILTERING_OFF" << "" << "" << ""; -#if defined(Q_OS_WINCE) - QTest::newRow("()") << "" << "" << "/" << "/"; - QTest::newRow("()") << "\\Program" << "" << "Program Files" << "\\Program Files"; -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) QTest::newRow("()") << "C" << "" << "C:" << "C:"; QTest::newRow("()") << "C:\\Program" << "" << "Program Files" << "C:\\Program Files"; #elif defined (Q_OS_MAC) @@ -649,10 +646,7 @@ void tst_QCompleter::fileSystemModel_data() if (i == 1) QTest::newRow("FILTERING_OFF") << "FILTERING_OFF" << "" << "" << ""; -#if defined(Q_OS_WINCE) - QTest::newRow("()") << "" << "" << "/" << "/"; - QTest::newRow("()") << "\\Program" << "" << "Program Files" << "\\Program Files"; -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) QTest::newRow("()") << "C" << "" << "C:" << "C:"; QTest::newRow("()") << "C:\\Program" << "" << "Program Files" << "C:\\Program Files"; #elif defined (Q_OS_MAC) diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index 2c398e1b2f..67bae43c9d 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -125,6 +125,9 @@ private slots: void scrollTo(); void scroll(); void overshoot(); + +private: + QTouchDevice *m_touchScreen = QTest::createTouchDevice(); }; /*! \internal @@ -150,11 +153,8 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setPos(touchStart); touchPoint.setScenePos(touchStart); touchPoint.setScreenPos(touchStart); - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); QTouchEvent touchEvent1(QEvent::TouchBegin, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -168,7 +168,7 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setScenePos(touchUpdate); touchPoint.setScreenPos(touchUpdate); QTouchEvent touchEvent2(QEvent::TouchUpdate, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointMoved, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -192,7 +192,7 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchPoint.setScenePos(touchEnd); touchPoint.setScreenPos(touchEnd); QTouchEvent touchEvent5(QEvent::TouchEnd, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointReleased, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -223,11 +223,8 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setPos(touchStart); touchPoint.setScenePos(touchStart); touchPoint.setScreenPos(touchStart); - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); QTouchEvent touchEvent1(QEvent::TouchBegin, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointPressed, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -239,7 +236,7 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setScenePos(touchUpdate); touchPoint.setScreenPos(touchUpdate); QTouchEvent touchEvent2(QEvent::TouchUpdate, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointMoved, (QList<QTouchEvent::TouchPoint>() << touchPoint)); @@ -252,7 +249,7 @@ void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, touchPoint.setScenePos(touchEnd); touchPoint.setScreenPos(touchEnd); QTouchEvent touchEvent5(QEvent::TouchEnd, - device, + m_touchScreen, Qt::NoModifier, Qt::TouchPointReleased, (QList<QTouchEvent::TouchPoint>() << touchPoint)); diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index a932cf5984..616898c4c5 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -107,9 +107,6 @@ void tst_QSystemTrayIcon::getSetCheck() void tst_QSystemTrayIcon::supportsMessages() { // ### fixme: Check platforms. -#if defined(Q_OS_WINCE) - QCOMPARE(QSystemTrayIcon::supportsMessages(), false); -#else const QString platform = QGuiApplication::platformName(); if (platform.compare(QStringLiteral("xcb"), Qt::CaseInsensitive) && platform.compare(QStringLiteral("windows"), Qt::CaseInsensitive) @@ -117,7 +114,6 @@ void tst_QSystemTrayIcon::supportsMessages() QEXPECT_FAIL("", "QTBUG-20978 QSystemTrayIcon is unimplemented for this platform", Abort); } QCOMPARE(QSystemTrayIcon::supportsMessages(), true); -#endif } void tst_QSystemTrayIcon::lastWindowClosed() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 50024460fc..816fe1faba 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -78,9 +78,6 @@ class tst_QComboBox : public QObject public: tst_QComboBox() {} -public slots: - void init(); - private slots: void getSetCheck(); void ensureReturnIsIgnored(); @@ -396,13 +393,6 @@ private: }; -void tst_QComboBox::init() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QComboBox::setEditable() { TestWidget topLevel; @@ -2753,7 +2743,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() QCOMPARE(combo.currentText(), QLatin1String("0")); // When calling cursor function, Windows CE responds with: This function is not supported on this system. -#if !defined Q_OS_WINCE && !defined Q_OS_QNX +#if !defined Q_OS_QNX // Force cursor movement to prevent QCursor::setPos() from returning prematurely on QPA: centerCursor(combo.view()); QTest::qWait(200); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro index 411185ae2a..c4bc1cab21 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro +++ b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_qdatetimeedit QT += widgets testlib core-private widgets-private SOURCES += tst_qdatetimeedit.cpp - -wincewm50smart-msvc2005: DEFINES += WINCE_NO_MODIFIER_KEYS diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 831d7257ba..28c2e92f78 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -84,30 +84,6 @@ Q_DECLARE_METATYPE(Qt::Key); Q_DECLARE_METATYPE(Qt::KeyboardModifiers); Q_DECLARE_METATYPE(Qt::KeyboardModifier); -#if defined(Q_OS_WINCE) -#ifndef SPI_GETPLATFORMTYPE -#define SPI_GETPLATFORMTYPE 257 -#endif - -bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, - sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} -bool qt_wince_is_pocket_pc() { - return qt_wince_is_platform(QString::fromLatin1("PocketPC")); -} -bool qt_wince_is_smartphone() { - return qt_wince_is_platform(QString::fromLatin1("Smartphone")); -} -bool qt_wince_is_mobile() { - return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()); -} -#endif - class EditorDateEdit : public QDateTimeEdit { Q_OBJECT @@ -331,7 +307,7 @@ void tst_QDateTimeEdit::cleanupTestCase() void tst_QDateTimeEdit::init() { QLocale::setDefault(QLocale(QLocale::C)); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); #endif testWidget->setDisplayFormat("dd/MM/yyyy"); // Nice default to have @@ -3107,7 +3083,7 @@ void tst_QDateTimeEdit::nextPrevSection_data() // 1. mac doesn't do these, // 2. some WinCE devices do not have modifiers -#if !defined(Q_OS_MAC) && !defined(WINCE_NO_MODIFIER_KEYS) +#if !defined(Q_OS_DARWIN) QTest::newRow("ctrl-right") << Qt::Key_Right << (Qt::KeyboardModifiers)Qt::ControlModifier << QString("56"); QTest::newRow("ctrl-left") << Qt::Key_Left << (Qt::KeyboardModifiers)Qt::ControlModifier << QString("12"); #endif diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 598b518810..a4614d0a9d 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -70,8 +70,6 @@ #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> -#include "../../../qtest-config.h" - QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE @@ -252,7 +250,7 @@ private slots: void noTextEditedOnClear(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void cursor(); #endif @@ -3484,7 +3482,7 @@ void tst_QLineEdit::textMargin() QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QLineEdit::cursor() { QLineEdit *testWidget = ensureTestWidget(); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 5bd26c632c..30e4f63aa1 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -45,7 +45,9 @@ #include <private/qmainwindowlayout_p.h> #include <private/qdockarealayout_p.h> -#include "../../../qtest-config.h" +#ifndef QT_NO_TABBAR +#include <qtabbar.h> +#endif static uchar restoreData41[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x1, 0x19, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x0, 0x8d, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0xd4, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x1, 0x19, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x35, 0x1, 0x0, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x39, 0x1, 0x0, 0x0, 0x0, 0x8d, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0xd4, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x1, 0x89, 0x0, 0x0, 0x0, 0xe, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x36, 0x1, 0x0, 0x0, 0x0, 0x63, 0x0, 0x0, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x5e, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x34, 0x1, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x1, 0x89, 0x0, 0x0, 0x0, 0xe, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x37, 0x1, 0x0, 0x0, 0x0, 0x63, 0x0, 0x0, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x5e, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x0, 0x1, 0x19}; static uchar restoreData42[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x2, 0x2b, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0xb6, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x87, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x32, 0x1, 0x0, 0x0, 0x1, 0xcd, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x98, 0x0, 0x0, 0x2, 0x2b, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x35, 0x1, 0x0, 0x0, 0x0, 0xb6, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x39, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x87, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x33, 0x1, 0x0, 0x0, 0x1, 0xcd, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x4, 0x4e, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x12, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x36, 0x1, 0x0, 0x0, 0x1, 0x16, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x30, 0x1, 0x0, 0x0, 0x2, 0x28, 0x0, 0x0, 0x1, 0x14, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x34, 0x1, 0x0, 0x0, 0x3, 0x40, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x4, 0x4e, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x12, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x37, 0x1, 0x0, 0x0, 0x1, 0x16, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x31, 0x1, 0x0, 0x0, 0x2, 0x28, 0x0, 0x0, 0x1, 0x14, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x3, 0x40, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x3, 0x8a, 0x0, 0x0, 0x2, 0x2b, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8}; @@ -131,7 +133,7 @@ private slots: void contentsMargins_data(); void contentsMargins(); void isSeparator(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void setCursor(); #endif void addToolbarAfterShow(); @@ -146,6 +148,9 @@ private slots: void QTBUG21378_animationFinished(); void resizeDocks(); void resizeDocks_data(); +#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR) + void QTBUG52175_tabifiedDockWidgetActivated(); +#endif }; @@ -595,9 +600,6 @@ void tst_QMainWindow::menuBar() mw.setMenuBar(mb1); QVERIFY(mw.menuBar() != 0); QCOMPARE(mw.menuBar(), (QMenuBar *)mb1); -#ifdef Q_OS_WINCE_WM - QSKIP("With native menubar integration the menubar is not a child"); -#endif QCOMPARE(mb1->parentWidget(), (QWidget *)&mw); mw.setMenuBar(0); @@ -1728,7 +1730,7 @@ class MainWindow : public QMainWindow { using QMainWindow::event; }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QMainWindow::setCursor() { MainWindow mw; @@ -2038,5 +2040,52 @@ void tst_QMainWindow::resizeDocks() } } +#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR) +void tst_QMainWindow::QTBUG52175_tabifiedDockWidgetActivated() +{ + QMainWindow w; + + QDockWidget *dwFirst = new QDockWidget(&w); + dwFirst->setWidget(new QWidget(dwFirst)); + w.addDockWidget(Qt::LeftDockWidgetArea, dwFirst); + + QDockWidget *dwSecond = new QDockWidget(&w); + dwSecond->setWidget(new QWidget(dwSecond)); + w.addDockWidget(Qt::LeftDockWidgetArea, dwSecond); + + w.tabifyDockWidget(dwFirst, dwSecond); + w.show(); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QTabBar *tabBar = w.findChild<QTabBar *>(); + QVERIFY(tabBar); + + QDockWidget *activated = nullptr; + connect(&w, &QMainWindow::tabifiedDockWidgetActivated, [&activated](QDockWidget *dockWidget) + { + activated = dockWidget; + }); + + w.hide(); + QCoreApplication::processEvents(); + QCOMPARE(activated, nullptr); + + w.show(); + QCoreApplication::processEvents(); + QCOMPARE(activated, nullptr); + + tabBar->setCurrentIndex(1); + QCoreApplication::processEvents(); + QCOMPARE(activated, nullptr); + + tabBar->setCurrentIndex(0); + QTRY_COMPARE(activated, dwFirst); + activated = nullptr; + + tabBar->setCurrentIndex(1); + QTRY_COMPARE(activated, dwSecond); +} +#endif + QTEST_MAIN(tst_QMainWindow) #include "tst_qmainwindow.moc" diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 809fa56a61..2b8f3032bf 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -228,7 +228,6 @@ class tst_QMdiArea : public QObject public: tst_QMdiArea(); public slots: - void initTestCase(); void cleanup(); protected slots: @@ -293,13 +292,6 @@ tst_QMdiArea::tst_QMdiArea() qRegisterMetaType<QMdiSubWindow *>(); } -void tst_QMdiArea::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QMdiArea::cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); @@ -509,9 +501,6 @@ void tst_QMdiArea::subWindowActivated2() if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort); #endif -#ifdef Q_OS_WINCE - QSKIP("Not fixed yet. See Task 197453"); -#endif #ifdef Q_OS_MAC QSKIP("QTBUG-25298: This test is unstable on Mac."); #endif @@ -649,7 +638,7 @@ void tst_QMdiArea::changeWindowTitle() #else widget->setWindowState(Qt::WindowMaximized); #endif -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) ); #endif @@ -658,7 +647,7 @@ void tst_QMdiArea::changeWindowTitle() mw->show(); QVERIFY(QTest::qWaitForWindowExposed(mw)); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) ); #endif @@ -676,7 +665,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowMaximized); #endif qApp->processEvents(); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QTRY_COMPARE( mw->windowTitle(), windowTitle(mwc, wc) ); widget->setWindowTitle( wc2 ); QCOMPARE( mw->windowTitle(), windowTitle(mwc, wc2) ); @@ -694,7 +683,7 @@ void tst_QMdiArea::changeWindowTitle() #endif qApp->processEvents(); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QCOMPARE( mw->windowTitle(), windowTitle(mwc2, wc2) ); #endif #ifdef USE_SHOW @@ -703,7 +692,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowNoState); #endif qApp->processEvents(); -#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) +#if defined(Q_OS_DARWIN) QCOMPARE(mw->windowTitle(), mwc); #else QCOMPARE( mw->windowTitle(), mwc2 ); @@ -715,7 +704,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowMaximized); #endif qApp->processEvents(); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QCOMPARE( mw->windowTitle(), windowTitle(mwc2, wc2) ); #endif @@ -764,7 +753,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( mw->isWindowModified(), false); QCOMPARE( widget->isWindowModified(), true); widget->setWindowState(Qt::WindowMaximized); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -774,7 +763,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( widget->isWindowModified(), true); widget->setWindowState(Qt::WindowMaximized); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -784,7 +773,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( widget->isWindowModified(), false); widget->setWindowModified(true); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -1598,9 +1587,7 @@ void tst_QMdiArea::tileSubWindows() qApp->processEvents(); } workspace.setActiveSubWindow(0); -#ifndef Q_OS_WINCE //See Task 197453 ToDo QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect()); -#endif QMdiSubWindow *window = windows.at(0); @@ -1724,9 +1711,6 @@ void tst_QMdiArea::tileSubWindows() frameWidth = workspace.style()->pixelMetric(QStyle::PM_DefaultFrameWidth); const int spacing = 2 * frameWidth + 2; const QSize expectedViewportSize(3 * minSize.width() + spacing, 3 * minSize.height() + spacing); -#ifdef Q_OS_WINCE - QSKIP("Not fixed yet! See task 197453"); -#endif QTRY_COMPARE(workspace.viewport()->rect().size(), expectedViewportSize); // Restore original scrollbar behavior for test below @@ -2005,7 +1989,7 @@ void tst_QMdiArea::delayedPlacement() void tst_QMdiArea::iconGeometryInMenuBar() { -#if !defined (Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QMainWindow mainWindow; QMenuBar *menuBar = mainWindow.menuBar(); menuBar->setNativeMenuBar(false); @@ -2063,11 +2047,7 @@ void tst_QMdiArea::resizeTimer() mdiArea.show(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); -#ifndef Q_OS_WINCE int time = 250; -#else - int time = 1000; -#endif EventSpy timerEventSpy(subWindow, QEvent::Timer); QCOMPARE(timerEventSpy.count(), 0); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index fe5c3a14a0..086c1049ab 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -48,8 +48,6 @@ #include <QScreen> #include <QSizeGrip> -#include "../../../qtest-config.h" - QT_BEGIN_NAMESPACE #if !defined(Q_DEAD_CODE_FROM_QT4_WIN) extern bool qt_tab_all_widgets(); @@ -161,7 +159,7 @@ private slots: void showShaded(); void showNormal_data(); void showNormal(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void setOpaqueResizeAndMove_data(); void setOpaqueResizeAndMove(); #endif @@ -184,7 +182,7 @@ private slots: void explicitlyHiddenWidget(); void resizeTimer(); void fixedMinMaxSize(); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) void replaceMenuBarWhileMaximized(); void closeOnDoubleClick_data(); void closeOnDoubleClick(); @@ -361,7 +359,7 @@ void tst_QMdiSubWindow::mainWindowSupport() qApp->setActiveWindow(&mainWindow); // QMainWindow's window title is empty -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) { QCOMPARE(mainWindow.windowTitle(), QString()); QMdiSubWindow *window = workspace->addSubWindow(new QPushButton(QLatin1String("Test"))); @@ -413,7 +411,7 @@ void tst_QMdiSubWindow::mainWindowSupport() window->showMaximized(); qApp->processEvents(); QVERIFY(window->isMaximized()); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QVERIFY(window->maximizedButtonsWidget()); QCOMPARE(window->maximizedButtonsWidget(), mainWindow.menuBar()->cornerWidget(Qt::TopRightCorner)); QVERIFY(window->maximizedSystemMenuIconWidget()); @@ -436,13 +434,13 @@ void tst_QMdiSubWindow::mainWindowSupport() QVERIFY(!nestedWindow->maximizedButtonsWidget()); QVERIFY(!nestedWindow->maximizedSystemMenuIconWidget()); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_QNX) +#if !defined(Q_OS_DARWIN) && !defined(Q_OS_QNX) QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]") .arg(originalWindowTitle, window->widget()->windowTitle())); #endif } -#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) +#if defined(Q_OS_DARWIN) return; #endif @@ -576,10 +574,6 @@ void tst_QMdiSubWindow::showShaded() window->showNormal(); QTest::qWait(250); -#ifdef Q_OS_WINCE - QSKIP("Until we have a QEvent::WindowFlagsChange event, this will skip"); -#endif - const QSize minimumSizeHint = window->minimumSizeHint(); QVERIFY(minimumSizeHint.height() < 300); const int maxHeightDiff = 300 - minimumSizeHint.height(); @@ -670,7 +664,7 @@ private: int _count; }; -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QMdiSubWindow::setOpaqueResizeAndMove_data() { QTest::addColumn<bool>("opaqueMode"); @@ -1011,7 +1005,7 @@ void tst_QMdiSubWindow::setSystemMenu() systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) // System menu in menu bar. subWindow->showMaximized(); QVERIFY(subWindow->isMaximized()); @@ -1044,7 +1038,7 @@ void tst_QMdiSubWindow::setSystemMenu() systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) // System menu in menu bar in reverse mode. subWindow->showMaximized(); QVERIFY(subWindow->isMaximized()); @@ -1475,7 +1469,7 @@ void tst_QMdiSubWindow::hideAndShow() QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner)); QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QTextEdit); subWindow->showMaximized(); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner)); QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget()); #endif @@ -1490,7 +1484,7 @@ void tst_QMdiSubWindow::hideAndShow() // Show QMdiArea. tabWidget->setCurrentIndex(0); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner)); QVERIFY(subWindow->maximizedButtonsWidget()); QVERIFY(subWindow->maximizedSystemMenuIconWidget()); @@ -1512,7 +1506,7 @@ void tst_QMdiSubWindow::hideAndShow() QVERIFY(subWindow); QCOMPARE(mdiArea->activeSubWindow(), subWindow); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner)); #if defined Q_OS_QNX QEXPECT_FAIL("", "QTBUG-38231", Abort); @@ -1540,7 +1534,7 @@ void tst_QMdiSubWindow::hideAndShow() QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner)); subWindow->show(); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QVERIFY(subWindow->maximizedButtonsWidget()); QVERIFY(subWindow->maximizedSystemMenuIconWidget()); QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget()); @@ -1554,7 +1548,7 @@ void tst_QMdiSubWindow::hideAndShow() // Show QMainWindow. mainWindow.show(); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) +#if !defined (Q_OS_DARWIN) QVERIFY(subWindow->maximizedButtonsWidget()); QVERIFY(subWindow->maximizedSystemMenuIconWidget()); QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget()); @@ -1724,7 +1718,7 @@ void tst_QMdiSubWindow::fixedMinMaxSize() QCOMPARE(subWindow->size(), minimumSize); } -#if !defined( Q_OS_MAC) && !defined( Q_OS_WINCE) +#if !defined( Q_OS_DARWIN) void tst_QMdiSubWindow::replaceMenuBarWhileMaximized() { @@ -1911,7 +1905,7 @@ void tst_QMdiSubWindow::mdiArea() void tst_QMdiSubWindow::task_182852() { -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QMdiArea *workspace = new QMdiArea; QMainWindow mainWindow; diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 741d6839db..cb7643d1ac 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -81,9 +81,7 @@ private slots: void overrideMenuAction(); void statusTip(); void widgetActionFocus(); -#ifndef Q_OS_WINCE void mouseActivation(); -#endif void tearOff(); void submenuTearOffDontClose(); void layoutDirection(); @@ -96,9 +94,7 @@ private slots: void task250673_activeMultiColumnSubMenuPosition(); void task256918_setFont(); void menuSizeHint(); -#ifndef Q_OS_WINCE void task258920_mouseBorder(); -#endif void setFixedWidth(); void deleteActionInTriggered(); void pushButtonPopulateOnAboutToShow(); @@ -293,8 +289,6 @@ void tst_QMenu::addActionsConnect() #endif // !QT_NO_SHORTCUT } -// We have a separate mouseActivation test for Windows mobile -#ifndef Q_OS_WINCE void tst_QMenu::mouseActivation() { QWidget topLevel; @@ -334,7 +328,6 @@ void tst_QMenu::mouseActivation() QVERIFY(submenu.isVisible()); #endif } -#endif void tst_QMenu::keyboardNavigation_data() { @@ -465,7 +458,7 @@ void tst_QMenu::overrideMenuAction() // On Mac and Windows CE, we need to create native key events to test menu // action activation, so skip this part of the test. -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) QAction *aQuit = new QAction("Quit", &w); aQuit->setShortcut(QKeySequence("Ctrl+X")); m->addAction(aQuit); @@ -762,10 +755,8 @@ void tst_QMenu::activeSubMenuPosition() QVERIFY(sub->pos() != QPoint(0,0)); // well, it's enough to check the pos is not (0,0) but it's more safe // to check that submenu is to the right of the main menu too. -#ifndef Q_OS_WINCE_WM QVERIFY(sub->pos().x() > main->pos().x()); QCOMPARE(sub->activeAction(), subAction); -#endif } // QTBUG-49588, QTBUG-48396: activeSubMenuPositionExec() is the same as @@ -817,10 +808,8 @@ private: void tst_QMenu::activeSubMenuPositionExec() { -#ifndef Q_OS_WINCE SubMenuPositionExecMenu menu; menu.exec(QGuiApplication::primaryScreen()->availableGeometry().center()); -#endif // !Q_OS_WINCE } void tst_QMenu::task242454_sizeHint() @@ -954,7 +943,6 @@ public: }; // Mouse move related signals for Windows Mobile unavailable -#ifndef Q_OS_WINCE void tst_QMenu::task258920_mouseBorder() { Menu258920 menu; @@ -983,7 +971,6 @@ void tst_QMenu::task258920_mouseBorder() QTRY_COMPARE(static_cast<QAction*>(0), menu.activeAction()); QTRY_VERIFY(menu.painted); } -#endif void tst_QMenu::setFixedWidth() { diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 4b4bec9920..58725346d0 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -90,7 +90,7 @@ private slots: void count(); void insertItem_QString_QObject(); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void accel(); void activatedCount(); void allowActiveAndDisabled(); @@ -113,7 +113,7 @@ private slots: void check_altPress(); void check_altClosePress(); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void check_shortcutPress(); void check_menuPosition(); #endif @@ -164,8 +164,6 @@ void tst_QMenuBar::getSetCheck() #include <qcursor.h> -const int RESET = 0; - /*! Test plan: insertItem (all flavors and combinations) @@ -311,7 +309,7 @@ inline TestMenu tst_QMenuBar::initWindowWithComplexMenuBar(QMainWindow &w) } // On Mac/WinCE, native key events are needed to test menu action activation -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::accel() { // create a popup menu with menu items set the accelerators later... @@ -329,7 +327,7 @@ void tst_QMenuBar::accel() #endif // On Mac/WinCE, native key events are needed to test menu action activation -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::activatedCount() { // create a popup menu with menu items set the accelerators later... @@ -520,7 +518,7 @@ void tst_QMenuBar::insertItem_QString_QObject() } // On Mac/WinCE, native key events are needed to test menu action activation -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_accelKeys() { QMainWindow w; @@ -593,7 +591,7 @@ void tst_QMenuBar::check_accelKeys() #endif // On Mac/WinCE, native key events are needed to test menu action activation -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys1() { QMainWindow w; @@ -627,7 +625,7 @@ void tst_QMenuBar::check_cursorKeys1() #endif // Qt/Mac,WinCE does not use the native popups/menubar -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys2() { QMainWindow w; @@ -660,7 +658,7 @@ void tst_QMenuBar::check_cursorKeys2() If a popupmenu is active you can use Left to move to the menu to the left of it. */ // Qt/Mac,WinCE does not use the native popups/menubar -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys3() { QMainWindow w; @@ -775,7 +773,7 @@ void tst_QMenuBar::check_endKey() */ // Qt/Mac,WinCE does not use the native popups/menubar -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_escKey() { QMainWindow w; @@ -920,7 +918,7 @@ void tst_QMenuBar::check_escKey() // QCOMPARE(m_complexActionTriggerCount['h'], (uint)itemH_count); // } -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::allowActiveAndDisabled() { QMenuBar menuBar; @@ -1010,7 +1008,7 @@ void tst_QMenuBar::check_altClosePress() } // Qt/Mac,WinCE does not use the native popups/menubar -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_shortcutPress() { QMainWindow w; @@ -1053,7 +1051,7 @@ private: }; // Qt/Mac,WinCE does not use the native popups/menubar -#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_menuPosition() { QMainWindow w; @@ -1122,7 +1120,7 @@ void tst_QMenuBar::check_menuPosition() menu.close(); } -# ifndef QTEST_NO_CURSOR +# ifndef QT_NO_CURSOR // QTBUG-28031: Click at bottom-right corner. { w.move(400, 200); @@ -1136,7 +1134,7 @@ void tst_QMenuBar::check_menuPosition() QCOMPARE(menu.geometry().right() - 1, globalPos.x()); menu.close(); } -# endif // QTEST_NO_CURSOR +# endif // QT_NO_CURSOR } #endif @@ -1209,7 +1207,7 @@ void tst_QMenuBar::task256322_highlight() QTRY_VERIFY(!menu2.isVisible()); QVERIFY(!menu.isVisible()); #ifdef Q_OS_MAC - if ((QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) && (win.menuBar()->activeAction() != nothing)) + if (win.menuBar()->activeAction() != nothing) QEXPECT_FAIL("", "QTBUG-30565: Unstable test", Continue); #endif QTRY_COMPARE(win.menuBar()->activeAction(), nothing); @@ -1392,7 +1390,7 @@ void tst_QMenuBar::cornerWidgets() QFETCH(Qt::Corner, corner); -#if defined(Q_OS_OSX) || defined(Q_OS_WINCE) +#if defined(Q_OS_OSX) QSKIP("Test interferes with native menu bars on this platform"); #endif diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index b58d236a91..31bbcf9c7f 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -48,8 +48,6 @@ #include "qplaintextedit.h" #include "../../../shared/platformclipboard.h" -#include "../../../qtest-config.h" - //Used in copyAvailable typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType; typedef QList<keyPairType> pairListType; @@ -64,7 +62,6 @@ public: tst_QPlainTextEdit(); public slots: - void initTestCase(); void init(); void cleanup(); private slots: @@ -104,7 +101,7 @@ private slots: void shiftDownInLineLastShouldSelectToEnd(); void undoRedoShouldRepositionTextEditCursor(); void lineWrapModes(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void mouseCursorShape(); #endif void implicitClear(); @@ -208,16 +205,8 @@ void tst_QPlainTextEdit::getSetCheck() QCOMPARE(0, obj1.tabStopWidth()); obj1.setTabStopWidth(INT_MIN); QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value -#if defined(Q_OS_WINCE) - // due to rounding error in qRound when qreal==float - // we cannot use INT_MAX for this check - obj1.setTabStopWidth(SHRT_MAX*2); - QCOMPARE(SHRT_MAX*2, obj1.tabStopWidth()); -#else obj1.setTabStopWidth(INT_MAX); QCOMPARE(INT_MAX, obj1.tabStopWidth()); -#endif - } class QtTestDocumentLayout : public QAbstractTextDocumentLayout @@ -251,13 +240,6 @@ public: tst_QPlainTextEdit::tst_QPlainTextEdit() {} -void tst_QPlainTextEdit::initTestCase() -{ -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif -} - void tst_QPlainTextEdit::init() { ed = new QPlainTextEdit(0); @@ -896,7 +878,7 @@ void tst_QPlainTextEdit::lineWrapModes() delete window; } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QPlainTextEdit::mouseCursorShape() { // always show an IBeamCursor, see change 170146 diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 302d290c72..7bbbc46b5a 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -526,12 +526,6 @@ void tst_QPushButton::sizeHint_data() #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) QTest::newRow("windowsvista") << QString::fromLatin1("windowsvista"); #endif -#if defined(Q_OS_WINCE) && !defined(QT_NO_STYLE_WINDOWSCE) - QTest::newRow("windowsce") << QString::fromLatin1("windowsce"); -#endif -#if defined(Q_OS_WINCE_WM) && !defined(QT_NO_STYLE_WINDOWSCE) - QTest::newRow("windowsmobile") << QString::fromLatin1("windowsmobile"); -#endif } void tst_QPushButton::sizeHint() diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro index 92c2f6cb7e..6523209c32 100644 --- a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro +++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro @@ -8,4 +8,4 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtabwidget.cpp -win32:!wince:!winrt: LIBS += -luser32 +win32:!winrt: LIBS += -luser32 diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index f8125bf749..2a2331c3bf 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -35,7 +35,7 @@ #include <qlabel.h> #include <QtWidgets/qboxlayout.h> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) # include <qt_windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ @@ -553,9 +553,7 @@ void tst_QTabWidget::paintEventCount() // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point. static const int MaxInitialPaintCount = -#if defined(Q_OS_WINCE) - 4; -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN) 2; #elif defined(Q_OS_MAC) 5; diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 69f0ff0f7e..cecec48113 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -55,8 +55,6 @@ #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> -#include "../../../qtest-config.h" - //Used in copyAvailable typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType; typedef QList<keyPairType> pairListType; @@ -125,7 +123,7 @@ private slots: void shiftDownInLineLastShouldSelectToEnd(); void undoRedoShouldRepositionTextEditCursor(); void lineWrapModes(); -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void mouseCursorShape(); #endif void implicitClear(); @@ -276,15 +274,8 @@ void tst_QTextEdit::getSetCheck() QCOMPARE(0, obj1.tabStopWidth()); obj1.setTabStopWidth(INT_MIN); QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value -#if defined(Q_OS_WINCE) - // due to rounding error in qRound when qreal==float - // we cannot use INT_MAX for this check - obj1.setTabStopWidth(SHRT_MAX*2); - QCOMPARE(SHRT_MAX*2, obj1.tabStopWidth()); -#else obj1.setTabStopWidth(INT_MAX); QCOMPARE(INT_MAX, obj1.tabStopWidth()); -#endif // bool QTextEdit::acceptRichText() // void QTextEdit::setAcceptRichText(bool) @@ -378,10 +369,6 @@ void tst_QTextEdit::cleanupTestCase() void tst_QTextEdit::init() { -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif - ed = new QTextEdit(0); rootFrameMargin = ed->document()->documentMargin(); } @@ -1230,7 +1217,7 @@ void tst_QTextEdit::lineWrapModes() QCOMPARE(ed->document()->pageSize().width(), qreal(1000)); } -#ifndef QTEST_NO_CURSOR +#ifndef QT_NO_CURSOR void tst_QTextEdit::mouseCursorShape() { // always show an IBeamCursor, see change 170146 diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index 0651583867..a8e8f6d865 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -48,10 +48,10 @@ SUBDIRS=\ qtoolbutton \ # The following tests depend on private API: -!contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!qtConfig(private_tests): SUBDIRS -= \ qcombobox \ qmainwindow \ qtextedit \ qtoolbar \ -contains(QT_CONFIG, opengl): SUBDIRS += qopenglwidget +qtConfig(opengl): SUBDIRS += qopenglwidget diff --git a/tests/auto/xml/dom/qdom/qdom.pro b/tests/auto/xml/dom/qdom/qdom.pro index 3248b8e0e2..dd1fa1a75b 100644 --- a/tests/auto/xml/dom/qdom/qdom.pro +++ b/tests/auto/xml/dom/qdom/qdom.pro @@ -4,9 +4,4 @@ SOURCES += tst_qdom.cpp QT = core xml testlib -wince* { - wince*|qt_not_deployed { - DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs - } -} TESTDATA += testdata/* doubleNamespaces.xml umlaut.xml diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index 5d5e00ac42..da38ed254b 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -257,6 +257,7 @@ static QStringList findXmlFiles(QString dir_name) { QStringList result; + dir_name = QFINDTESTDATA(dir_name); QDir dir(dir_name); QFileInfoList file_list = dir.entryInfoList(QStringList("*.xml"), QDir::Files, QDir::Name); @@ -300,7 +301,7 @@ void tst_QXmlSimpleReader::testGoodXmlFile() QVERIFY(file.open(QIODevice::ReadOnly)); Parser parser; - QEXPECT_FAIL("xmldocs/valid/sa/089.xml", "a form feed character is not accepted in XML", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/valid/sa/089.xml").toLocal8Bit().constData(), "a form feed character is not accepted in XML", Continue); QVERIFY(parser.parseFile(&file)); QFile ref_file(file_name + ".ref"); @@ -337,46 +338,46 @@ void tst_QXmlSimpleReader::testBadXmlFile() QVERIFY(file.open(QIODevice::ReadOnly)); Parser parser; - QEXPECT_FAIL("xmldocs/not-wf/sa/030.xml", "a form feed character is not accepted in XML", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/031.xml", "a form feed character is not accepted in a processing instruction", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/032.xml", "a form feed character is not accepted in a comment", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/033.xml", "overlong sequence - small latin letter d should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/038.xml", "attribute x redefined; should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/072.xml", "entity foo not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/073.xml", "entity f not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/074.xml", "entity e is not well-formed (</foo><foo>)", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/076.xml", "entity foo is not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/077.xml", "entity bar is not defined within the definition of entity foo", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/078.xml", "entity foo not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/085.xml", "Unfinished Public or System Id", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/086.xml", "Unfinished Public or System Id", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/087.xml", "Unfinished Public or System Id", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/101.xml", "Invalid XML encoding name (space before utf-8)", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/102.xml", "Invalid version specification (1.0 followed by space)", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/104.xml", "Premature end of data in tag foo", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/116.xml", "Invalid decimal value", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/117.xml", "No name", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/119.xml", "No name", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/122.xml", "; expected in declaration of element", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/132.xml", "; expected in declaration of element", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/142.xml", "Invalid value '0'", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/143.xml", "Invalid value '31'", Continue); - - QEXPECT_FAIL("xmldocs/not-wf/sa/144.xml", "noncharacter code 0xFFFF should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/145.xml", "surrogate code point 0xD800 should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/146.xml", "code point out-of-range 0x110000 (must be < 0x10FFFE)", Abort); - QEXPECT_FAIL("xmldocs/not-wf/sa/160.xml", "Parameter references forbidden in internal subset", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/162.xml", "Parameter references forbidden in internal subset", Continue); - - QEXPECT_FAIL("xmldocs/not-wf/sa/168.xml", "Surrogate code point 0xEDA080 should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/169.xml", "Surrogate code point 0xEDB080 should be rejected", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/170.xml", "Code point 0xF7808080 should be rejected", Continue); - - QEXPECT_FAIL("xmldocs/not-wf/sa/180.xml", "Entity e is not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/181.xml", "Unregistered error message", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/182.xml", "Comment not terminated", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/185.xml", "Entity e not defined", Continue); - QEXPECT_FAIL("xmldocs/not-wf/sa/186.xml", "Attributes constructs error", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/030.xml").toLocal8Bit().constData(), "a form feed character is not accepted in XML", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/031.xml").toLocal8Bit().constData(), "a form feed character is not accepted in a processing instruction", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/032.xml").toLocal8Bit().constData(), "a form feed character is not accepted in a comment", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/033.xml").toLocal8Bit().constData(), "overlong sequence - small latin letter d should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/038.xml").toLocal8Bit().constData(), "attribute x redefined; should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/072.xml").toLocal8Bit().constData(), "entity foo not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/073.xml").toLocal8Bit().constData(), "entity f not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/074.xml").toLocal8Bit().constData(), "entity e is not well-formed (</foo><foo>)", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/076.xml").toLocal8Bit().constData(), "entity foo is not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/077.xml").toLocal8Bit().constData(), "entity bar is not defined within the definition of entity foo", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/078.xml").toLocal8Bit().constData(), "entity foo not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/085.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/086.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/087.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/101.xml").toLocal8Bit().constData(), "Invalid XML encoding name (space before utf-8)", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/102.xml").toLocal8Bit().constData(), "Invalid version specification (1.0 followed by space)", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/104.xml").toLocal8Bit().constData(), "Premature end of data in tag foo", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/116.xml").toLocal8Bit().constData(), "Invalid decimal value", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/117.xml").toLocal8Bit().constData(), "No name", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/119.xml").toLocal8Bit().constData(), "No name", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/122.xml").toLocal8Bit().constData(), "; expected in declaration of element", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/132.xml").toLocal8Bit().constData(), "; expected in declaration of element", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/142.xml").toLocal8Bit().constData(), "Invalid value '0'", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/143.xml").toLocal8Bit().constData(), "Invalid value '31'", Continue); + + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/144.xml").toLocal8Bit().constData(), "noncharacter code 0xFFFF should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/145.xml").toLocal8Bit().constData(), "surrogate code point 0xD800 should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/146.xml").toLocal8Bit().constData(), "code point out-of-range 0x110000 (must be < 0x10FFFE)", Abort); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/160.xml").toLocal8Bit().constData(), "Parameter references forbidden in internal subset", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/162.xml").toLocal8Bit().constData(), "Parameter references forbidden in internal subset", Continue); + + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/168.xml").toLocal8Bit().constData(), "Surrogate code point 0xEDA080 should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/169.xml").toLocal8Bit().constData(), "Surrogate code point 0xEDB080 should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/170.xml").toLocal8Bit().constData(), "Code point 0xF7808080 should be rejected", Continue); + + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/180.xml").toLocal8Bit().constData(), "Entity e is not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/181.xml").toLocal8Bit().constData(), "Unregistered error message", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/182.xml").toLocal8Bit().constData(), "Comment not terminated", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/185.xml").toLocal8Bit().constData(), "Entity e not defined", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/186.xml").toLocal8Bit().constData(), "Attributes constructs error", Continue); QVERIFY(!parser.parseFile(&file)); @@ -386,7 +387,7 @@ void tst_QXmlSimpleReader::testBadXmlFile() ref_stream.setCodec("UTF-8"); QString ref_file_contents = ref_stream.readAll(); - QEXPECT_FAIL("xmldocs/not-wf/sa/145.xml", "Surrogate code point 0xD800 should be rejected", Continue); + QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/145.xml").toLocal8Bit().constData(), "Surrogate code point 0xD800 should be rejected", Continue); QCOMPARE(parser.result(), ref_file_contents); } @@ -410,14 +411,20 @@ void tst_QXmlSimpleReader::testIncrementalParsing_data() for (int i=1; i<10; ++i) { QStringList::const_iterator it = good_file_list.begin(); + const QString skip49 = QFINDTESTDATA("xmldocs/valid/sa/049.xml"); + const QString skip50 = QFINDTESTDATA("xmldocs/valid/sa/050.xml"); + const QString skip51 = QFINDTESTDATA("xmldocs/valid/sa/051.xml"); + const QString skip52 = QFINDTESTDATA("xmldocs/valid/sa/052.xml"); + const QString skip89 = QFINDTESTDATA("xmldocs/valid/sa/089.xml"); + for (; it != good_file_list.end(); ++it) { - if ( *it == "xmldocs/valid/sa/089.xml" ) + if ( *it == skip89 ) continue;// TODO: fails at the moment -- don't bother if ( i==1 && ( - *it == "xmldocs/valid/sa/049.xml" || - *it == "xmldocs/valid/sa/050.xml" || - *it == "xmldocs/valid/sa/051.xml" || - *it == "xmldocs/valid/sa/052.xml" ) ) { + *it == skip49 || + *it == skip50 || + *it == skip51 || + *it == skip52 ) ) { continue; // TODO: fails at the moment -- don't bother } QTest::newRow(QString("%1 %2").arg(*it).arg(i).toLatin1()) << *it << i; @@ -551,6 +558,9 @@ void tst_QXmlSimpleReader::inputFromSocket_data() void tst_QXmlSimpleReader::inputFromSocket() { QFETCH(QString, file_name); +#ifdef Q_OS_WINRT + QSKIP("WinRT does not support connecting to localhost"); +#endif QTRY_VERIFY(server->listening); @@ -756,7 +766,7 @@ public: void tst_QXmlSimpleReader::dtdRecursionLimit() { - QFile file("xmldocs/2-levels-nested-dtd.xml"); + QFile file(QFINDTESTDATA("xmldocs/2-levels-nested-dtd.xml")); QVERIFY(file.open(QIODevice::ReadOnly)); QXmlSimpleReader xmlReader; { @@ -768,7 +778,7 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() } file.close(); - file.setFileName("xmldocs/1-levels-nested-dtd.xml"); + file.setFileName(QFINDTESTDATA("xmldocs/1-levels-nested-dtd.xml")); QVERIFY(file.open(QIODevice::ReadOnly)); { QXmlInputSource *source = new QXmlInputSource(&file); @@ -782,7 +792,7 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() } file.close(); - file.setFileName("xmldocs/internal-entity-polynomial-attribute.xml"); + file.setFileName(QFINDTESTDATA("xmldocs/internal-entity-polynomial-attribute.xml")); QVERIFY(file.open(QIODevice::ReadOnly)); { QXmlInputSource *source = new QXmlInputSource(&file); diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 305f7318a4..3335ff8ffc 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -94,9 +94,6 @@ PlatformInfo PlatformInfo::localHostInfo() uname.start(QLS("uname"), QStringList() << QLS("-r")); if (uname.waitForFinished(3000)) pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); -#elif defined(Q_OS_WINCE) - pi.insert(PI_OSName, QLS("WinCE")); - pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_WIN) pi.insert(PI_OSName, QLS("Windows")); pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 8ee8d017ab..9e288f7aa2 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -7,6 +7,7 @@ SUBDIRS = \ qtHaveModule(dbus): SUBDIRS += dbus qtHaveModule(network): SUBDIRS += network qtHaveModule(gui): SUBDIRS += gui +qtHaveModule(widgets): SUBDIRS += widgets check-trusted.CONFIG += recursive QMAKE_EXTRA_TARGETS += check-trusted diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp index a9fd7fd5ec..cd5a83e547 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp @@ -59,10 +59,6 @@ private slots: void tst_qdiriterator::data() { -#if defined(Q_OS_WINCE) - QByteArray qtdir = qPrintable(QCoreApplication::applicationDirPath()); - qtdir += "/depot"; -#else #if defined(Q_OS_WIN) const char *qtdir = "C:\\depot\\qt\\main"; #else @@ -72,7 +68,6 @@ void tst_qdiriterator::data() fprintf(stderr, "QTDIR not set\n"); exit(1); } -#endif QTest::addColumn<QByteArray>("dirpath"); QByteArray ba = QByteArray(qtdir) + "/src/corelib"; diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index 3cfb0b44de..061b22a5d1 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -6,10 +6,3 @@ CONFIG += release SOURCES += main.cpp qfilesystemiterator.cpp HEADERS += qfilesystemiterator.h - -wince* { - corelibdir.files = $$QT_SOURCE_TREE/src/corelib - corelibdir.path = ./depot/src - DEPLOYMENT += corelibdir -} - diff --git a/tests/benchmarks/corelib/io/qfile/main.cpp b/tests/benchmarks/corelib/io/qfile/main.cpp index 175dc74074..1966b30773 100644 --- a/tests/benchmarks/corelib/io/qfile/main.cpp +++ b/tests/benchmarks/corelib/io/qfile/main.cpp @@ -591,12 +591,7 @@ void tst_qfile::createSmallFiles() dir.cd("tst"); tmpDirName = dir.absolutePath(); -#if defined(Q_OS_WINCE) - for (int i = 0; i < 100; ++i) -#else - for (int i = 0; i < 1000; ++i) -#endif - { + for (int i = 0; i < 1000; ++i) { QFile f(tmpDirName + QLatin1Char('/') + QString::number(i)); f.open(QIODevice::WriteOnly); f.seek(511); diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/main.cpp index 24a32a7c72..5180e7c29e 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp +++ b/tests/benchmarks/corelib/io/qfileinfo/main.cpp @@ -41,7 +41,7 @@ class qfileinfo : public QObject private slots: void existsTemporary(); void existsStatic(); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void symLinkTargetPerformanceLNK(); void symLinkTargetPerformanceMounpoint(); #endif @@ -71,7 +71,7 @@ void qfileinfo::existsStatic() QBENCHMARK { QFileInfo::exists(appPath); } } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void qfileinfo::symLinkTargetPerformanceLNK() { QVERIFY(QFile::link("file","link.lnk")); diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp index d8792ed7ef..782cad94a1 100644 --- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -33,7 +33,7 @@ class tst_QProcess : public QObject { Q_OBJECT -#if !defined(QT_NO_PROCESS) && !defined(Q_OS_WINCE) +#if !defined(QT_NO_PROCESS) private slots: void echoTest_performance(); @@ -41,8 +41,7 @@ private slots: #endif // QT_NO_PROCESS }; -#if !defined(QT_NO_PROCESS) && !defined(Q_OS_WINCE) -// Reading and writing to a process is not supported on Qt/CE +#if !defined(QT_NO_PROCESS) void tst_QProcess::echoTest_performance() { QProcess process; @@ -88,7 +87,7 @@ void tst_QProcess::echoTest_performance() QVERIFY(process.waitForFinished()); } -#endif // QT_NO_PROCESS && Q_OS_WINCE +#endif // QT_NO_PROCESS QTEST_MAIN(tst_QProcess) #include "tst_bench_qprocess.moc" diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index 9abb9466df..287afff089 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -37,6 +37,15 @@ class tst_qvariant : public QObject { Q_OBJECT + +public: + enum ABenchmarkEnum { + FirstEnumValue, + SecondEnumValue, + ThirdEnumValue + }; + Q_ENUM(ABenchmarkEnum) + private slots: void testBound(); @@ -50,6 +59,7 @@ private slots: void stringListVariantCreation(); void bigClassVariantCreation(); void smallClassVariantCreation(); + void enumVariantCreation(); void doubleVariantSetValue(); void floatVariantSetValue(); @@ -58,6 +68,7 @@ private slots: void stringListVariantSetValue(); void bigClassVariantSetValue(); void smallClassVariantSetValue(); + void enumVariantSetValue(); void doubleVariantAssignment(); void floatVariantAssignment(); @@ -136,6 +147,16 @@ void variantCreation<SmallClass>(SmallClass val) } } +template <> +void variantCreation<tst_qvariant::ABenchmarkEnum>(tst_qvariant::ABenchmarkEnum val) +{ + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) { + QVariant::fromValue(val); + } + } +} + void tst_qvariant::doubleVariantCreation() { @@ -179,6 +200,12 @@ void tst_qvariant::smallClassVariantCreation() variantCreation<SmallClass>(SmallClass()); } +void tst_qvariant::enumVariantCreation() +{ + variantCreation<ABenchmarkEnum>(FirstEnumValue); +} + + template <typename T> static void variantSetValue(T d) { @@ -225,6 +252,11 @@ void tst_qvariant::smallClassVariantSetValue() variantSetValue<SmallClass>(SmallClass()); } +void tst_qvariant::enumVariantSetValue() +{ + variantSetValue<ABenchmarkEnum>(FirstEnumValue); +} + template <typename T> static void variantAssignment(T d) { diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro new file mode 100644 index 0000000000..86102adecd --- /dev/null +++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = tst_bench_qreadwritelock +QT = core testlib +SOURCES += tst_qreadwritelock.cpp +CONFIG += c++14 # for std::shared_timed_mutex + diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp new file mode 100644 index 0000000000..bdec6c3a0a --- /dev/null +++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QtCore> +#include <QtTest/QtTest> +#include <mutex> +#if QT_HAS_INCLUDE(<shared_mutex>) +#if __cplusplus > 201103L +#include <shared_mutex> +#endif +#endif + +// Wrapers that take pointers instead of reference to have the same interface as Qt +template <typename T> +struct LockerWrapper : T +{ + LockerWrapper(typename T::mutex_type *mtx) + : T(*mtx) + { + } +}; + +int threadCount; + +class tst_QReadWriteLock : public QObject +{ + Q_OBJECT +public: + tst_QReadWriteLock() + { + // at least 2 threads, even on single cpu/core machines + threadCount = qMax(2, QThread::idealThreadCount()); + qDebug("thread count: %d", threadCount); + } + +private slots: + void uncontended_data(); + void uncontended(); + void readOnly_data(); + void readOnly(); + // void readWrite(); +}; + +struct FunctionPtrHolder +{ + FunctionPtrHolder(QFunctionPointer value = nullptr) + : value(value) + { + } + QFunctionPointer value; +}; +Q_DECLARE_METATYPE(FunctionPtrHolder) + +struct FakeLock +{ + FakeLock(volatile int *i) { *i = 0; } +}; + +enum { Iterations = 1000000 }; + +template <typename Mutex, typename Locker> +void testUncontended() +{ + Mutex lock; + QBENCHMARK { + for (int i = 0; i < Iterations; ++i) { + Locker locker(&lock); + } + } +} + +void tst_QReadWriteLock::uncontended_data() +{ + QTest::addColumn<FunctionPtrHolder>("holder"); + + QTest::newRow("nothing") << FunctionPtrHolder(testUncontended<int, FakeLock>); + QTest::newRow("QMutex") << FunctionPtrHolder(testUncontended<QMutex, QMutexLocker>); + QTest::newRow("QReadWriteLock, read") + << FunctionPtrHolder(testUncontended<QReadWriteLock, QReadLocker>); + QTest::newRow("QReadWriteLock, write") + << FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>); + QTest::newRow("std::mutex") << FunctionPtrHolder( + testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>); +#if defined __cpp_lib_shared_timed_mutex + QTest::newRow("std::shared_timed_mutex, read") << FunctionPtrHolder( + testUncontended<std::shared_timed_mutex, + LockerWrapper<std::shared_lock<std::shared_timed_mutex>>>); + QTest::newRow("std::shared_timed_mutex, write") << FunctionPtrHolder( + testUncontended<std::shared_timed_mutex, + LockerWrapper<std::unique_lock<std::shared_timed_mutex>>>); +#endif +} + +void tst_QReadWriteLock::uncontended() +{ + QFETCH(FunctionPtrHolder, holder); + holder.value(); +} + +static QHash<QString, QString> global_hash; + +template <typename Mutex, typename Locker> +void testReadOnly() +{ + struct Thread : QThread + { + Mutex *lock; + void run() + { + for (int i = 0; i < Iterations; ++i) { + QString s = QString::number(i); // Do something outside the lock + Locker locker(lock); + global_hash.contains(s); + } + } + }; + Mutex lock; + QVector<QThread *> threads; + for (int i = 0; i < threadCount; ++i) { + auto t = new Thread; + t->lock = &lock; + threads.append(t); + } + QBENCHMARK { + for (auto t : threads) { + t->start(); + } + for (auto t : threads) { + t->wait(); + } + } + qDeleteAll(threads); +} + +void tst_QReadWriteLock::readOnly_data() +{ + QTest::addColumn<FunctionPtrHolder>("holder"); + + QTest::newRow("nothing") << FunctionPtrHolder(testReadOnly<int, FakeLock>); + QTest::newRow("QMutex") << FunctionPtrHolder(testReadOnly<QMutex, QMutexLocker>); + QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>); + QTest::newRow("std::mutex") << FunctionPtrHolder( + testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>); +#if defined __cpp_lib_shared_timed_mutex + QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder( + testReadOnly<std::shared_timed_mutex, + LockerWrapper<std::shared_lock<std::shared_timed_mutex>>>); +#endif +} + +void tst_QReadWriteLock::readOnly() +{ + QFETCH(FunctionPtrHolder, holder); + holder.value(); +} + +QTEST_MAIN(tst_QReadWriteLock) +#include "tst_qreadwritelock.moc" diff --git a/tests/benchmarks/corelib/thread/thread.pro b/tests/benchmarks/corelib/thread/thread.pro index 4e602ceb4e..6b3009bd0c 100644 --- a/tests/benchmarks/corelib/thread/thread.pro +++ b/tests/benchmarks/corelib/thread/thread.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = \ qmutex \ + qreadwritelock \ qthreadstorage \ qthreadpool \ qwaitcondition \ diff --git a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp index 9ce8fffa8e..64d3dd5733 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp +++ b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp @@ -119,12 +119,7 @@ struct Large { // A "large" item type int x[1000]; }; -// Embedded devices typically have limited memory -#if defined(Q_OS_WINCE) -# define LARGE_MAX_SIZE 2000 -#else -# define LARGE_MAX_SIZE 20000 -#endif +#define LARGE_MAX_SIZE 20000 class tst_vector_vs_std : public QObject { diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp index 045beb17f3..5799b32b1c 100644 --- a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp +++ b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp @@ -34,15 +34,6 @@ #include <time.h> -#ifdef Q_OS_WINCE -// no C89 time() on Windows CE: -// http://blogs.msdn.com/b/cenet/archive/2006/04/29/time-h-on-windows-ce.aspx -uint time(void *) -{ - return uint(-1); -} -#endif - class tst_bench_QCryptographicHash : public QObject { Q_OBJECT diff --git a/tests/benchmarks/dbus/qdbustype/qdbustype.pro b/tests/benchmarks/dbus/qdbustype/qdbustype.pro index d30bad8ce7..70f803f56f 100644 --- a/tests/benchmarks/dbus/qdbustype/qdbustype.pro +++ b/tests/benchmarks/dbus/qdbustype/qdbustype.pro @@ -1,10 +1,9 @@ TARGET = tst_bench_qdbustype QT -= gui QT += core-private dbus-private testlib -contains(QT_CONFIG, dbus-linked) { +qtConfig(dbus-linked) { DEFINES += QT_LINKED_LIBDBUS - LIBS += $$QT_LIBS_DBUS - QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS + QMAKE_USE += dbus } else { SOURCES += ../../../../src/dbus/qdbus_symbols.cpp } diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7f52bb0eba..0064ecbaaf 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -401,9 +401,6 @@ void tst_QGraphicsView::chipTester_data() void tst_QGraphicsView::chipTester() { -#ifdef Q_OS_WINCE_WM - QSKIP("WinCE WM: Fails on Windows Mobile w/o OpenGL"); -#endif QFETCH(bool, antialias); QFETCH(bool, opengl); QFETCH(int, operation); diff --git a/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro b/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro index 9e47f979e1..828f36348d 100644 --- a/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro +++ b/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro @@ -3,6 +3,6 @@ TARGET = tst_bench_imageConversion QT += testlib SOURCES += tst_qimageconversion.cpp -!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF -!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG -contains(QT_CONFIG, c++11): CONFIG += c++11 +qtConfig(gif): DEFINES += QTEST_HAVE_GIF +qtConfig(jpeg): DEFINES += QTEST_HAVE_JPEG +qtConfig(c++11): CONFIG += c++11 diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro index e54e2ffce5..7de1eedbdf 100644 --- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro +++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro @@ -5,22 +5,6 @@ TARGET = tst_bench_qimagereader SOURCES += tst_qimagereader.cpp -!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF -!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG +qtConfig(gif): DEFINES += QTEST_HAVE_GIF +qtConfig(jpeg): DEFINES += QTEST_HAVE_JPEG QT += network - -wince { - addFiles.files = images - addFiles.path = . - - CONFIG(debug, debug|release):{ - imageFormatsPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/*d4.dll - } - - CONFIG(release, debug|release):{ - imageFormatsPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/*[^d]4.dll - } - imageFormatsPlugins.path = imageformats - DEPLOYMENT += addFiles imageFormatsPlugins -} - diff --git a/tests/benchmarks/gui/text/qtextdocument/main.cpp b/tests/benchmarks/gui/text/qtextdocument/main.cpp new file mode 100644 index 0000000000..17fee3b2eb --- /dev/null +++ b/tests/benchmarks/gui/text/qtextdocument/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include <QTextDocument> +#include <qtest.h> + +class tst_QTextDocument : public QObject +{ + Q_OBJECT +private slots: + void mightBeRichText_data(); + void mightBeRichText(); +}; + +void tst_QTextDocument::mightBeRichText_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("isMaybeRichText"); + QTest::newRow("empty") << QString() << false; + QTest::newRow("simple") << QString::fromLatin1("<html><b>Foo</b></html>") << true; + QTest::newRow("simple2") << QString::fromLatin1("<b>Foo</b>") << true; + QTest::newRow("documentation-header") << QString("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" + "<!DOCTYPE html\n" + " PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">") + << true; + QTest::newRow("br-nospace") << QString("Test <br/> new line") << true; + QTest::newRow("br-space") << QString("Test <br /> new line") << true; + QTest::newRow("br-invalidspace") << QString("Test <br/ > new line") << false; + QTest::newRow("invalid closing tag") << QString("Test <br/ line") << false; + QTest::newRow("no tags") << QString("Test line") << false; +} + +void tst_QTextDocument::mightBeRichText() +{ + QFETCH(QString, source); + QFETCH(bool, isMaybeRichText); + QBENCHMARK { + QCOMPARE(isMaybeRichText, Qt::mightBeRichText(source)); + } +} + +QTEST_MAIN(tst_QTextDocument) + +#include "main.moc" diff --git a/tests/benchmarks/gui/text/qtextdocument/qtextdocument.pro b/tests/benchmarks/gui/text/qtextdocument/qtextdocument.pro new file mode 100644 index 0000000000..67cef8b25c --- /dev/null +++ b/tests/benchmarks/gui/text/qtextdocument/qtextdocument.pro @@ -0,0 +1,7 @@ +QT += testlib +QT += gui-private + +TEMPLATE = app +TARGET = tst_bench_QTextDocument + +SOURCES += main.cpp diff --git a/tests/benchmarks/gui/text/text.pro b/tests/benchmarks/gui/text/text.pro index 34e548b4d3..6dc4f5d16e 100644 --- a/tests/benchmarks/gui/text/text.pro +++ b/tests/benchmarks/gui/text/text.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ qfontmetrics \ - qtext + qtext \ + qtextdocument diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 73035be14f..dfa658df11 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -668,12 +668,8 @@ void tst_qnetworkreply::uploadPerformance() void tst_qnetworkreply::httpUploadPerformance() { -#if defined(Q_OS_WINCE_WM) - // Show some mercy for non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else enum {UploadSize = 128*1024*1024}; // 128 MB -#endif + ThreadedDataReaderHttpServer reader; FixedSizeDataGenerator generator(UploadSize); @@ -739,12 +735,9 @@ void tst_qnetworkreply::httpDownloadPerformance() { QFETCH(bool, serverSendsContentLength); QFETCH(bool, chunkedEncoding); -#if defined(Q_OS_WINCE_WM) - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else + enum {UploadSize = 128*1024*1024}; // 128 MB -#endif + HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); @@ -823,12 +816,7 @@ void tst_qnetworkreply::httpDownloadPerformanceDownloadBuffer() QFETCH(HttpDownloadPerformanceDownloadBufferTestType, testType); // On my Linux Desktop the results are already visible with 128 kB, however we use this to have good results. -#if defined(Q_OS_WINCE_WM) - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else enum {UploadSize = 32*1024*1024}; // 32 MB -#endif HttpDownloadPerformanceServer server(UploadSize, true, false); diff --git a/tests/benchmarks/network/kernel/kernel.pro b/tests/benchmarks/network/kernel/kernel.pro index 53ec370d60..7b18eefda2 100644 --- a/tests/benchmarks/network/kernel/kernel.pro +++ b/tests/benchmarks/network/kernel/kernel.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -contains(QT_CONFIG,private_tests):SUBDIRS += \ +qtConfig(private_tests): SUBDIRS += \ qhostinfo diff --git a/tests/benchmarks/network/network.pro b/tests/benchmarks/network/network.pro index ec812407f7..01b3b80ef4 100644 --- a/tests/benchmarks/network/network.pro +++ b/tests/benchmarks/network/network.pro @@ -8,7 +8,7 @@ TRUSTED_BENCHMARKS += \ kernel/qhostinfo \ socket/qtcpserver -contains(QT_CONFIG, openssl) { +qtConfig(openssl) { SUBDIRS += ssl TRUSTED_BENCHMARKS += ssl/qsslsocket } diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index 2e4a3b3fcd..3e731bec96 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -166,9 +166,6 @@ void tst_QTcpServer::ipv6LoopbackPerformanceTest() QFETCH_GLOBAL(bool, setProxy); if (setProxy) return; -#if defined(Q_OS_WINCE_WM) - QSKIP("WinCE WM: Not yet supported"); -#endif QTcpServer server; if (!server.listen(QHostAddress::LocalHostIPv6, 0)) { diff --git a/tests/benchmarks/widgets/widgets.pro b/tests/benchmarks/widgets/widgets.pro new file mode 100644 index 0000000000..8fe49ff2c6 --- /dev/null +++ b/tests/benchmarks/widgets/widgets.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + widgets \ diff --git a/tests/auto/other/windowsmobile/test/ddhelper.h b/tests/benchmarks/widgets/widgets/qtextbrowser/main.cpp index ce68654b76..e469ddcb5b 100644 --- a/tests/auto/other/windowsmobile/test/ddhelper.h +++ b/tests/benchmarks/widgets/widgets/qtextbrowser/main.cpp @@ -26,24 +26,31 @@ ** ****************************************************************************/ -#ifndef __DDHELPER__ -#define __DDHELPER__ - -extern uchar* q_frameBuffer(); - -extern int q_screenDepth(); - -extern int q_screenWidth(); - -extern int q_screenHeight(); - -extern int q_linestep(); - -extern void q_initDD(); - -extern void q_unlock(); - -extern void q_lock(); - -#endif //__DDHELPER__ - +#include <QDebug> +#include <QTextBrowser> +#include <qtest.h> + +class tst_QTextBrowser : public QObject +{ + Q_OBJECT +private slots: + void largeDocumentsLazyLayout(); +}; + +void tst_QTextBrowser::largeDocumentsLazyLayout() +{ + QString sl; + for (int i = 0; i < 150000; ++i) { + sl.append("long long text\n"); + } + + QBENCHMARK { + QTextBrowser browser; + browser.setPlainText(sl); + browser.show(); + } +} + +QTEST_MAIN(tst_QTextBrowser) + +#include "main.moc" diff --git a/tests/benchmarks/widgets/widgets/qtextbrowser/qtextbrowser.pro b/tests/benchmarks/widgets/widgets/qtextbrowser/qtextbrowser.pro new file mode 100644 index 0000000000..d4a533b335 --- /dev/null +++ b/tests/benchmarks/widgets/widgets/qtextbrowser/qtextbrowser.pro @@ -0,0 +1,6 @@ +QT += testlib widgets + +TEMPLATE = app +TARGET = tst_bench_QTextBrowser + +SOURCES += main.cpp diff --git a/tests/benchmarks/widgets/widgets/widgets.pro b/tests/benchmarks/widgets/widgets/widgets.pro new file mode 100644 index 0000000000..593413a770 --- /dev/null +++ b/tests/benchmarks/widgets/widgets/widgets.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qtextbrowser \ diff --git a/tests/manual/diaglib/debugproxystyle.cpp b/tests/manual/diaglib/debugproxystyle.cpp index 667ec403b7..d4e62f5dd6 100644 --- a/tests/manual/diaglib/debugproxystyle.cpp +++ b/tests/manual/diaglib/debugproxystyle.cpp @@ -45,13 +45,36 @@ QDebug operator<<(QDebug debug, const QStyleOption *option) { #if QT_VERSION >= 0x050000 QDebugStateSaver saver(debug); +# if QT_VERSION >= 0x050400 + debug.noquote(); +# endif debug.nospace(); #endif - debug << "QStyleOption("; - if (option) - debug << "rec=" << option->rect; - else - debug << '0'; + if (!option) { + debug << "QStyleOption(0)"; + return debug; + } + if (const QStyleOptionViewItem *ivo = qstyleoption_cast<const QStyleOptionViewItem *>(option)) { + debug << "QStyleOptionViewItem("; +#if QT_VERSION >= 0x050000 + debug << ivo->index; + if (const int textSize = ivo->text.size()) + debug << ", \"" << (textSize < 20 ? ivo->text : ivo->text.left(20) + QLatin1String("...")) << '"'; + debug << ", "; +#else // Qt 5 + Q_UNUSED(ivo) +#endif + } else { + debug << "QStyleOption("; + } + debug << "rect=" << option->rect.width() << 'x' << option->rect.height() + << forcesign << option->rect.x() << option->rect.y() << noforcesign; + if (option->state != QStyle::State_None) + debug << ", state=" << option->state; +#if QT_VERSION >= 0x050000 + if (option->styleObject && !option->styleObject->isWidgetType()) + debug << ", styleObject=" << option->styleObject; +#endif debug << ')'; return debug; } @@ -132,6 +155,15 @@ QRect DebugProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap & return result; } +int DebugProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, + QStyleHintReturn *returnData) const +{ + const int result = QProxyStyle::styleHint(hint, option, widget, returnData); + qDebug() << __FUNCTION__ << hint << option << widget << "returnData=" + << returnData << "returns" << result; + return result; +} + int DebugProxyStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { const int result = QProxyStyle::pixelMetric(metric, option, widget); diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h index 74407e7f3e..01e1e6b6d1 100644 --- a/tests/manual/diaglib/debugproxystyle.h +++ b/tests/manual/diaglib/debugproxystyle.h @@ -48,6 +48,7 @@ public: QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const; QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index 19c9ca30e9..4adb1da5f1 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -113,8 +113,6 @@ void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags) debugFlag(str, flags, Qt::WindowStaysOnBottomHint) debugFlag(str, flags, Qt::MacWindowToolBarButtonHint) debugFlag(str, flags, Qt::BypassGraphicsProxyWidget) - debugFlag(str, flags, Qt::WindowOkButtonHint) - debugFlag(str, flags, Qt::WindowCancelButtonHint) } #if QT_VERSION > 0x050000 diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index f8287f7d19..2fe96c2f93 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -53,18 +53,14 @@ dialogs \ windowtransparency \ unc -!contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions +!qtConfig(openssl):!qtConfig(openssl-linked): SUBDIRS -= qssloptions -contains(QT_CONFIG, opengl) { +qtConfig(opengl) { SUBDIRS += qopengltextureblitter - contains(QT_CONFIG, egl): SUBDIRS += qopenglcontext + qtConfig(egl): SUBDIRS += qopenglcontext } -win32 { - SUBDIRS -= network_remote_stresstest network_stresstest - # disable some tests on wince because of missing dependencies - wince: SUBDIRS -= lance windowmodality -} +win32: SUBDIRS -= network_remote_stresstest network_stresstest lessThan(QT_MAJOR_VERSION, 5): SUBDIRS -= bearerex lance qnetworkaccessmanager/qget qmimedatabase qnetworkreply \ qpainfo qscreen socketengine xembed-raster xembed-widgets windowtransparency \ diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.h b/tests/manual/qopenglcontext/qopenglcontextwindow.h index f436d1af0e..37ff1b2082 100644 --- a/tests/manual/qopenglcontext/qopenglcontextwindow.h +++ b/tests/manual/qopenglcontext/qopenglcontextwindow.h @@ -31,9 +31,9 @@ #include <QtGui/QWindow> #include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLTextureBlitter> #include <QtGui/QImage> #include <QtCore/QVariant> -#include <QtGui/private/qopengltextureblitter_p.h> class QOpenGLContextWindow : public QWindow { diff --git a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp index 63ac1e4e66..f4e093a967 100644 --- a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp +++ b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp @@ -123,9 +123,9 @@ void QOpenGLTextureBlitWindow::render() m_blitter.blit(texture.textureId(), topRightOriginTopLeftVertex, topLeftOrigin); m_blitter.blit(texture_mirrored.textureId(), bottomLeftOriginTopLeftVertex, topLeftOrigin); - m_blitter.setSwizzleRB(true); + m_blitter.setRedBlueSwizzle(true); m_blitter.blit(texture.textureId(), bottomRightOriginTopLeftVertex, texTopLeftOriginTopLeft); - m_blitter.setSwizzleRB(false); + m_blitter.setRedBlueSwizzle(false); m_blitter.release(); if (m_blitter.supportsExternalOESTarget()) { diff --git a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h index 957d833ef3..0912f096e4 100644 --- a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h +++ b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h @@ -31,7 +31,7 @@ #include <QtGui/QWindow> #include <QtGui/QOpenGLContext> -#include <QtGui/private/qopengltextureblitter_p.h> +#include <QtGui/QOpenGLTextureBlitter> class QOpenGLTextureBlitWindow : public QWindow { diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp index 13458d27e5..5add1e4f74 100644 --- a/tests/manual/qsysinfo/main.cpp +++ b/tests/manual/qsysinfo/main.cpp @@ -57,13 +57,6 @@ QByteArray windowsVersionToString(QSysInfo::WinVersion v) CASE_VERSION(WV_WINDOWS10); case QSysInfo::WV_NT_based: // shouldn't happen break; - - CASE_VERSION(WV_CE); - CASE_VERSION(WV_CENET); - CASE_VERSION(WV_CE_5); - CASE_VERSION(WV_CE_6); - case QSysInfo::WV_CE_based: // shouldn't happen - break; } return "WinVersion(0x" + QByteArray::number(v, 16) + ')'; @@ -87,6 +80,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v) CASE_VERSION(MV_10_8); CASE_VERSION(MV_10_9); CASE_VERSION(MV_10_10); + CASE_VERSION(MV_10_11); CASE_VERSION(MV_IOS_4_3); CASE_VERSION(MV_IOS_5_0); @@ -96,6 +90,11 @@ QByteArray macVersionToString(QSysInfo::MacVersion v) CASE_VERSION(MV_IOS_7_0); CASE_VERSION(MV_IOS_7_1); CASE_VERSION(MV_IOS_8_0); + CASE_VERSION(MV_IOS_8_1); + CASE_VERSION(MV_IOS_8_2); + CASE_VERSION(MV_IOS_8_3); + CASE_VERSION(MV_IOS_8_4); + CASE_VERSION(MV_IOS_9_0); case QSysInfo::MV_IOS: // shouldn't happen: break; } diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index 82c807b3e3..73d7d6523c 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -36,7 +36,7 @@ #include <QDir> #include <QFile> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) #include <windows.h> #include <winioctl.h> #ifndef IO_REPARSE_TAG_MOUNT_POINT diff --git a/tests/tests.pro b/tests/tests.pro index 79bee02b65..346102ab7b 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -4,4 +4,4 @@ SUBDIRS = auto # benchmarks in debug mode is rarely sensible # benchmarks are not sensible for code coverage (here with tool testcocoon) -!ios:!testcocoon:contains(QT_CONFIG,release):SUBDIRS += benchmarks +!uikit:!testcocoon:contains(QT_CONFIG, release): SUBDIRS += benchmarks |