From f08270439fb34925d0e5510983f9964369eabba3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 14 Sep 2016 15:41:18 +0200 Subject: Flickable: add a trackpad (touchpad) autotest We've had this feature for a long time, to use pixel deltas and scroll phase effectively, but no autotest until now. It's still not very thorough but it's a start. Task-number: QTBUG-55871 Change-Id: Iaf6e7a842ce90828da3253e8673cac9905abd046 Reviewed-by: J-P Nurmi --- .../quick/qquickflickable/tst_qquickflickable.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 7de0a0fa0e..da3d8c41e2 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -74,6 +74,7 @@ private slots: void returnToBounds(); void returnToBounds_data(); void wheel(); + void trackpad(); void movingAndFlicking(); void movingAndFlicking_data(); void movingAndDragging(); @@ -768,6 +769,50 @@ void tst_qquickflickable::wheel() QCOMPARE(flick->property("movementsAfterEnd").value(), 0); // QTBUG-55886 } +void tst_qquickflickable::trackpad() +{ + QScopedPointer window(new QQuickView); + window->setSource(testFileUrl("wheel.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *flick = window->rootObject()->findChild("flick"); + QVERIFY(flick != 0); + QSignalSpy moveEndSpy(flick, SIGNAL(movementEnded())); + QPoint pos(200, 200); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,-100), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentY() > 0); + QCOMPARE(flick->contentX(), qreal(0)); + + flick->setContentY(0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(-100,0), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollUpdate); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentX() > 0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,0), QPoint(0,0), 0, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_COMPARE(moveEndSpy.count(), 1); // QTBUG-55871 + QCOMPARE(flick->property("movementsAfterEnd").value(), 0); // QTBUG-55886 +} + void tst_qquickflickable::movingAndFlicking_data() { QTest::addColumn("verticalEnabled"); -- cgit v1.2.3