diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-03 13:59:12 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-03 15:07:13 +0000 |
commit | 284979ae8a6522ef6454966be69085e618c5c478 (patch) | |
tree | 296d1837a3a64e909f94ccfd0a6ca47aab77e69e /tests/auto/quick/pointerhandlers/qquickdraghandler | |
parent | 4d3d3e1099d628479929ab293d267016bb183c96 (diff) |
Input handler tests: remember positions of stationary points
We need Handlers to receive accurate positions for stationary touch
points: that is, the last-known position from the previous touch
event. (And we hope that all actual touch-capable platforms also send
proper QPA events with correct positions for stationary points.
We assert that it's a bug if they don't.)
As explained in qtbase 7cef4b6463fdb73ff602ade64b222333dd23e46c, it's
OK to retain a copy of a QTest::QTouchEventSequence for this purpose,
so that the QMap<int, QTouchEvent::TouchPoint> previousPoints will not
be discarded between events.
We have done this in other tests, but not consistently; e.g.
468626e99a90d6ac21cb311cde05c658ccb3b781 fixed the PinchArea test.
Change-Id: I4dbe69f8dcc4b1cca30fd7ce91d7d2ecf5ec4bc3
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickdraghandler')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 53bb10b7b8..0271924c9b 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -256,8 +256,9 @@ void tst_DragHandler::touchDragMulti() QPointF ball2Center = ball2->clipRect().center(); QPointF scenePressPos2 = ball2->mapToScene(ball2Center); QPoint p2 = scenePressPos2.toPoint(); + QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false); - QTest::touchEvent(window, touchDevice).press(1, p1, window).press(2, p2, window); + touchSeq.press(1, p1, window).press(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(!dragHandler1->active()); QCOMPARE(dragHandler1->point().position(), ball1Center); @@ -271,12 +272,12 @@ void tst_DragHandler::touchDragMulti() QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2); p1 += QPoint(dragThreshold, 0); p2 += QPoint(0, dragThreshold); - QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window); + touchSeq.move(1, p1, window).move(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(!dragHandler1->active()); p1 += QPoint(1, 0); p2 += QPoint(0, 1); - QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window); + touchSeq.move(1, p1, window).move(2, p2, window).commit(); QQuickTouchUtils::flush(window); QTRY_VERIFY(dragHandler1->active()); QVERIFY(dragHandler2->active()); @@ -292,7 +293,7 @@ void tst_DragHandler::touchDragMulti() QCOMPARE(translationChangedSpy2.count(), 0); QCOMPARE(dragHandler2->translation().x(), 0.0); QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2); - QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window); + touchSeq.move(1, p1, window).move(2, p2, window).commit(); QQuickTouchUtils::flush(window); QVERIFY(dragHandler1->active()); QVERIFY(dragHandler2->active()); @@ -310,14 +311,14 @@ void tst_DragHandler::touchDragMulti() QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2); QCOMPARE(dragHandler2->translation().x(), 0.0); QCOMPARE(dragHandler2->translation().y(), dragThreshold + 20.0); - QTest::touchEvent(window, touchDevice).release(1, p1, window).stationary(2); + 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(ball1->mapToScene(ball1Center).toPoint(), p1); QCOMPARE(translationChangedSpy1.count(), 1); - QTest::touchEvent(window, touchDevice).release(2, p2, window); + touchSeq.release(2, p2, window).commit(); QQuickTouchUtils::flush(window); QTRY_VERIFY(!dragHandler2->active()); QCOMPARE(ball2->mapToScene(ball2Center).toPoint(), p2); |