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

Qml TestCase: mouseDrag adds starting position twice

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.7.3, 6.8.0, 6.8.2, 6.8.3, 6.9.0
    • Testing: QuickTest
    • Linux/Wayland, Linux/X11

    Description

      The mouseDrag function is defined in TestCase provided by QtQuickTest and looks like this:

      // 
      function mouseDrag(item, x, y, dx, dy, button, modifiers, delay) {
          if (!qtest_verifyItem(item, "mouseDrag"))
              return
      
          if (item.x === undefined || item.y === undefined)
              return
          if (button === undefined)
              button = Qt.LeftButton
          if (modifiers === undefined)
              modifiers = Qt.NoModifier
          if (delay === undefined)
              delay = -1
          let moveDelay = Math.max(1, delay === -1 ? qtest_events.defaultMouseDelay : delay)
      
          // Divide dx and dy to have intermediate mouseMove while dragging
          // Fractions of dx/dy need be superior to the dragThreshold
          // to make the drag works though
          let intermediateDx = Math.round(dx/3)
          if (Math.abs(intermediateDx) < (util.dragThreshold + 1))
              intermediateDx = 0
          let intermediateDy = Math.round(dy/3)
          if (Math.abs(intermediateDy) < (util.dragThreshold + 1))
              intermediateDy = 0
      
          mousePress(item, x, y, button, modifiers, delay)
      
          // Trigger dragging by dragging past the drag threshold, but making sure to only drag
          // along a certain axis if a distance greater than zero was given for that axis.
          let dragTriggerXDistance = dx > 0 ? (util.dragThreshold + 1) : 0
          let dragTriggerYDistance = dy > 0 ? (util.dragThreshold + 1) : 0
          mouseMove(item, x + dragTriggerXDistance, y + dragTriggerYDistance, moveDelay, button, modifiers)
          if (intermediateDx !== 0 || intermediateDy !== 0) {
              mouseMove(item, x + intermediateDx, y + intermediateDy, moveDelay, button, modifiers)
              mouseMove(item, x + 2*intermediateDx, y + 2*intermediateDy, moveDelay, button, modifiers)
          }
          mouseMove(item, x + dx, y + dy, moveDelay, button, modifiers)
          mouseRelease(item, x + dx, y + dy, button, modifiers, delay)
      

      The last mouseMove moves by startingPosition + relativeMovement. This is wrong and leads to results always offset by the starting position. 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            el_mewo André Mewes
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes