aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-06-01 13:02:44 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-06-02 10:18:03 +0200
commit19b6f9591257b3a07bf1479bcc2d676e57506447 (patch)
treea726a3dec259d50d851d6d9de2d739ce78ccd6b8 /tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
parenta4fa74d3e7581cb5c6bb82223ee17257f66fa41d (diff)
Update sceneGrabPosition in MultiPointHandler's points, on grab
We seem to have gotten by without this somehow; but the debug output in QQuickPinchHandler::handlePointerEventImpl() made it clear that it wasn't being done: it would always say the points moved from 0,0 to their present locations. Change-Id: If611adea6ecf0c056ae7d9b34ca86a7530cfc144 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
index 0d29ae6516..6cf6214286 100644
--- a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
@@ -40,6 +40,12 @@
Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests")
+class PinchHandler : public QQuickPinchHandler {
+public:
+ const QQuickHandlerPoint &firstPoint() { return currentPoints().first(); }
+ const QQuickHandlerPoint &lastPoint() { return currentPoints().last(); }
+};
+
class tst_QQuickPinchHandler: public QQmlDataTest
{
Q_OBJECT
@@ -209,7 +215,7 @@ void tst_QQuickPinchHandler::scale()
QVERIFY(window->rootObject() != nullptr);
qApp->processEvents();
- QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ auto *pinchHandler = static_cast<PinchHandler *>(window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler"));
QVERIFY(pinchHandler != nullptr);
QSignalSpy grabChangedSpy(pinchHandler, SIGNAL(grabChanged(QPointingDevice::GrabTransition, QEventPoint)));
@@ -243,6 +249,11 @@ void tst_QQuickPinchHandler::scale()
QQuickTouchUtils::flush(window);
}
QCOMPARE(pinchHandler->active(), true);
+ // grabs occur when the handler becomes active; at that time, QQuickHandlerPoint.sceneGrabPosition should be correct
+ QVERIFY(pinchHandler->firstPoint().sceneGrabPosition() != QPointF());
+ QVERIFY(pinchHandler->lastPoint().sceneGrabPosition() != QPointF());
+ QCOMPARE(pinchHandler->firstPoint().sceneGrabPosition(), pinchHandler->firstPoint().scenePosition());
+ QCOMPARE(pinchHandler->lastPoint().sceneGrabPosition(), pinchHandler->lastPoint().scenePosition());
// first point got a passive grab; both points got exclusive grabs
QCOMPARE(grabChangedSpy.count(), 3);
QLineF line(p0, p1);