diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2024-03-26 14:08:42 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2024-03-26 21:33:04 +0100 |
commit | 92f39a3919375af7e0eeaa31d010fc7fde7f6c4f (patch) | |
tree | 55746e0fcd729410ddd754a8d7d093ce924a8f34 /src/qmltest | |
parent | f0fbedbe69532d9f5d1bc622f0b5b1ed16f23f2b (diff) |
qmltest: add a 'modifiers' argument to mouseMove()
As it stood, TestCase::mouseMove() didn't take a 'modifier'
argument. All the other mouse functions do that, including
mouseDrag(). But even for mouseDrag, the modifier argument was
only applied to mousePress() and mouseRelease(), but not to
the in-between mouse moves.
This patch will implement support for providing a modifier
argument also to mouseMove(). This is needed in order to
test API that distinguishes a normal drag from a ctrl+drag, like
e.g SelectionRectangle.
Pick-to: 6.7 6.6 6.5
Change-Id: Idd800eda4b5b4fd4e9cda94155ca4ec36e935d13
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/TestCase.qml | 14 | ||||
-rw-r--r-- | src/qmltest/quicktestevent.cpp | 4 | ||||
-rw-r--r-- | src/qmltest/quicktestevent_p.h | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/qmltest/TestCase.qml b/src/qmltest/TestCase.qml index 3046d0677c..68b6b1f2db 100644 --- a/src/qmltest/TestCase.qml +++ b/src/qmltest/TestCase.qml @@ -1570,12 +1570,12 @@ Item { // 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) + mouseMove(item, x + dragTriggerXDistance, y + dragTriggerYDistance, moveDelay, button, modifiers) if (intermediateDx !== 0 || intermediateDy !== 0) { - mouseMove(item, x + intermediateDx, y + intermediateDy, moveDelay, button) - mouseMove(item, x + 2*intermediateDx, y + 2*intermediateDy, moveDelay, button) + 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) + mouseMove(item, x + dx, y + dy, moveDelay, button, modifiers) mouseRelease(item, x + dx, y + dy, button, modifiers, delay) } @@ -1671,7 +1671,7 @@ Item { \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClickSequence(), mouseDrag(), mouseWheel() */ - function mouseMove(item, x, y, delay, buttons) { + function mouseMove(item, x, y, delay, buttons, modifiers) { if (!qtest_verifyItem(item, "mouseMove")) return @@ -1679,11 +1679,13 @@ Item { delay = -1 if (buttons === undefined) buttons = Qt.NoButton + if (modifiers === undefined) + modifiers = Qt.NoModifiers if (x === undefined) x = item.width / 2 if (y === undefined) y = item.height / 2 - if (!qtest_events.mouseMove(item, x, y, delay, buttons)) + if (!qtest_events.mouseMove(item, x, y, delay, buttons, modifiers)) qtest_fail("window not shown", 2) } diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index b1b8e60eab..9bd2a9887c 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -318,14 +318,14 @@ bool QuickTestEvent::mouseDoubleClickSequence } bool QuickTestEvent::mouseMove - (QObject *item, qreal x, qreal y, int delay, int buttons) + (QObject *item, qreal x, qreal y, int delay, int buttons, int modifiers) { QWindow *view = eventWindow(item); if (!view) return false; const Qt::MouseButtons effectiveButtons = buttons ? Qt::MouseButtons(buttons) : m_pressedButtons; QtQuickTest::mouseEvent(QtQuickTest::MouseMove, view, item, - Qt::MouseButton(int(effectiveButtons)), Qt::NoModifier, + Qt::MouseButton(int(effectiveButtons)), Qt::KeyboardModifiers(modifiers), QPointF(x, y), delay); return true; } diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h index 8f75dc1dd9..6f73130b5b 100644 --- a/src/qmltest/quicktestevent_p.h +++ b/src/qmltest/quicktestevent_p.h @@ -77,7 +77,7 @@ public Q_SLOTS: int modifiers, int delay); bool mouseDoubleClickSequence(QObject *item, qreal x, qreal y, int button, int modifiers, int delay); - bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons); + bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons, int modifiers); #if QT_CONFIG(wheelevent) bool mouseWheel(QObject *item, qreal x, qreal y, int buttons, |