ActionBarFragment extends BaseFragment { protected boolean startActionMode() { return startActionMode(new ActionModeCallback(this)); }  @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 testStartActionMode() { final ActionBarFragment fragment = new TestFragment(); final ActivityDelegate mockActivityDelegate = mock(ActivityDelegate.class); final ActionMode mockActionMode = mock(ActionMode.class); when(mockActivityDelegate.startActionMode(any(ActionMode.Callback.class))).thenReturn(mockActionMode); fragment.activityDelegate = mockActivityDelegate; assertThat(fragment.startActionMode(), is(true)); assertThat(fragment.isInActionMode(), is(true)); assertThat(fragment.getActionMode(), is(mockActionMode)); }