on xenial help sign in
Improve the tap() method
commit5593d686dee29fb6767c0b61253fb7fd3d7703a8 authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 10 Oct 2014, 16:15 (12 years ago) parent35f1284
2 files changed+10−1
tests/qmltests/tst_ShellWithPin.qml+1−1 tests/utils/modules/Unity/Test/UnityTestCase.qml+9
tests/qmltests/tst_ShellWithPin.qml+1−1
@@ -186,7 +186,7 @@ Item {
186186 for (var i = 0; i < pin.length; ++i) {
187187 var character = pin.charAt(i)
188188 var button = findChild(shell, "pinPadButton" + character)
189− mouseClick(button, units.gu(1), units.gu(1))
189+ tap(button)
190190 }
191191 }
192192
tests/utils/modules/Unity/Test/UnityTestCase.qml+9
@@ -321,7 +321,16 @@ TestCase {
321321 event.commit()
322322 }
323323
324+ /*! \brief Tap the item with a touch event.
325+
326+ \param item The item to be tapped
327+ \param x The x coordinate of the tap, defaults to horizontal center
328+ \param y The y coordinate of the tap, defaults to vertical center
329+ */
324330 function tap(item, x, y) {
331+ if (typeof x !== "number") x = item.width / 2;
332+ if (typeof y !== "number") y = item.height / 2;
333+
325334 var root = fetchRootItem(item)
326335 var rootPoint = item.mapToItem(root, x, y)
327336