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();
}
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();
}
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();
}
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());
}
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();
}
Aggregations