aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-07-29 09:29:04 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-29 04:08:13 +0200
commit44f82f2078897270622581e1c3f385d12c3aba42 (patch)
tree6ed42ab4fb990a8722dd35bf92dd45ec99a429c7 /tests
parent2b9cccc859edb271f84728350d1a7666bbba111f (diff)
Clicking on a disabled ListView's delegate breaks mouse interaction
A disabled Flickable should not filter children. Change-Id: I9f0d8fbfd0922b5c6a9eaffa69212867359f79e0 Fixes: QTBUG-20584 Reviewed-on: http://codereview.qt.nokia.com/2354 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgflickable/data/disabled.qml30
-rw-r--r--tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp34
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp33
4 files changed, 127 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsgflickable/data/disabled.qml b/tests/auto/declarative/qsgflickable/data/disabled.qml
new file mode 100644
index 0000000000..9b679827c7
--- /dev/null
+++ b/tests/auto/declarative/qsgflickable/data/disabled.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 100; height: 100
+ property bool clicked: false
+
+ Flickable {
+ objectName: "flickable"
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+ enabled: false
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle {
+ width: 200; height: 300; color: "blue"
+ MouseArea { anchors.fill: parent; onClicked: { } }
+ }
+ }
+ }
+ }
+
+ MouseArea {
+ width: 100; height: 30
+ onClicked: root.clicked = true
+ }
+}
diff --git a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
index b7c43ce5b0..fe96453140 100644
--- a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
+++ b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
@@ -78,6 +78,7 @@ private slots:
void returnToBounds();
void wheel();
void movingAndDragging();
+ void disabled();
private:
QDeclarativeEngine engine;
@@ -512,6 +513,39 @@ void tst_qsgflickable::movingAndDragging()
delete canvas;
}
+void tst_qsgflickable::disabled()
+{
+ QSGView *canvas = new QSGView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QSGFlickable *flick = canvas->rootObject()->findChild<QSGFlickable*>("flickable");
+ QVERIFY(flick != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, QPoint(50, 70), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, QPoint(50, 60), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ QVERIFY(flick->isMoving() == false);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ // verify that mouse clicks on other elements still work (QTBUG-20584)
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+
+ QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
+}
+
template<typename T>
T *tst_qsgflickable::findItem(QSGItem *parent, const QString &objectName)
{
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml
new file mode 100644
index 0000000000..ac63cd461b
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml
@@ -0,0 +1,30 @@
+import QtQuick 1.0
+
+Rectangle {
+ id: root
+ width: 100; height: 100
+ property bool clicked: false
+
+ Flickable {
+ objectName: "flickable"
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+ enabled: false
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle {
+ width: 200; height: 300; color: "blue"
+ MouseArea { anchors.fill: parent; onClicked: { } }
+ }
+ }
+ }
+ }
+
+ MouseArea {
+ width: 100; height: 30
+ onClicked: root.clicked = true
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index f74f02c8ff..a0473a620b 100644
--- a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -78,6 +78,7 @@ private slots:
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
void wheel();
+ void disabled();
private:
QDeclarativeEngine engine;
@@ -480,6 +481,38 @@ void tst_qdeclarativeflickable::wheel()
delete canvas;
}
+void tst_qdeclarativeflickable::disabled()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarative1Flickable *flick = canvas->rootObject()->findChild<QDeclarative1Flickable*>("flickable");
+ QVERIFY(flick != 0);
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50,90)));
+
+ QMouseEvent moveEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ QVERIFY(flick->isMoving() == false);
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 60)));
+
+ // verify that mouse clicks on other elements still work (QTBUG-20584)
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10)));
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10)));
+
+ QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
+}
template<typename T>
T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)