aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-17 12:35:32 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-17 16:18:18 +0100
commit79a3119a955f5edc5476818d5c44b0603b677403 (patch)
treed48cb9d83622c727f4942e3f3725e7e32e8692d7 /tests/auto
parent2ba1afa46ce1d3d2648d682a7c7dc5d24cca8362 (diff)
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 <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp8
-rw-r--r--tests/auto/quick/qquickpathview/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp7
3 files changed, 8 insertions, 9 deletions
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<QQuickView> 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<QQuickItem*>("row");
- item->grabMouse();
+ auto mouse = QPointingDevice::primaryPointingDevice();
+ auto mousePriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(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<QQuickItem*>("text");
- item->grabMouse();
+ auto mouse = QPointingDevice::primaryPointingDevice();
+ auto mousePriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(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()