OAuthWebViewClient extends WebViewClient { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { super.onReceivedSslError(view, handler, error); listener.onError(new WebViewException(error.getPrimaryError(), null, null)); } OAuthWebViewClient(String completeUrl, Listener listener); @Override void onPageFinished(WebView view, String url); @Override boolean shouldOverrideUrlLoading(WebView view, String url); @Override void onReceivedError(WebView view, int errorCode,
            String description, String failingUrl); @Override void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error);  }
@Test public void testOnReceivedSslError() { final SslError mockSslError = mock(SslError.class); when(mockSslError.getPrimaryError()).thenReturn(TEST_ERROR_CODE); webViewClient.onReceivedSslError(mock(WebView.class), mock(SslErrorHandler.class), mockSslError); verifyOnError(TEST_ERROR_CODE, null, null); }