diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2016-10-01 13:18:08 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-10-03 09:26:55 +0000 |
commit | b0bc5f81eb3ef5f5e99bd0e49ca9a7c33b131260 (patch) | |
tree | 3464b0eaf2eccaa9b84d60dfab9f5289948072e5 /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | |
parent | 5a59b11ce8c4230e3a7609e3ca46119340153052 (diff) |
Add a test that verifies that keepMouseGrab works
Change-Id: I17c736994f05a63574b518b1d23facde001eacbf
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index a03e3b8170..18dd1bc325 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -33,6 +33,7 @@ #include <QtQuick/qquickview.h> #include <private/qquickflickable_p.h> #include <private/qquickflickable_p_p.h> +#include <private/qquickmousearea_p.h> #include <private/qquicktransition_p.h> #include <private/qqmlvaluetype_p.h> #include <math.h> @@ -92,6 +93,7 @@ private slots: void contentSize(); void ratios_smallContent(); void contentXYNotTruncatedToInt(); + void keepGrab(); private: void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); @@ -1863,6 +1865,52 @@ void tst_qquickflickable::contentXYNotTruncatedToInt() QVERIFY(flickable->contentX() > qreal(1e10)); } +void tst_qquickflickable::keepGrab() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("keepGrab.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(flickable); + + QQuickMouseArea *ma = flickable->findChild<QQuickMouseArea*>("ma"); + QVERIFY(ma); + ma->setPreventStealing(true); + + QPoint pos(250, 250); + moveAndPress(window.data(), pos); + for (int i = 0; i < 6; ++i) { + pos += QPoint(10, 10); + QTest::mouseMove(window.data(), pos); + QTest::qWait(10); + } + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(310, 310)); + QTest::qWait(10); + + QCOMPARE(flickable->contentX(), 0.0); + QCOMPARE(flickable->contentY(), 0.0); + + ma->setPreventStealing(false); + + pos = QPoint(250, 250); + moveAndPress(window.data(), pos); + for (int i = 0; i < 6; ++i) { + pos += QPoint(10, 10); + QTest::mouseMove(window.data(), pos); + QTest::qWait(10); + } + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(310, 310)); + QTest::qWait(10); + + QVERIFY(flickable->contentX() != 0.0); + QVERIFY(flickable->contentY() != 0.0); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |