WebFragment extends ActionBarFragment { @VisibleForTesting @ContentType static int resolveContentType(@Nullable final String content) { final int contentType; if (TextUtils.isEmpty(content)) { contentType = CONTENT_EMPTY; } else { if (WEB_URL_MATCHER.reset(content).matches()) { contentType = CONTENT_URL; } else if (FILE_URL_MATCHER.reset(content).matches()) { contentType = CONTENT_FILE; } else { contentType = CONTENT_HTML; } } return contentType; }  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 testResolveContentType() { assertThat(WebFragment.resolveContentType(null), is(WebFragment.CONTENT_EMPTY)); assertThat(WebFragment.resolveContentType(""), is(WebFragment.CONTENT_EMPTY)); assertThat(WebFragment.resolveContentType("http: assertThat(WebFragment.resolveContentType("<h3>Content</h3>"), is(WebFragment.CONTENT_HTML)); assertThat(WebFragment.resolveContentType("Content"), is(WebFragment.CONTENT_HTML)); assertThat(WebFragment.resolveContentType("file: }