summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-09-14 15:41:18 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-10-04 05:16:02 +0000
commitf08270439fb34925d0e5510983f9964369eabba3 (patch)
tree6f6ff49d3bb4627e78a8293606e021984d57657f
parentf986c0c3390ba7d033b6e6276f63dcd4818adb5c (diff)
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 <jpnurmi@qt.io>
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp45
1 files changed, 45 insertions, 0 deletions
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<int>(), 0); // QTBUG-55886
}
+void tst_qquickflickable::trackpad()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("wheel.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("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<int>(), 0); // QTBUG-55886
+}
+
void tst_qquickflickable::movingAndFlicking_data()
{
QTest::addColumn<bool>("verticalEnabled");