@Test
  public void testDirectAccountSetupWithConfirmationRejected() throws Throwable {
    // start AuthenticatorActivity with a valid Uri for account setup.
    String secret = "CQAHUXJ2VWDI7WFF";
    String accountName = "9.99.99.999";
    AccountIndex index = new AccountIndex(accountName, null); // Use a null issuer for now
    activityTestRule.launchActivity(
        new Intent(
            Intent.ACTION_VIEW, Uri.parse("otpauth://totp/" + accountName + "?secret=" + secret)));
    // check main screen does not have focus because of save confirmation dialog.
    View contentView = activityTestRule.getActivity().findViewById(R.id.content_no_accounts);
    assertThat(contentView.hasWindowFocus()).isFalse();
    // click Cancel on the save confirmation dialog box.
    TestUtilities.tapDialogNegativeButton(InstrumentationRegistry.getInstrumentation());
    // check main screen gets focus back after dialog window disappears.
    TestUtilities.waitForWindowFocus(contentView);
    // check database has not been updated.
    assertThat(mAccountDb.getAccounts()).isEmpty();
    assertThat(mAccountDb.getSecret(index)).isNull();
  }
Invokes the activity's {@code onActivityResult} as though it received the specified scanned
URI.
javatests/com/google/android/apps/authenticator/AuthenticatorActivityPart2Test.java