X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fandroid_webview%2Fjavatests%2Fsrc%2Forg%2Fchromium%2Fandroid_webview%2Ftest%2Futil%2FAwTestTouchUtils.java;h=bdae4ec3bf84a655b25184fae4ba2e65cd586777;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=2c83e43163abddfd6ce1574efb1123800a279abe;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java b/src/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java index 2c83e43..bdae4ec 100644 --- a/src/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java +++ b/src/android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java @@ -76,5 +76,29 @@ public class AwTestTouchUtils { } }); } + + /** + * Performs a single touch on the center of the supplied view. + * 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, + x, y, 0)); + } + }); + } }