aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmultipointtoucharea
diff options
context:
space:
mode:
authorAdriano Rezende <atdrez@gmail.com>2012-02-26 17:26:46 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-13 17:01:28 +0200
commit5d480e52f8cc91c29d71687447fe77f2fa1f51fd (patch)
tree4f8ada99d05db6461a8050743c96ee9ccd896754 /tests/auto/quick/qquickmultipointtoucharea
parent2821134d18f221505983bfbdd622470cb363d9a6 (diff)
MultiPointTouchArea autotest checks touch events with transformations
Tests touch events with graphical transformations applied to the element. Change-Id: Ie070ed2dc0ab64249455b95c382f920b3cd7b7b2 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickmultipointtoucharea')
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml26
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp61
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml b/tests/auto/quick/qquickmultipointtoucharea/data/transformedMultiPointTouchArea.qml
new file mode 100644
index 0000000000..296bf7996f
--- /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 2fc823131b..fa5fb58225 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<QPoint>("p1");
+ QTest::addColumn<QPoint>("p2");
+ QTest::addColumn<QPoint>("p3");
+ QTest::addColumn<int>("total1");
+ QTest::addColumn<int>("total2");
+ QTest::addColumn<int>("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<QQuickMultiPointTouchArea *>("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)
{