aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable
diff options
context:
space:
mode:
authorAdriano Rezende <atdrez@gmail.com>2012-02-26 17:26:49 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-14 15:07:19 +0200
commitcb86525df6e4721cd150dea2a2f93d1bf54f478f (patch)
tree457a39fb7af1926e9410c65117426b127c2f9b18 /tests/auto/quick/qquickflickable
parentd3e6cffa7f7f803cc216e801ed77b7be222d1aff (diff)
Adjust Flickable autotest to check mouse events with transformation
Tests mouse events with graphical transformations applied to the element. Change-Id: I767a40ca0d5ed748bcb27ad23212ddbc22272fc5 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r--tests/auto/quick/qquickflickable/data/transformedFlickable.qml43
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp48
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/transformedFlickable.qml b/tests/auto/quick/qquickflickable/data/transformedFlickable.qml
new file mode 100644
index 0000000000..ed5b0ae8c5
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/transformedFlickable.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ x: 100
+ y: 100
+ width: 200
+ height: 200
+ rotation: 45
+
+ Rectangle {
+ scale: 0.5
+ color: "#888888"
+ anchors.fill: parent
+
+ Flickable {
+ id: flickable
+ contentHeight: 300
+ anchors.fill: parent
+ objectName: "flickable"
+
+ property alias itemPressed: mouseArea.pressed
+
+ Rectangle {
+ x: 50
+ y: 50
+ width: 100
+ height: 100
+ scale: 0.4
+ color: "red"
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 242f639ee2..90f4b6c311 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <qtest.h>
#include <QtTest/QSignalSpy>
+#include <QtGui/QStyleHints>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/qquickview.h>
@@ -86,6 +87,7 @@ private slots:
void flickVelocity();
void margins();
void cancelOnMouseGrab();
+ void clickAndDragWhenTransformed();
private:
QQmlEngine engine;
@@ -1133,6 +1135,52 @@ void tst_qquickflickable::cancelOnMouseGrab()
QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
}
+void tst_qquickflickable::clickAndDragWhenTransformed()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("transformedFlickable.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = canvas->rootObject()->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flickable != 0);
+
+ // click outside child rect
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(190, 190));
+ QTest::qWait(10);
+ QCOMPARE(flickable->property("itemPressed").toBool(), false);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(190, 190));
+
+ // click inside child rect
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(200, 200));
+ QTest::qWait(10);
+ QCOMPARE(flickable->property("itemPressed").toBool(), true);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(200, 200));
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ // drag outside bounds
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(160, 160));
+ QTest::qWait(10);
+ QTest::mouseMove(canvas, QPoint(160 + threshold * 2, 160));
+ QTest::mouseMove(canvas, QPoint(160 + threshold * 3, 160));
+ QCOMPARE(flickable->isDragging(), false);
+ QCOMPARE(flickable->property("itemPressed").toBool(), false);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(180, 160));
+
+ // drag inside bounds
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(200, 140));
+ QTest::qWait(10);
+ QTest::mouseMove(canvas, QPoint(200 + threshold * 2, 140));
+ QTest::mouseMove(canvas, QPoint(200 + threshold * 3, 140));
+ QCOMPARE(flickable->isDragging(), true);
+ QCOMPARE(flickable->property("itemPressed").toBool(), false);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(220, 140));
+
+ delete canvas;
+}
QTEST_MAIN(tst_qquickflickable)