aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-29 12:07:33 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-30 09:08:23 +0200
commitb1493678fc295765ce93e565c5194e860e746436 (patch)
tree33b056e122f20ff2ea8b90be78194649558df9f5 /tests/auto/quick/pointerhandlers
parent71fb4c17a4d58fb558194431a30dd2a9cd9edba1 (diff)
Change the cursor within HoverHandler.margin
The visual cursor feedback was inconsistent with the hovered property when a margin is set. Amends 1c44804600ad3dbeb60d1f5209ce9cf937d30ab3 Pick-to: 5.15 Fixes: QTBUG-85303 Task-number: QTBUG-68073 Change-Id: I25506baecaecbd6450a0e95786f103024b46b1b8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverMargin.qml20
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp51
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverMargin.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverMargin.qml
new file mode 100644
index 0000000000..908b200c36
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverMargin.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.15
+import QtQuick.Window 2.15
+
+Item {
+ visible: true
+ width: 200
+ height: 200
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 50
+ height: 50
+ color: hh.hovered ? "tomato" : "wheat"
+ HoverHandler {
+ id: hh
+ margin: 20
+ cursorShape: Qt.OpenHandCursor
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
index 61f2752dd2..11a5393390 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -61,6 +61,7 @@ private slots:
void mouseAreaAndUnderlyingHoverHandler();
void hoverHandlerAndUnderlyingMouseArea();
void movingItemWithHoverHandler();
+ void margin();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
@@ -312,6 +313,56 @@ void tst_HoverHandler::movingItemWithHoverHandler()
QTRY_COMPARE(paddleHH->isHovered(), false);
}
+void tst_HoverHandler::margin() // QTBUG-85303
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "hoverMargin.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * item = window->rootObject()->findChild<QQuickItem *>();
+ QVERIFY(item);
+ QQuickHoverHandler *hh = item->findChild<QQuickHoverHandler *>();
+ QVERIFY(hh);
+
+ QPoint itemCenter(item->mapToScene(QPointF(item->width() / 2, item->height() / 2)).toPoint());
+ QPoint leftMargin = itemCenter - QPoint(35, 35);
+ QSignalSpy hoveredSpy(hh, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, {10, 10});
+ QCOMPARE(hh->isHovered(), false);
+ QCOMPARE(hoveredSpy.count(), 0);
+#if QT_CONFIG(cursor)
+ QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
+#endif
+
+ QTest::mouseMove(window, leftMargin);
+ QCOMPARE(hh->isHovered(), true);
+ QCOMPARE(hoveredSpy.count(), 1);
+#if QT_CONFIG(cursor)
+ QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
+#endif
+
+ QTest::mouseMove(window, itemCenter);
+ QCOMPARE(hh->isHovered(), true);
+ QCOMPARE(hoveredSpy.count(), 1);
+#if QT_CONFIG(cursor)
+ QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
+#endif
+
+ QTest::mouseMove(window, leftMargin);
+ QCOMPARE(hh->isHovered(), true);
+// QCOMPARE(hoveredSpy.count(), 1);
+#if QT_CONFIG(cursor)
+ QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
+#endif
+
+ QTest::mouseMove(window, {10, 10});
+ QCOMPARE(hh->isHovered(), false);
+// QCOMPARE(hoveredSpy.count(), 2);
+#if QT_CONFIG(cursor)
+ QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
+#endif
+}
+
QTEST_MAIN(tst_HoverHandler)
#include "tst_qquickhoverhandler.moc"