Index: android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java b/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java |
index 2c83e43163abddfd6ce1574efb1123800a279abe..b0ba9c16d218a64941315ff8bcf7a679f26ddbaa 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java |
@@ -76,5 +76,29 @@ public class AwTestTouchUtils { |
} |
}); |
} |
+ |
+ /** |
+ * Performs a single ttouch on the center of the supplied view. |
benm (inactive)
2014/09/08 16:00:18
nit: touch
mkosiba (inactive)
2014/09/08 16:54:36
Done.
|
+ * This is safe to call from the instrumentation thread and will invoke the touch |
+ * asynchronously. |
+ * |
+ * @param view The view the coordinates are relative to. |
+ */ |
+ public static void simulateTouchCenterOfView(final View view) throws Throwable { |
+ view.post(new Runnable() { |
+ @Override |
+ public void run() { |
+ long eventTime = SystemClock.uptimeMillis(); |
+ float x = (float) (view.getRight() - view.getLeft()) / 2; |
+ float y = (float) (view.getBottom() - view.getTop()) / 2; |
+ view.onTouchEvent(MotionEvent.obtain( |
+ eventTime, eventTime, MotionEvent.ACTION_DOWN, |
+ x, y, 0)); |
+ view.onTouchEvent(MotionEvent.obtain( |
+ eventTime, eventTime, MotionEvent.ACTION_UP, |
benm (inactive)
2014/09/08 16:00:18
I guess it's ok that ACTION_UP time == ACTION_DOWN
mkosiba (inactive)
2014/09/08 16:54:36
seems to work fine, yeath. IIRC we only use time t
|
+ x, y, 0)); |
+ } |
+ }); |
+ } |
} |