ActionBarFragment extends BaseFragment { @NonNull protected ActionBarDelegate getActionBarDelegate() { if (actionBarDelegate == null) { throw new IllegalStateException("The parent activity does not have ActionBar presented!"); } return actionBarDelegate; }  @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(expected = IllegalStateException.class) public void testGetActionBarDelegateWhenNotAttached() { final TestFragment fragment = new TestFragment(); fragment.getActionBarDelegate(); }