@Test
  public void testContextMenuRemove() throws Exception {
    accountDb.add(HOTP_ACCOUNT_NAME, "7777777777777777", OtpType.HOTP, null, null, "Yahoo");

    activityTestRule.launchActivity(null);

    final ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    final View listEntry0 = userList.getChildAt(0);
    openContextualActionBarOrMenuAndInvokeItem(userList, 0, R.string.context_menu_remove_account);
    // Select Remove on confirmation dialog to remove account.
    TestUtilities.tapDialogPositiveButton(InstrumentationRegistry.getInstrumentation());
    // check main screen gets focus back;
    TestUtilities.waitForWindowFocus(listEntry0);
    // check that account is deleted in database.
    assertThat(accountDb.getAccounts()).isEmpty();
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java