From 344b19f8e906183b6f5ed6370966edc711ed6c71 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Fri, 17 Apr 2015 15:26:24 +0200 Subject: Tests: Use blacklist for tst_NetworkSelfTest::ftpProxyServer() Remove the insignificant_tests CONFIG option in favor of a BLACKLIST file. The test blacklisted have been found using CI builds logs. Change-Id: Iac07316862cff9b5085dacdf9f35e691cff09384 Task-number: QTBUG-27571 Reviewed-by: Janne Anttila Reviewed-by: Frederik Gladhorn --- tests/auto/other/networkselftest/BLACKLIST | 4 ++++ tests/auto/other/networkselftest/networkselftest.pro | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/auto/other/networkselftest/BLACKLIST (limited to 'tests') diff --git a/tests/auto/other/networkselftest/BLACKLIST b/tests/auto/other/networkselftest/BLACKLIST new file mode 100644 index 0000000000..4a958b43a5 --- /dev/null +++ b/tests/auto/other/networkselftest/BLACKLIST @@ -0,0 +1,4 @@ +# QTBUG-27571 +[ftpProxyServer] +windows 32bit +windows 64bit diff --git a/tests/auto/other/networkselftest/networkselftest.pro b/tests/auto/other/networkselftest/networkselftest.pro index 22208e02fb..60b45e6b5e 100644 --- a/tests/auto/other/networkselftest/networkselftest.pro +++ b/tests/auto/other/networkselftest/networkselftest.pro @@ -4,5 +4,4 @@ TARGET = tst_networkselftest SOURCES += tst_networkselftest.cpp QT = core core-private network testlib -win32:CONFIG += insignificant_test # QTBUG-27571 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -- cgit v1.2.3 From 13b1c23f8b2cdf283703a75f475ddcf06653bf7e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Oct 2015 16:24:50 +0200 Subject: QLineEdit: Fix visibility handling of side widgets. Compare against isVisibleTo() in QLineEditIconButton::actionEvent() so that action events received before show() are handled correctly. Fix a regression introduced by change 4dccb2ca674e9eafca65da0775254932102c7f4b for handling action events causing side widgets to overlap when added before the widget was shown. Use QAction::isVisible() to determine visibility. Task-number: QTBUG-48806 Task-number: QTBUG-48899 Task-number: QTBUG-39660 Change-Id: I7a39a3b9a094f2c74cde09544f1158deb2b81cf2 Reviewed-by: David Faure --- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 58 +++++++++++++++------- 1 file changed, 41 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index e6d63ee4d9..1d70e8a8ab 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -4319,10 +4319,10 @@ void tst_QLineEdit::clearButtonVisibleAfterSettingText_QTBUG_45518() #endif // QT_BUILD_INTERNAL } -static inline QIcon sideWidgetTestIcon() +static inline QIcon sideWidgetTestIcon(Qt::GlobalColor color = Qt::yellow) { QImage image(QSize(20, 20), QImage::Format_ARGB32); - image.fill(Qt::yellow); + image.fill(color); return QIcon(QPixmap::fromImage(image)); } @@ -4360,6 +4360,15 @@ void tst_QLineEdit::sideWidgets() lineEdit->addAction(iconAction); } +template T *findAssociatedWidget(const QAction *a) +{ + foreach (QWidget *w, a->associatedWidgets()) { + if (T *result = qobject_cast(w)) + return result; + } + return Q_NULLPTR; +} + void tst_QLineEdit::sideWidgetsActionEvents() { // QTBUG-39660, verify whether action events are handled by the widget. @@ -4368,28 +4377,43 @@ void tst_QLineEdit::sideWidgetsActionEvents() QLineEdit *lineEdit = new QLineEdit(&testWidget); l->addWidget(lineEdit); l->addSpacerItem(new QSpacerItem(0, 50, QSizePolicy::Ignored, QSizePolicy::Fixed)); - QAction *iconAction = lineEdit->addAction(sideWidgetTestIcon(), QLineEdit::LeadingPosition); + QAction *iconAction1 = lineEdit->addAction(sideWidgetTestIcon(Qt::red), QLineEdit::LeadingPosition); + QAction *iconAction2 = lineEdit->addAction(sideWidgetTestIcon(Qt::blue), QLineEdit::LeadingPosition); + QAction *iconAction3 = lineEdit->addAction(sideWidgetTestIcon(Qt::yellow), QLineEdit::LeadingPosition); + iconAction3->setVisible(false); + testWidget.move(300, 300); testWidget.show(); QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); - QWidget *toolButton = Q_NULLPTR; - foreach (QWidget *w, iconAction->associatedWidgets()) { - if (qobject_cast(w)) { - toolButton = w; - break; - } - } - QVERIFY(toolButton); + QWidget *toolButton1 = findAssociatedWidget(iconAction1); + QWidget *toolButton2 = findAssociatedWidget(iconAction2); + QWidget *toolButton3 = findAssociatedWidget(iconAction3); + + QVERIFY(toolButton1); + QVERIFY(toolButton2); + QVERIFY(toolButton3); + + QVERIFY(!toolButton3->isVisible()); // QTBUG-48899 , action hidden before show(). + + QVERIFY(toolButton1->isVisible()); + QVERIFY(toolButton1->isEnabled()); + + QVERIFY(toolButton2->isVisible()); + QVERIFY(toolButton2->isEnabled()); + + const int toolButton1X = toolButton1->x(); + const int toolButton2X = toolButton2->x(); + QVERIFY(toolButton1X < toolButton2X); // QTBUG-48806, positioned beside each other. - QVERIFY(toolButton->isVisible()); - QVERIFY(toolButton->isEnabled()); + iconAction1->setEnabled(false); + QVERIFY(!toolButton1->isEnabled()); - iconAction->setEnabled(false); - QVERIFY(!toolButton->isEnabled()); + iconAction1->setVisible(false); + QVERIFY(!toolButton1->isVisible()); - iconAction->setVisible(false); - QVERIFY(!toolButton->isVisible()); + // QTBUG-39660, button 2 takes position of invisible button 1. + QCOMPARE(toolButton2->x(), toolButton1X); } Q_DECLARE_METATYPE(Qt::AlignmentFlag) -- cgit v1.2.3 From f0c915de70575225d0e968a2fbba07b631970a0d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Oct 2015 13:56:48 -0700 Subject: Autotest: remove AIX-related QT_POINTER_SIZE code This test hasn't been run for years, so clean up. And besides, it's extremely fragile and would depend on how IBM packages their OpenGL libraries. Change-Id: I1d0f78915b5942aab07cffff140f9db5a09ee7e2 Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index e87585163b..f31a7af6dd 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -413,15 +413,6 @@ void tst_QLibrary::loadHints_data() QTest::addColumn("result"); QLibrary::LoadHints lh; -#if defined(Q_OS_AIX) - if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) { -# if QT_POINTER_SIZE == 4 - QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << true; -# else - QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << true; -#endif - } -#endif QString appDir = QCoreApplication::applicationDirPath(); -- cgit v1.2.3 From 8b9346c7404287b4c546b49c23f24ccbef0f8b6e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 26 Oct 2015 15:28:36 +0100 Subject: Item Views: Avoid reentrant call in updateEditorGeometries() This may result in incrementing an invalid iterator after the iterator's container has changed. Also, for this to happen, the view needs to have an active editor. The reentrant call happens as follows in QTreeView, after the model adds new rows to the view: QTreeView::rowsInserted() QAbstractItemView::rowsInserted() QAbstractItemView::updateEditorGeometries() QTreeView::visualRect() QAbstractItemViewPrivate::executePostedLayout() QTreeView::doItemsLayout() QAbstractItemView::doItemsLayout() QTreeView::updateGeometries() QAbstractItemView::updateGeometries() QAbstractItemView::updateEditorGeometries() Other concrete item view classes may be prone to the same issue. The fix consists in relayouting the items if needed, which should trigger calling updateEditorGeometries() again. This doesn't invalidate previous optimizations regarding item relayouting since we only force relayouting when it'll be done by visualRect(). Change-Id: Id31507fdc8d9a84d50265298191d690d1a06792b Task-number: QTBUG-48968 Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../qabstractitemview/tst_qabstractitemview.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index fac3f5857b..3a17f7c690 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -250,6 +250,7 @@ private slots: void QTBUG39324_settingSameInstanceOfIndexWidget(); void sizeHintChangeTriggersLayout(); void shiftSelectionAfterChangingModelContents(); + void QTBUG48968_reentrant_updateEditorGeometries(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1990,5 +1991,42 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() QVERIFY(selected.contains(indexE)); } +void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries() +{ + + QStandardItemModel *m = new QStandardItemModel(this); + for (int i=0; i<10; ++i) { + QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + item->setEditable(true); + for (int j=0; j<5; ++j) { + QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j)); + item->setChild(j, 0, child); + } + m->setItem(i, 0, item); + } + + QTreeView tree; + tree.setModel(m); + tree.setRootIsDecorated(false); + QObject::connect(&tree, SIGNAL(doubleClicked(QModelIndex)), &tree, SLOT(setRootIndex(QModelIndex))); + tree.show(); + QTest::qWaitForWindowActive(&tree); + + // Trigger editing idx + QModelIndex idx = m->index(1, 0); + const QPoint pos = tree.visualRect(idx).center(); + QTest::mouseClick(tree.viewport(), Qt::LeftButton, Qt::NoModifier, pos); + QTest::mouseDClick(tree.viewport(), Qt::LeftButton, Qt::NoModifier, pos); + + // Add more children to idx + QStandardItem *item = m->itemFromIndex(idx); + for (int j=5; j<10; ++j) { + QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j)); + item->setChild(j, 0, child); + } + + // No crash, all fine. +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" -- cgit v1.2.3 From 1e32ade79ced64597ef4148f16e0d8a329733c4e Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 11 Sep 2015 12:15:03 +0300 Subject: QIODevice: fix interleaving read() and write() in text mode under Windows Skip the correct number of bytes in the read buffer when expanding '\n' into "\r\n" upon writing. Change-Id: I5b01fc47c330dee5c83001abf0acd7d63d790b96 Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 565ca18899..334f5aba05 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -59,6 +59,7 @@ private slots: void peekBug(); void readAllKeepPosition(); + void writeInTextMode(); }; void tst_QIODevice::initTestCase() @@ -628,5 +629,45 @@ void tst_QIODevice::readAllKeepPosition() QCOMPARE(resultArray, buffer.buffer()); } +class RandomAccessBuffer : public QIODevice +{ +public: + RandomAccessBuffer(const char *data) : QIODevice(), buf(data) { } + +protected: + qint64 readData(char *data, qint64 maxSize) Q_DECL_OVERRIDE + { + maxSize = qMin(maxSize, qint64(buf.size() - pos())); + memcpy(data, buf.constData() + pos(), maxSize); + return maxSize; + } + qint64 writeData(const char *data, qint64 maxSize) Q_DECL_OVERRIDE + { + maxSize = qMin(maxSize, qint64(buf.size() - pos())); + memcpy(buf.data() + pos(), data, maxSize); + return maxSize; + } + +private: + QByteArray buf; +}; + +// Test write() on skipping correct number of bytes in read buffer +void tst_QIODevice::writeInTextMode() +{ + // Unlike other platforms, Windows implementation expands '\n' into + // "\r\n" sequence in write(). Ensure that write() properly works with + // a read buffer on random-access devices. +#ifndef Q_OS_WIN + QSKIP("This is a Windows-only test"); +#else + RandomAccessBuffer buffer("one\r\ntwo\r\nthree\r\n"); + buffer.open(QBuffer::ReadWrite | QBuffer::Text); + QCOMPARE(buffer.readLine(), QByteArray("one\n")); + QCOMPARE(buffer.write("two\n"), 4); + QCOMPARE(buffer.readLine(), QByteArray("three\n")); +#endif +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" -- cgit v1.2.3 From b20d6cded7be8b86bed93ee705420bfb01700c5b Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 29 Oct 2015 09:43:33 +0200 Subject: Fix QDomNamedNodeMap::item crash with negative index Task-number: QTBUG-49113 Change-Id: I62dee4c112b73a25628657bc3d2ae675f26b87d8 Reviewed-by: David Faure --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index a4a3f1f6b3..04cd0b300f 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -119,6 +119,7 @@ private slots: void cloneDTD_QTBUG8398() const; void DTDNotationDecl(); void DTDEntityDecl(); + void QTBUG49113_dontCrashWithNegativeIndex() const; void cleanupTestCase() const; @@ -1979,5 +1980,13 @@ void tst_QDom::DTDEntityDecl() QCOMPARE(doctype.namedItem(QString("logo")).toEntity().notationName(), QString("gif")); } +void tst_QDom::QTBUG49113_dontCrashWithNegativeIndex() const +{ + QDomDocument doc; + QDomElement elem = doc.appendChild(doc.createElement("root")).toElement(); + QDomNode node = elem.attributes().item(-1); + QVERIFY(node.isNull()); +} + QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" -- cgit v1.2.3 From 0667ba3f24c2637adab41b6ea8e7c08f933a6cf3 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 29 Oct 2015 11:52:24 +0200 Subject: Disable tst_QSslCertificate::subjectAndIssuerAttributes completely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a follow-up for 5c1b9bbdf14a9537bd66aedbfd1c72bde0c899e0 disable the test on all platforms, since it fails on newer openssl. This was now also happening on Windows, so until a fix is there, skip the test. Change-Id: I6c8822c0ac5411b1114e9cd426219574ab1c9b54 Reviewed-by: Simon Hausmann Reviewed-by: Jędrzej Nowacki --- tests/auto/network/ssl/qsslcertificate/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/network/ssl/qsslcertificate/BLACKLIST b/tests/auto/network/ssl/qsslcertificate/BLACKLIST index 2e376fa2a9..25509a5ca8 100644 --- a/tests/auto/network/ssl/qsslcertificate/BLACKLIST +++ b/tests/auto/network/ssl/qsslcertificate/BLACKLIST @@ -1,3 +1,3 @@ # OpenSSL version is too new. Rich will fix :) [subjectAndIssuerAttributes] -osx +* -- cgit v1.2.3 From 11638dad106cee87eec2f6cafbfd6c7879c5e689 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 30 Oct 2015 12:56:24 +0100 Subject: Add a test case for conflicting transitions This tests a fix: ff3ba1045e8322caa0293b05aecbff4411963ea2 Change-Id: I623b4e270c7eba1af0c4c023e83b6eea50fb45a1 Reviewed-by: Simon Hausmann --- .../qstatemachine/tst_qstatemachine.cpp | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 28df7cce7b..cfbb88a123 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -249,6 +249,7 @@ private slots: void qtbug_44783(); void internalTransition(); void conflictingTransition(); + void conflictingTransition2(); void qtbug_46059(); void qtbug_46703(); }; @@ -6448,6 +6449,71 @@ void tst_QStateMachine::conflictingTransition() QVERIFY(machine.isRunning()); } +void tst_QStateMachine::conflictingTransition2() +{ + SignalEmitter emitter; + + QStateMachine machine; + QState s0(&machine); + QState p0(QState::ParallelStates, &s0); + QState p0s1(&p0); + QState p0s2(&p0); + QState p0s3(&p0); + QState s1(&machine); + + machine.setInitialState(&s0); + s0.setInitialState(&p0); + + QSignalTransition *t1 = new QSignalTransition(&emitter, SIGNAL(signalWithNoArg())); + p0s1.addTransition(t1); + QSignalTransition *t2 = p0s2.addTransition(&emitter, SIGNAL(signalWithNoArg()), &p0s1); + QSignalTransition *t3 = p0s3.addTransition(&emitter, SIGNAL(signalWithNoArg()), &s1); + QSignalSpy t1Spy(t1, &QAbstractTransition::triggered); + QSignalSpy t2Spy(t2, &QAbstractTransition::triggered); + QSignalSpy t3Spy(t3, &QAbstractTransition::triggered); + QVERIFY(t1Spy.isValid()); + QVERIFY(t2Spy.isValid()); + QVERIFY(t3Spy.isValid()); + + s0.setObjectName("s0"); + p0.setObjectName("p0"); + p0s1.setObjectName("p0s1"); + p0s2.setObjectName("p0s2"); + p0s3.setObjectName("p0s3"); + s1.setObjectName("s1"); + t1->setObjectName("p0s1->p0s1"); + t2->setObjectName("p0s2->p0s1"); + t3->setObjectName("p0s3->s1"); + + machine.start(); + + QTRY_COMPARE(machine.configuration().contains(&s0), true); + QTRY_COMPARE(machine.configuration().contains(&p0), true); + QTRY_COMPARE(machine.configuration().contains(&p0s1), true); + QTRY_COMPARE(machine.configuration().contains(&p0s2), true); + QTRY_COMPARE(machine.configuration().contains(&p0s3), true); + QTRY_COMPARE(machine.configuration().contains(&s1), false); + + QCOMPARE(t1Spy.count(), 0); + QCOMPARE(t2Spy.count(), 0); + QCOMPARE(t3Spy.count(), 0); + + emitter.emitSignalWithNoArg(); + + QTRY_COMPARE(machine.configuration().contains(&s0), true); + QTRY_COMPARE(machine.configuration().contains(&p0), true); + QTRY_COMPARE(machine.configuration().contains(&p0s1), true); + QTRY_COMPARE(machine.configuration().contains(&p0s2), true); + QTRY_COMPARE(machine.configuration().contains(&p0s3), true); + QTRY_COMPARE(machine.configuration().contains(&s1), false); + + QCOMPARE(t1Spy.count(), 1); + QCOMPARE(t2Spy.count(), 1); + QCOMPARE(t3Spy.count(), 0); // t3 got preempted by t2 + + QVERIFY(machine.isRunning()); +} + void tst_QStateMachine::qtbug_46059() { QStateMachine machine; -- cgit v1.2.3 From 25717bedfbd29191c8722fd96641fbd24d17e171 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 29 Oct 2015 13:23:02 +0100 Subject: tst_qudpsocket::multicast - blacklist several combinations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Different multicast tests fail on different platforms for different reasons. Blacklist them to get rid of insignificant and later fix/un-blacklist. Change-Id: I91548366c7666478ea1cc446bbf337becfdefd49 Task-number: QTBUG-46612 Reviewed-by: Tony Sarajärvi --- tests/auto/network/socket/qudpsocket/BLACKLIST | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/auto/network/socket/qudpsocket/BLACKLIST (limited to 'tests') diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST new file mode 100644 index 0000000000..3e936aebf6 --- /dev/null +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -0,0 +1,8 @@ +[multicast:same bind, group ipv6 address] +* +[multicast:valid bind, group ipv6 address] +osx +[multicast:dual bind, group ipv6 address] +osx +[multicast:same bind, group ipv4 address] +osx -- cgit v1.2.3 From ada4b4aaa5ccb9a41a42eb2b4f8f0e7625e8ef9c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 27 Oct 2015 12:23:42 +0100 Subject: Attach all signal spies before setting the watcher's future. Attaching spies afterwards was provoking a warning during tests: QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race Change-Id: I6ee8c3613cecebd1c69b0337139d8a19a33f4a11 Reviewed-by: Marc Mutz --- .../thread/qfuturewatcher/tst_qfuturewatcher.cpp | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index 5ec32b1d02..f64d92dcdb 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -313,10 +313,16 @@ void tst_QFutureWatcher::futureSignals() // (QSignalSpy does not trigger it.) connect(&f, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); a.reportStarted(); - f.setFuture(a.future()); QSignalSpy progressSpy(&f, &QFutureWatcher::progressValueChanged); + QSignalSpy finishedSpy(&f, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(&f, &QFutureWatcher::resultReadyAt); + QVERIFY(progressSpy.isValid()); + QVERIFY(finishedSpy.isValid()); + QVERIFY(resultReadySpy.isValid()); + f.setFuture(a.future()); + const int progress = 1; a.setProgressValue(progress); QTest::qWait(10); @@ -324,12 +330,6 @@ void tst_QFutureWatcher::futureSignals() QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); - QSignalSpy finishedSpy(&f, &QFutureWatcher::finished); - QSignalSpy resultReadySpy(&f, &QFutureWatcher::resultReadyAt); - - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - const int result = 10; a.reportResult(&result); QTest::qWait(10); @@ -427,16 +427,15 @@ void tst_QFutureWatcher::disconnectRunningFuture() QFuture f = a.future(); QFutureWatcher *watcher = new QFutureWatcher(); - watcher->setFuture(f); - - SignalSlotObject object; - connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy finishedSpy(watcher, &QFutureWatcher::finished); QSignalSpy resultReadySpy(watcher, &QFutureWatcher::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); + watcher->setFuture(f); + + SignalSlotObject object; + connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); const int result = 10; a.reportResult(&result); -- cgit v1.2.3 From ab1a5f10039429e9114cd905716b31bbec601d60 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 27 Oct 2015 12:02:54 +0100 Subject: Fix pauseEvents() test to test what should be true, not what is. If the future is finished when a watcher starts watching it, it is perfectly reasonable for the watcher to get the finished message promptly. If you pause the watcher before any message loops get to run, the message presently won't get through until the watcher is resumed, but there is no reason to guarantee that; indeed, one could consider it somewhat perverse behavior. So move the reportFinished() calls to after the pause()s. Also eliminate a used-once local variable and use QTRY_VERIFY() in one place where qWait() was used before. Change-Id: I4bc6091fd7437a4d341be511b7a140f3d72d850e Reviewed-by: Marc Mutz --- .../thread/qfuturewatcher/tst_qfuturewatcher.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index f64d92dcdb..c4fad93e4b 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -677,11 +677,6 @@ void tst_QFutureWatcher::pauseEvents() QFutureInterface iface; iface.reportStarted(); - QFuture a = iface.future(); - - int value = 0; - iface.reportFinished(&value); - QFutureWatcher watcher; SignalSlotObject object; @@ -689,14 +684,17 @@ void tst_QFutureWatcher::pauseEvents() QSignalSpy resultReadySpy(&watcher, &QFutureWatcher::resultReadyAt); QVERIFY(resultReadySpy.isValid()); - watcher.setFuture(a); + watcher.setFuture(iface.future()); watcher.pause(); + int value = 0; + iface.reportFinished(&value); + QTest::qWait(10); QCOMPARE(resultReadySpy.count(), 0); watcher.resume(); - QTest::qWait(10); + QTRY_VERIFY2(!resultReadySpy.isEmpty(), "Result didn't arrive"); QCOMPARE(resultReadySpy.count(), 1); } { @@ -705,9 +703,6 @@ void tst_QFutureWatcher::pauseEvents() QFuture a = iface.future(); - int value = 0; - iface.reportFinished(&value); - QFutureWatcher watcher; SignalSlotObject object; @@ -718,6 +713,9 @@ void tst_QFutureWatcher::pauseEvents() watcher.setFuture(a); a.pause(); + int value = 0; + iface.reportFinished(&value); + QFuture b; watcher.setFuture(b); // If we watch b instead, resuming a a.resume(); // should give us no results. -- cgit v1.2.3 From dfaffcbf2a20cd7ff781de88ac3e73d9f17d1cdf Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 30 Oct 2015 15:09:55 +0100 Subject: QWindowsPipeReader: fix occasional "Unknown error 995" After canceling the asynchronous read operation, the notified() slot receives ERROR_OPERATION_ABORTED. We must not handle this situation as an error. This amends commit 5ce567c5. Task-number: QTBUG-48336 Change-Id: Iff948ceb3ad1f805a9de8c188fbc39ed4c76ba82 Reviewed-by: Oswald Buddenhagen --- .../socket/qlocalsocket/tst_qlocalsocket.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 4881d86937..9130aff4e2 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -98,6 +98,7 @@ private slots: void removeServer(); void recycleServer(); + void recycleClientSocket(); void multiConnect(); void writeOnlySocket(); @@ -954,6 +955,34 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::recycleClientSocket() +{ + const QByteArrayList lines = QByteArrayList() << "Have you heard of that new band" + << "\"1023 Megabytes\"?" + << "They haven't made it to a gig yet."; + QLocalServer server; + const QString serverName = QStringLiteral("recycleClientSocket"); + QVERIFY(server.listen(serverName)); + QLocalSocket client; + QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead())); + QSignalSpy clientErrorSpy(&client, SIGNAL(error(QLocalSocket::LocalSocketError))); + for (int i = 0; i < lines.count(); ++i) { + client.abort(); + clientReadyReadSpy.clear(); + client.connectToServer(serverName); + QVERIFY(client.waitForConnected()); + QVERIFY(server.waitForNewConnection()); + QLocalSocket *serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + connect(serverSocket, &QLocalSocket::disconnected, &QLocalSocket::deleteLater); + serverSocket->write(lines.at(i)); + serverSocket->flush(); + QVERIFY(clientReadyReadSpy.wait()); + QCOMPARE(client.readAll(), lines.at(i)); + QVERIFY(clientErrorSpy.isEmpty()); + } +} + void tst_QLocalSocket::multiConnect() { QLocalServer server; -- cgit v1.2.3 From 358715acc987c84316dd95a9567e37f99a44b302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 3 Nov 2015 13:12:19 +0100 Subject: Fix build with Xcode 7.1 toolchain Change-Id: Iab8111e4d3fd7ce68aae35eb6c0b600262ba3f10 Reviewed-by: Simon Hausmann --- tests/auto/other/macgui/guitest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/other/macgui/guitest.cpp b/tests/auto/other/macgui/guitest.cpp index 1ddd0ca870..dee7ace1b9 100644 --- a/tests/auto/other/macgui/guitest.cpp +++ b/tests/auto/other/macgui/guitest.cpp @@ -145,7 +145,9 @@ namespace NativeEvents { CGEventType mouseDownType = (buttons & Qt::LeftButton) ? kCGEventLeftMouseDown : (buttons & Qt::RightButton) ? kCGEventRightMouseDown : kCGEventOtherMouseDown; - CGMouseButton mouseButton = mouseDownType == kCGEventOtherMouseDown ? kCGMouseButtonCenter : kCGEventLeftMouseDown; + // The mouseButton argument to CGEventCreateMouseEvent() is ignored unless the type + // is kCGEventOtherMouseDown, so defaulting to kCGMouseButtonLeft is fine. + CGMouseButton mouseButton = mouseDownType == kCGEventOtherMouseDown ? kCGMouseButtonCenter : kCGMouseButtonLeft; CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, mouseDownType, position, mouseButton); CGEventPost(kCGHIDEventTap, mouseEvent); -- cgit v1.2.3 From b825c702ac6111b1bedc8fcebee53b6aab289a67 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 2 Nov 2015 21:30:07 +0100 Subject: Blacklist tst_QPrinter::doubleSidedPrinting for msvc 2013 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test keeps on failing on Windows 8 with 32 bit. Let's add the platform despite this one test failing. Change-Id: Id6a2b3e0b587d3cff29d1f616d5edacfcf68746d Reviewed-by: Jędrzej Nowacki --- tests/auto/printsupport/kernel/qprinter/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/printsupport/kernel/qprinter/BLACKLIST (limited to 'tests') diff --git a/tests/auto/printsupport/kernel/qprinter/BLACKLIST b/tests/auto/printsupport/kernel/qprinter/BLACKLIST new file mode 100644 index 0000000000..250a18787c --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinter/BLACKLIST @@ -0,0 +1,3 @@ +[doubleSidedPrinting] +windows 32bit msvc-2013 + -- cgit v1.2.3 From 99d1969284dba08c68a5153a64b17aa160afd51f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 Nov 2015 16:42:21 +0100 Subject: tests: remove use of obsolete QStyleOption*V They are obsolete since Qt 5.0. Change-Id: Iefe47684526832def8fc5be5a170817059dcc530 Reviewed-by: Jake Petroules --- .../widgets/itemviews/qlistview/tst_qlistview.cpp | 3 +-- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 19 +++++++++---------- .../widgets/styles/qstyleoption/tst_qstyleoption.cpp | 16 ---------------- .../styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 4 ++-- .../widgets/widgets/qprogressbar/tst_qprogressbar.cpp | 2 +- 5 files changed, 13 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index d94a3c8bca..5b206af357 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -2020,8 +2020,7 @@ void tst_QListView::styleOptionViewItem() public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QVERIFY(qstyleoption_cast(&option)); - QStyleOptionViewItemV4 opt(option); + QStyleOptionViewItem opt(option); initStyleOption(&opt, index); QCOMPARE(opt.index, index); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 6d5f5a1c60..033464c9db 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -3075,7 +3075,7 @@ void tst_QTreeView::styleOptionViewItem() { class MyDelegate : public QStyledItemDelegate { - static QString posToString(QStyleOptionViewItemV4::ViewItemPosition pos) { + static QString posToString(QStyleOptionViewItem::ViewItemPosition pos) { static const char* s_pos[] = { "Invalid", "Beginning", "Middle", "End", "OnlyOne" }; return s_pos[pos]; } @@ -3088,8 +3088,7 @@ void tst_QTreeView::styleOptionViewItem() void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { - QVERIFY(qstyleoption_cast(&option)); - QStyleOptionViewItemV4 opt(option); + QStyleOptionViewItem opt(option); initStyleOption(&opt, index); QVERIFY(!opt.text.isEmpty()); @@ -3097,20 +3096,20 @@ void tst_QTreeView::styleOptionViewItem() //qDebug() << index << opt.text; if (allCollapsed) - QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2)); - QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable")); + QCOMPARE(!(opt.features & QStyleOptionViewItem::Alternate), !(index.row() % 2)); + QCOMPARE(!(opt.features & QStyleOptionViewItem::HasCheckIndicator), !opt.text.contains("Checkable")); if (opt.text.contains("Beginning")) - QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::Beginning)); + QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::Beginning)); if (opt.text.contains("Middle")) - QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::Middle)); + QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::Middle)); if (opt.text.contains("End")) - QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::End)); + QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::End)); if (opt.text.contains("OnlyOne")) - QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::OnlyOne)); + QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::OnlyOne)); if (opt.text.contains("Checked")) QCOMPARE(opt.checkState, Qt::Checked); @@ -4192,7 +4191,7 @@ void tst_QTreeView::taskQTBUG_25333_adjustViewOptionsForIndex() #ifdef QT_BUILD_INTERNAL { - QStyleOptionViewItemV4 option; + QStyleOptionViewItem option; view.aiv_priv()->adjustViewOptionsForIndex(&option, model.indexFromItem(item1)); diff --git a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp index 3c1d4c589b..2e26ba609b 100644 --- a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp +++ b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp @@ -43,7 +43,6 @@ class tst_QStyleOption: public QObject private slots: void qstyleoptioncast_data(); void qstyleoptioncast(); - void copyconstructors(); }; // Just a simple container for QStyleOption-pointer @@ -133,21 +132,6 @@ void tst_QStyleOption::qstyleoptioncast() delete testOption; } -void tst_QStyleOption::copyconstructors() -{ - QStyleOptionFrame frame; - QStyleOptionFrameV2 frame2(frame); - QCOMPARE(frame2.version, int(QStyleOptionFrameV2::Version)); - frame2 = frame; - QCOMPARE(frame2.version, int(QStyleOptionFrameV2::Version)); - - QStyleOptionProgressBar bar; - QStyleOptionProgressBarV2 bar2(bar); - QCOMPARE(bar2.version, int(QStyleOptionProgressBarV2::Version)); - bar2 = bar; - QCOMPARE(bar2.version, int(QStyleOptionProgressBarV2::Version)); -} - QTEST_MAIN(tst_QStyleOption) #include "tst_qstyleoption.moc" diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index a511e91e2c..a360803c50 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1301,9 +1301,9 @@ void tst_QStyleSheetStyle::proxyStyle() QTest::qWait(100); // Test for QTBUG-7198 - style sheet overrides custom element size - QStyleOptionViewItemV4 opt; + QStyleOptionViewItem opt; opt.initFrom(w); - opt.features |= QStyleOptionViewItemV2::HasCheckIndicator; + opt.features |= QStyleOptionViewItem::HasCheckIndicator; QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, pb5).width() == 3); delete w; diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index 4a5f9d535b..5455ebb830 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -267,7 +267,7 @@ void tst_QProgressBar::sizeHint() //test if the sizeHint is big enough QFontMetrics fm = bar.fontMetrics(); - QStyleOptionProgressBarV2 opt; + QStyleOptionProgressBar opt; bar.initStyleOption(&opt); QSize size = QSize(9 * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8); size= bar.style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, &bar); -- cgit v1.2.3 From dbb013d98429f9eed399392da979e42759875db3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 3 Nov 2015 13:54:19 +0100 Subject: QDockAreaLayoutInfo::updateTabBar(): Save and restore current index. When rebuilding the tab bar after hiding several dock widgets, the index gets offset. Task-number: QTBUG-49045 Change-Id: I05f6a976ca1d8c6f7cdf6532f1a728483398eabc Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../widgets/qdockwidget/tst_qdockwidget.cpp | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 82832bced1..70df31ed69 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include "private/qdockwidget_p.h" @@ -68,6 +69,7 @@ private slots: void allowedAreas(); void toggleViewAction(); void visibilityChanged(); + void updateTabBarOnVisibilityChanged(); void dockLocationChanged(); void setTitleBarWidget(); void titleBarDoubleClick(); @@ -586,6 +588,44 @@ void tst_QDockWidget::visibilityChanged() QCOMPARE(spy.at(0).at(0).toBool(), true); } +void tst_QDockWidget::updateTabBarOnVisibilityChanged() +{ + // QTBUG49045: Populate tabified dock area with 4 widgets, set the tab + // index to 2 (dw2), hide dw0, dw1 and check that the tab index is 0 (dw3). + QMainWindow mw; + mw.setMinimumSize(400, 400); + mw.setWindowTitle(QTest::currentTestFunction()); + QDockWidget *dw0 = new QDockWidget("d1", &mw); + dw0->setAllowedAreas(Qt::LeftDockWidgetArea); + mw.addDockWidget(Qt::LeftDockWidgetArea, dw0); + QDockWidget *dw1 = new QDockWidget("d2", &mw); + dw1->setAllowedAreas(Qt::LeftDockWidgetArea); + mw.addDockWidget(Qt::LeftDockWidgetArea, dw1); + QDockWidget *dw2 = new QDockWidget("d3", &mw); + dw2->setAllowedAreas(Qt::LeftDockWidgetArea); + mw.addDockWidget(Qt::LeftDockWidgetArea, dw2); + QDockWidget *dw3 = new QDockWidget("d4", &mw); + dw3->setAllowedAreas(Qt::LeftDockWidgetArea); + mw.addDockWidget(Qt::LeftDockWidgetArea, dw3); + mw.tabifyDockWidget(dw0, dw1); + mw.tabifyDockWidget(dw1, dw2); + mw.tabifyDockWidget(dw2, dw3); + + QTabBar *tabBar = mw.findChild(); + QVERIFY(tabBar); + tabBar->setCurrentIndex(2); + + mw.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); + + QCOMPARE(tabBar->currentIndex(), 2); + + dw0->hide(); + dw1->hide(); + QTRY_COMPARE(tabBar->count(), 2); + QCOMPARE(tabBar->currentIndex(), 0); +} + Q_DECLARE_METATYPE(Qt::DockWidgetArea) void tst_QDockWidget::dockLocationChanged() -- cgit v1.2.3 From 3dbdc367ffa50b1482d037c956336c809e53a0e6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Nov 2015 09:27:21 +0100 Subject: Suppress the modal window handling for dialogs embedded into QGraphicsView. A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen set (similar to a native dialog). It must not trigger the modal handling though as not to lock up. Task-number: QTBUG-49124 Change-Id: I22ce3f18d01df017b9317666770686bd4491387f Reviewed-by: Andreas Aardal Hanssen --- tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 2982d80477..d5769554be 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include #include @@ -80,6 +82,7 @@ private slots: void snapToDefaultButton(); void transientParent_data(); void transientParent(); + void dialogInGraphicsView(); private: QDialog *testWidget; @@ -118,9 +121,11 @@ public: class ToolDialog : public QDialog { public: - ToolDialog(QWidget *parent = 0) : QDialog(parent, Qt::Tool), mWasActive(false), tId(-1) { - } + ToolDialog(QWidget *parent = 0) + : QDialog(parent, Qt::Tool), mWasActive(false), mWasModalWindow(false), tId(-1) {} + bool wasActive() const { return mWasActive; } + bool wasModalWindow() const { return mWasModalWindow; } int exec() { tId = startTimer(300); @@ -131,12 +136,14 @@ protected: if (tId == event->timerId()) { killTimer(tId); mWasActive = isActiveWindow(); + mWasModalWindow = QGuiApplication::modalWindow() == windowHandle(); reject(); } } private: int mWasActive; + bool mWasModalWindow; int tId; }; @@ -616,5 +623,27 @@ void tst_QDialog::transientParent() QCOMPARE(dialog.windowHandle()->transientParent(), topLevel.windowHandle()); } +void tst_QDialog::dialogInGraphicsView() +{ + // QTBUG-49124: A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen + // set (as has a native dialog). It must not trigger the modal handling though + // as not to lock up. + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + view.resize(availableGeometry.size() / 2); + view.move(availableGeometry.left() + availableGeometry.width() / 4, + availableGeometry.top() + availableGeometry.height() / 4); + ToolDialog *dialog = new ToolDialog; + scene.addWidget(dialog); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + for (int i = 0; i < 3; ++i) { + dialog->exec(); + QVERIFY(!dialog->wasModalWindow()); + } +} + QTEST_MAIN(tst_QDialog) #include "tst_qdialog.moc" -- cgit v1.2.3