aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-03-15 14:58:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 04:24:32 +0100
commit5d901a7435e98629b7f50488dbd45a1635bf767b (patch)
treecff467858d17fb21f9a120023fca5a7e72b2a847 /tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
parent610df5cdf87b9e1566b01a273fe67905b035cb93 (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/qquickpathview/tst_qquickpathview.cpp')
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 8866cafd80..613156b2f5 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -123,6 +123,7 @@ private slots:
void creationContext();
void currentOffsetOnInsertion();
void asynchronous();
+ void cancelDrag();
};
class TestObject : public QObject
@@ -1453,6 +1454,41 @@ void tst_QQuickPathView::missingPercent()
delete obj;
}
+void tst_QQuickPathView::cancelDrag()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("dragpath.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(canvas, qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ // drag between snap points
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
+ QTest::qWait(100);
+ QTest::mouseMove(canvas, QPoint(30, 100));
+ QTest::mouseMove(canvas, QPoint(85, 100));
+
+ QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset()));
+ QTRY_VERIFY(pathview->isMoving());
+
+ // steal mouse grab - cancels PathView dragging
+ QQuickItem *item = canvas->rootObject()->findChild<QQuickItem*>("text");
+ item->grabMouse();
+
+ // returns to a snap point.
+ QTRY_VERIFY(pathview->offset() == qFloor(pathview->offset()));
+ QTRY_VERIFY(!pathview->isMoving());
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
+
+ delete canvas;
+}
+
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"