From e524724f9dc6f64f6f94b842682c751dcd07225f Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 15 Oct 2018 09:51:12 +0200 Subject: tst_qfilesystemmodel: Do not use nested calls of auto test functions Calling rowCount inside another auto test function yields unexpected results, if rowCount fails. Without a check for QTest::currentTestFailed the failure will not stop the calling function and other functions like rowsInserted and rowsRemoved might happily continue even though their requirements are not met. That caused a crash on winrt under certain circumstances. In addition to that TRY_WAIT now does not only wait for the given amount of time, but also gives feedback about its result. Before this change TRY_WAIT was basically useless, as it gave no indication about its success/failure. Fixes: QTBUG-71121 Change-Id: Ibd3f233a0b913db799814be97c4274d510643c74 Reviewed-by: Friedemann Kleint --- .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 79 +++++++++++++++------- 1 file changed, 56 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index d8a680881a..9ee5292fcb 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -51,10 +51,15 @@ // Will try to wait for the condition while allowing event processing // for a maximum of 5 seconds. -#define TRY_WAIT(expr) \ +#define TRY_WAIT(expr, timedOut) \ do { \ + *timedOut = true; \ const int step = 50; \ - for (int __i = 0; __i < 5000 && !(expr); __i+=step) { \ + for (int __i = 0; __i < 5000; __i += step) { \ + if (expr) { \ + *timedOut = false; \ + break; \ + } \ QTest::qWait(step); \ } \ } while(0) @@ -123,6 +128,8 @@ private slots: protected: bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList()); + QModelIndex prepareTestModelRoot(const QString &test_path, QSignalSpy **spy2 = nullptr, + QSignalSpy **spy3 = nullptr); private: QFileSystemModel *model; @@ -306,7 +313,11 @@ void tst_QFileSystemModel::iconProvider() bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs) { //qDebug() << (model->rowCount(model->index(test_path))) << existingFileCount << initial_files; - TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount)); + bool timedOut = false; + TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount), &timedOut); + if (timedOut) + return false; + for (int i = 0; i < initial_dirs.count(); ++i) { QDir dir(test_path); if (!dir.exists()) { @@ -363,23 +374,45 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi return true; } -void tst_QFileSystemModel::rowCount() +QModelIndex tst_QFileSystemModel::prepareTestModelRoot(const QString &test_path, QSignalSpy **spy2, + QSignalSpy **spy3) { - QString tmp = flatDirTestPath; - QVERIFY(createFiles(tmp, QStringList())); + if (model->rowCount(model->index(test_path)) != 0) + return QModelIndex(); - QSignalSpy spy2(model, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy spy3(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + if (spy2) + *spy2 = new QSignalSpy(model, &QFileSystemModel::rowsInserted); + if (spy3) + *spy3 = new QSignalSpy(model, &QFileSystemModel::rowsAboutToBeInserted); - QStringList files = QStringList() << "b" << "d" << "f" << "h" << "j" << ".a" << ".c" << ".e" << ".g"; + QStringList files = { "b", "d", "f", "h", "j", ".a", ".c", ".e", ".g" }; QString l = "b,d,f,h,j,.a,.c,.e,.g"; - QVERIFY(createFiles(tmp, files)); + if (!createFiles(test_path, files)) + return QModelIndex(); - QModelIndex root = model->setRootPath(tmp); - QTRY_COMPARE(model->rowCount(root), 5); - QVERIFY(spy2.count() > 0); - QVERIFY(spy3.count() > 0); + QModelIndex root = model->setRootPath(test_path); + if (!root.isValid()) + return QModelIndex(); + + bool timedOut = false; + TRY_WAIT(model->rowCount(root) == 5, &timedOut); + if (timedOut) + return QModelIndex(); + + return root; +} + +void tst_QFileSystemModel::rowCount() +{ + const QString tmp = flatDirTestPath; + QSignalSpy *spy2 = nullptr; + QSignalSpy *spy3 = nullptr; + QModelIndex root = prepareTestModelRoot(flatDirTestPath, &spy2, &spy3); + QVERIFY(root.isValid()); + + QVERIFY(spy2 && spy2->count() > 0); + QVERIFY(spy3 && spy3->count() > 0); } void tst_QFileSystemModel::rowsInserted_data() @@ -401,9 +434,9 @@ static inline QString lastEntry(const QModelIndex &root) void tst_QFileSystemModel::rowsInserted() { - QString tmp = flatDirTestPath; - rowCount(); - QModelIndex root = model->index(model->rootPath()); + const QString tmp = flatDirTestPath; + QModelIndex root = prepareTestModelRoot(tmp); + QVERIFY(root.isValid()); QFETCH(int, ascending); QFETCH(int, count); @@ -454,9 +487,9 @@ void tst_QFileSystemModel::rowsRemoved_data() void tst_QFileSystemModel::rowsRemoved() { - QString tmp = flatDirTestPath; - rowCount(); - QModelIndex root = model->index(model->rootPath()); + const QString tmp = flatDirTestPath; + QModelIndex root = prepareTestModelRoot(tmp); + QVERIFY(root.isValid()); QFETCH(int, count); QFETCH(int, ascending); @@ -509,9 +542,9 @@ void tst_QFileSystemModel::dataChanged() { QSKIP("This can't be tested right now since we don't watch files, only directories."); - QString tmp = flatDirTestPath; - rowCount(); - QModelIndex root = model->index(model->rootPath()); + const QString tmp = flatDirTestPath; + QModelIndex root = prepareTestModelRoot(tmp); + QVERIFY(root.isValid()); QFETCH(int, count); QFETCH(int, assending); -- cgit v1.2.3 From 95ba049f8787258ccb28eeda72d1fac71f90e6f6 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 23 Oct 2018 11:18:22 +0200 Subject: Remove QSKIP and bring the test back to business MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on macOS, where it was skipped but where it now seems to be stable/work. Task-number: QTBUG-39983 Change-Id: I100a57f23b43074ebacc012be247d92acc6ae336 Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne --- tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index fed05698fd..da5327594c 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -209,9 +209,6 @@ void tst_QIODevice::read_QByteArray() //-------------------------------------------------------------------- void tst_QIODevice::unget() { -#if defined(Q_OS_MAC) - QSKIP("The unget network test is unstable on Mac. See QTBUG-39983."); -#endif QBuffer buffer; buffer.open(QBuffer::ReadWrite); buffer.write("ZXCV"); -- cgit v1.2.3 From 321f11db53422fe797c881cafa36ee44406d803c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 23 Oct 2018 11:37:07 +0200 Subject: tst_QLocalSocket::processConnections: remove QSKIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on macOS, the test seems to be stable nowadays. Task-number: QTBUG-39986 Change-Id: I18430c3feb27a5bee5474e1eb95f7d89b25f00a9 Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 779d55a77a..45ab275510 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -962,9 +962,6 @@ void tst_QLocalSocket::processConnection() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else -#ifdef Q_OS_MAC - QSKIP("The processConnection test is unstable on Mac. See QTBUG-39986."); -#endif #ifdef Q_OS_WIN const QString exeSuffix = QStringLiteral(".exe"); -- cgit v1.2.3 From b10ee45546e152e08b2494bd45eb22426e9d2dc9 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 23 Oct 2018 15:42:24 +0200 Subject: tst_qeventdispatcher: remove macOS from the BLACKLIST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the test is stable in Qt 5.12. Task-number: QTBUG-60993 Change-Id: I0c366567121688d9518e90b5e8f9ec1b4006b7b9 Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne --- tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST index fb7e025b7c..b1590a5ccf 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST +++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST @@ -1,7 +1,5 @@ [sendPostedEvents] windows -osx [registerTimer] windows -osx winrt -- cgit v1.2.3 From 95476bfcf64aa9cb43775ebfe3410ce9565de4d5 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Mon, 22 Oct 2018 19:08:57 +0200 Subject: qendian: Fix float conversions Since Qt 5.10, qTo/FromBig/LittleEndian stopped working. It may be confusing, but big endian floats do exist, so not to break old code, we should support them. Change-Id: I21cdbc7f48ec030ce3d82f1cd1aad212f0fe5dd0 Reviewed-by: Thiago Macieira --- .../auto/corelib/global/qtendian/tst_qtendian.cpp | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp index 7043969c2f..2345bb39c1 100644 --- a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp +++ b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp @@ -64,6 +64,9 @@ struct TestData quint16 data16; quint8 data8; + float dataFloat; + double dataDouble; + quint8 reserved; }; @@ -72,6 +75,7 @@ template <> quint8 getData(const TestData &d) { return d.data8; } template <> quint16 getData(const TestData &d) { return d.data16; } template <> quint32 getData(const TestData &d) { return d.data32; } template <> quint64 getData(const TestData &d) { return d.data64; } +template <> float getData(const TestData &d) { return d.dataFloat; } union RawTestData { @@ -79,9 +83,39 @@ union RawTestData TestData data; }; -static const TestData inNativeEndian = { Q_UINT64_C(0x0123456789abcdef), 0x00c0ffee, 0xcafe, 0xcf, '\0' }; -static const RawTestData inBigEndian = { "\x01\x23\x45\x67\x89\xab\xcd\xef" "\x00\xc0\xff\xee" "\xca\xfe" "\xcf" }; -static const RawTestData inLittleEndian = { "\xef\xcd\xab\x89\x67\x45\x23\x01" "\xee\xff\xc0\x00" "\xfe\xca" "\xcf" }; +template +Float int2Float(typename QIntegerForSizeof::Unsigned i) +{ + Float result = 0; + memcpy(reinterpret_cast(&result), reinterpret_cast(&i), sizeof (Float)); + return result; +} + +static const TestData inNativeEndian = { + Q_UINT64_C(0x0123456789abcdef), + 0x00c0ffee, + 0xcafe, + 0xcf, + int2Float(0x00c0ffeeU), + int2Float(Q_UINT64_C(0x0123456789abcdef)), + '\0' +}; +static const RawTestData inBigEndian = { + "\x01\x23\x45\x67\x89\xab\xcd\xef" + "\x00\xc0\xff\xee" + "\xca\xfe" + "\xcf" + "\x00\xc0\xff\xee" + "\x01\x23\x45\x67\x89\xab\xcd\xef" +}; +static const RawTestData inLittleEndian = { + "\xef\xcd\xab\x89\x67\x45\x23\x01" + "\xee\xff\xc0\x00" + "\xfe\xca" + "\xcf" + "\xee\xff\xc0\x00" + "\xef\xcd\xab\x89\x67\x45\x23\x01" +}; #define EXPAND_ENDIAN_TEST(endian) \ do { \ -- cgit v1.2.3 From 7e7514482fb2086fda100439a34b5b4ef627d329 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 25 Oct 2018 15:28:40 +0200 Subject: winrt: Skip a test row of tst_QRegularExpression::threadSafety PCRE2 does not support JIT on winrt. This test row takes a long time (30 seconds here) without JIT and thus might cause test timeouts in COIN when run on winrt. Change-Id: I79d9f6be16dbe16594ae2bf51f353acd06b3d2fe Reviewed-by: Simon Hausmann --- .../auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index f520e9742a..18098f16bf 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -2108,12 +2108,16 @@ void tst_QRegularExpression::threadSafety_data() QTest::addRow("pattern%d", ++i) << "ab.*cd" << subject; } + // pcre2 does not support JIT for winrt. As this test row takes a long time without JIT we skip + // it for winrt as it might time out in COIN. +#ifndef Q_OS_WINRT { QString subject = "ab"; subject.append(QString(512*1024, QLatin1Char('x'))); subject.append("c"); QTest::addRow("pattern%d", ++i) << "ab.*cd" << subject; } +#endif // Q_OS_WINRT { QString subject = "ab"; -- cgit v1.2.3 From 497f43c90f7160c1b198d829eab21c8c010fc7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 24 Oct 2018 12:46:04 +0200 Subject: tst_QCborValue: Disable support for spaceship operator Spaceship operator was disabled for QCborValue, but not the test. Change-Id: Icb91da689f62ef6de9f4fa926346505c5e50e9eb Reviewed-by: Thiago Macieira --- tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 38b26e7de4..4b753eab6b 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -330,7 +330,7 @@ void tst_QCborValue::copyCompare() QCOMPARE(v, other); QVERIFY(!(v != other)); QVERIFY(!(v < other)); -#if QT_HAS_INCLUDE() +#if 0 && QT_HAS_INCLUDE() QVERIFY(v <= other); QVERIFY(v >= other); QVERIFY(!(v > other)); -- cgit v1.2.3 From a952fd7d5b03ce1968ec58871fbb8b3600895900 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 26 Sep 2018 10:29:14 +0300 Subject: QObject: Fix isSignalConnected() when signals have been disconnected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bitmap cache for the first 64 signals being connected was only set when the connection is added. It was never unset when the connection was removed. Internal use of the connectedSignals bitmap is not hurt by it occasionally saying a signal is connected even though it is not, since the purpose of those checks is avoiding expensive operations that are not necessary if nothing is connected to the signal. However, the public API using this cache meant that it also never spotted signals being disconnected. This was not documented. Fix the behavior by only using the cache if it is up to date. If it is not, use a slower path that gives the correct answer. To avoid making disconnections and QObject destructions slower, the cache is only updated to unset disconnected signals when new signal connections are added. No extra work is done in the common case where signals are only removed in the end of the QObject's lifetime. Fixes: QTBUG-32340 Change-Id: Ieb6e498060157153cec60d9c8f1c33056993fda1 Reviewed-by: Ville Voutilainen Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Jędrzej Nowacki --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 68c6ece583..effc82261b 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -103,6 +103,7 @@ private slots: void deleteQObjectWhenDeletingEvent(); void overloads(); void isSignalConnected(); + void isSignalConnectedAfterDisconnection(); void qMetaObjectConnect(); void qMetaObjectDisconnectOne(); void sameName(); @@ -3835,6 +3836,58 @@ void tst_QObject::isSignalConnected() QVERIFY(!o.isSignalConnected(QMetaMethod())); } +void tst_QObject::isSignalConnectedAfterDisconnection() +{ + ManySignals o; + const QMetaObject *meta = o.metaObject(); + + const QMetaMethod sig00 = meta->method(meta->indexOfSignal("sig00()")); + QVERIFY(!o.isSignalConnected(sig00)); + QObject::connect(&o, &ManySignals::sig00, qt_noop); + QVERIFY(o.isSignalConnected(sig00)); + QVERIFY(QObject::disconnect(&o, &ManySignals::sig00, 0, 0)); + QVERIFY(!o.isSignalConnected(sig00)); + + const QMetaMethod sig69 = meta->method(meta->indexOfSignal("sig69()")); + QVERIFY(!o.isSignalConnected(sig69)); + QObject::connect(&o, &ManySignals::sig69, qt_noop); + QVERIFY(o.isSignalConnected(sig69)); + QVERIFY(QObject::disconnect(&o, &ManySignals::sig69, 0, 0)); + QVERIFY(!o.isSignalConnected(sig69)); + + { + ManySignals o2; + QObject::connect(&o, &ManySignals::sig00, &o2, &ManySignals::sig00); + QVERIFY(o.isSignalConnected(sig00)); + // o2 is destructed + } + QVERIFY(!o.isSignalConnected(sig00)); + + const QMetaMethod sig01 = meta->method(meta->indexOfSignal("sig01()")); + QObject::connect(&o, &ManySignals::sig00, qt_noop); + QObject::connect(&o, &ManySignals::sig01, qt_noop); + QObject::connect(&o, &ManySignals::sig69, qt_noop); + QVERIFY(o.isSignalConnected(sig00)); + QVERIFY(o.isSignalConnected(sig01)); + QVERIFY(o.isSignalConnected(sig69)); + QVERIFY(QObject::disconnect(&o, &ManySignals::sig69, 0, 0)); + QVERIFY(o.isSignalConnected(sig00)); + QVERIFY(o.isSignalConnected(sig01)); + QVERIFY(!o.isSignalConnected(sig69)); + QVERIFY(QObject::disconnect(&o, &ManySignals::sig00, 0, 0)); + QVERIFY(!o.isSignalConnected(sig00)); + QVERIFY(o.isSignalConnected(sig01)); + QVERIFY(!o.isSignalConnected(sig69)); + QObject::connect(&o, &ManySignals::sig69, qt_noop); + QVERIFY(!o.isSignalConnected(sig00)); + QVERIFY(o.isSignalConnected(sig01)); + QVERIFY(o.isSignalConnected(sig69)); + QVERIFY(QObject::disconnect(&o, &ManySignals::sig01, 0, 0)); + QVERIFY(!o.isSignalConnected(sig00)); + QVERIFY(!o.isSignalConnected(sig01)); + QVERIFY(o.isSignalConnected(sig69)); +} + void tst_QObject::qMetaObjectConnect() { SenderObject *s = new SenderObject; -- cgit v1.2.3