diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-28 13:59:00 +0200 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2020-08-26 05:34:53 -0300 |
commit | dfcb37b13ae964aff19a798c29fbc8bee1a56eb3 (patch) | |
tree | 877e678982892800779dc414aef94b17ff81668f | |
parent | 68199cec0e47ff15e8e9b2708441e46cc7c48b84 (diff) |
Update tst_DragHandler::mouseDragThreshold zero-threshold test case
After qtbase b50daef9771d8829fc7f808898cbe051a5464b79, a mouse move
event that does not contain a mouse location different than the last
known location is no longer delivered.
It's intended to be OK to set DragHandler.threshold to 0, and this test
was checking functionality in that case; but we now need to move the
mouse at least one pixel to test it. Then, the drag threshold is
immediately exceeded, the drag begins, translation starts to occur, etc.
Amends ab5df626bef9365089ce716ce476bccae1d0a04b
Fixes: QTBUG-86213
Task-number: QTBUG-85431
Change-Id: I89c0dc13ed06fbf1443f42fa5b63713da56ecf6d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 051e18a02fcdcb177cd602665424e53253f4d88c)
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 47cfd27817..4d6866041e 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -356,19 +356,20 @@ void tst_DragHandler::mouseDragThreshold() QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); QCOMPARE(dragHandler->centroid().velocity(), QVector2D()); QCOMPARE(centroidChangedSpy.count(), 1); - p1 += QPoint(dragThreshold, 0); + p1 += QPoint(qMax(1, dragThreshold), 0); // QTBUG-85431: zero-distance mouse moves are not delivered QTest::mouseMove(window, p1); if (dragThreshold > 0) QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 2); - QVERIFY(!dragHandler->active()); + // the handler is not yet active, unless the drag threshold was already exceeded + QCOMPARE(dragHandler->active(), dragThreshold == 0); p1 += QPoint(1, 0); QTest::mouseMove(window, p1); QTRY_VERIFY(dragHandler->active()); - QCOMPARE(translationChangedSpy.count(), 0); + QCOMPARE(translationChangedSpy.count(), dragThreshold ? 0 : 1); QCOMPARE(centroidChangedSpy.count(), 3); - QCOMPARE(dragHandler->translation().x(), 0.0); - QPointF sceneGrabPos = p1; + QCOMPARE(dragHandler->translation().x(), dragThreshold ? 0 : 2); + QPointF sceneGrabPos = dragThreshold ? p1 : p1 - QPoint(1, 0); QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos); p1 += QPoint(19, 0); QTest::mouseMove(window, p1); @@ -378,7 +379,7 @@ void tst_DragHandler::mouseDragThreshold() QCOMPARE(dragHandler->centroid().scenePosition(), ball->mapToScene(ballCenter)); QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos); - QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0); + QCOMPARE(dragHandler->translation().x(), dragThreshold + (dragThreshold ? 20 : 21)); QCOMPARE(dragHandler->translation().y(), 0.0); QVERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 4); @@ -386,7 +387,7 @@ void tst_DragHandler::mouseDragThreshold() QTRY_VERIFY(!dragHandler->active()); QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton); QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1); - QCOMPARE(translationChangedSpy.count(), 1); + QCOMPARE(translationChangedSpy.count(), dragThreshold ? 1 : 2); QCOMPARE(centroidChangedSpy.count(), 5); } |