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

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

Issue 430443003: Use unchecked InputStream methods in the android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove old InputStream jni Created 6 years, 5 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 34c0511f30a46c4b725df919dc55f41777cfe5bd..de8e625172ba8af2e4378988897cdff843a58210 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
@@ -355,6 +355,49 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
mContentsClient.getOnPageFinishedHelper().waitForCallback(onPageFinishedCallCount);
}
+ private static class ThrowingInputStream extends EmptyInputStream {
+ @Override
+ public int available() {
+ return 100;
+ }
+
+ @Override
+ public int read() throws IOException {
+ throw new IOException("test exception");
+ }
+
+ @Override
+ public int read(byte b[]) throws IOException {
+ throw new IOException("test exception");
+ }
+
+ @Override
+ public int read(byte b[], int off, int len) throws IOException {
+ throw new IOException("test exception");
+ }
+
+ @Override
+ public long skip(long n) throws IOException {
+ return n;
+ }
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testDoesNotCrashOnThrowingStream() throws Throwable {
+ final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+
+ mShouldInterceptRequestHelper.setReturnValue(
+ new AwWebResourceResponse("text/html", "UTF-8", new ThrowingInputStream()));
+ int shouldInterceptRequestCallCount = mShouldInterceptRequestHelper.getCallCount();
+ int onPageFinishedCallCount = mContentsClient.getOnPageFinishedHelper().getCallCount();
+
+ loadUrlAsync(mAwContents, aboutPageUrl);
+
+ mShouldInterceptRequestHelper.waitForCallback(shouldInterceptRequestCallCount);
+ mContentsClient.getOnPageFinishedHelper().waitForCallback(onPageFinishedCallCount);
+ }
+
private static class SlowAwWebResourceResponse extends AwWebResourceResponse {
private CallbackHelper mReadStartedCallbackHelper = new CallbackHelper();
private CountDownLatch mLatch = new CountDownLatch(1);

Powered by Google App Engine
This is Rietveld 408576698