Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/util/AwTestTouchUtils.java

Issue 552813002: [android_webview] Use a MotionEvent to trigger ShouldInterceptRequest tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bdae4ec3bf84a655b25184fae4ba2e65cd586777 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 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));
+ }
+ });
+ }
}
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/WebKitHitTestTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698