@Before
  public void setUp() throws Exception {
    Intents.init();

    DependencyInjector.resetForIntegrationTesting(
        InstrumentationRegistry.getInstrumentation().getTargetContext());
    accountDb = DependencyInjector.getAccountDb();

    initMocks(this);
    otpSource = new OtpProvider(accountDb, mockTotpClock);

    // To launch the SettingsActivity, setting the mock module here.
    // (SettingsActivity is used in the testOptionsMenuSettings test)
    DaggerInjector.init(new MockModule());
    when(mockTotpClock.nowMillis()).thenReturn(NOW_MILLIS);

    // Make sure the notice for first account added is not showing.
    PreferenceManager
        .getDefaultSharedPreferences(
            InstrumentationRegistry.getInstrumentation().getTargetContext())
        .edit()
        .putInt(AuthenticatorActivity.PREF_KEY_LAST_LAUNCH_ACCOUNT_COUNT, 1)
        .commit();

    when(mockBarcodeConditionChecker.isCameraAvailableOnDevice(any(Activity.class)))
        .thenReturn(true);
    when(mockBarcodeConditionChecker.isGooglePlayServicesAvailable(any(Activity.class)))
        .thenReturn(true);
    when(mockBarcodeConditionChecker.getIsBarcodeDetectorOperational(any(Activity.class)))
        .thenReturn(true);
    when(mockBarcodeConditionChecker.isLowStorage(any(Activity.class))).thenReturn(false);

    when(mockPermissionRequestor.shouldShowRequestPermissionRationale(
            any(Activity.class), eq(Manifest.permission.CAMERA)))
        .thenReturn(false);
    when(mockPermissionRequestor.checkSelfPermission(
            any(Context.class), eq(Manifest.permission.CAMERA)))
        .thenReturn(PackageManager.PERMISSION_GRANTED);

    setDarkModeEnabled(InstrumentationRegistry.getInstrumentation().getTargetContext(), false);
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java