Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
QTestLlib: Stop using QCursor:pos() for mouse event geometry
QMouseEvent has a constructor which takes a single local position and then sets the global position by calling QCursor::pos(). This constructor is used several places in our unit tests, often in conjunction with a QCursor::setPos() call or a QTest::mouseEvent () call (see below).
On macOS 10.14+, QCursor::setPos() requires user approval (via system dialog interaction), and is no longer suitable for auto test use.
Existing QTestLib API:
(qtestmouse.h)
- QTest::mouseEvent(MouseAction, QWindow *, LocalPosition, …)
Creates and sends a mouse event (correctly), using window->mapToGlobal() to get global coordinates. - QTest::mouseEvent(MouseAction, QWidget *, LocalPosition, …)
As the QWindow version, except that it has an exception for MouseMove events: in this case (only), QCursor::setPos() is called, and no mouse event is created or sent.
Fixes:
- Manually patch tests code which creates QMouseEvents, starting with the ones that fail on macOS 10,14:
https://codereview.qt-project.org/c/qt/qtbase/+/264434
- Change QTest::mouseEvent() to send a mouse event in all cases, and port tests to use that.
OR - Introduce new API for creating mouse events: QTest::createMouseEvent()
Change history:
- d130382776e8b9db491385a0db45a3daaa79890c added QWindow overload for mouseEvent()
- 1762bf3394219db3a7a9cc99306f4111e6cb8492 replaced the QCursor::setPos() call with QWindowSystemInterface::handleMouseEvent(), for the QWindow overload.
Attachments
Issue Links
- relates to
-
QTBUG-81884 qtdeclarative: tst_HoverHandler::movingItemWithHoverHandler fails on macOS >= 10.14 because it uses QCursor::setPos()
- Closed
- resulted from
-
QTBUG-75786 macOS 10.14 autotest failures
- Closed