diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-02 13:18:34 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-02 12:48:43 +0000 |
commit | eb7bf1825ede649ae35ebec91ef430686ae2c70a (patch) | |
tree | b05b8f3f98dc2b35b2a34c0214d9f783a7a31df6 /tests/auto/popup/tst_popup.cpp | |
parent | 2069f1cae020113306f150309fb55de1c478ea59 (diff) |
Popup: don't steal focus on close from another opening popup
In the Gallery example, the settings dialog does not get focus (or to
be exact, loses it immediately), because the closing menu incorrectly
transfers focus back to the tool button that opened the menu.
Change-Id: I5328d8e825de9a977619688dc4478e6592db654f
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/popup/tst_popup.cpp')
-rw-r--r-- | tests/auto/popup/tst_popup.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp index 6d1e1e3c..af6ccf34 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -64,6 +64,7 @@ private slots: void closePolicy(); void activeFocusOnClose1(); void activeFocusOnClose2(); + void activeFocusOnClose3(); void hover_data(); void hover(); void wheel_data(); @@ -454,6 +455,38 @@ void tst_popup::activeFocusOnClose2() QVERIFY(popup1->hasActiveFocus()); } +void tst_popup::activeFocusOnClose3() +{ + // Test that a closing popup that had focus doesn't steal focus from + // another popup that the focus was transferred to. + QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup1 = helper.appWindow->property("popup1").value<QQuickPopup*>(); + QVERIFY(popup1); + + QQuickPopup *popup2 = helper.appWindow->property("popup2").value<QQuickPopup*>(); + QVERIFY(popup2); + + popup1->open(); + QVERIFY(popup1->isVisible()); + QTRY_VERIFY(popup1->hasActiveFocus()); + + popup2->open(); + popup1->close(); + + QSignalSpy closedSpy(popup1, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + QVERIFY(closedSpy.wait()); + + QVERIFY(!popup1->isVisible()); + QVERIFY(popup2->isVisible()); + QTRY_VERIFY(popup2->hasActiveFocus()); +} + void tst_popup::hover_data() { QTest::addColumn<QString>("source"); |