diff options
author | Pasi Pentikainen <ext-pasi.a.pentikainen@nokia.com> | 2012-05-04 14:47:55 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-08 00:39:44 (GMT) |
commit | 0f73af96c8ac823761f6ad4f364ce346688e4621 (patch) | |
tree | 3d3c34648ec1cf2d877253f9ed245903e41476e4 /tests | |
parent | b889b3c8e83a56526eae04289ab9b1608d268b2a (diff) | |
download | Qt-0f73af96c8ac823761f6ad4f364ce346688e4621.zip Qt-0f73af96c8ac823761f6ad4f364ce346688e4621.tar.gz Qt-0f73af96c8ac823761f6ad4f364ce346688e4621.tar.bz2 |
Clicking on a disabled ListView's delegate breaks mouse interaction
A disabled Flickable should not filter children.
This is a backport of change I9f0d8fbfd0922b5c6a9eaffa69212867359f79e0,
from Qt5 (later discarded in QtQuick1 restructuring of Qt5).
Task-number: QTBUG-20584
Change-Id: Id279907ee90faf19284c12b548467850662a7019
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeflickable/data/disabled.qml | 30 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 35 |
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/disabled.qml b/tests/auto/declarative/qdeclarativeflickable/data/disabled.qml new file mode 100644 index 0000000..ac63cd4 --- /dev/null +++ b/tests/auto/declarative/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/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 748760a..c248d8c 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -79,6 +79,7 @@ private slots: void testQtQuick11Attributes_data(); void wheel(); void flickVelocity(); + void disabled(); private: QDeclarativeEngine engine; @@ -528,6 +529,40 @@ void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); } +void tst_qdeclarativeflickable::disabled() +{ + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlickable *flick = canvas->rootObject()->findChild<QDeclarativeFlickable*>("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) { |