diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-02-14 11:47:24 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-02-20 08:58:33 +0000 |
commit | bcbcb8d0d60b94fe9e739a9c95b4e78ac8184a0e (patch) | |
tree | be3bfee2068998236a1a36633120dfe51fbee991 /tests/auto/popup/tst_popup.cpp | |
parent | 751ca5dfb7c3f0edd76110a5dc3a3696d3e0539c (diff) |
QQuickPopup: ensure that the cursor is correct when overlapping items
When a popup is over an item that has a different cursor (such as a
TextField), the cursor incorrectly took on that shape, because
QQuickPopup didn’t have an explicitly set cursor.
Task-number: QTBUG-58810
Change-Id: I4df6dd725cac027b2c30fe69ad81d9cd7e622c15
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 25904003..ab96869a 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -72,6 +72,7 @@ private slots: void parentDestroyed(); void nested(); void grabber(); + void cursorShape(); }; void tst_popup::visible_data() @@ -721,6 +722,38 @@ void tst_popup::grabber() QCOMPARE(combo->isVisible(), false); } +void tst_popup::cursorShape() +{ + // Ensure that the mouse cursor has the correct shape when over a popup + // which is itself over an item with a different shape. + QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>(); + QVERIFY(popup); + + popup->open(); + QVERIFY(popup->isVisible()); + + QQuickItem *textField = helper.appWindow->property("textField").value<QQuickItem*>(); + QVERIFY(textField); + + // Move the mouse over the text field. + const QPoint textFieldPos(popup->x() - 10, popup->y() + popup->height() / 2); + QTest::mouseMove(window, textFieldPos); + QCOMPARE(window->cursor().shape(), textField->cursor().shape()); + + // Move the mouse over the popup where it overlaps with the text field. + const QPoint textFieldOverlapPos(popup->x() + 10, popup->y() + popup->height() / 2); + QTest::mouseMove(window, textFieldOverlapPos); + QCOMPARE(window->cursor().shape(), popup->popupItem()->cursor().shape()); + + popup->close(); + QTRY_VERIFY(!popup->isVisible()); +} + QTEST_MAIN(tst_popup) #include "tst_popup.moc" |