Commit e8a8fdd8 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Commit Bot

webview: better error output in SSL tests.

When we're not expecting an error but we get one, fail stating the
actual error we received, not just the error count.

Bug: 1106472
Bug: 1117289
Change-Id: I355b307a9dcf2ba0ecf24191541d6e74db761ded
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2399522
Commit-Queue: Richard Coles <torne@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Auto-Submit: Richard Coles <torne@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805090}
parent d46483a8
......@@ -22,8 +22,8 @@ import org.junit.runner.RunWith;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient.AwWebResourceRequest;
import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedSslErrorHelper;
import org.chromium.base.BuildInfo;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.Feature;
import org.chromium.net.test.EmbeddedTestServer;
......@@ -68,7 +68,8 @@ public class AwNetworkConfigurationTest {
InstrumentationRegistry.getInstrumentation().getContext(),
ServerCertificate.CERT_SHA1_LEAF);
try {
CallbackHelper onReceivedSslErrorHelper = mContentsClient.getOnReceivedSslErrorHelper();
OnReceivedSslErrorHelper onReceivedSslErrorHelper =
mContentsClient.getOnReceivedSslErrorHelper();
int count = onReceivedSslErrorHelper.getCallCount();
String url = mTestServer.getURL("/android_webview/test/data/hello_world.html");
mActivityTestRule.loadUrlSync(
......@@ -77,8 +78,10 @@ public class AwNetworkConfigurationTest {
Assert.assertEquals("We should generate an SSL error on >= Q", count + 1,
onReceivedSslErrorHelper.getCallCount());
} else {
Assert.assertEquals("We should not have received any SSL errors on < Q", count,
onReceivedSslErrorHelper.getCallCount());
if (count != onReceivedSslErrorHelper.getCallCount()) {
Assert.fail("We should not have received any SSL errors on < Q but we received"
+ " error " + onReceivedSslErrorHelper.getError());
}
}
} finally {
mTestServer.stopAndDestroyServer();
......
......@@ -66,8 +66,10 @@ public class SslPreferencesTest {
mActivityTestRule.loadUrlSync(
mAwContents, mContentsClient.getOnPageFinishedHelper(), pageUrl);
Assert.assertEquals("onReceivedSslError should not be called", onSslErrorCallCount,
onReceivedSslErrorHelper.getCallCount());
if (onSslErrorCallCount != onReceivedSslErrorHelper.getCallCount()) {
Assert.fail("onReceivedSslError should not be called, but was called with error "
+ onReceivedSslErrorHelper.getError());
}
} finally {
mTestServer.stopAndDestroyServer();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment