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..7a66bbdbbd15f36f21d989747a4bfb4702016598 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,25 @@ 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 |
+ // |
+ // The code here is waiting for the "link" (which is a full-screen blue div) to appear on |
+ // screen. |
+ 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(-(float)mTestContainerView.getWidth() / 2, |
+ -(float)mTestContainerView.getHeight() / 2); |
+ mAwContents.onDraw(canvas); |
+ return bitmap.getPixel(0, 0) == Color.BLUE; |
+ } |
+ }); |
callCount = mShouldInterceptRequestHelper.getCallCount(); |
- JSUtils.clickOnLinkUsingJs(this, mAwContents, |
- mContentsClient.getOnEvaluateJavaScriptResultHelper(), "link"); |
+ AwTestTouchUtils.simulateTouchCenterOfView(mTestContainerView); |
mShouldInterceptRequestHelper.waitForCallback(callCount); |
assertEquals(true, |
mShouldInterceptRequestHelper.getParamsForUrl(aboutPageUrl).hasUserGesture); |