diff options
Diffstat (limited to 'tests')
22 files changed, 282 insertions, 120 deletions
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 3c93fd5e1f..eee2c0e30d 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -65,6 +65,9 @@ win32:!qtConfig(private_tests): SUBDIRS -= \ qprocess \ qprocess-noapplication +!qtConfig(settings): SUBDIRS -= \ + qsettings + winrt: SUBDIRS -= \ qstorageinfo diff --git a/tests/auto/corelib/io/qresourceengine/.gitattributes b/tests/auto/corelib/io/qresourceengine/.gitattributes index add3716d81..88edd3681a 100644 --- a/tests/auto/corelib/io/qresourceengine/.gitattributes +++ b/tests/auto/corelib/io/qresourceengine/.gitattributes @@ -1 +1,2 @@ testqrc/test.qrc -crlf +*.txt -crlf diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt index 21a3dfa0b8..dcf7937f0a 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/aliasdir/aliasdir.txt @@ -1 +1 @@ -"This is a korean text file" +"This is a korean text file" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt index 436c4d11c3..19f0805d8d 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/blahblah.txt @@ -1 +1 @@ -qwerty +qwerty diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt index 38e389979a..65f1f43def 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir.txt @@ -1 +1 @@ -"This is the current dir" +"This is the current dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt index 6ac16a3306..7d89108011 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/currentdir2.txt @@ -1 +1 @@ -"This is also the current dir" +"This is also the current dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt index b0e4a124ee..e1b430f33b 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/otherdir/otherdir.txt @@ -1 +1 @@ -"This is the other dir" +"This is the other dir" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt index b6115207a2..4506acf413 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/subdir/subdir.txt @@ -1 +1 @@ -"This is in the sub directory" +"This is in the sub directory" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt index adc01d1354..8baef1b4ab 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test1.txt @@ -1 +1 @@ -abc +abc diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt index 3f48e3cdc3..24c5735c3e 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/test/test2.txt @@ -1 +1 @@ -def +def diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt index 40ee68dccb..b8cb3a8c01 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir.txt @@ -1 +1 @@ -"This is in the test directory" +"This is in the test directory" diff --git a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt index 051430298a..dccfdc9bcf 100644 --- a/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt +++ b/tests/auto/corelib/io/qresourceengine/testqrc/test/testdir2.txt @@ -1 +1 @@ -"This is another file in this directory" +"This is another file in this directory" diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index ab49dea6d8..0b50c391b8 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -104,7 +105,7 @@ void tst_QResourceEngine::cleanupTestCase() void tst_QResourceEngine::checkStructure_data() { QTest::addColumn<QString>("pathName"); - QTest::addColumn<QString>("contents"); + QTest::addColumn<QByteArray>("contents"); QTest::addColumn<QStringList>("containedFiles"); QTest::addColumn<QStringList>("containedDirs"); QTest::addColumn<QLocale>("locale"); @@ -134,7 +135,7 @@ void tst_QResourceEngine::checkStructure_data() QTest::newRow("root dir") << QString(":/") - << QString() + << QByteArray() << (QStringList() #if defined(BUILTIN_TESTDATA) << "parentdir.txt" @@ -146,7 +147,7 @@ void tst_QResourceEngine::checkStructure_data() << qlonglong(0); QTest::newRow("secondary root") << QString(":/secondary_root/") - << QString() + << QByteArray() << QStringList() << (QStringList() << QLatin1String("runtime_resource")) << QLocale::c() @@ -157,73 +158,73 @@ void tst_QResourceEngine::checkStructure_data() for(int i = 0; i < roots.size(); ++i) { const QString root = roots.at(i); - QTest::newRow(QString(root + "prefix dir").toLatin1().constData()) << QString(root + "test/abc/123/+++") - << QString() + QTest::addRow("%s prefix dir", qPrintable(root)) << QString(root + "test/abc/123/+++") + << QByteArray() << (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt")) << (QStringList() << QLatin1String("subdir")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "parent to prefix").toLatin1().constData()) << QString(root + "test/abc/123") - << QString() + QTest::addRow("%s parent to prefix", qPrintable(root)) << QString(root + "test/abc/123") + << QByteArray() << QStringList() << (QStringList() << QLatin1String("+++")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc") - << QString() + QTest::addRow("%s two parents prefix", qPrintable(root)) << QString(root + "test/abc") + << QByteArray() << QStringList() << QStringList(QLatin1String("123")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "test dir ").toLatin1().constData()) << QString(root + "test") - << QString() + QTest::addRow("%s test dir ", qPrintable(root)) << QString(root + "test") + << QByteArray() << (QStringList() << QLatin1String("testdir.txt")) << (QStringList() << QLatin1String("abc") << QLatin1String("test")) << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes") - << QString() + QTest::addRow("%s prefix no slashes", qPrintable(root)) << QString(root + "withoutslashes") + << QByteArray() << QStringList("blahblah.txt") << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "other dir").toLatin1().constData()) << QString(root + "otherdir") - << QString() + QTest::addRow("%s other dir", qPrintable(root)) << QString(root + "otherdir") + << QByteArray() << QStringList(QLatin1String("otherdir.txt")) << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "alias dir").toLatin1().constData()) << QString(root + "aliasdir") - << QString() + QTest::addRow("%s alias dir", qPrintable(root)) << QString(root + "aliasdir") + << QByteArray() << QStringList(QLatin1String("aliasdir.txt")) << QStringList() << QLocale::c() << qlonglong(0); - QTest::newRow(QString(root + "second test dir").toLatin1().constData()) << QString(root + "test/test") - << QString() + QTest::addRow("%s second test dir", qPrintable(root)) << QString(root + "test/test") + << QByteArray() << (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt")) << QStringList() << QLocale::c() << qlonglong(0); info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test1.txt")); - QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt") - << QString("abc") + QTest::addRow("%s test1 text", qPrintable(root)) << QString(root + "test/test/test1.txt") + << QByteArray("abc\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/blahblah.txt")); - QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt") - << QString("qwerty") + QTest::addRow("%s text no slashes", qPrintable(root)) << QString(root + "withoutslashes/blahblah.txt") + << QByteArray("qwerty\n") << QStringList() << QStringList() << QLocale::c() @@ -231,96 +232,96 @@ void tst_QResourceEngine::checkStructure_data() info = QFileInfo(QFINDTESTDATA("testqrc/test/test/test2.txt")); - QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt") - << QString("def") + QTest::addRow("%s test1 text", qPrintable(root)) << QString(root + "test/test/test2.txt") + << QByteArray("def\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/currentdir.txt")); - QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt") - << QString("\"This is the current dir\" ") + QTest::addRow("%s currentdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/currentdir.txt") + << QByteArray("\"This is the current dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/currentdir2.txt")); - QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt") - << QString("\"This is also the current dir\" ") + QTest::addRow("%s currentdir text2", qPrintable(root)) << QString(root + "test/abc/123/+++/currentdir2.txt") + << QByteArray("\"This is also the current dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("parentdir.txt")); - QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt") - << QString("abcdefgihklmnopqrstuvwxyz ") + QTest::addRow("%s parentdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/parentdir.txt") + << QByteArray("abcdefgihklmnopqrstuvwxyz \n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/subdir/subdir.txt")); - QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt") - << QString("\"This is in the sub directory\" ") + QTest::addRow("%s subdir text", qPrintable(root)) << QString(root + "test/abc/123/+++/subdir/subdir.txt") + << QByteArray("\"This is in the sub directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir.txt")); - QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt") - << QString("\"This is in the test directory\" ") + QTest::addRow("%s testdir text", qPrintable(root)) << QString(root + "test/testdir.txt") + << QByteArray("\"This is in the test directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/otherdir/otherdir.txt")); - QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt") - << QString("\"This is the other dir\" ") + QTest::addRow("%s otherdir text", qPrintable(root)) << QString(root + "otherdir/otherdir.txt") + << QByteArray("\"This is the other dir\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/testdir2.txt")); - QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is another file in this directory\" ") + QTest::addRow("%s alias text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is another file in this directory\"\n") << QStringList() << QStringList() << QLocale::c() << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); - QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is a korean text file\" ") + QTest::addRow("%s korean text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is a korean text file\"\n") << QStringList() << QStringList() << QLocale("ko") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/aliasdir.txt")); - QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("\"This is a korean text file\" ") + QTest::addRow("%s korean text 2", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("\"This is a korean text file\"\n") << QStringList() << QStringList() << QLocale("ko_KR") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); - QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("Deutsch") + QTest::addRow("%s german text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("Deutsch\n") << QStringList() << QStringList() << QLocale("de") << qlonglong(info.size()); info = QFileInfo(QFINDTESTDATA("testqrc/test/german.txt")); - QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString("Deutsch") + QTest::addRow("%s german text 2", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << QByteArray("Deutsch\n") << QStringList() << QStringList() << QLocale("de_DE") @@ -329,8 +330,8 @@ void tst_QResourceEngine::checkStructure_data() QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); file.open(QFile::ReadOnly); info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt")); - QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") - << QString(file.readAll()) + QTest::addRow("%s compressed text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt") + << file.readAll() << QStringList() << QStringList() << QLocale("de_CH") @@ -341,7 +342,7 @@ void tst_QResourceEngine::checkStructure_data() void tst_QResourceEngine::checkStructure() { QFETCH(QString, pathName); - QFETCH(QString, contents); + QFETCH(QByteArray, contents); QFETCH(QStringList, containedFiles); QFETCH(QStringList, containedDirs); QFETCH(QLocale, locale); @@ -401,8 +402,18 @@ void tst_QResourceEngine::checkStructure() QFile file(pathName); QVERIFY(file.open(QFile::ReadOnly)); - QByteArray ba = file.readAll(); - QVERIFY(QString(ba).startsWith(contents)); + // check contents + QCOMPARE(file.readAll(), contents); + + // check memory map too + uchar *ptr = file.map(0, file.size(), QFile::MapPrivateOption); + QVERIFY2(ptr, qPrintable(file.errorString())); + QByteArray ba = QByteArray::fromRawData(reinterpret_cast<const char *>(ptr), file.size()); + QCOMPARE(ba, contents); + + // check that it is still valid after closing the file + file.close(); + QCOMPARE(ba, contents); } QLocale::setDefault(QLocale::system()); } diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST index b1590a5ccf..06588188d4 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST +++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST @@ -3,3 +3,4 @@ windows [registerTimer] windows winrt +osx diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index 5784f0728c..49c10c6a24 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -28,6 +28,7 @@ #ifdef QT_GUI_LIB # include <QtGui/QGuiApplication> +# define tst_QEventDispatcher tst_QGuiEventDispatcher #else # include <QtCore/QCoreApplication> #endif @@ -92,77 +93,151 @@ void tst_QEventDispatcher::initTestCase() } } +class TimerManager { + Q_DISABLE_COPY(TimerManager) + +public: + TimerManager(QAbstractEventDispatcher *eventDispatcher, QObject *parent) + : m_eventDispatcher(eventDispatcher), m_parent(parent) + { + } + + ~TimerManager() + { + if (!registeredTimers().isEmpty()) + m_eventDispatcher->unregisterTimers(m_parent); + } + + TimerManager(TimerManager &&) = delete; + TimerManager &operator=(TimerManager &&) = delete; + + int preciseTimerId() const { return m_preciseTimerId; } + int coarseTimerId() const { return m_coarseTimerId; } + int veryCoarseTimerId() const { return m_veryCoarseTimerId; } + + bool foundPrecise() const { return m_preciseTimerId > 0; } + bool foundCoarse() const { return m_coarseTimerId > 0; } + bool foundVeryCoarse() const { return m_veryCoarseTimerId > 0; } + + QList<QAbstractEventDispatcher::TimerInfo> registeredTimers() const + { + return m_eventDispatcher->registeredTimers(m_parent); + } + + void registerAll() + { + // start 3 timers, each with the different timer types and different intervals + m_preciseTimerId = m_eventDispatcher->registerTimer( + PreciseTimerInterval, Qt::PreciseTimer, m_parent); + m_coarseTimerId = m_eventDispatcher->registerTimer( + CoarseTimerInterval, Qt::CoarseTimer, m_parent); + m_veryCoarseTimerId = m_eventDispatcher->registerTimer( + VeryCoarseTimerInterval, Qt::VeryCoarseTimer, m_parent); + QVERIFY(m_preciseTimerId > 0); + QVERIFY(m_coarseTimerId > 0); + QVERIFY(m_veryCoarseTimerId > 0); + findTimers(); + } + + void unregister(int timerId) + { + m_eventDispatcher->unregisterTimer(timerId); + findTimers(); + } + + void unregisterAll() + { + m_eventDispatcher->unregisterTimers(m_parent); + findTimers(); + } + +private: + void findTimers() + { + bool foundPrecise = false; + bool foundCoarse = false; + bool foundVeryCoarse = false; + const QList<QAbstractEventDispatcher::TimerInfo> timers = registeredTimers(); + for (int i = 0; i < timers.count(); ++i) { + const QAbstractEventDispatcher::TimerInfo &timerInfo = timers.at(i); + if (timerInfo.timerId == m_preciseTimerId) { + QCOMPARE(timerInfo.interval, int(PreciseTimerInterval)); + QCOMPARE(timerInfo.timerType, Qt::PreciseTimer); + foundPrecise = true; + } else if (timerInfo.timerId == m_coarseTimerId) { + QCOMPARE(timerInfo.interval, int(CoarseTimerInterval)); + QCOMPARE(timerInfo.timerType, Qt::CoarseTimer); + foundCoarse = true; + } else if (timerInfo.timerId == m_veryCoarseTimerId) { + QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval)); + QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer); + foundVeryCoarse = true; + } + } + if (!foundPrecise) + m_preciseTimerId = -1; + if (!foundCoarse) + m_coarseTimerId = -1; + if (!foundVeryCoarse) + m_veryCoarseTimerId = -1; + } + + QAbstractEventDispatcher *m_eventDispatcher = nullptr; + + int m_preciseTimerId = -1; + int m_coarseTimerId = -1; + int m_veryCoarseTimerId = -1; + + QObject *m_parent = nullptr; +}; + // test that the eventDispatcher's timer implementation is complete and working void tst_QEventDispatcher::registerTimer() { -#define FIND_TIMERS() \ - do { \ - foundPrecise = false; \ - foundCoarse = false; \ - foundVeryCoarse = false; \ - for (int i = 0; i < registeredTimers.count(); ++i) { \ - const QAbstractEventDispatcher::TimerInfo &timerInfo = registeredTimers.at(i); \ - if (timerInfo.timerId == preciseTimerId) { \ - QCOMPARE(timerInfo.interval, int(PreciseTimerInterval)); \ - QCOMPARE(timerInfo.timerType, Qt::PreciseTimer); \ - foundPrecise = true; \ - } else if (timerInfo.timerId == coarseTimerId) { \ - QCOMPARE(timerInfo.interval, int(CoarseTimerInterval)); \ - QCOMPARE(timerInfo.timerType, Qt::CoarseTimer); \ - foundCoarse = true; \ - } else if (timerInfo.timerId == veryCoarseTimerId) { \ - QCOMPARE(timerInfo.interval, int(VeryCoarseTimerInterval)); \ - QCOMPARE(timerInfo.timerType, Qt::VeryCoarseTimer); \ - foundVeryCoarse = true; \ - } \ - } \ - } while (0) - - // start 3 timers, each with the different timer types and different intervals - int preciseTimerId = eventDispatcher->registerTimer(PreciseTimerInterval, Qt::PreciseTimer, this); - int coarseTimerId = eventDispatcher->registerTimer(CoarseTimerInterval, Qt::CoarseTimer, this); - int veryCoarseTimerId = eventDispatcher->registerTimer(VeryCoarseTimerInterval, Qt::VeryCoarseTimer, this); - QVERIFY(preciseTimerId > 0); - QVERIFY(coarseTimerId > 0); - QVERIFY(veryCoarseTimerId > 0); + TimerManager timers(eventDispatcher, this); + timers.registerAll(); + if (QTest::currentTestFailed()) + return; // check that all 3 are present in the eventDispatcher's registeredTimer() list - QList<QAbstractEventDispatcher::TimerInfo> registeredTimers = eventDispatcher->registeredTimers(this); - QCOMPARE(registeredTimers.count(), 3); - bool foundPrecise, foundCoarse, foundVeryCoarse; - FIND_TIMERS(); - QVERIFY(foundPrecise && foundCoarse && foundVeryCoarse); + QCOMPARE(timers.registeredTimers().count(), 3); + QVERIFY(timers.foundPrecise()); + QVERIFY(timers.foundCoarse()); + QVERIFY(timers.foundVeryCoarse()); // process events, waiting for the next event... this should only fire the precise timer receivedEventType = -1; timerIdFromEvent = -1; QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2); - QCOMPARE(timerIdFromEvent, preciseTimerId); + QCOMPARE(timerIdFromEvent, timers.preciseTimerId()); // now unregister it and make sure it's gone - eventDispatcher->unregisterTimer(preciseTimerId); - registeredTimers = eventDispatcher->registeredTimers(this); - QCOMPARE(registeredTimers.count(), 2); - FIND_TIMERS(); - QVERIFY(!foundPrecise && foundCoarse && foundVeryCoarse); + timers.unregister(timers.preciseTimerId()); + if (QTest::currentTestFailed()) + return; + QCOMPARE(timers.registeredTimers().count(), 2); + QVERIFY(!timers.foundPrecise()); + QVERIFY(timers.foundCoarse()); + QVERIFY(timers.foundVeryCoarse()); // do the same again for the coarse timer receivedEventType = -1; timerIdFromEvent = -1; QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2); - QCOMPARE(timerIdFromEvent, coarseTimerId); + QCOMPARE(timerIdFromEvent, timers.coarseTimerId()); // now unregister it and make sure it's gone - eventDispatcher->unregisterTimer(coarseTimerId); - registeredTimers = eventDispatcher->registeredTimers(this); - QCOMPARE(registeredTimers.count(), 1); - FIND_TIMERS(); - QVERIFY(!foundPrecise && !foundCoarse && foundVeryCoarse); + timers.unregister(timers.coarseTimerId()); + if (QTest::currentTestFailed()) + return; + QCOMPARE(timers.registeredTimers().count(), 1); + QVERIFY(!timers.foundPrecise()); + QVERIFY(!timers.foundCoarse()); + QVERIFY(timers.foundVeryCoarse()); // not going to wait for the VeryCoarseTimer, would take too long, just unregister it - eventDispatcher->unregisterTimers(this); - registeredTimers = eventDispatcher->registeredTimers(this); - QVERIFY(registeredTimers.isEmpty()); - -#undef FIND_TIMERS + timers.unregisterAll(); + if (QTest::currentTestFailed()) + return; + QVERIFY(timers.registeredTimers().isEmpty()); } void tst_QEventDispatcher::sendPostedEvents_data() diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 18098f16bf..c23ee3b0ba 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -2135,11 +2135,12 @@ void tst_QRegularExpression::threadSafety() QFETCH(QString, pattern); QFETCH(QString, subject); + QElapsedTimer time; + time.start(); static const int THREAD_SAFETY_ITERATIONS = 50; - const int threadCount = qMax(QThread::idealThreadCount(), 4); - for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS; ++threadSafetyIteration) { + for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS && time.elapsed() < 2000; ++threadSafetyIteration) { QRegularExpression re(pattern); QVector<MatcherThread *> threads; diff --git a/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST new file mode 100644 index 0000000000..b1590a5ccf --- /dev/null +++ b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST @@ -0,0 +1,5 @@ +[sendPostedEvents] +windows +[registerTimer] +windows +winrt diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index ece7a30830..72bad03a6a 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -318,6 +318,9 @@ void tst_QColor::namehex_data() QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan); QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta); QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow); + QTest::newRow("#RGB") << "#888" << QColor(0x88, 0x88, 0x88); + QTest::newRow("#RRRGGGBBB") << "#80F80F80F" << QColor(qRgba64(0x80f8, 0x80f8, 0x80f8, 0xffff)); + QTest::newRow("#RRRRGGGGBBBB") << "#808180818081" << QColor(qRgba64(0x8081, 0x8081, 0x8081, 0xffff)); QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102); QTest::newRow("invalid red") << "#gg0000" << QColor(); QTest::newRow("invalid transparent") << "#gg00ff00" << QColor(); diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index fab8224431..4d29a830e9 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -8,6 +8,9 @@ windows * [getErrors:ftp-host] linux +# QTBUG-71953 +[getFromHttp:success-external] +* [getFromHttpIntoBuffer] windows [getFromHttpIntoBuffer2] diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 395b30846d..3e55278b4f 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1025,6 +1025,26 @@ void tst_QSslSocket::protocol() socket->abort(); } #endif +#ifdef TLS1_3_VERSION + { + // qt-test-server probably doesn't allow TLSV1.3 + socket->setProtocol(QSsl::TlsV1_3); + QCOMPARE(socket->protocol(), QSsl::TlsV1_3); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + if (setProxy && !socket->waitForEncrypted()) + QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941"); + QCOMPARE(socket->protocol(), QSsl::TlsV1_3); + socket->abort(); + QCOMPARE(socket->protocol(), QSsl::TlsV1_3); + socket->connectToHost(QtNetworkSettings::serverName(), 443); + QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); + socket->startClientEncryption(); + if (setProxy && !socket->waitForEncrypted()) + QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941"); + QCOMPARE(socket->sessionProtocol(), QSsl::TlsV1_3); + socket->abort(); + } +#endif // TLS1_3_VERSION #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) { // qt-test-server allows SSLV2. @@ -1279,7 +1299,9 @@ void tst_QSslSocket::protocolServerSide_data() QTest::newRow("tls1.0orlater-tls1.0") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_0 << true; QTest::newRow("tls1.0orlater-tls1.1") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_1 << true; QTest::newRow("tls1.0orlater-tls1.2") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_2 << true; - +#ifdef TLS1_3_VERSION + QTest::newRow("tls1.0orlater-tls1.3") << QSsl::TlsV1_0OrLater << QSsl::TlsV1_3 << true; +#endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("tls1.1orlater-ssl2") << QSsl::TlsV1_1OrLater << QSsl::SslV2 << false; #endif @@ -1290,7 +1312,9 @@ void tst_QSslSocket::protocolServerSide_data() QTest::newRow("tls1.1orlater-tls1.0") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_0 << false; QTest::newRow("tls1.1orlater-tls1.1") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_1 << true; QTest::newRow("tls1.1orlater-tls1.2") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_2 << true; - +#ifdef TLS1_3_VERSION + QTest::newRow("tls1.1orlater-tls1.3") << QSsl::TlsV1_1OrLater << QSsl::TlsV1_3 << true; +#endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("tls1.2orlater-ssl2") << QSsl::TlsV1_2OrLater << QSsl::SslV2 << false; #endif @@ -1300,6 +1324,21 @@ void tst_QSslSocket::protocolServerSide_data() QTest::newRow("tls1.2orlater-tls1.0") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_0 << false; QTest::newRow("tls1.2orlater-tls1.1") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_1 << false; QTest::newRow("tls1.2orlater-tls1.2") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_2 << true; +#ifdef TLS1_3_VERSION + QTest::newRow("tls1.2orlater-tls1.3") << QSsl::TlsV1_2OrLater << QSsl::TlsV1_3 << true; +#endif +#ifdef TLS1_3_VERSION +#if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) + QTest::newRow("tls1.3orlater-ssl2") << QSsl::TlsV1_3OrLater << QSsl::SslV2 << false; +#endif +#if !defined(OPENSSL_NO_SSL3) + QTest::newRow("tls1.3orlater-ssl3") << QSsl::TlsV1_3OrLater << QSsl::SslV3 << false; +#endif + QTest::newRow("tls1.3orlater-tls1.0") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_0 << false; + QTest::newRow("tls1.3orlater-tls1.1") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_1 << false; + QTest::newRow("tls1.3orlater-tls1.2") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_2 << false; + QTest::newRow("tls1.3orlater-tls1.3") << QSsl::TlsV1_3OrLater << QSsl::TlsV1_3 << true; +#endif // TLS1_3_VERSION QTest::newRow("any-tls1.0") << QSsl::AnyProtocol << QSsl::TlsV1_0 << true; QTest::newRow("any-tls1ssl3") << QSsl::AnyProtocol << QSsl::TlsV1SslV3 << true; @@ -3511,7 +3550,12 @@ protected: socket = new QSslSocket(this); socket->setSslConfiguration(config); socket->setPeerVerifyMode(peerVerifyMode); - socket->setProtocol(protocol); + if (QSslSocket::sslLibraryVersionNumber() > 0x10101000L) { + // FIXME. With OpenSSL 1.1.1 and TLS 1.3 PSK auto-test is broken. + socket->setProtocol(QSsl::TlsV1_2); + } else { + socket->setProtocol(protocol); + } if (ignoreSslErrors) connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); @@ -3891,6 +3935,11 @@ void tst_QSslSocket::pskServer() return; QSslSocket socket; +#ifdef TLS1_3_VERSION + // FIXME: with OpenSSL 1.1.1 (thus TLS 1.3) test is known to fail + // due to the different PSK mechanism (?) - to be investigated ASAP. + socket.setProtocol(QSsl::TlsV1_2); +#endif this->socket = &socket; QSignalSpy connectedSpy(&socket, SIGNAL(connected())); @@ -3976,6 +4025,11 @@ void tst_QSslSocket::signatureAlgorithm_data() if (QSslSocket::sslLibraryVersionNumber() < 0x10002000L) QSKIP("Signature algorithms cannot be tested with OpenSSL < 1.0.2"); + if (QSslSocket::sslLibraryVersionNumber() >= 0x10101000L) { + // FIXME: investigate if this test makes any sense with TLS 1.3. + QSKIP("Test is not valid for TLS 1.3/OpenSSL 1.1.1"); + } + QTest::addColumn<QByteArrayList>("serverSigAlgPairs"); QTest::addColumn<QSsl::SslProtocol>("serverProtocol"); QTest::addColumn<QByteArrayList>("clientSigAlgPairs"); diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index 09bea20d26..b7b5b505a0 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -355,6 +355,11 @@ void tst_QGLThreads::renderInThread() QFETCH(bool, resize); QFETCH(bool, update); +#if defined(Q_OS_MACOS) + if (resize) + QSKIP("gldSetZero crashes in render thread, QTBUG-68524"); +#endif + ThreadSafeGLWidget widget; widget.resize(200, 200); SceneRenderingThread thread(&widget); diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index fc4adebcc0..2676ceeb52 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -94,7 +94,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); QAction *action = editMenu->addAction(tr("Cut")); - action->setShortcut(QKeySequence(QKeySequence::Quit)); + action->setShortcut(QKeySequence(QKeySequence::Cut)); action = editMenu->addAction(tr("Copy")); action->setShortcut(QKeySequence(QKeySequence::Copy)); action = editMenu->addAction(tr("Paste")); |