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

    activityTestRule.launchActivity(null);

    ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    assertThat(userList.getChildCount()).isEqualTo(1);
    View listEntry = userList.getChildAt(0);
    String user = ((TextView) listEntry.findViewById(R.id.current_user)).getText().toString();
    String pin =
        getOriginalPincode(
            ((TextView) listEntry.findViewById(R.id.pin_value)).getText().toString());
    assertThat(user).isEqualTo(HOTP_ACCOUNT_NAME);
    // starts empty
    assertThat(pin).isEqualTo(activityTestRule.getActivity().getString(R.string.empty_pin));
    assertThat(listEntry.findViewById(R.id.countdown_icon).isShown()).isFalse();

    // Get next OTP value by clicking the "Get next code" button of this list item.
    View buttonView = listEntry.findViewById(R.id.next_otp);
    assertThat(buttonView.isShown()).isTrue();
    TestUtilities.clickView(InstrumentationRegistry.getInstrumentation(), buttonView);
    pin =
        getOriginalPincode(
            ((TextView) listEntry.findViewById(R.id.pin_value)).getText().toString());
    assertThat(pin).isEqualTo(FIRST_HOTP_EXPECTED_PIN);
    assertThat(accountDb.getCounter(new AccountIndex(HOTP_ACCOUNT_NAME, null)))
        .isEqualTo(Integer.valueOf(1));

    // Check the styled pin code
    String styledPin = ((TextView) listEntry.findViewById(R.id.pin_value)).getText().toString();
    assertThat(Utilities.getStyledPincode(FIRST_HOTP_EXPECTED_PIN)).isEqualTo(styledPin);
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java