diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-08-15 18:40:58 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-08-15 18:44:54 +0200 |
commit | 2be575b4b1e6f6e11a8dbd0b1c05c003828d2598 (patch) | |
tree | 55d2bfaff9583b3e1e9f3291f4b91f34adae1d92 /tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp | |
parent | 4a5939d26d1e36efdb2b30cdee1f3672587c3fa5 (diff) | |
parent | 9e32b23a1514f367921b4a9ee25bc864a008463c (diff) |
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I6f2152aeecaeb8e63fdbc1cdf1444132a054b6f5
Diffstat (limited to 'tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp')
-rw-r--r-- | tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp index 58bc3d40b5..35fed99e8b 100644 --- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp @@ -56,6 +56,7 @@ private slots: void touchDrag(); void touchesThenPinch(); void unloadHandlerWithPassiveGrab(); + void dragHandlerInParentStealingGrabFromItem(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -300,6 +301,48 @@ void tst_MptaInterop::unloadHandlerWithPassiveGrab() QTest::mouseRelease(window, Qt::LeftButton, 0, point); // QTBUG-73819: don't crash } +void tst_MptaInterop::dragHandlerInParentStealingGrabFromItem() // QTBUG-75025 +{ + const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "dragParentOfMPTA.qml"); + QQuickView * window = windowPtr.data(); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::genericMouseDevice()); + + QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); + QVERIFY(handler); + QQuickMultiPointTouchArea *mpta = window->rootObject()->findChild<QQuickMultiPointTouchArea*>(); + QVERIFY(mpta); + + // In QTBUG-75025 there is a QQ Controls Button; the MPTA here stands in for that, + // simply as an Item that grabs the mouse. The bug has nothing to do with MPTA specifically. + + QPoint point(20, 20); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, point); + QCOMPARE(window->mouseGrabberItem(), mpta); + QCOMPARE(window->rootObject()->property("touchpointPressed").toBool(), true); + + // Start dragging + // DragHandler keeps monitoring, due to its passive grab, + // and eventually steals the exclusive grab from MPTA + int dragStoleGrab = 0; + for (int i = 0; i < 4; ++i) { + point += QPoint(dragThreshold / 2, 0); + QTest::mouseMove(window, point); + if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler) + dragStoleGrab = i; + } + if (dragStoleGrab) + qCDebug(lcPointerTests, "DragHandler stole the grab after %d events", dragStoleGrab); + QVERIFY(dragStoleGrab > 1); + QCOMPARE(handler->active(), true); + QCOMPARE(window->rootObject()->property("touchpointPressed").toBool(), false); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, point); + QCOMPARE(handler->active(), false); + QCOMPARE(window->rootObject()->property("touchpointPressed").toBool(), false); +} + QTEST_MAIN(tst_MptaInterop) #include "tst_multipointtoucharea_interop.moc" |