use of io.reactivex.Scheduler.Worker in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerScheduleOnceWithNegativeDelayPostsImmediately.
@Test
public void workerScheduleOnceWithNegativeDelayPostsImmediately() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable();
worker.schedule(counter, -1, TimeUnit.MINUTES);
runUiThreadTasks();
assertEquals(1, counter.get());
}
use of io.reactivex.Scheduler.Worker in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerScheduleOncePostsImmediately.
@Test
public void workerScheduleOncePostsImmediately() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable();
worker.schedule(counter);
runUiThreadTasks();
assertEquals(1, counter.get());
}
use of io.reactivex.Scheduler.Worker in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerScheduleOnceWithDelayDisposedDoesNotRun.
@Test
public void workerScheduleOnceWithDelayDisposedDoesNotRun() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable();
Disposable disposable = worker.schedule(counter, 1, MINUTES);
idleMainLooper(30, SECONDS);
disposable.dispose();
idleMainLooper(30, SECONDS);
runUiThreadTasks();
assertEquals(0, counter.get());
}
use of io.reactivex.Scheduler.Worker in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerScheduleOnceWithDelayPostsWithDelay.
@Test
public void workerScheduleOnceWithDelayPostsWithDelay() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable();
worker.schedule(counter, 1, MINUTES);
runUiThreadTasks();
assertEquals(0, counter.get());
idleMainLooper(1, MINUTES);
runUiThreadTasks();
assertEquals(1, counter.get());
}
use of io.reactivex.Scheduler.Worker in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerDisposableTracksDisposedState.
@Test
public void workerDisposableTracksDisposedState() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable();
Disposable disposable = worker.schedule(counter);
assertFalse(disposable.isDisposed());
disposable.dispose();
assertTrue(disposable.isDisposed());
}
Aggregations