Search in sources :

Example 61 with Disposable

use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.

the class ResourceObserverTest method addResources.

@Test
public void addResources() {
    TestResourceObserver<Integer> ro = new TestResourceObserver<Integer>();
    assertFalse(ro.isDisposed());
    Disposable d = Disposables.empty();
    ro.add(d);
    assertFalse(d.isDisposed());
    ro.dispose();
    assertTrue(ro.isDisposed());
    assertTrue(d.isDisposed());
    ro.dispose();
    assertTrue(ro.isDisposed());
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 62 with Disposable

use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.

the class ResourceObserverTest method onErrorCleansUp.

@Test
public void onErrorCleansUp() {
    TestResourceObserver<Integer> ro = new TestResourceObserver<Integer>();
    assertFalse(ro.isDisposed());
    Disposable d = Disposables.empty();
    ro.add(d);
    assertFalse(d.isDisposed());
    ro.onError(new TestException());
    assertTrue(ro.isDisposed());
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.disposables.Disposable) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 63 with Disposable

use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.

the class ResourceObserverTest method dispose.

@Test
public void dispose() {
    TestResourceObserver<Integer> tc = new TestResourceObserver<Integer>();
    tc.dispose();
    Disposable d = Disposables.empty();
    tc.onSubscribe(d);
    assertTrue(d.isDisposed());
    assertEquals(0, tc.start);
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 64 with Disposable

use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.

the class ResourceSingleObserverTest method onSuccessCleansUp.

@Test
public void onSuccessCleansUp() {
    TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
    assertFalse(rso.isDisposed());
    Disposable d = Disposables.empty();
    rso.add(d);
    assertFalse(d.isDisposed());
    rso.onSuccess(1);
    assertTrue(rso.isDisposed());
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 65 with Disposable

use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.

the class ResourceSingleObserverTest method startOnce.

@Test
public void startOnce() {
    List<Throwable> error = TestHelper.trackPluginErrors();
    try {
        TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
        rso.onSubscribe(Disposables.empty());
        Disposable d = Disposables.empty();
        rso.onSubscribe(d);
        assertTrue(d.isDisposed());
        assertEquals(1, rso.start);
        TestHelper.assertError(error, 0, IllegalStateException.class, "Disposable already set!");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Aggregations

Disposable (io.reactivex.disposables.Disposable)224 Test (org.junit.Test)95 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)31 Logger (chat.rocket.android.helper.Logger)19 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)18 Worker (io.reactivex.Scheduler.Worker)15 List (java.util.List)14 Single (io.reactivex.Single)13 Function (io.reactivex.functions.Function)13 NonNull (io.reactivex.annotations.NonNull)12 Nullable (android.support.annotation.Nullable)11 Bundle (android.os.Bundle)10 CountingRunnable (io.reactivex.android.testutil.CountingRunnable)10 EmptyDisposable (io.reactivex.internal.disposables.EmptyDisposable)10 TestSubscriber (io.reactivex.subscribers.TestSubscriber)10 Optional (com.fernandocejas.arrow.optional.Optional)9 Schedulers (io.reactivex.schedulers.Schedulers)9 TimeUnit (java.util.concurrent.TimeUnit)8 NonNull (android.support.annotation.NonNull)7