diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-01-16 13:45:15 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-01-31 11:13:26 +0100 |
commit | 1c44804600ad3dbeb60d1f5209ce9cf937d30ab3 (patch) | |
tree | cfa4c668cb527d89ae666ea1c2290a1cab4bc256 /tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp | |
parent | a6e661d25bf7ebeb8f4e58925aa9375f5ca10ef3 (diff) |
Add PointerHandler.cursorShape property
Also, QQuickItemPrivate::setHasCursorInChild() was unable to check
the QQuickItemPrivate::hasCursor variable, because the function
argument hasCursor was shadowing that, even though the comment
"nope! sorry, I have a cursor myself" hints that the intention
was to check that. So this change exposed a problem there, and
we have to fix that too, in order to keep the tst_qquickwindow::cursor()
test passing.
[ChangeLog][Event Handlers] Pointer Handlers now have a cursorShape
property to set the cursor when the handler is active and the mouse is
hovering, and restore to the previous cursor when the mouse leaves.
Fixes: QTBUG-68073
Change-Id: Ib5c66bd59c4691c4210ee5465e1c95e7bdcf5ae1
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 65c5ac9ef4..47cfd27817 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -249,8 +249,11 @@ void tst_DragHandler::mouseDrag() QPointF ballCenter = ball->clipRect().center(); QPointF scenePressPos = ball->mapToScene(ballCenter); QPoint p1 = scenePressPos.toPoint(); - QTest::mousePress(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1); + QTest::mousePress(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1, 500); QVERIFY(!dragHandler->active()); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif if (shouldDrag) { QCOMPARE(dragHandler->centroid().position(), ballCenter); QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); @@ -265,6 +268,9 @@ void tst_DragHandler::mouseDrag() QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 2); QVERIFY(!dragHandler->active()); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } p1 += QPoint(1, 0); QTest::mouseMove(window, p1); @@ -292,6 +298,9 @@ void tst_DragHandler::mouseDrag() QCOMPARE(dragHandler->translation().y(), 0.0); QVERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 4); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor); +#endif } QTest::mouseRelease(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1); QTRY_VERIFY(!dragHandler->active()); @@ -300,6 +309,10 @@ void tst_DragHandler::mouseDrag() QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1); QCOMPARE(translationChangedSpy.count(), shouldDrag ? 1 : 0); QCOMPARE(centroidChangedSpy.count(), shouldDrag ? 5 : 0); +#if QT_CONFIG(cursor) + QTest::mouseMove(window, p1 + QPoint(1, 0)); // TODO after fixing QTBUG-53987, don't send mouseMove + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_DragHandler::mouseDragThreshold_data() |