Search in sources :

Example 51 with Disposable

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

the class AsyncSubscriptionTest method testCancelOnce.

@Test
public void testCancelOnce() {
    Disposable r = mock(Disposable.class);
    AsyncSubscription as = new AsyncSubscription(r);
    Subscription s = mock(Subscription.class);
    as.setSubscription(s);
    as.cancel();
    as.cancel();
    as.cancel();
    verify(s, never()).request(anyLong());
    verify(s).cancel();
    verify(r).dispose();
}
Also used : Disposable(io.reactivex.disposables.Disposable) Subscription(org.reactivestreams.Subscription) Test(org.junit.Test)

Example 52 with Disposable

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

the class AsyncSubscriptionTest method testInitialResource.

@Test
public void testInitialResource() {
    Disposable r = mock(Disposable.class);
    AsyncSubscription as = new AsyncSubscription(r);
    as.cancel();
    verify(r).dispose();
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 53 with Disposable

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

the class AsyncSubscriptionTest method testReplaceResource.

@Test
public void testReplaceResource() {
    AsyncSubscription as = new AsyncSubscription();
    Disposable r = mock(Disposable.class);
    assertTrue(as.replaceResource(r));
    as.cancel();
    verify(r).dispose();
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 54 with Disposable

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

the class AsyncSubscriptionTest method testSetResourceAfterCancel.

@Test
public void testSetResourceAfterCancel() {
    AsyncSubscription as = new AsyncSubscription();
    as.cancel();
    Disposable r = mock(Disposable.class);
    as.setResource(r);
    verify(r).dispose();
}
Also used : Disposable(io.reactivex.disposables.Disposable) Test(org.junit.Test)

Example 55 with Disposable

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

the class ExecutorSchedulerTest method runnableDisposed.

@Test
public void runnableDisposed() {
    final Scheduler s = Schedulers.from(new Executor() {

        @Override
        public void execute(Runnable r) {
            r.run();
        }
    });
    Disposable d = s.scheduleDirect(Functions.EMPTY_RUNNABLE);
    assertTrue(d.isDisposed());
}
Also used : Disposable(io.reactivex.disposables.Disposable) EmptyDisposable(io.reactivex.internal.disposables.EmptyDisposable)

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