ActionBarFragment extends BaseFragment { protected boolean finishActionMode() { if (actionMode != null) { actionMode.finish(); return true; } return false; }  @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 testFinishActionMode() { final ActionBarFragment fragment = new TestFragment(); final ActionMode mockActionMode = mock(ActionMode.class); fragment.onActionModeStarted(mockActionMode); fragment.onActionModeFinished(); assertThat(fragment.isInActionMode(), is(false)); assertThat(fragment.getActionMode(), is(nullValue())); verifyZeroInteractions(mockActionMode); }