diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-10-01 15:58:46 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-10-02 10:48:05 +0200 |
commit | ed7719a3af58b9ba36a6fbaccd08c85b78f8a961 (patch) | |
tree | 0c68af42ac2d47d165e807fb759e45139a4beeee /src | |
parent | 2dfe9010c61e07af823aef94cd158088d09ef804 (diff) |
TestCase.qml: make mouseMove(item) move to the center of the item
Undefined x and y now mean item center, as with the double-click method from
726eaaeeeede086ed341899b8ee0c1570e6bf6f5, and others from
b40a2a881291b3eaea4b4834a162091537e6a34e.
Some Controls 2 tests are doing this:
tst_controls::Basic::ScrollBar::test_hover,
tst_controls::Basic::TextArea::test_hover and
tst_controls::Basic::TextField::test_hover
Also document the buttons argument which was added in
7100a74def3a82bc52c93b800cec973bf312b1b3.
[ChangeLog][QtQuickTest][TestCase] The mouseMove() QML test method now
interprets missing x and y coordinates as meaning that the mouse should move to
the center of the given item.
Task-number: QTBUG-87018
Change-Id: Ied1df3521c0cffd703cc1120ba4eb43eb5c5e163
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/testlib/TestCase.qml | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 7aab7ef612..8dfc8038ee 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -1550,11 +1550,14 @@ Item { } /*! - \qmlmethod TestCase::mouseMove(item, x, y, delay = -1) + \qmlmethod TestCase::mouseMove(item, x = item.width / 2, y = item.height / 2, delay = -1, buttons = Qt.NoButton) Moves the mouse pointer to the position given by \a x and \a y within - \a item. If a \a delay (in milliseconds) is given, the test will wait - before moving the mouse pointer. + \a item, while holding \a buttons if given. Since Qt 6.0, if \a x and + \a y are not defined, the position will be the center of \a item. + + If a \a delay (in milliseconds) is given, the test will wait before + moving the mouse pointer. The position given by \a x and \a y is transformed from the co-ordinate system of \a item into window co-ordinates and then delivered. @@ -1571,6 +1574,10 @@ Item { delay = -1 if (buttons == undefined) buttons = Qt.NoButton + if (x === undefined) + x = item.width / 2 + if (y === undefined) + y = item.height / 2 if (!qtest_events.mouseMove(item, x, y, delay, buttons)) qtest_fail("window not shown", 2) } |