use of android.app.job.JobInfo.Builder in project android_frameworks_base by ResurrectionRemix.
the class JobStoreTest method testNonPersistedTaskIsNotPersisted.
/**
* Test that non persisted job is not written to disk.
*/
public void testNonPersistedTaskIsNotPersisted() throws Exception {
JobInfo.Builder b = new Builder(42, mComponent).setOverrideDeadline(10000).setPersisted(false);
JobStatus jsNonPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(jsNonPersisted);
b = new Builder(43, mComponent).setOverrideDeadline(10000).setPersisted(true);
JobStatus jsPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(jsPersisted);
Thread.sleep(IO_WAIT);
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
assertEquals("Job count is incorrect.", 1, jobStatusSet.size());
JobStatus jobStatus = jobStatusSet.getAllJobs().iterator().next();
assertEquals("Wrong job persisted.", 43, jobStatus.getJobId());
}
use of android.app.job.JobInfo.Builder in project android_frameworks_base by ResurrectionRemix.
the class JobStoreTest method testWritingTaskWithExtras.
public void testWritingTaskWithExtras() throws Exception {
JobInfo.Builder b = new Builder(8, mComponent).setRequiresDeviceIdle(true).setPeriodic(10000L).setRequiresCharging(true).setPersisted(true);
PersistableBundle extras = new PersistableBundle();
extras.putDouble("hello", 3.2);
extras.putString("hi", "there");
extras.putInt("into", 3);
b.setExtras(extras);
final JobInfo task = b.build();
JobStatus taskStatus = JobStatus.createFromJobInfo(task, SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(taskStatus);
Thread.sleep(IO_WAIT);
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
assertTasksEqual(task, loaded.getJob());
}
use of android.app.job.JobInfo.Builder in project android_frameworks_base by ResurrectionRemix.
the class JobStoreTest method testPriorityPersisted.
public void testPriorityPersisted() throws Exception {
JobInfo.Builder b = new Builder(92, mComponent).setOverrideDeadline(5000).setPriority(42).setPersisted(true);
final JobStatus js = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(js);
Thread.sleep(IO_WAIT);
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
assertEquals("Priority not correctly persisted.", 42, loaded.getPriority());
}
use of android.app.job.JobInfo.Builder in project android_frameworks_base by crdroidandroid.
the class JobStoreTest method testWritingTaskWithExtras.
public void testWritingTaskWithExtras() throws Exception {
JobInfo.Builder b = new Builder(8, mComponent).setRequiresDeviceIdle(true).setPeriodic(10000L).setRequiresCharging(true).setPersisted(true);
PersistableBundle extras = new PersistableBundle();
extras.putDouble("hello", 3.2);
extras.putString("hi", "there");
extras.putInt("into", 3);
b.setExtras(extras);
final JobInfo task = b.build();
JobStatus taskStatus = JobStatus.createFromJobInfo(task, SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(taskStatus);
Thread.sleep(IO_WAIT);
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
assertTasksEqual(task, loaded.getJob());
}
use of android.app.job.JobInfo.Builder in project android_frameworks_base by crdroidandroid.
the class JobStoreTest method testNonPersistedTaskIsNotPersisted.
/**
* Test that non persisted job is not written to disk.
*/
public void testNonPersistedTaskIsNotPersisted() throws Exception {
JobInfo.Builder b = new Builder(42, mComponent).setOverrideDeadline(10000).setPersisted(false);
JobStatus jsNonPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(jsNonPersisted);
b = new Builder(43, mComponent).setOverrideDeadline(10000).setPersisted(true);
JobStatus jsPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(jsPersisted);
Thread.sleep(IO_WAIT);
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
assertEquals("Job count is incorrect.", 1, jobStatusSet.size());
JobStatus jobStatus = jobStatusSet.getAllJobs().iterator().next();
assertEquals("Wrong job persisted.", 43, jobStatus.getJobId());
}
Aggregations