Search in sources :

Example 11 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class AlarmManagerDriverTest method testScheduleJobWithExecutionWindowTriggerAndTag.

@Test
public void testScheduleJobWithExecutionWindowTriggerAndTag() throws Exception {
    final Job job = jobBuilder().setTag("REGULAR").setTrigger(Trigger.executionWindow(30, 30)).build();
    final int result = subject.schedule(job);
    assertThat(result).isEqualTo(SCHEDULE_RESULT_SUCCESS);
    assertAlarmScheduled("REGULAR");
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 12 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class AlarmManagerDriverTest method testScheduleJobWithoutTrigger.

@Test
public void testScheduleJobWithoutTrigger() throws Exception {
    final Job job = jobBuilder().build();
    final int result = subject.schedule(job);
    assertThat(result).isEqualTo(SCHEDULE_RESULT_SUCCESS);
    assertAlarmScheduled("UNKNOWN");
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 13 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class AlarmManagerDriverTest method testScheduleJobWithUnknownTrigger.

@Test
public void testScheduleJobWithUnknownTrigger() throws Exception {
    final Job job = jobBuilder().setTrigger(Trigger.contentUriTrigger(Collections.singletonList(new ObservedUri(Uri.parse("foo://bar"), 0)))).build();
    final int result = subject.schedule(job);
    assertThat(result).isEqualTo(SCHEDULE_RESULT_UNSUPPORTED_TRIGGER);
}
Also used : ObservedUri(com.firebase.jobdispatcher.ObservedUri) Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 14 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldScheduleRegular.

@Test
public void shouldScheduleRegular() throws Exception {
    when(preferences.isAutoBackupEnabled()).thenReturn(true);
    when(preferences.getRegularTimeoutSecs()).thenReturn(2000);
    Job job = subject.scheduleRegular();
    verifyJobScheduled(job, 2000, "REGULAR");
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Example 15 with Job

use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.

the class BackupJobsTest method shouldScheduleRegularJobAfterBootForOldScheduler.

@Test
public void shouldScheduleRegularJobAfterBootForOldScheduler() throws Exception {
    when(preferences.isAutoBackupEnabled()).thenReturn(true);
    when(preferences.isUseOldScheduler()).thenReturn(true);
    Job job = subject.scheduleBootup();
    verifyJobScheduled(job, 60, "REGULAR");
}
Also used : Job(com.firebase.jobdispatcher.Job) Test(org.junit.Test)

Aggregations

Job (com.firebase.jobdispatcher.Job)20 Test (org.junit.Test)12 FirebaseJobDispatcher (com.firebase.jobdispatcher.FirebaseJobDispatcher)7 GooglePlayDriver (com.firebase.jobdispatcher.GooglePlayDriver)7 Bundle (android.os.Bundle)3 JobTrigger (com.firebase.jobdispatcher.JobTrigger)3 ObservedUri (com.firebase.jobdispatcher.ObservedUri)3 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 TextView (android.widget.TextView)2 AdView (com.google.android.gms.ads.AdView)2 CurrencyEnum (it.angelic.mpw.model.enums.CurrencyEnum)2 PoolEnum (it.angelic.mpw.model.enums.PoolEnum)2 Intent (android.content.Intent)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 NavigationView (android.support.design.widget.NavigationView)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 EditTextPreference (android.support.v7.preference.EditTextPreference)1 ListPreference (android.support.v7.preference.ListPreference)1