Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76312

QTestLib: Stop using QCursor:pos() for mouse event geometry

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • Testing: qtestlib
    • 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:

      • 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

          For Gerrit Dashboard: QTBUG-76312
          # Subject Branch Project Status CR V

          Activity

            People

              sorvig Morten Sørvig
              sorvig Morten Sørvig
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: