Search in sources :

Example 1 with SchedulerWhen

use of io.reactivex.rxjava3.internal.schedulers.SchedulerWhen in project RxJava by ReactiveX.

the class SchedulerWhenTest method syncDelaySubscription.

@Test
public void syncDelaySubscription() {
    final TestScheduler tSched = new TestScheduler();
    SchedulerWhen sched = throttleScheduler(tSched);
    TestSubscriber<Long> tSub = TestSubscriber.create();
    syncWork(sched).subscribe(tSub);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(0, SECONDS);
    tSub.assertValueCount(1);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(2);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(3);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(4);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(5);
    tSub.assertComplete();
    sched.dispose();
}
Also used : SchedulerWhen(io.reactivex.rxjava3.internal.schedulers.SchedulerWhen) Test(org.junit.Test)

Example 2 with SchedulerWhen

use of io.reactivex.rxjava3.internal.schedulers.SchedulerWhen in project RxJava by ReactiveX.

the class SchedulerWhenTest method asyncDelaySubscription.

@Test
public void asyncDelaySubscription() {
    final TestScheduler tSched = new TestScheduler();
    SchedulerWhen sched = throttleScheduler(tSched);
    TestSubscriber<Long> tSub = TestSubscriber.create();
    asyncWork(sched).subscribe(tSub);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(0, SECONDS);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(1);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(1);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(2);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(2);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(3);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(3);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(4);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(4);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(5);
    tSub.assertComplete();
    sched.dispose();
}
Also used : SchedulerWhen(io.reactivex.rxjava3.internal.schedulers.SchedulerWhen) Test(org.junit.Test)

Example 3 with SchedulerWhen

use of io.reactivex.rxjava3.internal.schedulers.SchedulerWhen in project RxJava by ReactiveX.

the class SchedulerWhenTest method syncMaxConcurrent.

@Test
public void syncMaxConcurrent() {
    TestScheduler tSched = new TestScheduler();
    SchedulerWhen sched = maxConcurrentScheduler(tSched);
    TestSubscriber<Long> tSub = TestSubscriber.create();
    syncWork(sched).subscribe(tSub);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(0, SECONDS);
    // since all the work is synchronous nothing is blocked and its all done
    tSub.assertValueCount(5);
    tSub.assertComplete();
    sched.dispose();
}
Also used : SchedulerWhen(io.reactivex.rxjava3.internal.schedulers.SchedulerWhen) Test(org.junit.Test)

Example 4 with SchedulerWhen

use of io.reactivex.rxjava3.internal.schedulers.SchedulerWhen in project RxJava by ReactiveX.

the class SchedulerWhenTest method disposed.

@Test
public void disposed() {
    SchedulerWhen sw = new SchedulerWhen(new Function<Flowable<Flowable<Completable>>, Completable>() {

        @Override
        public Completable apply(Flowable<Flowable<Completable>> v) throws Exception {
            return Completable.never();
        }
    }, Schedulers.single());
    assertFalse(sw.isDisposed());
    sw.dispose();
    assertTrue(sw.isDisposed());
}
Also used : SchedulerWhen(io.reactivex.rxjava3.internal.schedulers.SchedulerWhen) TestException(io.reactivex.rxjava3.exceptions.TestException) Flowable(io.reactivex.rxjava3.core.Flowable) Test(org.junit.Test)

Example 5 with SchedulerWhen

use of io.reactivex.rxjava3.internal.schedulers.SchedulerWhen in project RxJava by ReactiveX.

the class SchedulerWhenTest method asyncMaxConcurrent.

@Test
public void asyncMaxConcurrent() {
    TestScheduler tSched = new TestScheduler();
    SchedulerWhen sched = maxConcurrentScheduler(tSched);
    TestSubscriber<Long> tSub = TestSubscriber.create();
    asyncWork(sched).subscribe(tSub);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(0, SECONDS);
    tSub.assertValueCount(0);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(2);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(4);
    tSched.advanceTimeBy(1, SECONDS);
    tSub.assertValueCount(5);
    tSub.assertComplete();
    sched.dispose();
}
Also used : SchedulerWhen(io.reactivex.rxjava3.internal.schedulers.SchedulerWhen) Test(org.junit.Test)

Aggregations

SchedulerWhen (io.reactivex.rxjava3.internal.schedulers.SchedulerWhen)5 Test (org.junit.Test)5 Flowable (io.reactivex.rxjava3.core.Flowable)1 TestException (io.reactivex.rxjava3.exceptions.TestException)1