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

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

Issue 831903004: [WebView] Add a new flushVisualState API to AwContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 11 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 4606961c507fbbe0e54010678c53a104d3001a53..ec59ec3458a5f0f51a8398621044bb5fd263ee47 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
@@ -5,16 +5,15 @@
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.GraphicsTestUtils;
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil;
@@ -249,11 +248,9 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
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,
+ Bitmap bitmap = GraphicsTestUtils.drawAwContents(mAwContents, 2, 2,
+ -(float) mTestContainerView.getWidth() / 2,
-(float) mTestContainerView.getHeight() / 2);
- mAwContents.onDraw(canvas);
return bitmap.getPixel(0, 0) == Color.BLUE;
}
});
@@ -273,12 +270,12 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
CommonResources.ABOUT_HTML);
final String mainPageUrl = addPageToTestServer(mWebServer, "/main",
CommonResources.makeHtmlPageFrom("",
- "<script>" +
- " var xhr = new XMLHttpRequest();" +
- " xhr.open('GET', '" + syncGetUrl + "', false);" +
- " xhr.setRequestHeader('" + headerName + "', '" + headerValue + "'); " +
- " xhr.send(null);" +
- "</script>"));
+ "<script>"
+ + " var xhr = new XMLHttpRequest();"
+ + " xhr.open('GET', '" + syncGetUrl + "', false);"
+ + " xhr.setRequestHeader('" + headerName + "', '" + headerValue + "'); "
+ + " xhr.send(null);"
+ + "</script>"));
enableJavaScriptOnUiThread(mAwContents);
int callCount = mShouldInterceptRequestHelper.getCallCount();
@@ -487,14 +484,14 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
public void testHttpStatusCodeAndText() throws Throwable {
final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
final String syncGetJs =
- "(function() {" +
- " var xhr = new XMLHttpRequest();" +
- " xhr.open('GET', '" + syncGetUrl + "', false);" +
- " xhr.send(null);" +
- " console.info('xhr.status = ' + xhr.status);" +
- " console.info('xhr.statusText = ' + xhr.statusText);" +
- " return '[' + xhr.status + '][' + xhr.statusText + ']';" +
- "})();";
+ "(function() {"
+ + " var xhr = new XMLHttpRequest();"
+ + " xhr.open('GET', '" + syncGetUrl + "', false);"
+ + " xhr.send(null);"
+ + " console.info('xhr.status = ' + xhr.status);"
+ + " console.info('xhr.statusText = ' + xhr.statusText);"
+ + " return '[' + xhr.status + '][' + xhr.statusText + ']';"
+ + "})();";
enableJavaScriptOnUiThread(mAwContents);
final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
@@ -520,13 +517,13 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
private String getHeaderValue(AwContents awContents, TestAwContentsClient contentsClient,
String url, String headerName) throws Exception {
final String syncGetJs =
- "(function() {" +
- " var xhr = new XMLHttpRequest();" +
- " xhr.open('GET', '" + url + "', false);" +
- " xhr.send(null);" +
- " console.info(xhr.getAllResponseHeaders());" +
- " return xhr.getResponseHeader('" + headerName + "');" +
- "})();";
+ "(function() {"
+ + " var xhr = new XMLHttpRequest();"
+ + " xhr.open('GET', '" + url + "', false);"
+ + " xhr.send(null);"
+ + " console.info(xhr.getAllResponseHeaders());"
+ + " return xhr.getResponseHeader('" + headerName + "');"
+ + "})();";
String header = executeJavaScriptAndWaitForResult(awContents, contentsClient, syncGetJs);
if (header.equals("null"))

Powered by Google App Engine
This is Rietveld 408576698