diff options
author | Martin Jones <martin.jones@nokia.com> | 2012-03-15 14:58:03 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-20 04:24:32 +0100 |
commit | 5d901a7435e98629b7f50488dbd45a1635bf767b (patch) | |
tree | cff467858d17fb21f9a120023fca5a7e72b2a847 /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | |
parent | 610df5cdf87b9e1566b01a273fe67905b035cb93 (diff) |
Restore view to sensible position if grab is cancelled.
If the mouse grab is stolen, return to allowed bounds.
Change-Id: Icc44da32ff62bed273f0ccbb5498766981cdf9a4
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 4b157a434b..9f5bd46864 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -77,6 +77,7 @@ private slots: void disabled(); void flickVelocity(); void margins(); + void cancel(); private: QQmlEngine engine; @@ -657,6 +658,41 @@ void tst_qquickflickable::margins() delete root; } +void tst_qquickflickable::cancel() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("cancel.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject()); + QVERIFY(flickable != 0); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10, 10)); + // drag out of bounds + QTest::mouseMove(canvas, QPoint(50, 50)); + QTest::mouseMove(canvas, QPoint(100, 100)); + QTest::mouseMove(canvas, QPoint(150, 150)); + + QVERIFY(flickable->contentX() != 0); + QVERIFY(flickable->contentY() != 0); + QVERIFY(flickable->isMoving()); + QVERIFY(flickable->isDragging()); + + // grabbing mouse will cancel flickable interaction. + QQuickItem *item = canvas->rootObject()->findChild<QQuickItem*>("row"); + item->grabMouse(); + + QTRY_COMPARE(flickable->contentX(), 0.); + QTRY_COMPARE(flickable->contentY(), 0.); + QTRY_VERIFY(!flickable->isMoving()); + QTRY_VERIFY(!flickable->isDragging()); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10)); +} + + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |