@Test public void testOnReceivedError() throws Exception { Assume.assumeTrue( WebViewFeature.isFeatureSupported(WebViewFeature.RECEIVE_WEB_RESOURCE_ERROR)); Assume.assumeTrue( WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_ERROR_GET_CODE)); final MockWebViewClient webViewClient = new MockWebViewClient(); mWebViewOnUiThread.setWebViewClient(webViewClient); String wrongUri = "invalidscheme: Assert.assertNull(webViewClient.getOnReceivedResourceError()); mWebViewOnUiThread.loadUrlAndWaitForCompletion(wrongUri); Assert.assertNotNull(webViewClient.getOnReceivedResourceError()); Assert.assertEquals(WebViewClient.ERROR_UNSUPPORTED_SCHEME, webViewClient.getOnReceivedResourceError().getErrorCode()); }
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request, @NonNull InvocationHandler handler) { onReceivedError(view, request, new WebResourceErrorImpl(handler)); }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request, @NonNull InvocationHandler handler) { onReceivedError(view, request, new WebResourceErrorImpl(handler)); } }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request, @NonNull InvocationHandler handler) { onReceivedError(view, request, new WebResourceErrorImpl(handler)); }  }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request, @NonNull InvocationHandler handler) { onReceivedError(view, request, new WebResourceErrorImpl(handler)); }  @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) final String[] getSupportedFeatures(); @Override void onPageCommitVisible(@NonNull WebView view, @NonNull String url); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            /* WebResourceError */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(23) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceError error); @SuppressWarnings("deprecation") // for invoking the old onReceivedError. @RequiresApi(21) void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceErrorCompat error); @Override void onReceivedHttpError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceResponse errorResponse); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType,
            /* SafeBrowsingResponse */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(27) final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponse response); void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponseCompat callback); @Override @SuppressWarnings("deprecation") // for invoking the old shouldOverrideUrlLoading. @RequiresApi(21) boolean shouldOverrideUrlLoading(@NonNull WebView view,
            @NonNull WebResourceRequest request); }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) public final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request, @NonNull InvocationHandler handler) { onReceivedError(view, request, new WebResourceErrorImpl(handler)); }  @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) final String[] getSupportedFeatures(); @Override void onPageCommitVisible(@NonNull WebView view, @NonNull String url); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            /* WebResourceError */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(23) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceError error); @SuppressWarnings("deprecation") // for invoking the old onReceivedError. @RequiresApi(21) void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceErrorCompat error); @Override void onReceivedHttpError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceResponse errorResponse); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType,
            /* SafeBrowsingResponse */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(27) final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponse response); void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponseCompat callback); @Override @SuppressWarnings("deprecation") // for invoking the old shouldOverrideUrlLoading. @RequiresApi(21) boolean shouldOverrideUrlLoading(@NonNull WebView view,
            @NonNull WebResourceRequest request);  }