diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-24 13:41:17 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2016-10-25 09:00:17 +0000 |
commit | 6f6e073815d5b05aba553b83809fb701541260c6 (patch) | |
tree | 3e6b3cd911d807f42ad23c31290e023b67f815cf /tests/auto/popup/tst_popup.cpp | |
parent | 6f076d71e45ffc318169454035297b2882d2a63b (diff) |
Fix popups to close on click outsidev5.7.1
When a popup closes itself on press outside, it accepts the press
event so that it doesn't propagate to other popups or the content
below. We must make sure that such closing popup does not become
the mouse grabber, because it doesn't make sense to route the
subsequent mouse events to the popup that was just closed.
Change-Id: I80c6e26a1d94aa1526a61862f00af2fd0778aa82
Task-number: QTBUG-56697
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/popup/tst_popup.cpp')
-rw-r--r-- | tests/auto/popup/tst_popup.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp index af6ccf34..fbd0605b 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -71,6 +71,7 @@ private slots: void wheel(); void parentDestroyed(); void nested(); + void grabber(); }; void tst_popup::visible_data() @@ -669,6 +670,57 @@ void tst_popup::nested() QCOMPARE(modalPopup->isVisible(), true); } +// QTBUG-56697 +void tst_popup::grabber() +{ + QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *menu = window->property("menu").value<QQuickPopup *>(); + QVERIFY(menu); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup *>(); + QVERIFY(popup); + + QQuickPopup *combo = window->property("combo").value<QQuickPopup *>(); + QVERIFY(combo); + + menu->open(); + QCOMPARE(menu->isVisible(), true); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + // click a menu item to open the popup + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->width() / 2, menu->height() / 2)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), true); + QCOMPARE(combo->isVisible(), false); + + combo->open(); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), true); + QCOMPARE(combo->isVisible(), true); + + // click outside to close both the combo popup and the parent popup + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + menu->open(); + QCOMPARE(menu->isVisible(), true); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + // click outside the menu to close it (QTBUG-56697) + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); +} + QTEST_MAIN(tst_popup) #include "tst_popup.moc" |