summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-02-02 06:06:36 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2011-02-02 06:14:25 (GMT)
commitac5e89a2fd94c4eb45e79e2c19b3ef5e9b240cb9 (patch)
tree75f62aa41f7c56416d38b02222eccad0bbf6584d /tests
parent7836b89fbbb29ee16df863aea460c1c34d4321c9 (diff)
downloadQt-ac5e89a2fd94c4eb45e79e2c19b3ef5e9b240cb9.zip
Qt-ac5e89a2fd94c4eb45e79e2c19b3ef5e9b240cb9.tar.gz
Qt-ac5e89a2fd94c4eb45e79e2c19b3ef5e9b240cb9.tar.bz2
Make Flickable's wheel handling more like QAbstractScrollArea.
Vertical scrolling should only affect vertical movement, and horizontal scrolling should only affect horizontal movement. Task-number: QTBUG-7369 Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/wheel.qml21
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp39
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/wheel.qml b/tests/auto/declarative/qdeclarativeflickable/data/wheel.qml
new file mode 100644
index 0000000..6ea81b2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/wheel.qml
@@ -0,0 +1,21 @@
+import QtQuick 1.1
+
+Rectangle {
+ width: 400
+ height: 400
+ color: "gray"
+
+ Flickable {
+ id: flick
+ objectName: "flick"
+ anchors.fill: parent
+ contentWidth: 800
+ contentHeight: 800
+
+ Rectangle {
+ width: flick.contentWidth
+ height: flick.contentHeight
+ color: "red"
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index ae1e99e..f4bec8f 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QSignalSpy>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
#include <private/qdeclarativeflickable_p.h>
#include <private/qdeclarativevaluetype_p.h>
#include <QtGui/qgraphicswidget.h>
@@ -74,6 +75,7 @@ private slots:
void returnToBounds();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
+ void wheel();
private:
QDeclarativeEngine engine;
@@ -373,6 +375,43 @@ void tst_qdeclarativeflickable::testQtQuick11Attributes_data()
}
+void tst_qdeclarativeflickable::wheel()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/wheel.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeFlickable *flick = canvas->rootObject()->findChild<QDeclarativeFlickable*>("flick");
+ QVERIFY(flick != 0);
+
+ QGraphicsScene *scene = canvas->scene();
+ QGraphicsSceneWheelEvent event(QEvent::GraphicsSceneWheel);
+ event.setScenePos(QPointF(200, 200));
+ event.setDelta(-120);
+ event.setOrientation(Qt::Vertical);
+ event.setAccepted(false);
+ QApplication::sendEvent(scene, &event);
+
+ QTRY_VERIFY(flick->contentY() > 0);
+ QVERIFY(flick->contentX() == 0);
+
+ flick->setContentY(0);
+ QVERIFY(flick->contentY() == 0);
+
+ event.setScenePos(QPointF(200, 200));
+ event.setDelta(-120);
+ event.setOrientation(Qt::Horizontal);
+ event.setAccepted(false);
+ QApplication::sendEvent(scene, &event);
+
+ QTRY_VERIFY(flick->contentX() > 0);
+ QVERIFY(flick->contentY() == 0);
+
+ delete canvas;
+}
+
template<typename T>
T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)