diff options
author | Seokha Ko <seokha.ko@qt.io> | 2022-08-24 14:09:53 +0900 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-26 06:05:03 +0000 |
commit | b7a6d0670533bd69c814a9454a1eb4bace30a352 (patch) | |
tree | c58080520c9c6c4d261296d1531da6ca213cd486 /tests | |
parent | f2959e57b6dfe1cc2dcbd6d34b6c9d10e9a4af89 (diff) |
Use the time stamp of the touch event when deliver touch as mouse
Use the time stamp of the touch event when converting a touch event
to a mouse event for items that do not handle touch events
Fixes: QTBUG-105907
Change-Id: I642093346459a031b77174eeecba8470e103e8dc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 3c3aef14865fe8a9865403feb044771a27522256)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 0d894c8581..cc134dce5a 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -129,6 +129,10 @@ private slots: void objectModelMove(); void requiredPropertiesInDelegate(); void requiredPropertiesInDelegatePreventUnrelated(); + void touchMove(); + +private: + QScopedPointer<QPointingDevice> touchDevice = QScopedPointer<QPointingDevice>(QTest::createTouchDevice()); }; class TestObject : public QObject @@ -2741,6 +2745,112 @@ void tst_QQuickPathView::requiredPropertiesInDelegatePreventUnrelated() window->show(); } +void tst_QQuickPathView::touchMove() +{ + QScopedPointer<QQuickView> window(createView()); + QQuickVisualTestUtils::moveMouseAway(window.data()); + window->setSource(testFileUrl("dragpath.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); + QVERIFY(pathview != nullptr); + + QSignalSpy movingSpy(pathview, SIGNAL(movingChanged())); + QSignalSpy moveStartedSpy(pathview, SIGNAL(movementStarted())); + QSignalSpy moveEndedSpy(pathview, SIGNAL(movementEnded())); + QSignalSpy draggingSpy(pathview, SIGNAL(draggingChanged())); + QSignalSpy dragStartedSpy(pathview, SIGNAL(dragStarted())); + QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded())); + QSignalSpy flickStartedSpy(pathview, SIGNAL(flickStarted())); + QSignalSpy flickEndedSpy(pathview, SIGNAL(flickEnded())); + + int current = pathview->currentIndex(); + + // touch move from left to right + QPoint from(250, 100); + QPoint to(10, 100); + + QTest::touchEvent(window.data(), touchDevice.data()).press(0, from, window.data()); + QQuickTouchUtils::flush(window.data()); + + QVERIFY(!pathview->isMoving()); + QVERIFY(!pathview->isDragging()); + QCOMPARE(movingSpy.count(), 0); + QCOMPARE(moveStartedSpy.count(), 0); + QCOMPARE(moveEndedSpy.count(), 0); + QCOMPARE(draggingSpy.count(), 0); + QCOMPARE(dragStartedSpy.count(), 0); + QCOMPARE(dragEndedSpy.count(), 0); + QCOMPARE(flickStartedSpy.count(), 0); + QCOMPARE(flickEndedSpy.count(), 0); + + from -= QPoint(QGuiApplication::styleHints()->startDragDistance() + 1, 0); + QTest::touchEvent(window.data(), touchDevice.data()).move(0, from, window.data()); + QQuickTouchUtils::flush(window.data()); + + // first move does not trigger move/drag + QVERIFY(!pathview->isMoving()); + QVERIFY(!pathview->isDragging()); + QCOMPARE(movingSpy.count(), 0); + QCOMPARE(moveStartedSpy.count(), 0); + QCOMPARE(moveEndedSpy.count(), 0); + QCOMPARE(draggingSpy.count(), 0); + QCOMPARE(dragStartedSpy.count(), 0); + QCOMPARE(dragEndedSpy.count(), 0); + QCOMPARE(flickStartedSpy.count(), 0); + QCOMPARE(flickEndedSpy.count(), 0); + + QPoint diff = from - to; + int moveCount = 4; + for (int i = 1; i <= moveCount; ++i) { + QTest::touchEvent(window.data(), touchDevice.data()).move(0, from - i * diff / moveCount, window.data()); + QQuickTouchUtils::flush(window.data()); + + QVERIFY(pathview->isMoving()); + QVERIFY(pathview->isDragging()); + QCOMPARE(movingSpy.count(), 1); + QCOMPARE(moveStartedSpy.count(), 1); + QCOMPARE(moveEndedSpy.count(), 0); + QCOMPARE(draggingSpy.count(), 1); + QCOMPARE(dragStartedSpy.count(), 1); + QCOMPARE(dragEndedSpy.count(), 0); + QCOMPARE(flickStartedSpy.count(), 0); + QCOMPARE(flickEndedSpy.count(), 0); + } + QVERIFY(pathview->currentIndex() != current); + + QTest::touchEvent(window.data(), touchDevice.data()).release(0, to, window.data()); + QQuickTouchUtils::flush(window.data()); + + QVERIFY(pathview->isMoving()); + QVERIFY(!pathview->isDragging()); + QCOMPARE(movingSpy.count(), 1); + QCOMPARE(moveStartedSpy.count(), 1); + QCOMPARE(moveEndedSpy.count(), 0); + QCOMPARE(draggingSpy.count(), 2); + QCOMPARE(dragStartedSpy.count(), 1); + QCOMPARE(dragEndedSpy.count(), 1); + QCOMPARE(flickStartedSpy.count(), 1); + QCOMPARE(flickEndedSpy.count(), 0); + + // Wait for the flick to finish + QVERIFY(QTest::qWaitFor([&]() + { return !pathview->isFlicking(); } + )); + QVERIFY(!pathview->isMoving()); + QVERIFY(!pathview->isDragging()); + QCOMPARE(movingSpy.count(), 2); + QCOMPARE(moveStartedSpy.count(), 1); + QCOMPARE(moveEndedSpy.count(), 1); + QCOMPARE(draggingSpy.count(), 2); + QCOMPARE(dragStartedSpy.count(), 1); + QCOMPARE(dragEndedSpy.count(), 1); + QCOMPARE(flickStartedSpy.count(), 1); + QCOMPARE(flickEndedSpy.count(), 1); + +} + QTEST_MAIN(tst_QQuickPathView) #include "tst_qquickpathview.moc" |