public void doAccountSetupWithValidUri(
      String accountName, String issuer, OtpType type, Integer counter) {
    String secret = "CQAHUXJ2VWDI7WFF";
    String uriType = type.name().toLowerCase();
    String counterParam = (counter == null) ? "" : "&counter=" + counter;
    String issuerParam = (issuer == null) ? "" : "&issuer=" + uriEncode(issuer);
    String path = uriType + "/" + accountName;
    callOnActivityResultOnUiThreadWithScannedUri(
        "otpauth://" + path + "?secret=" + secret + counterParam + issuerParam);

    AccountIndex index = new AccountIndex(accountName, issuer);
    assertThat(mAccountDb.getAccounts()).containsExactly(index).inOrder();
    assertThat(mAccountDb.getSecret(index)).isEqualTo(secret);
    assertThat(mAccountDb.getType(index)).isEqualTo(type);
    if (counter != null) {
      assertThat(mAccountDb.getCounter(index)).isEqualTo(counter);
    }
    assertThat(activityTestRule.getActivity().isFinishing()).isFalse(); // AuthenticatorActivity should continue
    mAccountDb.deleteAllData(); // Reset for next run
  }
Unit test for authenticator activity (part/shard 2).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityPart2Test.java