diff options
| author | Morten Sørvig <morten.sorvig@qt.io> | 2026-09-01 13:46:49 +0200 |
|---|---|---|
| committer | Morten Sørvig <morten.sorvig@qt.io> | 2026-09-21 11:01:30 +0000 |
| commit | 61abcb17f61af40038ce3caeb1a2b219ca01f2ee (patch) | |
| tree | f89372631b6567c70e097f230fd17b1613e04afb | |
| parent | 97dfdce4ab605d13cd55ddf6db6b0687259b93d0 (diff) | |
tst_QQuickMultiPointTouchArea: restore exact touch point comparisons
Revert e7edfba8 and restore exact touch point comparisons, now that
Qt and test code has been updated to handle fractional scale factors.
Fixes include:
- update QTouchEventSequence to not round touch coordinates
- update mouseGestureStarted test to store coords using real
- update drag threshold detection to handle float rounding errors.
Task-number: QTBUG-146901
Change-Id: Ia8fdd65c8aa73b57949f287a7adf8f148e9d1ec2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| -rw-r--r-- | tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp | 115 |
1 files changed, 57 insertions, 58 deletions
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index a59e7bc4ad..7398720a95 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -14,7 +14,6 @@ #include <QtGui/private/qevent_p.h> #include <QtGui/private/qeventpoint_p.h> #include <QtGui/private/qpointingdevice_p.h> -#include <QtQuickTestUtils/private/geometrytestutils_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/viewtestutils_p.h> @@ -174,7 +173,7 @@ void tst_QQuickMultiPointTouchArea::release() QQuickTouchUtils::flush(&window); QCOMPARE(point1->pressed(), true); - VERIFY_POINT_NEAR("point1", QPointF(point1->x(), point1->y()), QPointF(20, 110)); + QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110)); p1 += QPoint(4,10); @@ -183,7 +182,7 @@ void tst_QQuickMultiPointTouchArea::release() //test that a release without a prior move to the release position successfully updates the point's position QCOMPARE(point1->pressed(), false); - VERIFY_POINT_NEAR("point1", QPointF(point1->x(), point1->y()), QPointF(24, 120)); + QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120)); } void tst_QQuickMultiPointTouchArea::reuse() @@ -250,7 +249,7 @@ void tst_QQuickMultiPointTouchArea::reuse() QCOMPARE(point2->pressed(), true); QCOMPARE(point3->pressed(), false); - VERIFY_POINT_NEAR("point1", QPointF(point1->x(), point1->y()), QPointF(80, 100)); + QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100)); } void tst_QQuickMultiPointTouchArea::nonOverlapping() @@ -296,8 +295,8 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping() QCOMPARE(point22->pressed(), false); QCOMPARE(point23->pressed(), false); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 100)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(40, 100)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); + QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); p1 += QPoint(0,10); p2 += QPoint(5,0); @@ -310,8 +309,8 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping() QCOMPARE(point22->pressed(), false); QCOMPARE(point23->pressed(), false); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); sequence.stationary(0).stationary(1).press(2, p3).commit(); QQuickTouchUtils::flush(&window); @@ -331,11 +330,11 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping() QCOMPARE(point22->pressed(), true); QCOMPARE(point23->pressed(), true); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(60, 20)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(80, 20)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(100, 20)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20)); + QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20)); + QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20)); p1 += QPoint(4,10); p2 += QPoint(17,17); @@ -351,11 +350,11 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping() QCOMPARE(point22->pressed(), true); QCOMPARE(point23->pressed(), true); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(63, 20)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(81, 19)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(93, 30)); + QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); + QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20)); + QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19)); + QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30)); sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit(); QQuickTouchUtils::flush(&window); @@ -408,8 +407,8 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point22->pressed(), false); QCOMPARE(point23->pressed(), false); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 100)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(40, 100)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); + QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); p1 += QPoint(0,10); p2 += QPoint(5,0); @@ -422,8 +421,8 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point22->pressed(), false); QCOMPARE(point23->pressed(), false); - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); sequence.stationary(0).stationary(1).press(2, p3).commit(); QQuickTouchUtils::flush(&window); @@ -435,11 +434,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point23->pressed(), true); //point11 should be same as point21, point12 same as point22 - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(60, 180)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit(); QQuickTouchUtils::flush(&window); @@ -451,11 +450,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point23->pressed(), true); //new touch points should be ignored (have no impact on our existing touch points) - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(60, 180)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit(); @@ -471,11 +470,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point22->pressed(), true); QCOMPARE(point23->pressed(), true); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(63, 180)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); p1 += QPoint(4,10); p2 += QPoint(17,17); @@ -490,11 +489,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point23->pressed(), true); //first two remain the same (touches now grabbed by inner touch area) - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(28, 130)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(79, 134)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(66, 180)); + QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); + QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130)); + QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134)); + QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180)); sequence.release(0, p1).release(1, p2).release(2, p3).commit(); @@ -534,11 +533,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point22->pressed(), true); QCOMPARE(point23->pressed(), true); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(24, 120)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(62, 117)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(63, 180)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); p1 -= QPoint(4,10); p2 -= QPoint(17,17); @@ -553,11 +552,11 @@ void tst_QQuickMultiPointTouchArea::nested() QCOMPARE(point23->pressed(), true); //all change (touches not grabbed by inner touch area) - VERIFY_POINT_NEAR("point11", QPointF(point11->x(), point11->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point12", QPointF(point12->x(), point12->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point21", QPointF(point21->x(), point21->y()), QPointF(20, 110)); - VERIFY_POINT_NEAR("point22", QPointF(point22->x(), point22->y()), QPointF(45, 100)); - VERIFY_POINT_NEAR("point23", QPointF(point23->x(), point23->y()), QPointF(60, 180)); + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); sequence.release(0, p1).release(1, p2).release(2, p3).commit(); QQuickTouchUtils::flush(&window); @@ -1327,22 +1326,22 @@ void tst_QQuickMultiPointTouchArea::mouseGestureStarted() // QTBUG-70258 QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1); QCOMPARE(gestureStartedSpy.size(), 0); - p1 += QPoint(dragThreshold - 1, dragThreshold - 1); + p1 += QPoint(dragThreshold, dragThreshold); QTest::mouseMove(&window, p1); QCOMPARE(gestureStartedSpy.size(), 0); - p1 += QPoint(2, 2); + p1 += QPoint(1, 1); QTest::mouseMove(&window, p1); QTRY_COMPARE(gestureStartedSpy.size(), 1); - QTRY_VERIFY(qAbs(area->property("gestureStartedX").toInt() - distanceFromOrigin) <= 1); - QVERIFY(qAbs(area->property("gestureStartedY").toInt() - distanceFromOrigin) <= 1); + QTRY_COMPARE(area->property("gestureStartedX").toReal(), qreal(distanceFromOrigin)); + QCOMPARE(area->property("gestureStartedY").toReal(), qreal(distanceFromOrigin)); p1 += QPoint(10, 10); QTest::mouseMove(&window, p1); // if nobody called gesteure->grab(), gestureStarted will keep happening QTRY_COMPARE(gestureStartedSpy.size(), grabGesture ? 1 : 2); - QVERIFY(qAbs(area->property("gestureStartedX").toInt() - distanceFromOrigin) <= 1); - QVERIFY(qAbs(area->property("gestureStartedY").toInt() - distanceFromOrigin) <= 1); + QCOMPARE(area->property("gestureStartedX").toReal(), qreal(distanceFromOrigin)); + QCOMPARE(area->property("gestureStartedY").toReal(), qreal(distanceFromOrigin)); QTest::mouseRelease(&window, Qt::LeftButton); } |
