on xenial help sign in
Improve the tap() method
5593d68Michał Sawicz
tests/qmltests/tst_ShellWithPin.qml+1−1
@@ -186,7 +186,7 @@ Item {
186 for (var i = 0; i < pin.length; ++i) {
186 for (var i = 0; i < pin.length; ++i) {
187 var character = pin.charAt(i)
187 var character = pin.charAt(i)
188 var button = findChild(shell, "pinPadButton" + character)
188 var button = findChild(shell, "pinPadButton" + character)
189− mouseClick(button, units.gu(1), units.gu(1))
189+ tap(button)
190 }
190 }
191 }
191 }
192
192
tests/utils/modules/Unity/Test/UnityTestCase.qml+9
@@ -321,7 +321,16 @@ TestCase {
321 event.commit()
321 event.commit()
322 }
322 }
323
323
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+ */
324 function tap(item, x, y) {
330 function tap(item, x, y) {
331+ if (typeof x !== "number") x = item.width / 2;
332+ if (typeof y !== "number") y = item.height / 2;
333+
325 var root = fetchRootItem(item)
334 var root = fetchRootItem(item)
326 var rootPoint = item.mapToItem(root, x, y)
335 var rootPoint = item.mapToItem(root, x, y)
327
336