diff options
Diffstat (limited to 'tests/auto/corelib')
13 files changed, 367 insertions, 79 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index 25b6216075..290c2abc98 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -40,6 +40,16 @@ #ifdef BAD_TIMER_RESOLUTION static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; + +# define WAIT_FOR_STOPPED(animation, duration) \ + QTest::qWait(duration); \ + if (animation.state() != QAbstractAnimation::Stopped) \ + QEXPECT_FAIL("", timerError, Abort); \ + QCOMPARE(animation.state(), QAbstractAnimation::Stopped) +#else +// Use QTRY_COMPARE with one additional timer tick +# define WAIT_FOR_STOPPED(animation, duration) \ + QTRY_COMPARE_WITH_TIMEOUT(animation.state(), QAbstractAnimation::Stopped, (duration)) #endif class TestablePauseAnimation : public QPauseAnimation @@ -108,11 +118,10 @@ void tst_QPauseAnimation::changeDirectionWhileRunning() TestablePauseAnimation animation; animation.setDuration(400); animation.start(); - QTest::qWait(100); - QCOMPARE(animation.state(), QAbstractAnimation::Running); + QTRY_COMPARE(animation.state(), QAbstractAnimation::Running); animation.setDirection(QAbstractAnimation::Backward); - QTest::qWait(animation.totalDuration() + 50); - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 100; + WAIT_FOR_STOPPED(animation, expectedDuration); } void tst_QPauseAnimation::noTimerUpdates_data() @@ -137,14 +146,9 @@ void tst_QPauseAnimation::noTimerUpdates() animation.setDuration(duration); animation.setLoopCount(loopCount); animation.start(); - QTest::qWait(animation.totalDuration() + 100); - -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; #ifdef BAD_TIMER_RESOLUTION @@ -166,13 +170,9 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation.start(); animation2.start(); - QTest::qWait(animation.totalDuration() + 100); -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); #ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) @@ -192,13 +192,7 @@ void tst_QPauseAnimation::multiplePauseAnimations() #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); - QTest::qWait(550); - -#ifdef BAD_TIMER_RESOLUTION - if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation2.state(), QAbstractAnimation::Stopped); + WAIT_FOR_STOPPED(animation2, 600); #ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) @@ -229,13 +223,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QCOMPARE(pause.state(), QAbstractAnimation::Running); QCOMPARE(pause.m_updateCurrentTimeCount, 2); - QTest::qWait(animation.totalDuration() + 100); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); QCOMPARE(pause.state(), QAbstractAnimation::Stopped); QVERIFY(pause.m_updateCurrentTimeCount > 3); } @@ -405,13 +395,8 @@ void tst_QPauseAnimation::multipleSequentialGroups() // This is a pretty long animation so it tends to get rather out of sync // when using the consistent timer, so run for an extra half second for good // measure... - QTest::qWait(group.totalDuration() + 500); - -#ifdef BAD_TIMER_RESOLUTION - if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(group.state(), QAbstractAnimation::Stopped); + const int expectedDuration = group.totalDuration() + 550; + WAIT_FOR_STOPPED(group, expectedDuration); #ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) @@ -449,8 +434,9 @@ void tst_QPauseAnimation::zeroDuration() TestablePauseAnimation animation; animation.setDuration(0); animation.start(); - QTest::qWait(animation.totalDuration() + 100); - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); + QCOMPARE(animation.m_updateCurrentTimeCount, 1); } diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index 5666726a8c..8f78aa937c 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -237,39 +237,6 @@ void tst_Utf8::nonCharacters_data() QTest::addColumn<QByteArray>("utf8"); QTest::addColumn<QString>("utf16"); - // Unicode has a couple of "non-characters" that one can use internally - // These characters may be used for interchange; - // see: http://www.unicode.org/versions/corrigendum9.html - // - // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF, - // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and - // U+FDEF (inclusive) - - // U+FDD0 through U+FDEF - for (int i = 0; i < 32; ++i) { - char utf8[] = { char(0357), char(0267), char(0220 + i), 0 }; - QString utf16 = QChar(0xfdd0 + i); - QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16; - } - - // the last two in Planes 1 through 16 - for (uint plane = 1; plane <= 16; ++plane) { - for (uint lower = 0xfffe; lower < 0x10000; ++lower) { - uint ucs4 = (plane << 16) | lower; - char utf8[] = { char(0xf0 | uchar(ucs4 >> 18)), - char(0x80 | (uchar(ucs4 >> 12) & 0x3f)), - char(0x80 | (uchar(ucs4 >> 6) & 0x3f)), - char(0x80 | (uchar(ucs4) & 0x3f)), - 0 }; - ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 }; - - QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16); - } - } - - QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe)); - QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff)); - extern void loadNonCharactersRows(); loadNonCharactersRows(); } diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index e946f3104a..564b8547b1 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -68,6 +68,8 @@ private slots: void itemData(); + void persistIndexOnLayoutChange(); + protected: void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex()); @@ -377,5 +379,79 @@ void tst_QIdentityProxyModel::itemData() QCOMPARE(proxy.itemData(topIndex).value(Qt::DisplayRole).toString(), QStringLiteral("Monday_appended")); } +void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex const& parent = {}) +{ + for (auto row = 0; row < model->rowCount(parent); ++row) + { + auto idx = model->index(row, 0, parent); + qDebug() << (indent + idx.data().toString()); + dump(model, indent + "- ", idx); + } +} + +void tst_QIdentityProxyModel::persistIndexOnLayoutChange() +{ + DynamicTreeModel model; + + QList<int> ancestors; + for (auto i = 0; i < 3; ++i) + { + Q_UNUSED(i); + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(0); + insertCommand.doCommand(); + ancestors.push_back(0); + } + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(1); + insertCommand.doCommand(); + + // dump(&model); + // " - 1" + // " - - 2" + // " - - - 3" + // " - - - - 4" + // " - - - - 5" + + QIdentityProxyModel proxy; + proxy.setSourceModel(&model); + + QPersistentModelIndex persistentIndex; + + QPersistentModelIndex sourcePersistentIndex = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + + QCOMPARE(sourcePersistentIndex.data().toString(), QStringLiteral("5")); + + bool gotLayoutAboutToBeChanged = false; + bool gotLayoutChanged = false; + + QObject::connect(&proxy, &QAbstractItemModel::layoutAboutToBeChanged, &proxy, [&proxy, &persistentIndex, &gotLayoutAboutToBeChanged] + { + gotLayoutAboutToBeChanged = true; + persistentIndex = proxy.match(proxy.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + }); + + QObject::connect(&proxy, &QAbstractItemModel::layoutChanged, &proxy, [&proxy, &persistentIndex, &sourcePersistentIndex, &gotLayoutChanged] + { + gotLayoutChanged = true; + QCOMPARE(QModelIndex(persistentIndex), proxy.mapFromSource(sourcePersistentIndex)); + }); + + ModelChangeChildrenLayoutsCommand layoutChangeCommand(&model, 0); + + layoutChangeCommand.setAncestorRowNumbers(QList<int>{0, 0, 0}); + layoutChangeCommand.setSecondAncestorRowNumbers(QList<int>{0, 0}); + + layoutChangeCommand.doCommand(); + + QVERIFY(gotLayoutAboutToBeChanged); + QVERIFY(gotLayoutChanged); + QVERIFY(persistentIndex.isValid()); +} + QTEST_MAIN(tst_QIdentityProxyModel) #include "tst_qidentityproxymodel.moc" diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 38e3c6890d..7b6c470dc4 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -145,6 +145,9 @@ private slots: void canDropMimeData(); void filterHint(); + void sourceLayoutChangeLeavesValidPersistentIndexes(); + void rowMoveLeavesValidPersistentIndexes(); + protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); void checkHierarchy(const QStringList &data, const QAbstractItemModel *model); @@ -4181,5 +4184,174 @@ void tst_QSortFilterProxyModel::filterHint() QAbstractItemModel::NoLayoutChangeHint); } +/** + + Creates a model where each item has one child, to a set depth, + and the last item has no children. For a model created with + setDepth(4): + + - 1 + - - 2 + - - - 3 + - - - - 4 +*/ +class StepTreeModel : public QAbstractItemModel +{ + Q_OBJECT +public: + StepTreeModel(QObject * parent = 0) + : QAbstractItemModel(parent), m_depth(0) {} + + int columnCount(const QModelIndex& = QModelIndex()) const override { return 1; } + + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { + quintptr parentId = (parent.isValid()) ? parent.internalId() : 0; + return (parentId < m_depth) ? 1 : 0; + } + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override + { + if (role != Qt::DisplayRole) + return QVariant(); + + return QString::number(index.internalId()); + } + + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override + { + quintptr parentId = (parent.isValid()) ? parent.internalId() : 0; + if (parentId >= m_depth) + return QModelIndex(); + + return createIndex(0, 0, parentId + 1); + } + + QModelIndex parent(const QModelIndex& index) const override + { + if (index.internalId() == 0) + return QModelIndex(); + + return createIndex(0, 0, index.internalId() - 1); + } + + void setDepth(quintptr depth) + { + int parentIdWithLayoutChange = (m_depth < depth) ? m_depth : depth; + + QList<QPersistentModelIndex> parentsOfLayoutChange; + parentsOfLayoutChange.push_back(createIndex(0, 0, parentIdWithLayoutChange)); + + layoutAboutToBeChanged(parentsOfLayoutChange); + + auto existing = persistentIndexList(); + + QList<QModelIndex> updated; + + for (auto idx : existing) { + if (indexDepth(idx) <= depth) + updated.push_back(idx); + else + updated.push_back({}); + } + + m_depth = depth; + + changePersistentIndexList(existing, updated); + + layoutChanged(parentsOfLayoutChange); + } + +private: + static quintptr indexDepth(QModelIndex const& index) + { + return (index.isValid()) ? 1 + indexDepth(index.parent()) : 0; + } + +private: + quintptr m_depth; +}; + +void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes() +{ + StepTreeModel model; + Q_SET_OBJECT_NAME(model); + model.setDepth(4); + + QSortFilterProxyModel proxy1; + proxy1.setSourceModel(&model); + Q_SET_OBJECT_NAME(proxy1); + + proxy1.setFilterRegExp("1|2"); + + // The current state of things: + // model proxy + // - 1 - 1 + // - - 2 - - 2 + // - - - 3 + // - - - - 4 + + // The setDepth call below removes '4' with a layoutChanged call. + // Because the proxy filters that out anyway, the proxy doesn't need + // to emit any signals or update persistent indexes. + + QPersistentModelIndex persistentIndex = proxy1.index(0, 0, proxy1.index(0, 0)); + + model.setDepth(3); + + // Calling parent() causes the internalPointer to be used. + // Before fixing QTBUG-47711, that could be a dangling pointer. + // The use of qDebug here makes sufficient use of the heap to + // cause corruption at runtime with normal use on linux (before + // the fix). valgrind confirms the fix. + qDebug() << persistentIndex.parent(); + QVERIFY(persistentIndex.parent().isValid()); +} + +void tst_QSortFilterProxyModel::rowMoveLeavesValidPersistentIndexes() +{ + DynamicTreeModel model; + Q_SET_OBJECT_NAME(model); + + QList<int> ancestors; + for (auto i = 0; i < 5; ++i) + { + Q_UNUSED(i); + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(0); + insertCommand.doCommand(); + ancestors.push_back(0); + } + + QSortFilterProxyModel proxy1; + proxy1.setSourceModel(&model); + Q_SET_OBJECT_NAME(proxy1); + + proxy1.setFilterRegExp("1|2"); + + auto item5 = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + auto item3 = model.match(model.index(0, 0), Qt::DisplayRole, "3", 1, Qt::MatchRecursive).first(); + + Q_ASSERT(item5.isValid()); + Q_ASSERT(item3.isValid()); + + QPersistentModelIndex persistentIndex = proxy1.match(proxy1.index(0, 0), Qt::DisplayRole, "2", 1, Qt::MatchRecursive).first(); + + ModelMoveCommand moveCommand(&model, 0); + moveCommand.setAncestorRowNumbers(QList<int>{0, 0, 0, 0}); + moveCommand.setStartRow(0); + moveCommand.setEndRow(0); + moveCommand.setDestRow(0); + moveCommand.setDestAncestors(QList<int>{0, 0, 0}); + moveCommand.doCommand(); + + // Calling parent() causes the internalPointer to be used. + // Before fixing QTBUG-47711 (moveRows case), that could be + // a dangling pointer. + QVERIFY(persistentIndex.parent().isValid()); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/corelib/kernel/qobject/test/test.pro b/tests/auto/corelib/kernel/qobject/test/test.pro index f3bc045455..4e77cb48c5 100644 --- a/tests/auto/corelib/kernel/qobject/test/test.pro +++ b/tests/auto/corelib/kernel/qobject/test/test.pro @@ -3,5 +3,8 @@ TARGET = ../tst_qobject QT = core-private network testlib SOURCES = ../tst_qobject.cpp +# Force C++17 if available (needed due to P0012R1) +contains(QT_CONFIG, c++1z): CONFIG += c++1z + !winrt: TEST_HELPER_INSTALLS = ../signalbug/signalbug DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 5eea858107..f44c40c27f 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -120,6 +120,7 @@ private slots: void connectCxx0x(); void connectToStaticCxx0x(); void connectCxx0xTypeMatching(); + void connectCxx17Noexcept(); void connectConvert(); void connectWithReference(); void connectManyArguments(); @@ -4755,10 +4756,13 @@ class LotsOfSignalsAndSlots: public QObject public slots: void slot_v() {} + void slot_v_noexcept() Q_DECL_NOTHROW {} void slot_vi(int) {} + void slot_vi_noexcept() Q_DECL_NOTHROW {} void slot_vii(int, int) {} void slot_viii(int, int, int) {} int slot_i() { return 0; } + int slot_i_noexcept() Q_DECL_NOTHROW { return 0; } int slot_ii(int) { return 0; } int slot_iii(int, int) { return 0; } int slot_iiii(int, int, int) { return 0; } @@ -4772,13 +4776,18 @@ class LotsOfSignalsAndSlots: public QObject void slot_vPFvvE(fptr) {} void const_slot_v() const {}; + void const_slot_v_noexcept() const Q_DECL_NOTHROW {} void const_slot_vi(int) const {}; + void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {} static void static_slot_v() {} + static void static_slot_v_noexcept() Q_DECL_NOTHROW {} static void static_slot_vi(int) {} + static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {} static void static_slot_vii(int, int) {} static void static_slot_viii(int, int, int) {} static int static_slot_i() { return 0; } + static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; } static int static_slot_ii(int) { return 0; } static int static_slot_iii(int, int) { return 0; } static int static_slot_iiii(int, int, int) { return 0; } @@ -4941,6 +4950,32 @@ void tst_QObject::connectCxx0xTypeMatching() } +void receiverFunction_noexcept() Q_DECL_NOTHROW {} +struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} }; +void tst_QObject::connectCxx17Noexcept() +{ + // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier + // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html + typedef LotsOfSignalsAndSlots Foo; + Foo obj; + + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_v_noexcept); + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_i_noexcept); + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_vi_noexcept); + + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_v_noexcept); + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_i_noexcept); + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_vi_noexcept); + + QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_vi_noexcept)); + QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_v_noexcept)); + + QObject::connect(&obj, &Foo::signal_v, receiverFunction_noexcept); + + Functor_noexcept fn; + QObject::connect(&obj, &Foo::signal_v, fn); +} + class StringVariant : public QObject { Q_OBJECT signals: diff --git a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro index 69062a9741..3a4697750e 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro +++ b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs -!winrt: SUBDIRS = sharedmemoryhelper - -SUBDIRS += test +qtConfig(sharedmemory) { + !winrt: SUBDIRS = sharedmemoryhelper + SUBDIRS += test +} diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro index 8afdbb148e..b27d862bc5 100644 --- a/tests/auto/corelib/kernel/qtimer/qtimer.pro +++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qtimer QT = core testlib SOURCES = tst_qtimer.cpp + +# Force C++17 if available +contains(QT_CONFIG, c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index fe97695d19..29ff552f6a 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -767,6 +767,11 @@ class StaticEventLoop public: static void quitEventLoop() { + quitEventLoop_noexcept(); + } + + static void quitEventLoop_noexcept() Q_DECL_NOTHROW + { QVERIFY(!_e.isNull()); _e->quit(); if (_t) @@ -787,6 +792,9 @@ void tst_QTimer::singleShotToFunctors() QTimer::singleShot(0, &StaticEventLoop::quitEventLoop); QCOMPARE(_e->exec(), 0); + QTimer::singleShot(0, &StaticEventLoop::quitEventLoop_noexcept); + QCOMPARE(_e->exec(), 0); + QThread t1; QObject c1; c1.moveToThread(&t1); diff --git a/tests/auto/corelib/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro index ed9e189668..b1667760d6 100644 --- a/tests/auto/corelib/thread/qfuture/qfuture.pro +++ b/tests/auto/corelib/thread/qfuture/qfuture.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qfuture -QT = core core-private testlib concurrent +QT = core core-private testlib SOURCES = tst_qfuture.cpp DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro index 5eebd12deb..0d20117ed0 100644 --- a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro +++ b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qfuturesynchronizer -QT = core testlib concurrent +QT = core testlib SOURCES = tst_qfuturesynchronizer.cpp diff --git a/tests/auto/corelib/thread/qresultstore/qresultstore.pro b/tests/auto/corelib/thread/qresultstore/qresultstore.pro index 2f6c18f64c..bbebe0976b 100644 --- a/tests/auto/corelib/thread/qresultstore/qresultstore.pro +++ b/tests/auto/corelib/thread/qresultstore/qresultstore.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qresultstore -QT = core-private testlib concurrent +QT = core-private testlib SOURCES = tst_qresultstore.cpp DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 7681f4755c..f56cff4d29 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -186,12 +186,50 @@ void tst_QLocale::ctor() QVERIFY(l.country() == default_country); } +#define TEST_CTOR(req_lang, req_script, req_country, exp_lang, exp_script, exp_country) \ + { \ + QLocale l(QLocale::req_lang, QLocale::req_script, QLocale::req_country); \ + QCOMPARE((int)l.language(), (int)exp_lang); \ + QCOMPARE((int)l.script(), (int)exp_script); \ + QCOMPARE((int)l.country(), (int)exp_country); \ + } + + // Exact matches + TEST_CTOR(Chinese, SimplifiedHanScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, TraditionalHanScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong); + + // Best match for AnyCountry + TEST_CTOR(Chinese, SimplifiedHanScript, AnyCountry, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, AnyCountry, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Best match for AnyScript (and change country to supported one, if necessary) + TEST_CTOR(Chinese, AnyScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, AnyScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, AnyScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong); + TEST_CTOR(Chinese, AnyScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + + // Fully-specified not found; find best alternate country + TEST_CTOR(Chinese, SimplifiedHanScript, Taiwan, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, SimplifiedHanScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, China, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, TraditionalHanScript, UnitedStates, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Fully-specified not found; find best alternate script + TEST_CTOR(Chinese, LatinScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, LatinScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Fully-specified not found; find best alternate country and script + TEST_CTOR(Chinese, LatinScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + +#undef TEST_CTOR #define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \ { \ QLocale l(QLocale::req_lang, QLocale::req_country); \ QCOMPARE((int)l.language(), (int)exp_lang); \ QCOMPARE((int)l.country(), (int)exp_country); \ } + { QLocale l(QLocale::C, QLocale::AnyCountry); QCOMPARE(l.language(), QLocale::C); @@ -295,7 +333,6 @@ void tst_QLocale::ctor() TEST_CTOR(Uzbek, AnyCountry, QLocale::Uzbek, QLocale::Uzbekistan) #undef TEST_CTOR - #define TEST_CTOR(req_lc, exp_lang, exp_country) \ { \ QLocale l(req_lc); \ |