@Test
  @TargetApi(19)
  public void testContextualActionBarClosedAfterListUpdate() {
    accountDb.add(HOTP_ACCOUNT_NAME, "7777777777777777", OtpType.HOTP, null, null, null);

    activityTestRule.launchActivity(null);

    ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    openListViewContextualActionBar(activityTestRule.getActivity(), userList, 0);
    // Simulate a new account being added
    accountDb.add(
        "janedoeHotp@gmail.com",
        "8888888888888888",
        OtpType.HOTP,
        null,
        null,
        AccountDb.GOOGLE_ISSUER_NAME);
    refreshView();
    // We should no longer be in action mode
    assertThat(activityTestRule.getActivity().actionMode).isNull();
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java