### Question:
AndroidSchedulers { public static Scheduler from(Looper looper) { return from(looper, true); } private  AndroidSchedulers(); static Scheduler mainThread(); static Scheduler from(Looper looper); @SuppressLint("NewApi") // Checking for an @hide API. static Scheduler from(Looper looper, boolean async);  }### Answer:
@Test public void fromNullThrows() { try { AndroidSchedulers.from(null); fail(); } catch (NullPointerException e) { assertEquals("looper == null", e.getMessage()); } }
@Test public void fromNullThrowsTwoArg() { try { AndroidSchedulers.from(null, false); fail(); } catch (NullPointerException e) { assertEquals("looper == null", e.getMessage()); } }
@Test public void fromReturnsUsableScheduler() { assertNotNull(AndroidSchedulers.from(Looper.getMainLooper())); }
@Test public void fromAsyncMessagesByDefault() { ShadowLooper mainLooper = ShadowLooper.getShadowMainLooper(); 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()); }
@Test public void asyncIgnoredPre16() { ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 14); ShadowLooper mainLooper = ShadowLooper.getShadowMainLooper(); 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()); }