From 35bb55cd122bf1aba391aee157869dc68269c157 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 9 Aug 2017 11:32:07 +0200 Subject: Itemviews: Set the WA_InputMethodEnabled attribute correctly When focus is put back onto an itemview and the current item is editable then the WA_InputMethodEnabled attribute should be set. Likewise this should be set/unset when the current index changes too, depending on whether the index is editable or not. Change-Id: Iaea075e669efd21bdaa89a49c500c449272d098b Reviewed-by: Richard Moe Gustavsen --- .../qabstractitemview/tst_qabstractitemview.cpp | 106 +++++++++++++++++++++ 1 file changed, 106 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 83912fa2c3..2234b2b488 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -55,6 +55,8 @@ #include #include +Q_DECLARE_METATYPE(Qt::ItemFlags); + static inline void setFrameless(QWidget *w) { Qt::WindowFlags flags = w->windowFlags(); @@ -154,6 +156,8 @@ private slots: void testDialogAsEditor(); void QTBUG46785_mouseout_hover_state(); void testClearModelInClickedSignal(); + void inputMethodEnabled_data(); + void inputMethodEnabled(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -2291,5 +2295,107 @@ void tst_QAbstractItemView::testClearModelInClickedSignal() QCOMPARE(view.model(), nullptr); } +void tst_QAbstractItemView::inputMethodEnabled_data() +{ + QTest::addColumn("viewType"); + QTest::addColumn("itemFlags"); + QTest::addColumn("result"); + + QList widgets; + widgets << "QListView" << "QTreeView" << "QTableView"; + + for (const QByteArray &widget : qAsConst(widgets)) { + QTest::newRow(widget + ": no flags") << widget << Qt::ItemFlags(Qt::NoItemFlags) << false; + QTest::newRow(widget + ": checkable") << widget << Qt::ItemFlags(Qt::ItemIsUserCheckable) << false; + QTest::newRow(widget + ": selectable") << widget << Qt::ItemFlags(Qt::ItemIsSelectable) << false; + QTest::newRow(widget + ": enabled") << widget << Qt::ItemFlags(Qt::ItemIsEnabled) << false; + QTest::newRow(widget + ": selectable|enabled") + << widget << Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled) << false; + QTest::newRow(widget + ": editable|enabled") + << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled) << true; + QTest::newRow(widget + ": editable|enabled|selectable") + << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable) << true; + } +} + +void tst_QAbstractItemView::inputMethodEnabled() +{ + QFETCH(QByteArray, viewType); + QFETCH(Qt::ItemFlags, itemFlags); + QFETCH(bool, result); + + QScopedPointer view; + if (viewType == "QListView") + view.reset(new QListView()); + else if (viewType == "QTableView") + view.reset(new QTableView()); + else if (viewType == "QTreeView") + view.reset(new QTreeView()); + else + QVERIFY(0); + + centerOnScreen(view.data()); + view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); + + QStandardItemModel *model = new QStandardItemModel(view.data()); + QStandardItem *item = new QStandardItem("first item"); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + model->appendRow(item); + + QStandardItem *secondItem = new QStandardItem("test item"); + secondItem->setFlags(Qt::ItemFlags(itemFlags)); + model->appendRow(secondItem); + + view->setModel(model); + + // Check current changed + view->setCurrentIndex(model->index(0, 0)); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + view->setCurrentIndex(model->index(1, 0)); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + view->setCurrentIndex(model->index(0, 0)); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + + // Check focus by switching the activation of the window to force a focus in + view->setCurrentIndex(model->index(1, 0)); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + + view->setCurrentIndex(QModelIndex()); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QModelIndex index = model->index(1, 0); + QPoint p = view->visualRect(index).center(); + QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p); + if (itemFlags & Qt::ItemIsEnabled) + QCOMPARE(view->currentIndex(), index); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); + + index = model->index(0, 0); + QApplication::setActiveWindow(0); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + p = view->visualRect(index).center(); + QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p); + QCOMPARE(view->currentIndex(), index); + QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled)); + + // There is a case when it goes to the first visible item so we + // make the flags of the first item match the ones we are testing + // to check the attribute correctly + QApplication::setActiveWindow(0); + view->setCurrentIndex(QModelIndex()); + view->reset(); + item->setFlags(Qt::ItemFlags(itemFlags)); + QApplication::setActiveWindow(view.data()); + QVERIFY(QTest::qWaitForWindowActive(view.data())); + QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" -- cgit v1.2.3 From bbaedb9744810fe75d3254da5a51be6f49c23b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Wed, 13 Sep 2017 10:15:37 +0300 Subject: Blacklist flaky QItemDelegate tests in openSUSE 42.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-62967 Change-Id: I05cbf06f068701ee16b54e7052e02becc0c47702 Reviewed-by: Jędrzej Nowacki --- tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST index 0d658dcfb6..cd9d206f00 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST +++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST @@ -1,4 +1,2 @@ -[enterKey:plaintextedit tab] -opensuse-42.3 -[enterKey:plaintextedit backtab] -opensuse-42.3 +[enterKey] +opensuse-42.3 ci -- cgit v1.2.3 From 30a6557eb0922787b6879404e1c3bc2756b49702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Mon, 18 Sep 2017 15:49:25 +0300 Subject: Blacklist tst_QItemDelegate::testLineEditValidation in openSUSE 42.3 This autotest is blacklisted as it is deemed flaky. Task-number: QTBUG-63262 Change-Id: I216985e81d1c1cb3528fd8a005be48cad2a31ab7 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST index cd9d206f00..fea108f3fd 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST +++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST @@ -1,2 +1,4 @@ [enterKey] opensuse-42.3 ci +[testLineEditValidation] +opensuse-42.3 ci -- cgit v1.2.3 From e0c2d328b11ab893538393fad66ad61d22d823c6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 20 Sep 2017 10:28:48 +0200 Subject: Fix #if-ery and accompanying comment The comment was back-to-front on the meaning it needed to address; and the #if-ery used a deprecated define, now changed to match what sanity-bot asked for. Change-Id: I0a971ab2e405e5908066da86964d67c8b852f114 Reviewed-by: Timur Pocheptsov --- .../network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 01566d795d..7fef603003 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -368,8 +368,8 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QFETCH(QString, hostName); QFETCH(int, port); -// The generic system proxy is only available on the following platforms -#if (!defined Q_OS_WIN) && (!defined Q_OS_OSX) && !QT_CONFIG(libproxy) +// We can only use the generic system proxy where available: +#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && !QT_CONFIG(libproxy) qputenv(envVar, url); const QList systemProxy = QNetworkProxyFactory::systemProxyForQuery(); QCOMPARE(systemProxy.size(), 1); -- cgit v1.2.3 From 92ca09147fc239762927595165f71a0d1ecff98f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Sep 2017 19:20:46 -0700 Subject: Restore compatibility with pre-5.9 Keccak calculation Commit 12c5264d9add1826d543c36d893db77262195fc6 fixed the calculation of SHA-3 in QCryptographicHash: we were previously calculating Keccak. Unfortunately, turns out that replacing the algorithm wasn't the best idea: there are people who need to compare with the result obtained from a previous version of Qt and stored somewhere. This commit restores the enum values 7 through 10 to mean Keccak and moves SHA-3 to 12 through 15. The "Sha3_nnn" enums will switch between the two according to the QT_SHA3_KECCAK_COMPAT macro. [ChangeLog][Important Behavior Changes] This version of Qt restores compatibility with pre-5.9.0 calculation of QCryptographicHash algorithms that were labelled "Sha3_nnn": that is, applications compiled with old versions of Qt will continue using the Keccak algorithm. Applications recompiled with this version will use SHA-3, unless QT_SHA3_KECCAK_COMPAT is #define'd prior to #include . [ChangeLog][Binary Compatibility Note] This version of Qt changes the values assigned to enumerations QCryptographicHash::Sha3_nnn. Applications compiled with this version and using those enumerations will not work with Qt 5.9.0 and 5.9.1, unless QT_SHA3_KECCAK_COMPAT is defined. Task-number: QTBUG-62025 Discussed-at: http://lists.qt-project.org/pipermail/development/2017-September/030818.html Change-Id: I6e1fe42ae4b742a7b811fffd14e418fc04f096c3 Reviewed-by: Lars Knoll --- tests/benchmarks/corelib/tools/qcryptographichash/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp index 5799b32b1c..507e2af708 100644 --- a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp +++ b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp @@ -79,6 +79,14 @@ const char *algoname(int i) return "sha3_384-"; case QCryptographicHash::Sha3_512: return "sha3_512-"; + case QCryptographicHash::Keccak_224: + return "keccak_224-"; + case QCryptographicHash::Keccak_256: + return "keccak_256-"; + case QCryptographicHash::Keccak_384: + return "keccak_384-"; + case QCryptographicHash::Keccak_512: + return "keccak_512-"; } Q_UNREACHABLE(); return 0; -- cgit v1.2.3 From 4c025ca9c73bda320f0e7577a4fbd141c31d7c8c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 28 Aug 2017 10:04:35 +0700 Subject: QCompleter: Send activated() signal only once on return key Due to the complex event forwarding logic between QCompleter, QComboBox, QLineEdit and QWidgetLineControl, in some cases the same single user return key press could result in duplicated activated() signals being emitted by QComboBox. The first one would be emitted because QLineEdit emitted editingFinished() as a result of QCompleter::eventFilter() having forwarded the return key press event to QComboBox. The second one, would happen right after, as QCompleter::eventFilter() would process the same event on behalf of its popup. (We recall that QCompleter is installed as its own popup event filter. That's also the case for the completer's widget, although the purpose there is limited to focus-out events). The current fix consists on skipping the emit as a result of QLineEdit::editingFinished() if the completer's popup is still active. For this to be accurate, it helps to test whether the completer's popup is visible, so we will not be hiding it in QWidgetLineControl::processKeyEvent() anymore. Indeed, we know that if the popup is visible, that means that processKeyEvent() was called after being forwarded by the completer's popup event filter. Furthermore, the popup will be hidden by its event filter shortly after it returns from said event forwarding call. Based on a patch by Alexey Chernov <4ernov@gmail.com>. Task-number: QTBUG-51858 Task-number: QTBUG-51889 Change-Id: I013f6c3000ae37b5b0ec20eaf5cf7746c9c903e3 Reviewed-by: Richard Moe Gustavsen --- .../widgets/util/qcompleter/tst_qcompleter.cpp | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index f8095badb8..3818b83584 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -143,6 +143,8 @@ private slots: void task253125_lineEditCompletion(); void task247560_keyboardNavigation(); void QTBUG_14292_filesystem(); + void QTBUG_52028_tabAutoCompletes(); + void QTBUG_51889_activatedSentTwice(); private: void filter(bool assync = false); @@ -1742,5 +1744,108 @@ void tst_QCompleter::QTBUG_14292_filesystem() QVERIFY(!comp.popup()->isVisible()); } +void tst_QCompleter::QTBUG_52028_tabAutoCompletes() +{ + QStringList words; + words << "foobar1" << "foobar2" << "hux"; + + QWidget w; + w.setLayout(new QVBoxLayout); + + QComboBox cbox; + cbox.setEditable(true); + cbox.setInsertPolicy(QComboBox::NoInsert); + cbox.addItems(words); + + cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); + cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); + + w.layout()->addWidget(&cbox); + + // Adding a line edit is a good reason for tab to do something unrelated + QLineEdit le; + w.layout()->addWidget(&le); + + const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + w.move(pos); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QSignalSpy activatedSpy(&cbox, QOverload::of(&QComboBox::activated)); + + // Tab key will complete but not activate + cbox.lineEdit()->clear(); + QTest::keyClick(&cbox, Qt::Key_H); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Tab); + QCOMPARE(cbox.completer()->currentCompletion(), QLatin1String("hux")); + QCOMPARE(activatedSpy.count(), 0); + QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort); + QCOMPARE(cbox.currentText(), QLatin1String("hux")); + QCOMPARE(activatedSpy.count(), 0); + QVERIFY(!le.hasFocus()); +} + +void tst_QCompleter::QTBUG_51889_activatedSentTwice() +{ + QStringList words; + words << "foobar1" << "foobar2" << "bar" <<"hux"; + + QWidget w; + w.setLayout(new QVBoxLayout); + + QComboBox cbox; + setFrameless(&cbox); + cbox.setEditable(true); + cbox.setInsertPolicy(QComboBox::NoInsert); + cbox.addItems(words); + + cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive); + cbox.completer()->setCompletionMode(QCompleter::PopupCompletion); + + w.layout()->addWidget(&cbox); + + QLineEdit le; + w.layout()->addWidget(&le); + + const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200); + w.move(pos); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QSignalSpy activatedSpy(&cbox, QOverload::of(&QComboBox::activated)); + + // Navigate + enter activates only once (first item) + cbox.lineEdit()->clear(); + QTest::keyClick(&cbox, Qt::Key_F); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); + + // Navigate + enter activates only once (non-first item) + cbox.lineEdit()->clear(); + activatedSpy.clear(); + QTest::keyClick(&cbox, Qt::Key_H); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); + QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); + + // Full text + enter activates only once + cbox.lineEdit()->clear(); + activatedSpy.clear(); + QTest::keyClicks(&cbox, "foobar1"); + QVERIFY(cbox.completer()->popup()); + QTRY_VERIFY(cbox.completer()->popup()->isVisible()); + QTest::keyClick(&cbox, Qt::Key_Return); + QTRY_COMPARE(activatedSpy.count(), 1); +} + QTEST_MAIN(tst_QCompleter) #include "tst_qcompleter.moc" -- cgit v1.2.3 From 35781b358887facf954307b0d6c5958ce089eb72 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 23 Aug 2017 11:48:11 +0200 Subject: Return focus to correct widget after showing menu By the time we call setKeyboardMode(true), the menu may already have taken focus. This change sets keyboardFocusWidget before opening the popup, and makes sure that keyboardFocusWidget is not set to the popup. (We cannot remove the assignment from setKeyboardMode(), since it's called from several places.) [ChangeLog][QtWidgets] Fixed widget losing focus after showing menu second time. Task-number: QTBUG-56860 Change-Id: Ic01726bf694e6f365dd7b601ad555156e0fdf6c5 Reviewed-by: Richard Moe Gustavsen --- .../auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 9a0ca0565e..251a351cc1 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,7 @@ private slots: void allowActiveAndDisabled(); #endif + void taskQTBUG56860_focus(); void check_endKey(); void check_homeKey(); @@ -710,6 +712,52 @@ void tst_QMenuBar::check_cursorKeys3() } #endif +void tst_QMenuBar::taskQTBUG56860_focus() +{ +#if defined(Q_OS_DARWIN) + QSKIP("Native key events are needed to test menu action activation on macOS."); +#endif + QMainWindow w; + QMenuBar *mb = w.menuBar(); + + if (mb->platformMenuBar()) + QSKIP("This test requires the Qt menubar."); + + QMenu *em = mb->addMenu("&Edit"); + em->setObjectName("EditMenu"); + em->addAction("&Cut"); + em->addAction("C&opy"); + QPlainTextEdit *e = new QPlainTextEdit; + e->setObjectName("edit"); + + w.setCentralWidget(e); + w.show(); + QApplication::setActiveWindow(&w); + QVERIFY(QTest::qWaitForWindowActive(&w)); + + QTRY_COMPARE(QApplication::focusWidget(), e); + + // Open menu + QTest::keyClick(static_cast(0), Qt::Key_E, Qt::AltModifier ); + QTRY_COMPARE(QApplication::activePopupWidget(), em); + // key down to trigger focus + QTest::keyClick(static_cast(0), Qt::Key_Down ); + // and press ENTER to close + QTest::keyClick(static_cast(0), Qt::Key_Enter ); + QTRY_COMPARE(QApplication::activePopupWidget(), nullptr); + // focus should have returned to the editor by now + QTRY_COMPARE(QApplication::focusWidget(), e); + + // Now do it all over again... + QTest::keyClick(static_cast(0), Qt::Key_E, Qt::AltModifier ); + QTRY_COMPARE(QApplication::activePopupWidget(), em); + QTest::keyClick(static_cast(0), Qt::Key_Down ); + QTest::keyClick(static_cast(0), Qt::Key_Enter ); + QTRY_COMPARE(QApplication::activePopupWidget(), nullptr); + QTRY_COMPARE(QApplication::focusWidget(), e); + +} + /*! If a popupmenu is active you can use home to go quickly to the first item in the menu. */ -- cgit v1.2.3 From e96c56c740768143878d9e0f0acc5aa01dd52bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Tue, 26 Sep 2017 14:18:02 +0300 Subject: Blacklist tst_QWindow:testInputEvents on RHEL 7.4 Swapping from RHEL 7.2 to 7.4 produces new autotest failures. Task-number: QTBUG-63433 Change-Id: I3e59aa73b5874cfec06e166f521e06b0c7829743 Reviewed-by: Timur Pocheptsov --- tests/auto/gui/kernel/qwindow/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 1443359377..1a4885b895 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -19,3 +19,5 @@ ubuntu-16.04 osx [modalWindowModallity] osx +[testInputEvents] +rhel-7.4 -- cgit v1.2.3 From ff2e9a17e7583fe18b9ac3527e4aab2a6b395174 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 26 Sep 2017 18:08:25 +0200 Subject: Fix crash when reparenting window container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWindowContainer assumed that a widget could never change from native to non-native. This is not a fact when the window container is reparented to toplevel and back. In this case, usesNativeWidgets would be stuck at true, and parentWasChanged() would go down the native widget path, triggering an assert. The solution is to always recalculate the usesNativeWidgets bool. Task-number: QTBUG-63168 Change-Id: I88178259878ace9eb5de2ee45ff5e69b170da71c Reviewed-by: Laszlo Agocs Reviewed-by: Richard Moe Gustavsen Reviewed-by: Błażej Szczygieł --- .../qwindowcontainer/tst_qwindowcontainer.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 6ec1b754d0..a3e549aa50 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -74,6 +74,7 @@ private slots: void testOwnership(); void testBehindTheScenesDeletion(); void testUnparenting(); + void testUnparentReparent(); void testActivation(); void testAncestorChange(); void testDockWidget(); @@ -241,6 +242,31 @@ void tst_QWindowContainer::testUnparenting() QVERIFY(!window->isVisible()); } +void tst_QWindowContainer::testUnparentReparent() +{ + QWidget root; + + QWindow *window = new QWindow(); + QScopedPointer container(QWidget::createWindowContainer(window, &root)); + container->setWindowTitle(QTest::currentTestFunction()); + container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100); + + root.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&root)); + + QTRY_VERIFY(window->isVisible()); + + container->setParent(nullptr); + QTRY_VERIFY(!window->isVisible()); + + container->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + QTRY_VERIFY(window->isVisible()); + + container->setParent(&root); // This should not crash (QTBUG-63168) +} + void tst_QWindowContainer::testAncestorChange() { QWidget root; -- cgit v1.2.3 From 8b64a1054ab5a428b7fcc4efad3ff31bc55dd7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 28 Sep 2017 10:47:53 +0200 Subject: Fix cookies not being applied on redirect Task-number: QTBUG-63313 Change-Id: I5245fc837557f19062cbbf0f1dfb86353c85229f Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index e995b69f60..542246ff2d 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -487,6 +487,7 @@ private Q_SLOTS: void ioHttpRedirectPolicyErrors(); void ioHttpUserVerifiedRedirect_data(); void ioHttpUserVerifiedRedirect(); + void ioHttpCookiesDuringRedirect(); #ifndef QT_NO_SSL void putWithServerClosingConnectionImmediately(); #endif @@ -8410,6 +8411,33 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); } +void tst_QNetworkReply::ioHttpCookiesDuringRedirect() +{ + MiniHttpServer target(httpEmpty200Response, false); + + const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n"); + QString redirect = tempRedirectReplyStr(); + // Insert 'cookieHeader' before the final \r\n + redirect.insert(redirect.length() - 2, cookieHeader); + + QUrl url("http://localhost/"); + url.setPort(target.serverPort()); + redirect = redirect.arg(url.toString()); + MiniHttpServer redirectServer(redirect.toLatin1(), false); + + url = QUrl("http://localhost/"); + url.setPort(redirectServer.serverPort()); + QNetworkRequest request(url); + auto oldRedirectPolicy = manager.redirectPolicy(); + manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy); + QNetworkReplyPtr reply(manager.get(request)); + // Set policy back to whatever it was + manager.setRedirectPolicy(oldRedirectPolicy); + + QVERIFY(waitForFinish(reply) == Success); + QVERIFY(target.receivedData.contains("\r\nCookie: hello=world\r\n")); +} + #ifndef QT_NO_SSL class PutWithServerClosingConnectionImmediatelyHandler: public QObject -- cgit v1.2.3 From 3faf8f4d48abd982be8470786cc5f61372519722 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 3 Oct 2017 10:31:38 +0200 Subject: tst_QSsl(longlongnamefollows) - fix a flakey auto-test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original test was using QSslSocket::waitForEncrypted function, which is apparently a bad idea on Windows: connecting to 'www.qt.io' we have to verify certs and there is no guarantee a given Windows VM has the required CA certificate ready in its cert store. In such cases we start a background thread (aka CA fetcher's thread) and it calls a (potentially blocking for a significant amount of time) function (CryptoAPI). When finished, this thread reports the results via queued connection, which does not work if we are sitting in a tiny-loop inside waitForEncrypted. Re-factor the test to use signals/slots and a normally running event loop. Also, the last test makes a wrong assumption about Windows - fixed. Task-number: QTBUG-63481 Change-Id: I4abe9cda2a6c52d841ac858cccb6bf068e550cb8 Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- .../tst_qsslsocket_onDemandCertificates_member.cpp | 64 +++++++++++++++------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index b5bfde3cab..25c2701f69 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -168,29 +168,59 @@ void tst_QSslSocket_onDemandCertificates_member::proxyAuthenticationRequired(con #ifndef QT_NO_OPENSSL +static bool waitForEncrypted(QSslSocket *socket) +{ + Q_ASSERT(socket); + + QEventLoop eventLoop; + + QTimer connectionTimeoutWatcher; + connectionTimeoutWatcher.setSingleShot(true); + connectionTimeoutWatcher.connect(&connectionTimeoutWatcher, &QTimer::timeout, + [&eventLoop]() { + eventLoop.exit(); + }); + + bool encrypted = false; + socket->connect(socket, &QSslSocket::encrypted, [&eventLoop, &encrypted](){ + eventLoop.exit(); + encrypted = true; + }); + + socket->connect(socket, QOverload&>::of(&QSslSocket::sslErrors), + [&eventLoop](){ + eventLoop.exit(); + }); + + // Wait for 30 s. maximum - the default timeout in our QSslSocket::waitForEncrypted ... + connectionTimeoutWatcher.start(30000); + eventLoop.exec(); + return encrypted; +} + void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMethods() { - QString host("www.qt.io"); + const QString host("www.qt.io"); // not using any root certs -> should not work QSslSocketPtr socket2 = newSocket(); this->socket = socket2.data(); socket2->setCaCertificates(QList()); socket2->connectToHostEncrypted(host, 443); - QVERIFY(!socket2->waitForEncrypted()); + QVERIFY(!waitForEncrypted(socket2.data())); // default: using on demand loading -> should work QSslSocketPtr socket = newSocket(); this->socket = socket.data(); socket->connectToHostEncrypted(host, 443); - QVERIFY2(socket->waitForEncrypted(), qPrintable(socket->errorString())); + QVERIFY2(waitForEncrypted(socket.data()), qPrintable(socket->errorString())); // not using any root certs again -> should not work QSslSocketPtr socket3 = newSocket(); this->socket = socket3.data(); socket3->setCaCertificates(QList()); socket3->connectToHostEncrypted(host, 443); - QVERIFY(!socket3->waitForEncrypted()); + QVERIFY(!waitForEncrypted(socket3.data())); // setting empty SSL configuration explicitly -> depends on on-demand loading QSslSocketPtr socket4 = newSocket(); @@ -199,24 +229,16 @@ void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMe socket4->setSslConfiguration(conf); socket4->connectToHostEncrypted(host, 443); #ifdef QT_BUILD_INTERNAL - bool rootCertLoadingAllowed = QSslSocketPrivate::rootCertOnDemandLoadingSupported(); -#if defined(Q_OS_LINUX) - QCOMPARE(rootCertLoadingAllowed, true); + const bool works = QSslSocketPrivate::rootCertOnDemandLoadingSupported(); +#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) + QCOMPARE(works, true); #elif defined(Q_OS_MAC) - QCOMPARE(rootCertLoadingAllowed, false); -#endif // other platforms: undecided (Windows: depends on the version) - // when we allow on demand loading, it is enabled by default, - // so on Unix it will work without setting any certificates. Otherwise, - // the configuration contains an empty set of certificates - // and will fail. - bool works; -#if defined (Q_OS_WIN) - works = false; // on Windows, this won't work even though we use on demand loading - Q_UNUSED(rootCertLoadingAllowed) -#else - works = rootCertLoadingAllowed; -#endif - QCOMPARE(socket4->waitForEncrypted(), works); + QCOMPARE(works, false); +#endif // other platforms: undecided. + // When we *allow* on-demand loading, we enable it by default; so, on Unix, + // it will work without setting any certificates. Otherwise, the configuration + // contains an empty set of certificates, so on-demand loading shall fail. + QCOMPARE(waitForEncrypted(socket4.data()), works); #endif // QT_BUILD_INTERNAL } -- cgit v1.2.3