diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-03-24 15:50:42 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-03-27 12:21:22 +0000 |
commit | 09a62428cfdb1ced3767f38aba126cf466e37e30 (patch) | |
tree | 4b97cb825638ff8bce0236ea939390636683a016 /tests/auto/quick/qquickflickable | |
parent | 65e005a72d62d8a42a60e0b8b789d1f04da91ccf (diff) |
tst_qquickflickable: clean up touch event handling
Use QTest::createTouchDevice now that it exists. No need for each test
to create a device and pass it in to flickWithTouch
Change-Id: I81131a13aaba01cfa0f04b25f334c80263625d12
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 9ead271bfe..21d02ff5de 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -50,6 +50,9 @@ class tst_qquickflickable : public QQmlDataTest { Q_OBJECT public: + tst_qquickflickable() + : touchDevice(QTest::createTouchDevice()) + {} private slots: void create(); @@ -101,7 +104,8 @@ private slots: void overshoot_reentrant(); private: - void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); + void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to); + QTouchDevice *touchDevice; }; void tst_qquickflickable::cleanup() @@ -1530,12 +1534,6 @@ void tst_qquickflickable::clickAndDragWhenTransformed() void tst_qquickflickable::flickTwiceUsingTouches() { - QTouchDevice *touchDevice = new QTouchDevice; - touchDevice->setName("Fake Touchscreen"); - touchDevice->setType(QTouchDevice::TouchScreen); - touchDevice->setCapabilities(QTouchDevice::Position); - QWindowSystemInterface::registerTouchDevice(touchDevice); - QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("longList.qml")); QTRY_COMPARE(window->status(), QQuickView::Ready); @@ -1548,7 +1546,7 @@ void tst_qquickflickable::flickTwiceUsingTouches() QVERIFY(flickable != 0); QCOMPARE(flickable->contentY(), 0.0f); - flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240)); + flickWithTouch(window.data(), QPoint(100, 400), QPoint(100, 240)); qreal contentYAfterFirstFlick = flickable->contentY(); qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick; @@ -1556,7 +1554,7 @@ void tst_qquickflickable::flickTwiceUsingTouches() // Wait until view stops moving QTRY_VERIFY(!flickable->isMoving()); - flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240)); + flickWithTouch(window.data(), QPoint(100, 400), QPoint(100, 240)); // In the original bug, that second flick would cause Flickable to halt immediately qreal contentYAfterSecondFlick = flickable->contentY(); @@ -1564,7 +1562,7 @@ void tst_qquickflickable::flickTwiceUsingTouches() QTRY_VERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f)); } -void tst_qquickflickable::flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to) +void tst_qquickflickable::flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to) { QTest::touchEvent(window, touchDevice).press(0, from, window); QQuickTouchUtils::flush(window); @@ -1869,12 +1867,6 @@ void tst_qquickflickable::stopAtBounds() void tst_qquickflickable::nestedMouseAreaUsingTouch() { - QTouchDevice *touchDevice = new QTouchDevice; - touchDevice->setName("Fake Touchscreen"); - touchDevice->setType(QTouchDevice::TouchScreen); - touchDevice->setCapabilities(QTouchDevice::Position); - QWindowSystemInterface::registerTouchDevice(touchDevice); - QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("nestedmousearea.qml")); QTRY_COMPARE(window->status(), QQuickView::Ready); @@ -1887,7 +1879,7 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch() QVERIFY(flickable != 0); QCOMPARE(flickable->contentY(), 50.0f); - flickWithTouch(window.data(), touchDevice, QPoint(100, 300), QPoint(100, 200)); + flickWithTouch(window.data(), QPoint(100, 300), QPoint(100, 200)); // flickable should not have moved QCOMPARE(flickable->contentY(), 50.0); |