### Question:
MainThreadDisposable implements Disposable { public static void verifyMainThread() { if (Looper.myLooper() != Looper.getMainLooper()) { throw new IllegalStateException( "Expected to be called on the main thread but was " + Thread.currentThread().getName()); } }  static void verifyMainThread(); @Override final boolean isDisposed(); @Override final void dispose();  }### Answer:
@Test public void verifyDoesNotThrowOnMainThread() throws InterruptedException { MainThreadDisposable.verifyMainThread(); }
@Test public void verifyThrowsOffMainThread() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); new Thread(new Runnable() { @Override public void run() { try { MainThreadDisposable.verifyMainThread(); fail(); } catch (IllegalStateException e) { assertTrue(e.getMessage().startsWith("Expected to be called on the main thread")); latch.countDown(); } } }).start(); assertTrue(latch.await(1, SECONDS)); }