diff options
-rw-r--r-- | src/quick/util/qquickdeliveryagent.cpp | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 110 |
2 files changed, 111 insertions, 0 deletions
diff --git a/src/quick/util/qquickdeliveryagent.cpp b/src/quick/util/qquickdeliveryagent.cpp index c339bccf21..0de696c837 100644 --- a/src/quick/util/qquickdeliveryagent.cpp +++ b/src/quick/util/qquickdeliveryagent.cpp @@ -82,6 +82,7 @@ void QQuickDeliveryAgentPrivate::touchToMouseEvent(QEvent::Type type, const QEve (type == QEvent::MouseButtonRelease ? Qt::NoButton : Qt::LeftButton), touchEvent->modifiers(), Qt::MouseEventSynthesizedByQt); ret.setAccepted(true); // this now causes the persistent touchpoint to be accepted too + ret.setTimestamp(touchEvent->timestamp()); *mouseEvent = ret; } diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index b61520caf9..2b7aca72d0 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -153,6 +153,10 @@ private slots: void objectModelMove(); void requiredPropertiesInDelegate(); void requiredPropertiesInDelegatePreventUnrelated(); + void touchMove(); + +private: + QScopedPointer<QPointingDevice> touchDevice = QScopedPointer<QPointingDevice>(QTest::createTouchDevice()); }; class TestObject : public QObject @@ -2763,6 +2767,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" |