BackupJobs { public @Nullable Job scheduleBootup() { if (!preferences.isAutoBackupEnabled()) { Log.d(TAG, "auto backup no longer enabled, canceling all jobs"); cancelAll(); return null; } else if (preferences.isUseOldScheduler()) { return schedule(BOOT_BACKUP_DELAY, REGULAR, false); } else { return null; } } BackupJobs(Context context);   BackupJobs(Context context, Preferences preferences); @Nullable Job scheduleIncoming(); Job scheduleRegular(); @Nullable Job scheduleContentTriggerJob(); @Nullable Job scheduleBootup(); @Nullable Job scheduleImmediate(); void cancelAll(); void cancelRegular();  }
@Test public void shouldScheduleRegularJobAfterBootForOldScheduler() throws Exception { when(preferences.isAutoBackupEnabled()).thenReturn(true); when(preferences.isUseOldScheduler()).thenReturn(true); Job job = subject.scheduleBootup(); verifyJobScheduled(job, 60, "REGULAR"); }
@Test public void shouldScheduleNothingAfterBootForNewScheduler() throws Exception { when(preferences.isAutoBackupEnabled()).thenReturn(true); when(preferences.isUseOldScheduler()).thenReturn(false); Job job = subject.scheduleBootup(); assertThat(job).isNull(); }
@Test public void shouldCancelAllJobsAfterBootIfAutoBackupDisabled() throws Exception { when(preferences.isAutoBackupEnabled()).thenReturn(false); Job job = subject.scheduleBootup(); assertThat(job).isNull(); }