@Test
  public void testGetOtpWithOneTotpAccount() {
    accountDb.add("johndoeTotp@gmail.com", "7777777777777777", OtpType.TOTP, 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("johndoeTotp@gmail.com");
    assertThat(Integer.parseInt(pin) >= 0 && Integer.parseInt(pin) <= 999999).isTrue();
    assertThat(pin.length()).isEqualTo(6);
    assertThat(listEntry.findViewById(R.id.next_otp).isShown()).isFalse();
    assertThat(listEntry.findViewById(R.id.countdown_icon).isShown()).isTrue();
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java