diff options
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickhoverhandler/data/windowCursorShape.qml | 13 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp | 23 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/windowCursorShape.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/windowCursorShape.qml new file mode 100644 index 0000000000..b5c1f3d2ef --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/windowCursorShape.qml @@ -0,0 +1,13 @@ +import QtQuick 2.15 +import QtQuick.Window 2.15 + +Window { + width: 320 + height: 240 + visible: true + color: hh.hovered ? "lightsteelblue" : "beige" + HoverHandler { + id: hh + cursorShape: Qt.OpenHandCursor + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp index 11a5393390..c3429456ae 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp @@ -62,6 +62,7 @@ private slots: void hoverHandlerAndUnderlyingMouseArea(); void movingItemWithHoverHandler(); void margin(); + void window(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -363,6 +364,28 @@ void tst_HoverHandler::margin() // QTBUG-85303 #endif } +void tst_HoverHandler::window() // QTBUG-98717 +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("windowCursorShape.qml")); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); +#if QT_CONFIG(cursor) + if (isPlatformWayland()) + QSKIP("Wayland: QCursor::setPos() doesn't work."); +#ifdef Q_OS_MACOS + QSKIP("macOS: QCursor::setPos() doesn't work (QTBUG-76312)."); +#endif + auto cursorPos = window->mapToGlobal(QPoint(100, 100)); + qCDebug(lcPointerTests) << "in window @" << window->position() << "setting cursor pos" << cursorPos; + QCursor::setPos(cursorPos); + QTRY_COMPARE(window->cursor().shape(), Qt::OpenHandCursor); +#endif +} + QTEST_MAIN(tst_HoverHandler) #include "tst_qquickhoverhandler.moc" |