aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLuis Gabriel Lima <luis.gabriel@openbossa.org>2012-01-05 15:19:26 -0300
committerQt by Nokia <qt-info@nokia.com>2012-03-10 02:28:11 +0100
commitf2e1be963f885a6030136591414cdbda26d50695 (patch)
tree3ff02cedfbf5df61e8459dc6d58afd437b23e87b /tests
parent78356f6038065227acb2dc898994765f49f07b42 (diff)
Add mouse wheel events handler to MouseArea
This patch was based on the attached patch in QTBUG-7369. It basically exposes the wheel events to MouseArea via the onWheel signal. The current API is based on the new QWheelEvent API introduced by this patch: http://codereview.qt-project.org/#change,12532 Task-number: QTBUG-7369 Change-Id: Id58513715c2d0ae81e3a69e9e1ed400bbae07507 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickmousearea/data/wheel.qml24
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp21
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/data/wheel.qml b/tests/auto/quick/qquickmousearea/data/wheel.qml
new file mode 100644
index 0000000000..3e0c0c2a48
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/wheel.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ property var angleDeltaY
+ property real mouseX
+ property real mouseY
+ property bool controlPressed
+
+ width: 400
+ height: 400
+
+ MouseArea {
+ anchors.fill: parent
+
+ onWheel: {
+ root.angleDeltaY = wheel.angleDelta.y;
+ root.mouseX = wheel.x;
+ root.mouseY = wheel.y;
+ root.controlPressed = wheel.modifiers & Qt.ControlModifier;
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 4375e835aa..0b4a6fa438 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -73,6 +73,7 @@ private slots:
void hoverPropagation();
void hoverVisible();
void disableAfterPress();
+ void onWheel();
private:
QQuickView *createView();
@@ -906,6 +907,26 @@ void tst_QQuickMouseArea::disableAfterPress()
delete canvas;
}
+void tst_QQuickMouseArea::onWheel()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("wheel.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QWheelEvent wheelEvent(QPoint(10, 32), QPoint(10, 32), QPoint(60, 20), QPoint(0, 120),
+ 0, Qt::Vertical,Qt::NoButton, Qt::ControlModifier);
+ QGuiApplication::sendEvent(canvas, &wheelEvent);
+
+ QCOMPARE(root->property("angleDeltaY").toInt(), 120);
+ QCOMPARE(root->property("mouseX").toReal(), qreal(10));
+ QCOMPARE(root->property("mouseY").toReal(), qreal(32));
+ QCOMPARE(root->property("controlPressed").toBool(), true);
+
+ delete canvas;
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"