@Test
  public void testContextMenuRenameNotAvailableForGoogleCorpAccount() {
    accountDb.add(
        AccountDb.GOOGLE_CORP_ACCOUNT_NAME, "7777777777777777", OtpType.HOTP, null, null, null);

    activityTestRule.launchActivity(null);

    ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    // The Android framework does not out of the box provide a good enough way to check whether
    // the context menu item is present or not.
    // To help this test, AuthenticatorActivity keeps a reference to the most recently created
    // ContextMenu. We thus check that (1) opening the context menu and invoking the the
    // "Rename" menu item fails, and (2) that the most recent ContextMenu after that
    // invocation does not offer this menu item.
    MenuItem item =
        openListViewContextualActionBarAndFindMenuItem(
            activityTestRule.getActivity(), userList, 0, R.string.rename);

    // The item should either be not there (null) or should not be visible.
    if (item != null) {
      assertThat(item.isVisible()).isFalse();
    }
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java