aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
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/quick/qquickflickable/tst_qquickflickable.cpp
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/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp8
1 files changed, 4 insertions, 4 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()