Merge "Fix for UiDevice press button operations wait for idle" into jb-mr2-dev
diff --git a/uiautomator/api/current.txt b/uiautomator/api/current.txt
index 9d39975..7eeecf5 100644
--- a/uiautomator/api/current.txt
+++ b/uiautomator/api/current.txt
@@ -111,15 +111,15 @@
method public boolean longClick() throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean longClickBottomRight() throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean longClickTopLeft() throws com.android.uiautomator.core.UiObjectNotFoundException;
- method public void multiPointerGesture(android.view.MotionEvent.PointerCoords...);
- method public void pinchIn(int, int) throws com.android.uiautomator.core.UiObjectNotFoundException;
- method public void pinchOut(int, int) throws com.android.uiautomator.core.UiObjectNotFoundException;
+ method public boolean performMultiPointerGesture(android.view.MotionEvent.PointerCoords...);
+ method public boolean performTwoPointerGesture(android.graphics.Point, android.graphics.Point, android.graphics.Point, android.graphics.Point, int);
+ method public boolean pinchIn(int, int) throws com.android.uiautomator.core.UiObjectNotFoundException;
+ method public boolean pinchOut(int, int) throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean setText(java.lang.String) throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean swipeDown(int) throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean swipeLeft(int) throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean swipeRight(int) throws com.android.uiautomator.core.UiObjectNotFoundException;
method public boolean swipeUp(int) throws com.android.uiautomator.core.UiObjectNotFoundException;
- method public void twoPointerGesture(android.graphics.Point, android.graphics.Point, android.graphics.Point, android.graphics.Point, int);
method public boolean waitForExists(long);
method public boolean waitUntilGone(long);
field protected static final int FINGER_TOUCH_HALF_WIDTH = 20; // 0x14
diff --git a/uiautomator/library/core-src/com/android/uiautomator/core/InteractionController.java b/uiautomator/library/core-src/com/android/uiautomator/core/InteractionController.java
index bec318f..73e46f1 100644
--- a/uiautomator/library/core-src/com/android/uiautomator/core/InteractionController.java
+++ b/uiautomator/library/core-src/com/android/uiautomator/core/InteractionController.java
@@ -679,9 +679,12 @@
* @param touches each array of {@link PointerCoords} constitute a single pointer's touch path.
* Multiple {@link PointerCoords} arrays constitute multiple pointers, each with its own
* path. Each {@link PointerCoords} in an array constitute a point on a pointer's path.
+ * @return <code>true</code> if all points on all paths are injected successfully, <code>false
+ * </code>otherwise
* @since API Level 18
*/
- public void generateMultiPointerGesture(PointerCoords[] ... touches) {
+ public boolean performMultiPointerGesture(PointerCoords[] ... touches) {
+ boolean ret = true;
if (touches.length < 2) {
throw new IllegalArgumentException("Must provide coordinates for at least 2 pointers");
}
@@ -709,13 +712,13 @@
MotionEvent event;
event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 1,
properties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
- injectEventSync(event);
+ ret &= injectEventSync(event);
for (int x = 1; x < touches.length; x++) {
event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(),
getPointerAction(MotionEvent.ACTION_POINTER_DOWN, x), x + 1, properties,
pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
- injectEventSync(event);
+ ret &= injectEventSync(event);
}
// Move all pointers
@@ -733,7 +736,7 @@
MotionEvent.ACTION_MOVE, touches.length, properties, pointerCoords, 0, 0, 1, 1,
0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
- injectEventSync(event);
+ ret &= injectEventSync(event);
SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS);
}
@@ -746,14 +749,15 @@
event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(),
getPointerAction(MotionEvent.ACTION_POINTER_UP, x), x + 1, properties,
pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
- injectEventSync(event);
+ ret &= injectEventSync(event);
}
Log.i(LOG_TAG, "x " + pointerCoords[0].x);
// first to touch down is last up
event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 1,
properties, pointerCoords, 0, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
- injectEventSync(event);
+ ret &= injectEventSync(event);
+ return ret;
}
/**
diff --git a/uiautomator/library/core-src/com/android/uiautomator/core/UiObject.java b/uiautomator/library/core-src/com/android/uiautomator/core/UiObject.java
index 47404af..9fdfae5 100644
--- a/uiautomator/library/core-src/com/android/uiautomator/core/UiObject.java
+++ b/uiautomator/library/core-src/com/android/uiautomator/core/UiObject.java
@@ -899,10 +899,12 @@
* @param percent of the object's diagonal length to use for the pinch
* @param steps indicates the number of injected move steps into the system. Steps are
* injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.
+ * @return <code>true</code> if all touch events for this gesture are injected successfully,
+ * <code>false</code> otherwise
* @throws UiObjectNotFoundException
* @since API Level 18
*/
- public void pinchOut(int percent, int steps) throws UiObjectNotFoundException {
+ public boolean pinchOut(int percent, int steps) throws UiObjectNotFoundException {
// make value between 1 and 100
percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
@@ -926,7 +928,7 @@
Point endPoint2 = new Point(rect.centerX() + (int)((rect.width()/2) * percentage),
rect.centerY());
- twoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
+ return performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
/**
@@ -936,10 +938,12 @@
* @param percent of the object's diagonal length to use for the pinch
* @param steps indicates the number of injected move steps into the system. Steps are
* injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.
+ * @return <code>true</code> if all touch events for this gesture are injected successfully,
+ * <code>false</code> otherwise
* @throws UiObjectNotFoundException
* @since API Level 18
*/
- public void pinchIn(int percent, int steps) throws UiObjectNotFoundException {
+ public boolean pinchIn(int percent, int steps) throws UiObjectNotFoundException {
// make value between 1 and 100
percent = (percent < 0) ? 0 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
@@ -961,7 +965,7 @@
Point endPoint1 = new Point(rect.centerX() - FINGER_TOUCH_HALF_WIDTH, rect.centerY());
Point endPoint2 = new Point(rect.centerX() + FINGER_TOUCH_HALF_WIDTH, rect.centerY());
- twoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
+ return performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
/**
@@ -973,9 +977,11 @@
* @param endPoint2 end point of pointer 2
* @param steps indicates the number of injected move steps into the system. Steps are
* injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.
+ * @return <code>true</code> if all touch events for this gesture are injected successfully,
+ * <code>false</code> otherwise
* @since API Level 18
*/
- public void twoPointerGesture(Point startPoint1, Point startPoint2, Point endPoint1,
+ public boolean performTwoPointerGesture(Point startPoint1, Point startPoint2, Point endPoint1,
Point endPoint2, int steps) {
// avoid a divide by zero
@@ -1034,7 +1040,7 @@
p2.size = 1;
points2[steps + 1] = p2;
- multiPointerGesture(points1, points2);
+ return performMultiPointerGesture(points1, points2);
}
/**
@@ -1057,9 +1063,11 @@
* @param touches each array of {@link PointerCoords} constitute a single pointer's touch path.
* Multiple {@link PointerCoords} arrays constitute multiple pointers, each with its own
* path. Each {@link PointerCoords} in an array constitute a point on a pointer's path.
+ * @return <code>true</code> if all touch events for this gesture are injected successfully,
+ * <code>false</code> otherwise
* @since API Level 18
*/
- public void multiPointerGesture(PointerCoords[] ...touches) {
- getInteractionController().generateMultiPointerGesture(touches);
+ public boolean performMultiPointerGesture(PointerCoords[] ...touches) {
+ return getInteractionController().performMultiPointerGesture(touches);
}
}