aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-08-21 22:22:13 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-08-22 11:51:36 +0000
commit0eb65826c85aee9431c1a1f4ef3289abac2ae27d (patch)
tree63b660ff671671e7ffa9bf44d43b8ead0678fddd /tests/auto/quick/pointerhandlers
parentd83cb16d3cecad7ec2e9b45416620b87b52f2885 (diff)
Ensure that SinglePointHandler handles touch points
A QQuickPointerTouchEvent's button and buttons properties are not currently set (although we had some uncertainty in the past about whether it would be appropriate for a touch press to simulate a left button press). So it seems that f2ba3bd9792500b4d3fcfd23b03098a32641ef4f broke the behavior of PointHandler on touchscreens. Change-Id: I890cc9889e847636c8f385753e47a078ec582195 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
index 4253937280..d91c89d833 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
@@ -48,16 +48,19 @@ class tst_PointHandler : public QQmlDataTest
Q_OBJECT
public:
tst_PointHandler()
+ : touchDevice(QTest::createTouchDevice())
{}
private slots:
void initTestCase();
+ void singleTouch();
void pressedMultipleButtons_data();
void pressedMultipleButtons();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
+ QTouchDevice *touchDevice;
};
void tst_PointHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName)
@@ -81,6 +84,57 @@ void tst_PointHandler::initTestCase()
QQmlDataTest::initTestCase();
}
+void tst_PointHandler::singleTouch()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "pointTracker.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem *tracker = window->rootObject()->findChild<QQuickItem *>("pointTracker");
+ QVERIFY(tracker);
+ QQuickPointHandler *handler = window->rootObject()->findChild<QQuickPointHandler *>("pointHandler");
+ QVERIFY(handler);
+
+ QSignalSpy activeSpy(handler, SIGNAL(activeChanged()));
+ QSignalSpy pointSpy(handler, SIGNAL(pointChanged()));
+ QSignalSpy translationSpy(handler, SIGNAL(translationChanged()));
+
+ QPoint point(100,100);
+ QTest::touchEvent(window, touchDevice).press(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(pointSpy.count(), 1);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(handler->translation(), QVector2D());
+ QCOMPARE(translationSpy.count(), 1);
+
+ point += QPoint(10, 10);
+ QTest::touchEvent(window, touchDevice).move(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(pointSpy.count(), 2);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().scenePressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().pressedButtons(), Qt::NoButton);
+ QVERIFY(handler->point().velocity().x() > 0);
+ QVERIFY(handler->point().velocity().y() > 0);
+ QCOMPARE(handler->translation(), QVector2D(10, 10));
+ QCOMPARE(translationSpy.count(), 2);
+
+ QTest::touchEvent(window, touchDevice).release(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(handler->active(), false);
+ QCOMPARE(activeSpy.count(), 2);
+ QCOMPARE(pointSpy.count(), 3);
+ QCOMPARE(handler->translation(), QVector2D());
+ QCOMPARE(translationSpy.count(), 3);
+}
+
void tst_PointHandler::pressedMultipleButtons_data()
{
QTest::addColumn<Qt::MouseButtons>("accepted");