diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-02-21 04:57:08 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-02-21 06:08:41 (GMT) |
commit | 1bcddaaf318fc37c71c5191913f3487c49444ec6 (patch) | |
tree | 82984444b9874bdaf21c1b5f7a62dc593a98ebef /tests | |
parent | 8e9c28eaa4d7a3372b9a9a21a984701b62f96456 (diff) | |
download | Qt-1bcddaaf318fc37c71c5191913f3487c49444ec6.zip Qt-1bcddaaf318fc37c71c5191913f3487c49444ec6.tar.gz Qt-1bcddaaf318fc37c71c5191913f3487c49444ec6.tar.bz2 |
Prevent recursion due to nested Flickables with pressDelay
The outermost Flickable handles pressDelay for all descendents, rather
than having it cascade up and replayed multiple times.
Change-Id: Id294862469f3ce56b0940fbbb0e041d4c9f64f28
Task-number: QTBUG-17361
Reviewed-by: Michael Brasser
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 29 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 20 |
2 files changed, 34 insertions, 15 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index f4bec8f..736f8f4 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -69,6 +69,7 @@ private slots: void maximumFlickVelocity(); void flickDeceleration(); void pressDelay(); + void nestedPressDelay(); void flickableDirection(); void qgraphicswidget(); void resizeContent(); @@ -246,6 +247,34 @@ void tst_qdeclarativeflickable::pressDelay() QCOMPARE(spy.count(),1); } +// QTBUG-17361 +void tst_qdeclarativeflickable::nestedPressDelay() +{ + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/nestedPressDelay.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlickable *outer = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject()); + QVERIFY(outer != 0); + + QDeclarativeFlickable *inner = canvas->rootObject()->findChild<QDeclarativeFlickable*>("innerFlickable"); + QVERIFY(inner != 0); + + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150))); + // the MouseArea is not pressed immediately + QVERIFY(outer->property("pressed").toBool() == false); + + // The outer pressDelay will prevail (50ms, vs. 10sec) + QTest::qWait(300); + QVERIFY(outer->property("pressed").toBool() == true); + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150))); + + delete canvas; +} + void tst_qdeclarativeflickable::flickableDirection() { QDeclarativeComponent component(&engine); diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 60d51c6..e1c34fc 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -541,15 +541,11 @@ void tst_QDeclarativeMouseArea::preventStealing() QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QDeclarativeMouseEvent*))); - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(80, 80)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80))); // Without preventStealing, mouse movement over MouseArea would // cause the Flickable to steal mouse and trigger content movement. + QGraphicsScene *scene = canvas->scene(); QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); moveEvent.setScenePos(QPointF(70, 70)); moveEvent.setButton(Qt::LeftButton); @@ -574,17 +570,12 @@ void tst_QDeclarativeMouseArea::preventStealing() QCOMPARE(flickable->contentX(), 0.); QCOMPARE(flickable->contentY(), 0.); - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(50, 50)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50))); // Now allow stealing and confirm Flickable does its thing. canvas->rootObject()->setProperty("stealing", false); - pressEvent.setScenePos(QPointF(80, 80)); - QApplication::sendEvent(scene, &pressEvent); + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80))); // Without preventStealing, mouse movement over MouseArea would // cause the Flickable to steal mouse and trigger content movement. @@ -606,8 +597,7 @@ void tst_QDeclarativeMouseArea::preventStealing() QCOMPARE(flickable->contentX(), 10.); QCOMPARE(flickable->contentY(), 10.); - releaseEvent.setScenePos(QPointF(50, 50)); - QApplication::sendEvent(scene, &releaseEvent); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50))); delete canvas; } |