ActionBarFragment extends BaseFragment { @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); this.actionBarDelegate = ActionBarDelegate.create(requireActivity()); this.invalidateActionBar(); }  @Override void onCreate(@Nullable final Bundle savedInstanceState); @Override void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater); @Override void onActivityCreated(@Nullable final Bundle savedInstanceState); void invalidateActionBar();  }
@Test public void testOnActivityCreated() { final FragmentActivity activity = Robolectric.buildActivity(TestCompatActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getSupportFragmentManager(); final ActionBarFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); assertThat(fragment.isActionBarAvailable(), is(true)); assertThat(fragment.getActionBarDelegate(), is(notNullValue())); }