@Test
  public void testScreenWithOneTotpAccountWithFirstNoticeDisplayed() {
    PreferenceManager
        .getDefaultSharedPreferences(
            InstrumentationRegistry.getInstrumentation().getTargetContext())
        .edit()
        .putInt(AuthenticatorActivity.PREF_KEY_LAST_LAUNCH_ACCOUNT_COUNT, 0)
        .commit();

    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);

    onView(withId(R.id.add_account_fab)).check(matches(not(isDisplayed())));
    onView(withId(R.id.first_account_message_header)).check(matches(isDisplayed()));
    onView(withId(R.id.first_account_message_detail)).check(matches(isDisplayed()));
    onView(withId(R.id.first_account_message_button_done)).check(matches(isDisplayed()));

    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();

    // Click the "Done" button to dismiss the notice message
    onView(withId(R.id.first_account_message_button_done)).perform(click());
    onView(withId(R.id.add_account_fab)).check(matches(isDisplayed()));
    onView(withId(R.id.first_account_message_header)).check(matches(not(isDisplayed())));
    onView(withId(R.id.first_account_message_detail)).check(matches(not(isDisplayed())));
    onView(withId(R.id.first_account_message_button_done)).check(matches(not(isDisplayed())));
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java