use of io.reactivex.rxjava3.android.testutil.EmptyScheduler in project RxAndroid by ReactiveX.
the class RxAndroidPluginsTest method resetClearsMainThreadHandler.
@Test
public void resetClearsMainThreadHandler() {
RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) {
throw new AssertionError();
}
});
RxAndroidPlugins.reset();
Scheduler scheduler = new EmptyScheduler();
Scheduler actual = RxAndroidPlugins.onMainThreadScheduler(scheduler);
assertSame(scheduler, actual);
}
use of io.reactivex.rxjava3.android.testutil.EmptyScheduler in project RxAndroid by ReactiveX.
the class RxAndroidPluginsTest method initMainThreadHandlerCalled.
@Test
public void initMainThreadHandlerCalled() {
final AtomicReference<Callable<Scheduler>> schedulerRef = new AtomicReference<>();
final Scheduler newScheduler = new EmptyScheduler();
RxAndroidPlugins.setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(Callable<Scheduler> scheduler) {
schedulerRef.set(scheduler);
return newScheduler;
}
});
Callable<Scheduler> scheduler = new Callable<Scheduler>() {
@Override
public Scheduler call() throws Exception {
throw new AssertionError();
}
};
Scheduler actual = RxAndroidPlugins.initMainThreadScheduler(scheduler);
assertSame(newScheduler, actual);
assertSame(scheduler, schedulerRef.get());
}
use of io.reactivex.rxjava3.android.testutil.EmptyScheduler in project RxAndroid by ReactiveX.
the class RxAndroidPluginsTest method resetClearsInitMainThreadHandler.
@Test
public void resetClearsInitMainThreadHandler() throws Exception {
RxAndroidPlugins.setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {
@Override
public Scheduler apply(Callable<Scheduler> scheduler) {
throw new AssertionError();
}
});
final Scheduler scheduler = new EmptyScheduler();
Callable<Scheduler> schedulerCallable = new Callable<Scheduler>() {
@Override
public Scheduler call() throws Exception {
return scheduler;
}
};
RxAndroidPlugins.reset();
Scheduler actual = RxAndroidPlugins.initMainThreadScheduler(schedulerCallable);
assertSame(schedulerCallable.call(), actual);
}
use of io.reactivex.rxjava3.android.testutil.EmptyScheduler in project RxAndroid by ReactiveX.
the class AndroidSchedulersTest method mainThreadCallsThroughToHook.
@Test
public void mainThreadCallsThroughToHook() {
final AtomicInteger called = new AtomicInteger();
final Scheduler newScheduler = new EmptyScheduler();
RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) {
called.getAndIncrement();
return newScheduler;
}
});
assertSame(newScheduler, AndroidSchedulers.mainThread());
assertEquals(1, called.get());
assertSame(newScheduler, AndroidSchedulers.mainThread());
assertEquals(2, called.get());
}
use of io.reactivex.rxjava3.android.testutil.EmptyScheduler in project RxAndroid by ReactiveX.
the class RxAndroidPluginsTest method mainThreadHandlerCalled.
@Test
public void mainThreadHandlerCalled() {
final AtomicReference<Scheduler> schedulerRef = new AtomicReference<>();
final Scheduler newScheduler = new EmptyScheduler();
RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {
@Override
public Scheduler apply(Scheduler scheduler) {
schedulerRef.set(scheduler);
return newScheduler;
}
});
Scheduler scheduler = new EmptyScheduler();
Scheduler actual = RxAndroidPlugins.onMainThreadScheduler(scheduler);
assertSame(newScheduler, actual);
assertSame(scheduler, schedulerRef.get());
}
Aggregations