[AW NS] Split up and extend flaky testDoesNotCrashOnInvalidData test

AwContentsClientShouldInterceptRequestTest#testDoesNotCrashOnInvalidData
instrumentation test is flaky on android_mojo_rel bot. The current test
actually tests a number of (invalid) scenarios. So in this patch the test
is split up into more manageable atomic scenarios and a new test case is
also added [*].

[*] testDoesNotCrashOnInvalidData_ResponseWithAllNullValues

BUG=940932,841556

Cq-Include-Trybots: luci.chromium.try:android_mojo
Change-Id: Ifaaebab5866bacffd66ba5527317f24da2f0ab73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1530987
Reviewed-by: Tobias Sargeant <tobiasjs@chromium.org>
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642472}
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 e9bd805..a05296d 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
@@ -246,7 +246,7 @@
     @Test
     @SmallTest
     @Feature({"AndroidWebView"})
-    public void testDoesNotCrashOnInvalidData() throws Throwable {
+    public void testDoesNotCrashOnInvalidData_NullInputStream() throws Throwable {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
         mShouldInterceptRequestHelper.setReturnValue(
@@ -254,16 +254,45 @@
         int callCount = mShouldInterceptRequestHelper.getCallCount();
         mActivityTestRule.loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
+    }
+
+    @Test
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testDoesNotCrashOnInvalidData_NullMimeEncodingAndZeroLengthStream()
+            throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
         mShouldInterceptRequestHelper.setReturnValue(
                 new AwWebResourceResponse(null, null, new ByteArrayInputStream(new byte[0])));
-        callCount = mShouldInterceptRequestHelper.getCallCount();
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
         mActivityTestRule.loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
+    }
+
+    @Test
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testDoesNotCrashOnInvalidData_NullMimeEncodingAndInputStream() throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
         mShouldInterceptRequestHelper.setReturnValue(
                 new AwWebResourceResponse(null, null, null));
-        callCount = mShouldInterceptRequestHelper.getCallCount();
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
+        mActivityTestRule.loadUrlAsync(mAwContents, aboutPageUrl);
+        mShouldInterceptRequestHelper.waitForCallback(callCount);
+    }
+
+    @Test
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testDoesNotCrashOnInvalidData_ResponseWithAllNullValues() throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+
+        mShouldInterceptRequestHelper.setReturnValue(new AwWebResourceResponse(null /* mime type */,
+                null /* encoding */, null /* input stream */, 0 /* status code */,
+                null /* reason phrase */, null /* response headers */));
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
         mActivityTestRule.loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
     }