use of io.reactivex.rxjava3.core.Scheduler 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.core.Scheduler 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.core.Scheduler 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.core.Scheduler in project RxAndroid by ReactiveX.
the class AndroidSchedulersTest method asyncIgnoredPre16.
@Test
public void asyncIgnoredPre16() {
ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 14);
ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());
mainLooper.pause();
ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());
Scheduler main = AndroidSchedulers.from(Looper.getMainLooper(), true);
main.scheduleDirect(new Runnable() {
@Override
public void run() {
}
});
Message message = mainMessageQueue.getHead();
assertFalse(message.isAsynchronous());
}
use of io.reactivex.rxjava3.core.Scheduler in project RxAndroid by ReactiveX.
the class AndroidSchedulersTest method fromAsyncMessagesByDefault.
@Test
public void fromAsyncMessagesByDefault() {
ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());
mainLooper.pause();
ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());
Scheduler main = AndroidSchedulers.from(Looper.getMainLooper());
main.scheduleDirect(new Runnable() {
@Override
public void run() {
}
});
Message message = mainMessageQueue.getHead();
assertTrue(message.isAsynchronous());
}
Aggregations