WebFragment extends ActionBarFragment { @Override public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (annotationHandler != null) { final WebFragmentAnnotationHandler annotationHandler = (WebFragmentAnnotationHandler) this.annotationHandler; final int contentResId = annotationHandler.getWebContentResId(-1); if (contentResId == -1) { this.content = annotationHandler.getWebContent(null); } else { this.content = getString(contentResId); } } if (savedInstanceState != null) { this.options = savedInstanceState.getParcelable(BUNDLE_OPTIONS); this.privateFlags = savedInstanceState.getInt(BUNDLE_PRIVATE_FLAGS); this.content = savedInstanceState.getString(BUNDLE_CONTENT); } else if (options != null && !TextUtils.isEmpty(options.content)) { this.content = options.content; } this.contentType = resolveContentType(content); }  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 testOnCreate() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final WebFragment fragment = new TestFragmentWithWebContent(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); assertThat(fragment.getContent(), is(TestFragmentWithWebContent.CONTENT)); }