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