diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-28 13:59:00 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-28 19:20:54 +0200 |
commit | 051e18a02fcdcb177cd602665424e53253f4d88c (patch) | |
tree | 8b41f3ab9a8cfb1d7f6081968739c2ce221501ad /tests/auto/quick/pointerhandlers/qquickdraghandler | |
parent | 9ab1a6759018b78b0f160c5286f8b0235a34ec50 (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
Task-number: QTBUG-85431
Change-Id: I89c0dc13ed06fbf1443f42fa5b63713da56ecf6d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickdraghandler')
-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 3740bf5709..a5884659b3 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -354,19 +354,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); @@ -376,7 +377,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); @@ -384,7 +385,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); } |