Search in sources :

Example 56 with Disposable

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

the class ResourceMaybeObserverTest method onErrorCleansUp.

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

Example 57 with Disposable

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

the class ResourceMaybeObserverTest method addResources.

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

Example 58 with Disposable

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

the class ResourceMaybeObserverTest method onCompleteCleansUp.

@Test
public void onCompleteCleansUp() {
    TestResourceMaybeObserver<Integer> rmo = new TestResourceMaybeObserver<Integer>();
    assertFalse(rmo.isDisposed());
    Disposable d = Disposables.empty();
    rmo.add(d);
    assertFalse(d.isDisposed());
    rmo.onComplete();
    assertTrue(rmo.isDisposed());
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 59 with Disposable

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

the class ResourceMaybeObserverTest method startOnce.

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

Example 60 with Disposable

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

the class ResourceObserverTest method startOnce.

@Test
public void startOnce() {
    List<Throwable> error = TestHelper.trackPluginErrors();
    try {
        TestResourceObserver<Integer> tc = new TestResourceObserver<Integer>();
        tc.onSubscribe(Disposables.empty());
        Disposable d = Disposables.empty();
        tc.onSubscribe(d);
        assertTrue(d.isDisposed());
        assertEquals(1, tc.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