@Test public void shouldPostActionsToTheMessageQueueWithDelay() throws Exception { Robolectric.pauseMainLooper(); TestRunnable runnable = new TestRunnable(); view.postDelayed(runnable, 1); assertFalse(runnable.wasRun); Robolectric.getUiThreadScheduler().advanceBy(1); assertTrue(runnable.wasRun); }
@Implementation public void postInvalidateDelayed(long delayMilliseconds) { Robolectric.getUiThreadScheduler() .postDelayed( new Runnable() { @Override public void run() { realView.invalidate(); } }, delayMilliseconds); }
@Implementation public void postDelayed(Runnable action, long delayMills) { Robolectric.getUiThreadScheduler().postDelayed(action, delayMills); }
@Implementation public void post(Runnable action) { Robolectric.getUiThreadScheduler().post(action); }