@Test
  @SuppressWarnings("unchecked")
  public void testContextMenuCheckCodeForHotpAccount() {
    accountDb.add(
        HOTP_ACCOUNT_NAME,
        "7777777777777777",
        OtpType.HOTP,
        null,
        null,
        AccountDb.GOOGLE_ISSUER_NAME);

    activityTestRule.launchActivity(null);

    ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    openContextualActionBarOrMenuAndInvokeItem(userList, 0, R.string.check_code_menu_item);

    intended(
        allOf(
            hasComponent(
                equalTo(
                    new ComponentName(
                        InstrumentationRegistry.getInstrumentation().getTargetContext(),
                        CheckCodeActivity.class))),
            hasExtras(
                hasEntry(
                    equalTo("index"),
                    equalTo(new AccountIndex(HOTP_ACCOUNT_NAME, AccountDb.GOOGLE_ISSUER_NAME))))));
    assertThat(TestUtilities.isStrayIntentRemaining()).isFalse();
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java