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
Gerrit Reviews
For Gerrit Dashboard: QTBUG-76312 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
286469,2 | Blacklist tests on macOS that rely on moving the cursor | 5.14 | qt/qtbase | Status: MERGED | +2 | 0 |
287663,2 | Blacklist tst_QQuickMenu::popup on macOS | 5.14 | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |
287671,2 | Blacklist tst_QWebEnginePage::mouseMovementProperties on macOS | 5.14 | qt/qtwebengine | Status: MERGED | +2 | 0 |
289315,7 | qtdeclarative: Disable movingItemWithHoverHandler on macOS | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
290597,2 | Blacklist tst_QQuickMenu::popup on macOS | 5.15 | qt/qtquickcontrols2 | Status: MERGED | 0 | 0 |
292615,2 | Blacklist tst_QQuickMenu::popup on macOS | dev | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |
303595,3 | qtdeclarative: Disable movingItemWithHoverHandler on macOS | 5.15 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
385728,2 | macOS: Skip test only if cursor can't be moved | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
385773,2 | macOS: Skip test only if cursor can't be moved | 6.2 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
406554,1 | Skip tst_HoverHandler::movingItemWithHoverHandler() on Android | dev | qt/qtdeclarative | Status: ABANDONED | +1 | 0 |