From 5d480e52f8cc91c29d71687447fe77f2fa1f51fd Mon Sep 17 00:00:00 2001 From: Adriano Rezende Date: Sun, 26 Feb 2012 17:26:46 +0100 Subject: [PATCH] MultiPointTouchArea autotest checks touch events with transformations Tests touch events with graphical transformations applied to the element. Change-Id: Ie070ed2dc0ab64249455b95c382f920b3cd7b7b2 Reviewed-by: Frederik Gladhorn --- .../data/transformedMultiPointTouchArea.qml | 26 ++++++++ .../tst_qquickmultipointtoucharea.cpp | 61 ++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml b/tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml new file mode 100644 index 0000000..296bf79 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + x: 100 + y: 100 + width: 200 + height: 200 + rotation: 45 + + MultiPointTouchArea { + scale: 0.5 + anchors.fill: parent + maximumTouchPoints: 5 + objectName: "touchArea" + + property int pointCount: 0 + + onPressed: pointCount = touchPoints.length; + onTouchUpdated: pointCount = touchPoints.length; + } + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index 2fc8231..fa5fb58 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -72,6 +72,8 @@ private slots: void inFlickable(); void inFlickable2(); void invisible(); + void transformedTouchArea_data(); + void transformedTouchArea(); private: QQuickView *createAndShowView(const QString &file); @@ -784,6 +786,65 @@ void tst_QQuickMultiPointTouchArea::invisible() delete canvas; } +void tst_QQuickMultiPointTouchArea::transformedTouchArea_data() +{ + QTest::addColumn("p1"); + QTest::addColumn("p2"); + QTest::addColumn("p3"); + QTest::addColumn("total1"); + QTest::addColumn("total2"); + QTest::addColumn("total3"); + + QTest::newRow("1st point inside") + << QPoint(140, 200) << QPoint(260, 260) << QPoint(0, 140) << 1 << 1 << 1; + + QTest::newRow("2nd point inside") + << QPoint(260, 260) << QPoint(200, 200) << QPoint(0, 0) << 0 << 1 << 1; + + QTest::newRow("3rd point inside") + << QPoint(140, 260) << QPoint(260, 140) << QPoint(200, 140) << 0 << 0 << 1; + + QTest::newRow("all points inside") + << QPoint(200, 140) << QPoint(200, 260) << QPoint(140, 200) << 1 << 2 << 3; + + QTest::newRow("all points outside") + << QPoint(140, 140) << QPoint(260, 260) << QPoint(260, 140) << 0 << 0 << 0; + + QTest::newRow("1st and 2nd points inside") + << QPoint(200, 260) << QPoint(200, 140) << QPoint(140, 140) << 1 << 2 << 2; + + QTest::newRow("1st and 3rd points inside") + << QPoint(200, 200) << QPoint(0, 0) << QPoint(200, 260) << 1 << 1 << 2; +} + +void tst_QQuickMultiPointTouchArea::transformedTouchArea() +{ + QFETCH(QPoint, p1); + QFETCH(QPoint, p2); + QFETCH(QPoint, p3); + QFETCH(int, total1); + QFETCH(int, total2); + QFETCH(int, total3); + + QQuickView *canvas = createAndShowView("transformedMultiPointTouchArea.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickMultiPointTouchArea *area = canvas->rootObject()->findChild("touchArea"); + QVERIFY(area != 0); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).commit(); + QCOMPARE(area->property("pointCount").toInt(), total1); + + sequence.stationary(0).press(1, p2).commit(); + QCOMPARE(area->property("pointCount").toInt(), total2); + + sequence.stationary(0).stationary(1).press(2, p3).commit(); + QCOMPARE(area->property("pointCount").toInt(), total3); + + delete canvas; +} QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) { -- 1.7.2.5