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 <richard.gustavsen@qt.io>
This commit is contained in:
parent
9bcbba36c7
commit
fcc5323a08
@ -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)
|
static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0)
|
||||||
{
|
{
|
||||||
QTest::mouseMove(widget, point);
|
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::sendEvent(widget, &event);
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user