use of io.reactivex.rxjava3.subjects.PublishSubject in project RxPermissions by tbruyelle.
the class RxPermissionsTest method subscription_trigger_granted.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void subscription_trigger_granted() {
TestObserver<Boolean> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isGranted(permission)).thenReturn(false);
int[] result = new int[] { PackageManager.PERMISSION_GRANTED };
PublishSubject<Object> trigger = PublishSubject.create();
trigger.compose(mRxPermissions.ensure(permission)).subscribe(sub);
trigger.onNext(1);
mRxPermissions.onRequestPermissionsResult(new String[] { permission }, result);
sub.assertNoErrors();
sub.assertValue(true);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableSkipLastTimedTest method skipLastTimedErrorBeforeTimeDelayError.
@Test
public void skipLastTimedErrorBeforeTimeDelayError() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> source = PublishSubject.create();
Observable<Integer> result = source.skipLast(1, TimeUnit.SECONDS, scheduler, true);
Observer<Object> o = TestHelper.mockObserver();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
source.onError(new TestException());
scheduler.advanceTimeBy(1050, TimeUnit.MILLISECONDS);
verify(o).onError(any(TestException.class));
verify(o, never()).onComplete();
verify(o, never()).onNext(any());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableSkipTimedTest method skipTimedErrorAfterTime.
@Test
public void skipTimedErrorAfterTime() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> source = PublishSubject.create();
Observable<Integer> result = source.skip(1, TimeUnit.SECONDS, scheduler);
Observer<Object> o = TestHelper.mockObserver();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
source.onNext(5);
source.onNext(6);
source.onError(new TestException());
InOrder inOrder = inOrder(o);
inOrder.verify(o, never()).onNext(1);
inOrder.verify(o, never()).onNext(2);
inOrder.verify(o, never()).onNext(3);
inOrder.verify(o).onNext(4);
inOrder.verify(o).onNext(5);
inOrder.verify(o).onNext(6);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method disposeNoNeedForResetTimeBound.
@Test
public void disposeNoNeedForResetTimeBound() {
PublishSubject<Integer> ps = PublishSubject.create();
ConnectableObservable<Integer> co = ps.replay(10, TimeUnit.MINUTES, Schedulers.single(), true);
TestObserver<Integer> to = co.test();
Disposable d = co.connect();
ps.onNext(1);
d.dispose();
to = co.test();
to.assertEmpty();
co.connect();
to.assertEmpty();
ps.onNext(2);
to.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method disposeNoNeedForResetSizeBound.
@Test
public void disposeNoNeedForResetSizeBound() {
PublishSubject<Integer> ps = PublishSubject.create();
ConnectableObservable<Integer> co = ps.replay(10, true);
TestObserver<Integer> to = co.test();
Disposable d = co.connect();
ps.onNext(1);
d.dispose();
to = co.test();
to.assertEmpty();
co.connect();
to.assertEmpty();
ps.onNext(2);
to.assertValuesOnly(2);
}
Aggregations