use of com.android.server.job.MockPriorityJobService.TestEnvironment.Event in project platform_frameworks_base by android.
the class PrioritySchedulingTest method testHigherPriorityJobNotPreempted.
public void testHigherPriorityJobNotPreempted() throws Exception {
JobInfo job1 = new JobInfo.Builder(111, kJobServiceComponent).setPriority(2).setOverrideDeadline(7000L).build();
JobInfo job2 = new JobInfo.Builder(222, kJobServiceComponent).setPriority(2).setOverrideDeadline(7000L).build();
JobInfo job3 = new JobInfo.Builder(333, kJobServiceComponent).setPriority(2).setOverrideDeadline(7000L).build();
JobInfo job4 = new JobInfo.Builder(444, kJobServiceComponent).setPriority(1).setMinimumLatency(2000L).setOverrideDeadline(7000L).build();
mJobScheduler.schedule(job1);
mJobScheduler.schedule(job2);
mJobScheduler.schedule(job3);
mJobScheduler.schedule(job4);
// Wait for job 4 to preempt one of the higher priority jobs
Thread.sleep(10000);
Event job4Execution = new Event(TestEnvironment.EVENT_START_JOB, 444);
boolean wasJob4Executed = kTestEnvironment.getExecutedEvents().contains(job4Execution);
assertFalse("Higher priority job was preempted.", wasJob4Executed);
}
use of com.android.server.job.MockPriorityJobService.TestEnvironment.Event in project platform_frameworks_base by android.
the class PrioritySchedulingTest method testLowerPriorityJobPreempted.
public void testLowerPriorityJobPreempted() throws Exception {
JobInfo job1 = new JobInfo.Builder(111, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job2 = new JobInfo.Builder(222, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job3 = new JobInfo.Builder(333, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job4 = new JobInfo.Builder(444, kJobServiceComponent).setPriority(2).setMinimumLatency(2000L).setOverrideDeadline(7000L).build();
mJobScheduler.schedule(job1);
mJobScheduler.schedule(job2);
mJobScheduler.schedule(job3);
mJobScheduler.schedule(job4);
// Wait for job 4 to preempt one of the lower priority jobs
Thread.sleep(10000);
Event job4Execution = new Event(TestEnvironment.EVENT_START_JOB, 444);
ArrayList<Event> executedEvents = kTestEnvironment.getExecutedEvents();
boolean wasJob4Executed = executedEvents.contains(job4Execution);
boolean wasSomeJobPreempted = false;
for (Event event : executedEvents) {
if (event.event == TestEnvironment.EVENT_PREEMPT_JOB) {
wasSomeJobPreempted = true;
break;
}
}
assertTrue("No job was preempted.", wasSomeJobPreempted);
assertTrue("Lower priority jobs were not preempted.", wasJob4Executed);
}
use of com.android.server.job.MockPriorityJobService.TestEnvironment.Event in project android_frameworks_base by DirtyUnicorns.
the class PrioritySchedulingTest method testLowerPriorityJobPreempted.
public void testLowerPriorityJobPreempted() throws Exception {
JobInfo job1 = new JobInfo.Builder(111, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job2 = new JobInfo.Builder(222, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job3 = new JobInfo.Builder(333, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job4 = new JobInfo.Builder(444, kJobServiceComponent).setPriority(2).setMinimumLatency(2000L).setOverrideDeadline(7000L).build();
mJobScheduler.schedule(job1);
mJobScheduler.schedule(job2);
mJobScheduler.schedule(job3);
mJobScheduler.schedule(job4);
// Wait for job 4 to preempt one of the lower priority jobs
Thread.sleep(10000);
Event job4Execution = new Event(TestEnvironment.EVENT_START_JOB, 444);
ArrayList<Event> executedEvents = kTestEnvironment.getExecutedEvents();
boolean wasJob4Executed = executedEvents.contains(job4Execution);
boolean wasSomeJobPreempted = false;
for (Event event : executedEvents) {
if (event.event == TestEnvironment.EVENT_PREEMPT_JOB) {
wasSomeJobPreempted = true;
break;
}
}
assertTrue("No job was preempted.", wasSomeJobPreempted);
assertTrue("Lower priority jobs were not preempted.", wasJob4Executed);
}
use of com.android.server.job.MockPriorityJobService.TestEnvironment.Event in project android_frameworks_base by ResurrectionRemix.
the class PrioritySchedulingTest method testLowerPriorityJobPreempted.
public void testLowerPriorityJobPreempted() throws Exception {
JobInfo job1 = new JobInfo.Builder(111, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job2 = new JobInfo.Builder(222, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job3 = new JobInfo.Builder(333, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job4 = new JobInfo.Builder(444, kJobServiceComponent).setPriority(2).setMinimumLatency(2000L).setOverrideDeadline(7000L).build();
mJobScheduler.schedule(job1);
mJobScheduler.schedule(job2);
mJobScheduler.schedule(job3);
mJobScheduler.schedule(job4);
// Wait for job 4 to preempt one of the lower priority jobs
Thread.sleep(10000);
Event job4Execution = new Event(TestEnvironment.EVENT_START_JOB, 444);
ArrayList<Event> executedEvents = kTestEnvironment.getExecutedEvents();
boolean wasJob4Executed = executedEvents.contains(job4Execution);
boolean wasSomeJobPreempted = false;
for (Event event : executedEvents) {
if (event.event == TestEnvironment.EVENT_PREEMPT_JOB) {
wasSomeJobPreempted = true;
break;
}
}
assertTrue("No job was preempted.", wasSomeJobPreempted);
assertTrue("Lower priority jobs were not preempted.", wasJob4Executed);
}
use of com.android.server.job.MockPriorityJobService.TestEnvironment.Event in project android_frameworks_base by crdroidandroid.
the class PrioritySchedulingTest method testLowerPriorityJobPreempted.
public void testLowerPriorityJobPreempted() throws Exception {
JobInfo job1 = new JobInfo.Builder(111, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job2 = new JobInfo.Builder(222, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job3 = new JobInfo.Builder(333, kJobServiceComponent).setPriority(1).setOverrideDeadline(7000L).build();
JobInfo job4 = new JobInfo.Builder(444, kJobServiceComponent).setPriority(2).setMinimumLatency(2000L).setOverrideDeadline(7000L).build();
mJobScheduler.schedule(job1);
mJobScheduler.schedule(job2);
mJobScheduler.schedule(job3);
mJobScheduler.schedule(job4);
// Wait for job 4 to preempt one of the lower priority jobs
Thread.sleep(10000);
Event job4Execution = new Event(TestEnvironment.EVENT_START_JOB, 444);
ArrayList<Event> executedEvents = kTestEnvironment.getExecutedEvents();
boolean wasJob4Executed = executedEvents.contains(job4Execution);
boolean wasSomeJobPreempted = false;
for (Event event : executedEvents) {
if (event.event == TestEnvironment.EVENT_PREEMPT_JOB) {
wasSomeJobPreempted = true;
break;
}
}
assertTrue("No job was preempted.", wasSomeJobPreempted);
assertTrue("Lower priority jobs were not preempted.", wasJob4Executed);
}