Search in sources :

Example 1 with RunningJobSet

use of com.birbit.android.jobqueue.RunningJobSet in project android-priority-jobqueue by yigit.

the class RunningJobSetTest method testAddSameGroupTwiceWithTimeout.

@Test
public void testAddSameGroupTwiceWithTimeout() {
    MockTimer timer = new MockTimer();
    set = new RunningJobSet(timer);
    set.addGroupUntil("g1", 10L);
    set.addGroupUntil("g1", 12L);
    timer.setNow(5);
    assertList("g1");
    timer.setNow(11);
    assertList("g1");
    timer.setNow(13);
    assertList();
}
Also used : MockTimer(com.birbit.android.jobqueue.test.timer.MockTimer) RunningJobSet(com.birbit.android.jobqueue.RunningJobSet) Test(org.junit.Test)

Example 2 with RunningJobSet

use of com.birbit.android.jobqueue.RunningJobSet in project android-priority-jobqueue by yigit.

the class RunningJobSetTest method testAddWithTimeout.

@Test
public void testAddWithTimeout() {
    MockTimer timer = new MockTimer();
    set = new RunningJobSet(timer);
    set.addGroupUntil("g1", 10L);
    timer.setNow(5);
    assertList("g1");
    timer.setNow(11);
    assertList();
    timer.setNow(3);
    // should've pruned the list
    assertList();
}
Also used : MockTimer(com.birbit.android.jobqueue.test.timer.MockTimer) RunningJobSet(com.birbit.android.jobqueue.RunningJobSet) Test(org.junit.Test)

Example 3 with RunningJobSet

use of com.birbit.android.jobqueue.RunningJobSet in project android-priority-jobqueue by yigit.

the class RunningJobSetTest method testAddMultipleGroupTimeouts.

@Test
public void testAddMultipleGroupTimeouts() {
    MockTimer timer = new MockTimer();
    set = new RunningJobSet(timer);
    set.addGroupUntil("g1", 10L);
    set.addGroupUntil("g2", 20L);
    timer.setNow(5);
    assertList("g1", "g2");
    timer.setNow(11);
    assertList("g2");
    timer.setNow(21);
    assertList();
}
Also used : MockTimer(com.birbit.android.jobqueue.test.timer.MockTimer) RunningJobSet(com.birbit.android.jobqueue.RunningJobSet) Test(org.junit.Test)

Aggregations

RunningJobSet (com.birbit.android.jobqueue.RunningJobSet)3 MockTimer (com.birbit.android.jobqueue.test.timer.MockTimer)3 Test (org.junit.Test)3