diff options
author | Caroline Chao <caroline.chao@digia.com> | 2013-04-02 18:24:46 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-06 10:10:17 +0200 |
commit | d01e595d362fcc8347f410eecdf055f80dd5423f (patch) | |
tree | 40779340e02d54458ef17b5117be5a4c5fa66950 /src | |
parent | 8fe9280556897a0d37831aa5169f2a76aa8686d2 (diff) |
TestLib: Add more mouseMove in mouseDrag implementation
So the cursor has intermediate states while dragging instead of
jumping to the final position.
This is for example useful for testing the behavior of a control
during the drag.
Add autotest.
Change-Id: I061dd18ef7ac389aa4da4a5b60f9e128ee8c08d0
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/testlib/TestCase.qml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index f9a1a4918c..fbfad28209 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -441,9 +441,23 @@ Item { if (delay == undefined) delay = -1 + // 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 + var ddx = Math.round(dx/3) + if (ddx < (util.dragThreshold + 1)) + ddx = 0 + var ddy = Math.round(dy/3) + if (ddy < (util.dragThreshold + 1)) + ddy = 0 + mousePress(item, x, y, button, modifiers, delay) //trigger dragging mouseMove(item, x + util.dragThreshold + 1, y + util.dragThreshold + 1, delay, button) + if (ddx > 0 || ddy > 0) { + mouseMove(item, x + ddx, y + ddy, delay, button) + mouseMove(item, x + 2*ddx, y + 2*ddy, delay, button) + } mouseMove(item, x + dx, y + dy, delay, button) mouseRelease(item, x + dx, y + dy, button, modifiers, delay) } |