org.robolectric.util.Scheduler Java Examples
The following examples show how to use
org.robolectric.util.Scheduler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseFragmentActivityTest.java From edx-app-android with Apache License 2.0 | 6 votes |
/** * Generic method for asserting view animation method functionality * * @param view The animated view * @param trigger A {@link Runnable} that triggers the animation */ protected void assertAnimateLayouts(View view, Runnable trigger) { // The foreground scheduler needs to be paused so that the // temporary visibility of the animated View can be verified. Scheduler foregroundScheduler = ShadowApplication.getInstance() .getForegroundThreadScheduler(); boolean wasPaused = foregroundScheduler.isPaused(); if (!wasPaused) { foregroundScheduler.pause(); } assertThat(view).isGone(); trigger.run(); assertThat(view).isVisible(); Animation animation = view.getAnimation(); assertNotNull(animation); assertThat(animation.getStartTime()) .isLessThanOrEqualTo(AnimationUtils.currentAnimationTimeMillis()); assertThat(animation).hasStartOffset(0); foregroundScheduler.unPause(); assertThat(view).isGone(); if (wasPaused) { foregroundScheduler.pause(); } }
Example #2
Source File: TestUtil.java From BlueSTSDK_Android with BSD 3-Clause "New" or "Revised" License | 5 votes |
static public void execAllAsyncTask(){ Scheduler bgTask = Robolectric.getBackgroundThreadScheduler(); Scheduler fgTask = Robolectric.getForegroundThreadScheduler(); while (fgTask.size()!=0 || bgTask.size()!=0){ Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } }