use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testTwoWithDeadlinesAndBatch.
@Test
public void testTwoWithDeadlinesAndBatch() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0, 10L);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 0, 20L);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(0)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint.getOverrideDeadlineInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSameWithEnoughDeadline.
@Test
public void testAddTwoOfTheSameWithEnoughDeadline() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0, 0L);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 0, BatchingScheduler.DEFAULT_BATCHING_PERIOD_IN_MS);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(1)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint2.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint.getOverrideDeadlineInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint2.getOverrideDeadlineInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS * 2));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSameWithDelayWithTimeDiff.
@Test
public void testAddTwoOfTheSameWithDelayWithTimeDiff() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
timer.incrementMs(DEFAULT_BATCHING_PERIOD_IN_MS - 101);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 100);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(0)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSameWithDelay.
@Test
public void testAddTwoOfTheSameWithDelay() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 100);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(0)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSameWithEnoughDelay.
@Test
public void testAddTwoOfTheSameWithEnoughDelay() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, BatchingScheduler.DEFAULT_BATCHING_PERIOD_IN_MS);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(1)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint2.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS * 2));
}
Aggregations