Search in sources :

Example 31 with CountingRunnable

use of io.reactivex.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());
}
Also used : Disposable(io.reactivex.disposables.Disposable) CountingRunnable(io.reactivex.android.testutil.CountingRunnable) Worker(io.reactivex.Scheduler.Worker) Test(org.junit.Test)

Example 32 with CountingRunnable

use of io.reactivex.android.testutil.CountingRunnable in project RxAndroid by ReactiveX.

the class HandlerSchedulerTest method directSchedulePeriodicallyInputValidation.

@Test
@Ignore("Implementation delegated to default RxJava implementation")
public void directSchedulePeriodicallyInputValidation() {
    try {
        scheduler.schedulePeriodicallyDirect(null, 1, 1, MINUTES);
        fail();
    } catch (NullPointerException e) {
        assertEquals("run == null", e.getMessage());
    }
    try {
        scheduler.schedulePeriodicallyDirect(new CountingRunnable(), 1, -1, MINUTES);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("period < 0: -1", e.getMessage());
    }
    try {
        scheduler.schedulePeriodicallyDirect(new CountingRunnable(), 1, 1, null);
        fail();
    } catch (NullPointerException e) {
        assertEquals("unit == null", e.getMessage());
    }
}
Also used : CountingRunnable(io.reactivex.android.testutil.CountingRunnable) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 33 with CountingRunnable

use of io.reactivex.android.testutil.CountingRunnable in project RxAndroid by ReactiveX.

the class HandlerSchedulerTest method workerSchedulePeriodicallyReschedulesItself.

@Test
@Ignore("Implementation delegated to default RxJava implementation")
public void workerSchedulePeriodicallyReschedulesItself() {
    Worker worker = scheduler.createWorker();
    CountingRunnable counter = new CountingRunnable();
    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());
    idleMainLooper(1, MINUTES);
    runUiThreadTasks();
    assertEquals(3, counter.get());
}
Also used : CountingRunnable(io.reactivex.android.testutil.CountingRunnable) Worker(io.reactivex.Scheduler.Worker) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CountingRunnable (io.reactivex.android.testutil.CountingRunnable)33 Test (org.junit.Test)33 Worker (io.reactivex.Scheduler.Worker)19 Ignore (org.junit.Ignore)12 Disposable (io.reactivex.disposables.Disposable)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)9