aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpincharea
diff options
context:
space:
mode:
authorAdriano Rezende <atdrez@gmail.com>2012-02-26 17:26:32 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-13 17:01:28 +0200
commit2821134d18f221505983bfbdd622470cb363d9a6 (patch)
tree0681ac9c1cabe4dc90e8c093b398a89e19769ccb /tests/auto/quick/qquickpincharea
parent5094493d28dc3e4618eb02d1cbe949627e02556c (diff)
Adjust PinchArea autotest to check pinch events with transformations
Tests pinch events with graphical transformations applied to the element. Change-Id: I35810d9859678d4c468c0c1e8614f0928d52775b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickpincharea')
-rw-r--r--tests/auto/quick/qquickpincharea/data/transformedPinchArea.qml33
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp65
2 files changed, 98 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpincharea/data/transformedPinchArea.qml b/tests/auto/quick/qquickpincharea/data/transformedPinchArea.qml
new file mode 100644
index 0000000000..7d5d88a5bd
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/data/transformedPinchArea.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ x: 100
+ y: 100
+ width: 200
+ height: 200
+ rotation: 45
+
+ Rectangle {
+ id: rect
+ scale: 0.5
+ color: "black"
+ anchors.fill: parent
+
+ PinchArea {
+ anchors.fill: parent
+ objectName: "pinchArea"
+
+ property bool pinching: false
+
+ pinch.target: rect
+ pinch.dragAxis: Drag.XandYAxis
+ onPinchStarted: pinching = true
+ onPinchFinished: pinching = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
index e29ed48c68..f24daa30af 100644
--- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
+#include <QtGui/QStyleHints>
#include <private/qquickpincharea_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/qquickview.h>
@@ -60,6 +61,8 @@ private slots:
void scale();
void pan();
void retouch();
+ void transformedPinchArea_data();
+ void transformedPinchArea();
private:
QQuickView *createView();
@@ -414,6 +417,68 @@ void tst_QQuickPinchArea::retouch()
delete canvas;
}
+void tst_QQuickPinchArea::transformedPinchArea_data()
+{
+ QTest::addColumn<QPoint>("p1");
+ QTest::addColumn<QPoint>("p2");
+ QTest::addColumn<bool>("shouldPinch");
+
+ QTest::newRow("checking inner pinch 1")
+ << QPoint(200, 140) << QPoint(200, 260) << true;
+
+ QTest::newRow("checking inner pinch 2")
+ << QPoint(140, 200) << QPoint(200, 140) << true;
+
+ QTest::newRow("checking inner pinch 3")
+ << QPoint(140, 200) << QPoint(260, 200) << true;
+
+ QTest::newRow("checking outer pinch 1")
+ << QPoint(140, 140) << QPoint(260, 260) << false;
+
+ QTest::newRow("checking outer pinch 2")
+ << QPoint(140, 140) << QPoint(200, 200) << false;
+
+ QTest::newRow("checking outer pinch 3")
+ << QPoint(140, 260) << QPoint(260, 260) << false;
+}
+
+void tst_QQuickPinchArea::transformedPinchArea()
+{
+ QFETCH(QPoint, p1);
+ QFETCH(QPoint, p2);
+ QFETCH(bool, shouldPinch);
+
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("transformedPinchArea.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pinchArea");
+ QVERIFY(pinchArea != 0);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(canvas, device);
+ // start pinch
+ pinchSequence.press(0, p1, canvas).commit();
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object.
+ pinchSequence.stationary(0).press(1, p2, canvas).commit();
+ pinchSequence.stationary(0).move(1, p2 + QPoint(threshold * 2, 0), canvas).commit();
+ QCOMPARE(pinchArea->property("pinching").toBool(), shouldPinch);
+
+ // release pinch
+ pinchSequence.release(0, p1, canvas).release(1, p2, canvas).commit();
+ QCOMPARE(pinchArea->property("pinching").toBool(), false);
+ }
+
+ delete canvas;
+}
+
QQuickView *tst_QQuickPinchArea::createView()
{
QQuickView *canvas = new QQuickView(0);