diff options
Diffstat (limited to 'tests/auto')
3 files changed, 42 insertions, 2 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml index 9045247e94..011dc4e75f 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml @@ -90,7 +90,7 @@ Rectangle { id: paddle objectName: "paddle" width: 100 - height: 40 + height: 100 color: paddleHH.hovered ? "indianred" : "#888" x: (parent.width - width) / 2 y: parent.height - 100 diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp index 52074aec4f..f141a2546c 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp @@ -60,6 +60,7 @@ private slots: void hoverHandlerAndUnderlyingHoverHandler(); void mouseAreaAndUnderlyingHoverHandler(); void hoverHandlerAndUnderlyingMouseArea(); + void movingItemWithHoverHandler(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -229,6 +230,42 @@ void tst_HoverHandler::hoverHandlerAndUnderlyingMouseArea() QCOMPARE(buttonHoveredSpy.count(), 2); } +void tst_HoverHandler::movingItemWithHoverHandler() +{ + if (isPlatformWayland()) + QSKIP("Wayland: QCursor::setPos() doesn't work."); + + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "lesHoverables.qml"); + QQuickView * window = windowPtr.data(); + QQuickItem * paddle = window->rootObject()->findChild<QQuickItem *>("paddle"); + QVERIFY(paddle); + QQuickHoverHandler *paddleHH = paddle->findChild<QQuickHoverHandler *>("paddleHH"); + QVERIFY(paddleHH); + + // Find the global coordinate of the paddle + const QPoint p(paddle->mapToScene(paddle->clipRect().center()).toPoint()); + const QPoint paddlePos = window->mapToGlobal(p); + + // Now hide the window, put the cursor where the paddle was and show it again + window->hide(); + QTRY_COMPARE(window->isVisible(), false); + QCursor::setPos(paddlePos); + window->show(); + QTest::qWaitForWindowExposed(window); + + QTRY_COMPARE(paddleHH->isHovered(), true); + + paddle->setX(100); + QTRY_COMPARE(paddleHH->isHovered(), false); + + paddle->setX(p.x()); + QTRY_COMPARE(paddleHH->isHovered(), true); + + paddle->setX(540); + QTRY_COMPARE(paddleHH->isHovered(), false); +} + QTEST_MAIN(tst_HoverHandler) #include "tst_qquickhoverhandler.moc" diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 42dc766a13..aaf37b32cd 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -569,7 +569,10 @@ void tst_qquickwidget::mouseEventWindowPos() QVERIFY(!rootItem->property("wasClicked").toBool()); QVERIFY(!rootItem->property("wasDoubleClicked").toBool()); - QVERIFY(!rootItem->property("wasMoved").toBool()); + // Moving an item under the mouse cursor will trigger a mouse move event. + // The above quick->move() will trigger a mouse move event on macOS. + // Discard that in order to get a clean slate for the actual tests. + rootItem->setProperty("wasMoved", QVariant(false)); QWindow *window = widget.windowHandle(); QVERIFY(window); |