diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-03 14:38:46 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-07-03 15:07:24 +0000 |
commit | c42f0a618271b845cda3ba179f8b7831d2aaca39 (patch) | |
tree | 9b7552b0ff2e3a31f62cbf9257cef7359de77e3b /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | |
parent | 284979ae8a6522ef6454966be69085e618c5c478 (diff) |
Quick tests: remember positions of stationary points
We need Items 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.
Change-Id: I12a04323b0d82dc325348c0fa3e067a4b63f57e9
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 44cd1dd656..381da76fa3 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -631,9 +631,10 @@ void tst_qquickwindow::touchEvent_basic() topItem->setSize(QSizeF(150, 150)); QPointF pos(10, 10); + QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false); // press single point - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window).commit(); QQuickTouchUtils::flush(window); QTRY_COMPARE(topItem->lastEvent.touchPoints.count(), 1); @@ -643,11 +644,11 @@ void tst_qquickwindow::touchEvent_basic() // would put the decorated window at that position rather than the window itself. COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); topItem->reset(); - QTest::touchEvent(window, touchDevice).release(0, topItem->mapToScene(pos).toPoint(), window); + touchSeq.release(0, topItem->mapToScene(pos).toPoint(), window).commit(); // press multiple points - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window) - .press(1, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window) + .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); @@ -656,35 +657,35 @@ void tst_qquickwindow::touchEvent_basic() COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); topItem->reset(); bottomItem->reset(); - QTest::touchEvent(window, touchDevice).release(0, topItem->mapToScene(pos).toPoint(), window).release(1, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.release(0, topItem->mapToScene(pos).toPoint(), window).release(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); // touch point on top item moves to bottom item, but top item should still receive the event - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, Qt::TouchPointMoved, makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); topItem->reset(); - QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); // touch point on bottom item moves to top item, but bottom item should still receive the event - QTest::touchEvent(window, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.press(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), window); + touchSeq.move(0, topItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, Qt::TouchPointMoved, makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos))); bottomItem->reset(); - QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); // a single stationary press on an item shouldn't cause an event - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).stationary(0) - .press(1, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.stationary(0) + .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); @@ -696,13 +697,13 @@ void tst_qquickwindow::touchEvent_basic() // cleanup: what is pressed must be released // Otherwise you will get an assertion failure: // ASSERT: "itemForTouchPointId.isEmpty()" in file items/qquickwindow.cpp - QTest::touchEvent(window, touchDevice).release(0, pos.toPoint(), window).release(1, pos.toPoint(), window); + touchSeq.release(0, pos.toPoint(), window).release(1, pos.toPoint(), window).commit(); QQuickTouchUtils::flush(window); // move touch point from top item to bottom, and release - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),window); + touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(),window).commit(); QQuickTouchUtils::flush(window); QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, window, Qt::TouchPointReleased, @@ -710,13 +711,13 @@ void tst_qquickwindow::touchEvent_basic() topItem->reset(); // release while another point is pressed - QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window) - .press(1, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window) + .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), window); + touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).commit(); QQuickTouchUtils::flush(window); - QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window) - .stationary(1); + touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window) + .stationary(1).commit(); QQuickTouchUtils::flush(window); QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); |