Search in sources :

Example 21 with Disposable

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

the class DeferredScalarObserverTest method disposed.

@Test
public void disposed() {
    TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.NONE);
    TakeLast source = new TakeLast(to);
    Disposable d = Disposable.empty();
    source.onSubscribe(d);
    to.dispose();
    source.onNext(1);
    source.onComplete();
    to.assertNoValues().assertNoErrors().assertNotComplete();
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 22 with Disposable

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

the class DeferredScalarObserverTest method disposedAfterOnNext.

@Test
public void disposedAfterOnNext() {
    final TestObserver<Integer> to = new TestObserver<>();
    TakeLast source = new TakeLast(new Observer<Integer>() {

        Disposable upstream;

        @Override
        public void onSubscribe(Disposable d) {
            this.upstream = d;
            to.onSubscribe(d);
        }

        @Override
        public void onNext(Integer value) {
            to.onNext(value);
            upstream.dispose();
        }

        @Override
        public void onError(Throwable e) {
            to.onError(e);
        }

        @Override
        public void onComplete() {
            to.onComplete();
        }
    });
    source.onSubscribe(Disposable.empty());
    source.onNext(1);
    source.onComplete();
    to.assertValue(1).assertNoErrors().assertNotComplete();
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Example 23 with Disposable

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

the class DeferredScalarObserverTest method nonfusedEmpty.

@Test
public void nonfusedEmpty() {
    TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.NONE);
    TakeLast source = new TakeLast(to);
    Disposable d = Disposable.empty();
    source.onSubscribe(d);
    source.onComplete();
    to.assertResult();
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 24 with Disposable

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

the class DeferredScalarObserverTest method fused.

@Test
public void fused() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
        TakeFirst source = new TakeFirst(to);
        Disposable d = Disposable.empty();
        source.onSubscribe(d);
        to.assertFuseable();
        to.assertFusionMode(QueueFuseable.ASYNC);
        source.onNext(1);
        source.onNext(1);
        source.onError(new TestException());
        source.onComplete();
        assertTrue(d.isDisposed());
        to.assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) Test(org.junit.Test)

Example 25 with Disposable

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

the class DeferredScalarObserverTest method dispose.

@Test
public void dispose() {
    TestObserver<Integer> to = new TestObserver<>();
    TakeFirst source = new TakeFirst(to);
    Disposable d = Disposable.empty();
    source.onSubscribe(d);
    assertFalse(d.isDisposed());
    to.dispose();
    assertTrue(d.isDisposed());
    assertTrue(source.isDisposed());
}
Also used : QueueDisposable(io.reactivex.rxjava3.operators.QueueDisposable) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)251 Disposable (io.reactivex.rxjava3.disposables.Disposable)236 TestException (io.reactivex.rxjava3.exceptions.TestException)74 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)56 IOException (java.io.IOException)38 Scheduler (io.reactivex.rxjava3.core.Scheduler)36 EmptyDisposable (io.reactivex.rxjava3.internal.disposables.EmptyDisposable)35 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)34 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)32 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)22 TestObserver (io.reactivex.rxjava3.observers.TestObserver)18 SequentialDisposable (io.reactivex.rxjava3.internal.disposables.SequentialDisposable)15 QueueDisposable (io.reactivex.rxjava3.operators.QueueDisposable)13 CountingRunnable (io.reactivex.rxjava3.android.testutil.CountingRunnable)10 TrampolineScheduler (io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)9 LifecycleDisposable (org.thoughtcrime.securesms.util.LifecycleDisposable)8 Observable (io.reactivex.rxjava3.core.Observable)6 Observer (io.reactivex.rxjava3.core.Observer)6 ScalarDisposable (io.reactivex.rxjava3.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)6