Bug:2558977
Use the mock WebViewClient to accept the certificate, since the certificate isn't
added to the WebView until it has been validated, and since we don't accept the
invalid cert, it won't be validated.
Also, remove a comment claiming that onReceivedSslError is hidden and can't be called since
it is no longer hidden and it's needed.
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index ef7fb19..720a0c2 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -37,6 +37,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
+import android.net.http.SslError;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
@@ -47,6 +48,7 @@
 import android.view.animation.cts.DelayedCheck;
 import android.webkit.CacheManager;
 import android.webkit.DownloadListener;
+import android.webkit.SslErrorHandler;
 import android.webkit.WebBackForwardList;
 import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
@@ -268,7 +270,7 @@
             currScale = mWebView.getScale();
         }
 
-        // can not zoom out furtherholiday
+        // can not zoom out further
         assertFalse(mWebView.zoomOut());
         previousScale = currScale;
         currScale = mWebView.getScale();
@@ -1625,14 +1627,12 @@
 
         final MockWebView mockWebView = (MockWebView) mWebView;
         // need the client to handle error
-        mockWebView.setWebViewClient(new WebViewClient());
+        mockWebView.setWebViewClient(new MockWebViewClient());
 
         mockWebView.reset();
         startWebServer(true);
         String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
-        // attempt to load the url. This will fail during certificate verification, but the
-        // certificate will still be set. WebViewClient.onReceivedSslError() is a hidden API,
-        // so we cannot ignore the error.
+        // attempt to load the url.
         mockWebView.loadUrl(url);
         new DelayedCheck(TEST_TIMEOUT) {
             @Override
@@ -1984,6 +1984,12 @@
             super.onScaleChanged(view, oldScale, newScale);
             mOnScaleChangedCalled = true;
         }
+
+        @Override
+        public void onReceivedSslError(WebView view, SslErrorHandler handler,
+                                       SslError error) {
+            handler.proceed();
+        }
     }
 
     private static class MockWebChromeClient extends WebChromeClient {