From fcc5323a08f955bcedd8a8a9750173384fa7d71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 7 Jun 2019 16:04:23 +0200 Subject: Make test less dependent on moving the cursor The sendMouseMove() function calls QTest::mouseMove(), which again calls QCursor::setPos() to move the cursor. It then creates and sends a MouseMove event, using the constructor which picks up the global position by calling QCursor::pos(). On macOS 10.14, QCursor::setPos() may silently fail if the user does not grant the application permission to move the cursor (via a dialog). As result of this the mouse move event gets an incorrect global position. Provide the global position directly when creating the event to make sure it gets the correct value. Task-number: QTBUG-75786 Change-Id: I3e8df450fea802783a3d1dbe471753f502b42de3 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 28df3a3c38..1456b9e35c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -88,7 +88,7 @@ static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0) { QTest::mouseMove(widget, point); - QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0); + QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, buttons, 0); QApplication::sendEvent(widget, &event); QApplication::processEvents(); } -- cgit v1.2.3