From 79a3119a955f5edc5476818d5c44b0603b677403 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 17 Nov 2020 12:35:32 +0100 Subject: Fix tests that used out-of-context mouse grabs QQuickItem::grabMouse() is deprecated, and cannot be used at all when there is no current event being delivered. But we can still use QPointingDevicePrivate::setExclusiveGrabber(). Task-number: QTBUG-86729 Change-Id: I215de471e6dc44551720bc4c766b22cdfee94423 Reviewed-by: Volker Hilsheimer --- tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 8 ++++---- tests/auto/quick/qquickpathview/BLACKLIST | 2 -- tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 tests/auto/quick/qquickpathview/BLACKLIST (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 310ab17db4..2bd5d6bd1b 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1565,8 +1565,6 @@ void tst_qquickflickable::cancelOnHide() void tst_qquickflickable::cancelOnMouseGrab() { - QSKIP("need a realistic test scenario: can no longer grab mouse between events"); - QScopedPointer window(new QQuickView); window->setSource(testFileUrl("cancel.qml")); QTRY_COMPARE(window->status(), QQuickView::Ready); @@ -1592,7 +1590,10 @@ void tst_qquickflickable::cancelOnMouseGrab() // grabbing mouse will cancel flickable interaction. QQuickItem *item = window->rootObject()->findChild("row"); - item->grabMouse(); + auto mouse = QPointingDevice::primaryPointingDevice(); + auto mousePriv = QPointingDevicePrivate::get(const_cast(mouse)); + QMouseEvent fakeMouseEv(QEvent::MouseMove, QPoint(130, 100), Qt::NoButton, Qt::LeftButton, Qt::NoModifier, mouse); + mousePriv->setExclusiveGrabber(&fakeMouseEv, fakeMouseEv.points().first(), item); QTRY_COMPARE(flickable->contentX(), 0.); QTRY_COMPARE(flickable->contentY(), 0.); @@ -1600,7 +1601,6 @@ void tst_qquickflickable::cancelOnMouseGrab() QTRY_VERIFY(!flickable->isDragging()); moveAndRelease(window.data(), QPoint(50, 10)); - } void tst_qquickflickable::clickAndDragWhenTransformed() diff --git a/tests/auto/quick/qquickpathview/BLACKLIST b/tests/auto/quick/qquickpathview/BLACKLIST deleted file mode 100644 index b315b8e565..0000000000 --- a/tests/auto/quick/qquickpathview/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[cancelDrag] -* # QTBUG-86729 diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index da350e6a39..733281c20d 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1930,8 +1930,10 @@ void tst_QQuickPathView::cancelDrag() QCOMPARE(dragEndedSpy.count(), 0); // steal mouse grab - cancels PathView dragging - QQuickItem *item = window->rootObject()->findChild("text"); - item->grabMouse(); + auto mouse = QPointingDevice::primaryPointingDevice(); + auto mousePriv = QPointingDevicePrivate::get(const_cast(mouse)); + QMouseEvent fakeMouseEv(QEvent::MouseMove, QPoint(130, 100), Qt::NoButton, Qt::LeftButton, Qt::NoModifier, mouse); + mousePriv->setExclusiveGrabber(&fakeMouseEv, fakeMouseEv.points().first(), nullptr); // returns to a snap point. QTRY_COMPARE(pathview->offset(), qreal(qFloor(pathview->offset()))); @@ -1942,7 +1944,6 @@ void tst_QQuickPathView::cancelDrag() QCOMPARE(dragEndedSpy.count(), 1); QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(40,100)); - } void tst_QQuickPathView::maximumFlickVelocity() -- cgit v1.2.3