@Test
  public void testGetOtpWithMultipleAccounts_collidingNames() {
    // Different kinds of colliding names
    AccountIndex[] colliding = {
      new AccountIndex("collider@gmail.com", null),
      new AccountIndex("collider@gmail.com", AccountDb.GOOGLE_ISSUER_NAME),
      new AccountIndex("Yahoo:collider@yahoo.com", null),
      new AccountIndex("Yahoo:collider@yahoo.com", "Yahoo"),
    };

    accountDb.add(
        colliding[0].getName(),
        "5555555555555555",
        OtpType.TOTP,
        null,
        null,
        colliding[0].getIssuer());
    accountDb.add(
        colliding[1].getName(),
        "6666666666666666",
        OtpType.TOTP,
        null,
        null,
        colliding[1].getIssuer());
    accountDb.add(
        colliding[2].getName(),
        "2222222222222222",
        OtpType.TOTP,
        null,
        null,
        colliding[2].getIssuer());
    accountDb.add(
        colliding[3].getName(),
        "7777777777777777",
        OtpType.TOTP,
        null,
        null,
        colliding[3].getIssuer());

    activityTestRule.launchActivity(null);

    final ListView userList = activityTestRule.getActivity().findViewById(R.id.user_list);
    assertThat(userList.getChildCount()).isEqualTo(4);

    for (int i = 0; i < accountDb.getAccounts().size(); i++) {
      View listEntry = userList.getChildAt(i);
      String user = ((TextView) listEntry.findViewById(R.id.current_user)).getText().toString();
      String pin =
          getOriginalPincode(
              ((TextView) listEntry.findViewById(R.id.pin_value)).getText().toString());
      // Validate that the i-th entry in the list matches the i-th account added from colliding[]
      assertThat(user)
          .isEqualTo(
              Utilities.getCombinedTextForIssuerAndAccountName(
                  colliding[i].getIssuer(), colliding[i].getStrippedName()));
      // Check that the OTP code shown is in the normal range
      assertThat(Integer.parseInt(pin) > 0 && Integer.parseInt(pin) <= 999999).isTrue();
      // TOTP accounts don't have a "next otp" button, but they do have a countdown timer
      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