From ca7cdd71ee33f0d77eb6bf1367d2532e26155cb2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 11 Jun 2018 07:38:46 +0200 Subject: Make DragHandler a MultiPointHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That is, minimumPointCount can now be set to a value > 1 to require multiple fingers to do the dragging, or to track the displacement of multiple fingers to adjust some value (such as the tilt of a map). Task-number: QTBUG-68106 Change-Id: Ib35823e36deb81c8b277d3070fcc758c7c019564 Reviewed-by: Jan Arve Sæther --- .../flickableinterop/tst_flickableinterop.cpp | 2 +- .../tst_multipointtoucharea_interop.cpp | 71 ++++++------ .../qquickdraghandler/data/draggables.qml | 7 +- .../qquickdraghandler/tst_qquickdraghandler.cpp | 120 ++++++++++++--------- 4 files changed, 105 insertions(+), 95 deletions(-) (limited to 'tests/auto/quick/pointerhandlers') diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp index 6aa2eaa3cb..11a67cea82 100644 --- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp +++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp @@ -93,7 +93,7 @@ void tst_FlickableInterop::createView(QScopedPointer &window, const window->show(); QVERIFY(QTest::qWaitForWindowActive(window.data())); - QVERIFY(window->rootObject() != 0); + QVERIFY(window->rootObject() != nullptr); } void tst_FlickableInterop::initTestCase() diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp index 0561a9e4f1..5ea5a42044 100644 --- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp @@ -105,12 +105,12 @@ void tst_MptaInterop::touchDrag() // Press one touchpoint: // DragHandler gets a passive grab // PinchHandler declines, because it wants 3 touchpoints - // MPTA doesn't get a chance, because DragHandler accepted the single EventPoint + // MPTA grabs because DragHandler doesn't accept the single EventPoint QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint(); touch.press(1, p1).commit(); QQuickTouchUtils::flush(window); auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); - QCOMPARE(tp.at(0)->property("pressed").toBool(), false); + QCOMPARE(tp.at(0)->property("pressed").toBool(), true); QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag)); // Start moving @@ -161,7 +161,7 @@ void tst_MptaInterop::touchesThenPinch() QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint(); touch.press(1, p1).commit(); QQuickTouchUtils::flush(window); - QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr); + QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); QTRY_COMPARE(pointerEvent->point(0)->passiveGrabbers().first(), drag); // Press a second touchpoint: MPTA grabs it @@ -170,31 +170,21 @@ void tst_MptaInterop::touchesThenPinch() QQuickTouchUtils::flush(window); QVERIFY(tp.at(0)->property("pressed").toBool()); QTRY_VERIFY(tp.at(1)->property("pressed").toBool()); - QCOMPARE(mptaPressedSpy.count(), 1); + QCOMPARE(mptaPressedSpy.count(), 2); - // ATM it's required that when PinchHandler sees the third touchpoint, - // the pre-existing points must have moved far enough to exceed the drag threshold. - // If MPTA is allowed to grab that third point, then PinchHandler won't steal. - // TODO should we change that? make sure that if PH has a passive grab, it always gets updated even though MPTA has the grab? - for (int i = 0; i < 2; ++i) { - p1 += QPoint(dragThreshold, dragThreshold); - p2 += QPoint(dragThreshold, dragThreshold); - touch.move(1, p1).move(2, p2).commit(); - } - - // Press a third touchpoint: PinchHandler grabs, MPTA loses its grabs + // Press a third touchpoint: MPTA grabs it too QPoint p3 = mpta->mapToScene(QPointF(110, 200)).toPoint(); touch.stationary(1).stationary(2).press(3, p3).commit(); QQuickTouchUtils::flush(window); - QCOMPARE(tp.at(0)->property("pressed").toBool(), false); - QCOMPARE(tp.at(1)->property("pressed").toBool(), false); - QCOMPARE(tp.at(2)->property("pressed").toBool(), false); - QCOMPARE(mptaPressedSpy.count(), 1); - QCOMPARE(mptaCanceledSpy.count(), 1); - QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch); - QTRY_COMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch); - QTRY_COMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch); - QVERIFY(pinch->active()); + QCOMPARE(tp.at(0)->property("pressed").toBool(), true); + QCOMPARE(tp.at(1)->property("pressed").toBool(), true); + QCOMPARE(tp.at(2)->property("pressed").toBool(), true); + QCOMPARE(mptaPressedSpy.count(), 3); + QCOMPARE(mptaCanceledSpy.count(), 0); + QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); + QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta); + QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta); + QVERIFY(!pinch->active()); // Start moving: PinchHandler steals the exclusive grab from MPTA as soon as dragThreshold is exceeded int pinchStoleGrab = 0; @@ -204,11 +194,12 @@ void tst_MptaInterop::touchesThenPinch() p3 += QPoint(-dragThreshold / 2, dragThreshold / 2); touch.move(1, p1).move(2, p2).move(3, p3).commit(); QQuickTouchUtils::flush(window); - QTRY_COMPARE(tp.at(0)->property("pressed").toBool(), false); - QCOMPARE(tp.at(1)->property("pressed").toBool(), false); - QCOMPARE(tp.at(2)->property("pressed").toBool(), false); - if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch) + if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch) { pinchStoleGrab = i; + QCOMPARE(tp.at(0)->property("pressed").toBool(), false); + QCOMPARE(tp.at(1)->property("pressed").toBool(), false); + QCOMPARE(tp.at(2)->property("pressed").toBool(), false); + } } qCDebug(lcPointerTests) << "pinch started after" << pinchStoleGrab << "moves; ended with scale" << pinch->activeScale() << "rot" << pinch->rotation(); QTRY_VERIFY(pinch->rotation() > 4); @@ -217,28 +208,26 @@ void tst_MptaInterop::touchesThenPinch() // Press one more point (pinkie finger) QPoint p4 = mpta->mapToScene(QPointF(300, 200)).toPoint(); touch.move(1, p1).move(2, p2).move(3, p3).press(4, p4).commit(); - // PinchHandler gives up its grabs (only on non-stationary points at this time: see QQuickPointerHandler::handlePointerEvent()) - // because it has minimum touch points 3, maximum touch points 3, and now there are 4 points. - // MPTA grabs all points which are not already grabbed - QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); - QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta); - QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta); + // MPTA grabs the newly pressed point + QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch); + QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch); + QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch); QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta); - // Move some more... MPTA keeps reacting + // Move some more... PinchHandler and MPTA both keep reacting for (int i = 0; i < 8; ++i) { p1 += QPoint(4, 4); p2 += QPoint(4, 4); p3 += QPoint(-4, 4); p4 += QPoint(-4, -4); touch.move(1, p1).move(2, p2).move(3, p3).move(4, p4).commit(); - QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); - QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta); - QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta); + QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch); + QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch); + QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch); QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta); QCOMPARE(tp.at(0)->property("pressed").toBool(), true); - QCOMPARE(tp.at(1)->property("pressed").toBool(), true); - QCOMPARE(tp.at(2)->property("pressed").toBool(), true); - QCOMPARE(tp.at(3)->property("pressed").toBool(), true); + QCOMPARE(tp.at(1)->property("pressed").toBool(), false); + QCOMPARE(tp.at(2)->property("pressed").toBool(), false); + QCOMPARE(tp.at(3)->property("pressed").toBool(), false); } // Release the pinkie: PinchHandler acquires passive grabs on the 3 remaining points diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml index e468280ea6..7b3601bea0 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml @@ -39,20 +39,21 @@ Item { Rectangle { id: ball - objectName: "Ball " + index + objectName: "Ball " + (index + 1) color: dragHandler.active ? "blue" : "lightsteelblue" width: 80; height: 80; x: 200 + index * 200; y: 200; radius: width / 2 onParentChanged: console.log(this + " parent " + parent) DragHandler { id: dragHandler - objectName: "DragHandler " + index + objectName: "DragHandler " + (index + 1) } Text { color: "white" anchors.centerIn: parent - text: dragHandler.point.position.x.toFixed(1) + "," + dragHandler.point.position.y.toFixed(1) + horizontalAlignment: Text.AlignHCenter + text: ball.objectName + "\n" + dragHandler.centroid.position.x.toFixed(1) + "," + dragHandler.centroid.position.y.toFixed(1) } } } diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 0271924c9b..f71145c2bc 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -119,11 +119,11 @@ void tst_DragHandler::defaultPropertyValues() QCOMPARE(dragHandler->acceptedButtons(), Qt::LeftButton); QCOMPARE(dragHandler->translation(), QVector2D()); - QCOMPARE(dragHandler->point().position(), QPointF()); - QCOMPARE(dragHandler->point().scenePosition(), QPointF()); - QCOMPARE(dragHandler->point().pressPosition(), QPointF()); - QCOMPARE(dragHandler->point().scenePressPosition(), QPointF()); - QCOMPARE(dragHandler->point().sceneGrabPosition(), QPointF()); + QCOMPARE(dragHandler->centroid().position(), QPointF()); + QCOMPARE(dragHandler->centroid().scenePosition(), QPointF()); + QCOMPARE(dragHandler->centroid().pressPosition(), QPointF()); + QCOMPARE(dragHandler->centroid().scenePressPosition(), QPointF()); + QCOMPARE(dragHandler->centroid().sceneGrabPosition(), QPointF()); } void tst_DragHandler::touchDrag() @@ -146,10 +146,10 @@ void tst_DragHandler::touchDrag() QTest::touchEvent(window, touchDevice).press(1, p1, window); QQuickTouchUtils::flush(window); QVERIFY(!dragHandler->active()); - QCOMPARE(dragHandler->point().position(), ballCenter); - QCOMPARE(dragHandler->point().pressPosition(), ballCenter); - QCOMPARE(dragHandler->point().scenePosition(), scenePressPos); - QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().position(), ballCenter); + QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); + QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); p1 += QPoint(dragThreshold, 0); QTest::touchEvent(window, touchDevice).move(1, p1, window); QQuickTouchUtils::flush(window); @@ -161,22 +161,22 @@ void tst_DragHandler::touchDrag() QCOMPARE(translationChangedSpy.count(), 0); QCOMPARE(dragHandler->translation().x(), 0.0); QPointF sceneGrabPos = p1; - QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos); + QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos); p1 += QPoint(19, 0); QTest::touchEvent(window, touchDevice).move(1, p1, window); QQuickTouchUtils::flush(window); QTRY_VERIFY(dragHandler->active()); - QCOMPARE(dragHandler->point().position(), ballCenter); - QCOMPARE(dragHandler->point().pressPosition(), ballCenter); - QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter)); - QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos); - QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos); + QCOMPARE(dragHandler->centroid().position(), ballCenter); + QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); + 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().y(), 0.0); QTest::touchEvent(window, touchDevice).release(1, p1, window); QQuickTouchUtils::flush(window); QTRY_VERIFY(!dragHandler->active()); - QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton); + QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton); QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1); QCOMPARE(translationChangedSpy.count(), 1); } @@ -200,10 +200,10 @@ void tst_DragHandler::mouseDrag() QPoint p1 = scenePressPos.toPoint(); QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); QVERIFY(!dragHandler->active()); - QCOMPARE(dragHandler->point().position(), ballCenter); - QCOMPARE(dragHandler->point().pressPosition(), ballCenter); - QCOMPARE(dragHandler->point().scenePosition(), scenePressPos); - QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().position(), ballCenter); + QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); + QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); p1 += QPoint(dragThreshold, 0); QTest::mouseMove(window, p1); QVERIFY(!dragHandler->active()); @@ -213,20 +213,20 @@ void tst_DragHandler::mouseDrag() QCOMPARE(translationChangedSpy.count(), 0); QCOMPARE(dragHandler->translation().x(), 0.0); QPointF sceneGrabPos = p1; - QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos); + QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos); p1 += QPoint(19, 0); QTest::mouseMove(window, p1); QTRY_VERIFY(dragHandler->active()); - QCOMPARE(dragHandler->point().position(), ballCenter); - QCOMPARE(dragHandler->point().pressPosition(), ballCenter); - QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter)); - QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos); - QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos); + QCOMPARE(dragHandler->centroid().position(), ballCenter); + QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); + 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().y(), 0.0); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); QTRY_VERIFY(!dragHandler->active()); - QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton); + QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton); QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1); QCOMPARE(translationChangedSpy.count(), 1); } @@ -243,12 +243,14 @@ void tst_DragHandler::touchDragMulti() QQuickDragHandler *dragHandler1 = ball1->findChild(); QVERIFY(dragHandler1); QSignalSpy translationChangedSpy1(dragHandler1, SIGNAL(translationChanged())); + QSignalSpy centroidChangedSpy1(dragHandler1, SIGNAL(centroidChanged())); QQuickItem *ball2 = window->rootObject()->childItems().at(1); QVERIFY(ball2); QQuickDragHandler *dragHandler2 = ball2->findChild(); QVERIFY(dragHandler2); QSignalSpy translationChangedSpy2(dragHandler2, SIGNAL(translationChanged())); + QSignalSpy centroidChangedSpy2(dragHandler1, SIGNAL(centroidChanged())); QPointF ball1Center = ball1->clipRect().center(); QPointF scenePressPos1 = ball1->mapToScene(ball1Center); @@ -261,20 +263,33 @@ void tst_DragHandler::touchDragMulti() touchSeq.press(1, p1, window).press(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(!dragHandler1->active()); - QCOMPARE(dragHandler1->point().position(), ball1Center); - QCOMPARE(dragHandler1->point().pressPosition(), ball1Center); - QCOMPARE(dragHandler1->point().scenePosition(), scenePressPos1); - QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1); + QCOMPARE(centroidChangedSpy1.count(), 1); + QCOMPARE(dragHandler1->centroid().position(), ball1Center); + QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center); + QCOMPARE(dragHandler1->centroid().scenePosition(), scenePressPos1); + QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1); QVERIFY(!dragHandler2->active()); - QCOMPARE(dragHandler2->point().position(), ball2Center); - QCOMPARE(dragHandler2->point().pressPosition(), ball2Center); - QCOMPARE(dragHandler2->point().scenePosition(), scenePressPos2); - QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2); + QCOMPARE(centroidChangedSpy2.count(), 1); + QCOMPARE(dragHandler2->centroid().position(), ball2Center); + QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center); + QCOMPARE(dragHandler2->centroid().scenePosition(), scenePressPos2); + QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2); p1 += QPoint(dragThreshold, 0); p2 += QPoint(0, dragThreshold); touchSeq.move(1, p1, window).move(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(!dragHandler1->active()); + QCOMPARE(centroidChangedSpy1.count(), 2); + QCOMPARE(dragHandler1->centroid().position(), ball1Center + QPointF(dragThreshold, 0)); + QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center); + QCOMPARE(dragHandler1->centroid().scenePosition().toPoint(), p1); + QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1); + QVERIFY(!dragHandler2->active()); + QCOMPARE(centroidChangedSpy2.count(), 2); + QCOMPARE(dragHandler2->centroid().position(), ball2Center + QPointF(0, dragThreshold)); + QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center); + QCOMPARE(dragHandler2->centroid().scenePosition().toPoint(), p2); + QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2); p1 += QPoint(1, 0); p2 += QPoint(0, 1); touchSeq.move(1, p1, window).move(2, p2, window).commit(); @@ -285,37 +300,37 @@ void tst_DragHandler::touchDragMulti() QCOMPARE(dragHandler1->translation().x(), 0.0); QPointF sceneGrabPos1 = p1; QPointF sceneGrabPos2 = p2; - QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1); - QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2); + QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1); + QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2); p1 += QPoint(19, 0); p2 += QPoint(0, 19); QVERIFY(dragHandler2->active()); QCOMPARE(translationChangedSpy2.count(), 0); QCOMPARE(dragHandler2->translation().x(), 0.0); - QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2); + QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2); touchSeq.move(1, p1, window).move(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(dragHandler1->active()); QVERIFY(dragHandler2->active()); - QCOMPARE(dragHandler1->point().position(), ball1Center); - QCOMPARE(dragHandler1->point().pressPosition(), ball1Center); - QCOMPARE(dragHandler1->point().scenePosition(), ball1->mapToScene(ball1Center)); - QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1); - QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1); + QCOMPARE(dragHandler1->centroid().position(), ball1Center); + QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center); + QCOMPARE(dragHandler1->centroid().scenePosition(), ball1->mapToScene(ball1Center)); + QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1); + QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1); QCOMPARE(dragHandler1->translation().x(), dragThreshold + 20.0); QCOMPARE(dragHandler1->translation().y(), 0.0); - QCOMPARE(dragHandler2->point().position(), ball2Center); - QCOMPARE(dragHandler2->point().pressPosition(), ball2Center); - QCOMPARE(dragHandler2->point().scenePosition(), ball2->mapToScene(ball2Center)); - QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2); - QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2); + QCOMPARE(dragHandler2->centroid().position(), ball2Center); + QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center); + QCOMPARE(dragHandler2->centroid().scenePosition(), ball2->mapToScene(ball2Center)); + QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2); + QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2); QCOMPARE(dragHandler2->translation().x(), 0.0); QCOMPARE(dragHandler2->translation().y(), dragThreshold + 20.0); touchSeq.release(1, p1, window).stationary(2).commit(); QQuickTouchUtils::flush(window); QTRY_VERIFY(!dragHandler1->active()); QVERIFY(dragHandler2->active()); - QCOMPARE(dragHandler1->point().pressedButtons(), Qt::NoButton); + QCOMPARE(dragHandler1->centroid().pressedButtons(), Qt::NoButton); QCOMPARE(ball1->mapToScene(ball1Center).toPoint(), p1); QCOMPARE(translationChangedSpy1.count(), 1); touchSeq.release(2, p2, window).commit(); @@ -454,7 +469,12 @@ void tst_DragHandler::touchPassiveGrabbers() QQuickDragHandler *dragHandler = nullptr; for (QQuickPointerHandler *handler: expectedPassiveGrabbers) { - QCOMPARE(static_cast(handler)->point().scenePressPosition(), p1); + QPointF scenePressPos; + if (QQuickMultiPointHandler *mph = qmlobject_cast(handler)) + scenePressPos = mph->centroid().scenePressPosition(); + else + scenePressPos = static_cast(handler)->point().scenePressPosition(); + QCOMPARE(scenePressPos, p1); QQuickDragHandler *dh = qmlobject_cast(handler); if (dh) dragHandler = dh; -- cgit v1.2.3