AirshipWebViewClient extends WebViewClient { @CallSuper @Override public boolean shouldOverrideUrlLoading(@NonNull WebView webView, @Nullable String url) { if (interceptUrl(webView, url)) { return true; } return super.shouldOverrideUrlLoading(webView, url); } AirshipWebViewClient();  AirshipWebViewClient(@NonNull ActionRunRequestFactory requestFactory); @VisibleForTesting  AirshipWebViewClient(@NonNull NativeBridge nativeBridge); void setActionCompletionCallback(@Nullable ActionCompletionCallback actionCompletionCallback); @CallSuper @Override boolean shouldOverrideUrlLoading(@NonNull WebView webView, @Nullable String url); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void setFaviconEnabled(boolean enabled); @CallSuper @Override @Nullable WebResourceResponse shouldInterceptRequest(@NonNull WebView webView, @NonNull String url); @CallSuper @Override @SuppressLint("NewApi") @Nullable WebResourceResponse shouldInterceptRequest(@NonNull WebView webView, @NonNull WebResourceRequest request); @CallSuper @Override void onLoadResource(@NonNull WebView webView, @Nullable String url); @Override @CallSuper void onPageFinished(@Nullable final WebView view, final @Nullable String url); @CallSuper @Override void onPageStarted(@NonNull WebView view, @Nullable String url, @Nullable Bitmap favicon); @CallSuper @Override void onReceivedHttpAuthRequest(@NonNull WebView view, @NonNull HttpAuthHandler handler, @Nullable String host,
                                          @Nullable String realm); void addAuthRequestCredentials(@NonNull String expectedAuthHost, @Nullable String username, @Nullable String password); void removeAuthRequestCredentials(@NonNull String expectedAuthHost);  }
@Test public void testHandleCommandNotAllowed() { webViewUrl = "http: String url = "uairship: assertFalse(client.shouldOverrideUrlLoading(webView, url)); webViewUrl = null; assertFalse(client.shouldOverrideUrlLoading(webView, url)); verifyZeroInteractions(nativeBridge); }
@Test public void testHandleCommandJavaScriptExecutor() { String url = "uairship: ArgumentCaptor<JavaScriptExecutor> argument = ArgumentCaptor.forClass(JavaScriptExecutor.class); when(nativeBridge.onHandleCommand( eq(url), argument.capture(), any(ActionRunRequestExtender.class), any(NativeBridge.CommandDelegate.class))) .thenReturn(true); client.shouldOverrideUrlLoading(webView, url); argument.getValue().executeJavaScript("cool"); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) { verify(webView).loadUrl("javascript:cool"); } else { verify(webView).evaluateJavascript("cool", null); } }