use of io.reactivex.rxjava3.android.testutil.CountingRunnable in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method directScheduleOnceWithDelayPostsWithDelay.
@Test
public void directScheduleOnceWithDelayPostsWithDelay() {
CountingRunnable counter = new CountingRunnable();
scheduler.scheduleDirect(counter, 1, MINUTES);
runUiThreadTasks();
assertEquals(0, counter.get());
idleMainLooper(1, MINUTES);
runUiThreadTasks();
assertEquals(1, counter.get());
}
use of io.reactivex.rxjava3.android.testutil.CountingRunnable in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerSchedulePeriodicallyInputValidation.
@Test
@Ignore("Implementation delegated to default RxJava implementation")
public void workerSchedulePeriodicallyInputValidation() {
Worker worker = scheduler.createWorker();
try {
worker.schedulePeriodically(null, 1, 1, MINUTES);
fail();
} catch (NullPointerException e) {
assertEquals("run == null", e.getMessage());
}
try {
worker.schedulePeriodically(new CountingRunnable(), 1, -1, MINUTES);
fail();
} catch (IllegalArgumentException e) {
assertEquals("period < 0: -1", e.getMessage());
}
try {
worker.schedulePeriodically(new CountingRunnable(), 1, 1, null);
fail();
} catch (NullPointerException e) {
assertEquals("unit == null", e.getMessage());
}
}
use of io.reactivex.rxjava3.android.testutil.CountingRunnable 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.rxjava3.android.testutil.CountingRunnable 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());
}
use of io.reactivex.rxjava3.android.testutil.CountingRunnable in project RxAndroid by ReactiveX.
the class HandlerSchedulerTest method workerSchedulePeriodicallyThrowingDoesNotReschedule.
@Test
@Ignore("Implementation delegated to default RxJava implementation")
public void workerSchedulePeriodicallyThrowingDoesNotReschedule() {
Worker worker = scheduler.createWorker();
CountingRunnable counter = new CountingRunnable() {
@Override
public void run() {
super.run();
if (get() == 2) {
throw new RuntimeException("Broken!");
}
}
};
worker.schedulePeriodically(counter, 1, 1, MINUTES);
runUiThreadTasks();
assertEquals(0, counter.get());
idleMainLooper(1, MINUTES);
runUiThreadTasks();
assertEquals(1, counter.get());
idleMainLooper(1, MINUTES);
runUiThreadTasks();
assertEquals(2, counter.get());
// Exception will have happened here during the last run() execution.
idleMainLooper(1, MINUTES);
runUiThreadTasks();
assertEquals(2, counter.get());
}
Aggregations