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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.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
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
index d83c96a161ad5ebff4592afdf21dcc1e40c16c6c..e386a83504d8cd2fdd877105a2ba4734a061f3d3 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
@@ -4,12 +4,16 @@
package org.chromium.android_webview.test;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Pair;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient.ShouldInterceptRequestParams;
import org.chromium.android_webview.AwWebResourceResponse;
+import org.chromium.android_webview.test.util.AwTestTouchUtils;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.test.util.Feature;
@@ -236,9 +240,22 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
assertEquals(false,
mShouldInterceptRequestHelper.getParamsForUrl(pageWithLinkUrl).hasUserGesture);
+ // TODO(mkosiba): Remove this once we have a real API to wait for the page to load and
+ // display.
+ // http://crbug.com/364612
+ pollOnUiThread(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ Bitmap bitmap = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ canvas.translate(-mTestContainerView.getWidth() / 2,
+ -mTestContainerView.getHeight() / 2);
+ mAwContents.onDraw(canvas);
+ return bitmap.getPixel(0, 0) == Color.BLUE;
boliu 2014/09/08 16:02:55 That looks *super* brittle. What if text rendering
mkosiba (inactive) 2014/09/08 16:54:36 This is not checking the text to be blue. The "lin
boliu 2014/09/08 17:02:10 Meh, badly named function then. side note, why em
+ }
+ });
callCount = mShouldInterceptRequestHelper.getCallCount();
- JSUtils.clickOnLinkUsingJs(this, mAwContents,
- mContentsClient.getOnEvaluateJavaScriptResultHelper(), "link");
+ AwTestTouchUtils.simulateTouchCenterOfView(mTestContainerView);
mShouldInterceptRequestHelper.waitForCallback(callCount);
assertEquals(true,
mShouldInterceptRequestHelper.getParamsForUrl(aboutPageUrl).hasUserGesture);

Powered by Google App Engine
This is Rietveld 408576698