private void doAccountSetupViaReceivedIntentFor(String accountName, String issuer) {
    String issuerParam = (issuer == null) ? "" : "&issuer=" + uriEncode(issuer);
    activityTestRule.launchActivity(
        new Intent(Intent.ACTION_VIEW)
            .setData(
                Uri.parse("otpauth://totp/" + accountName + "?secret=AAAABBBB" + issuerParam)));
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();

    // The Activity is supposed to display a dialog prompting the user whether to add the account.
    assertThat(mAccountDb.getAccounts()).isEmpty();
    onView(withText(R.string.ok)).perform(click());

    AccountIndex index = new AccountIndex(accountName, issuer);
    assertThat(mAccountDb.getAccounts()).containsExactly(index).inOrder();
    assertThat(mAccountDb.getSecret(index)).isEqualTo("AAAABBBB");
    assertThat(mAccountDb.getType(index)).isEqualTo(OtpType.TOTP);
    // AuthenticatorActivity should continue
    assertThat(activityTestRule.getActivity().isFinishing()).isFalse();
  }
Unit test for authenticator activity (part/shard 2).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityPart2Test.java