WebFragment extends ActionBarFragment { @Override public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { this.webView = new WebView(inflater.getContext()); this.webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); this.webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); final WebViewClient client = onCreateWebViewClient(); if (client != null) { this.webView.setWebViewClient(client); } final WebChromeClient chromeClient = onCreateWebChromeClient(); if (chromeClient != null) { this.webView.setWebChromeClient(chromeClient); } this.webView.getSettings().setJavaScriptEnabled(options.javaScriptEnabled); return webView; }  static boolean isValidWebUrl(@Nullable final String url); @NonNull static WebFragment newInstance(); @NonNull static WebFragment newInstance(@NonNull final WebOptions options); @Override void onCreate(@Nullable final Bundle savedInstanceState); @NonNull final WebOptions getOptions(); void setOnWebContentLoadingListener(@Nullable final OnWebContentLoadingListener listener); @Override View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState); @Nullable WebView getWebView(); @Override void onActivityCreated(@Nullable final Bundle savedInstanceState); boolean loadContent(@Nullable final String content); @Nullable String getContent(); @ContentType int getContentType(); @Override void onSaveInstanceState(@NonNull final Bundle state); @Override void onDestroyView();  }
@Test public void testOnCreateView() { final WebFragment fragment = new WebFragment(); final View view = fragment.onCreateView(LayoutInflater.from(context), null, null); assertThat(view, is(notNullValue())); assertThat(view, instanceOf(WebView.class)); assertThat(fragment.getWebView(), is(view)); }