本文整理了Java中org.robolectric.util.Scheduler.pause()
方法的一些代码示例,展示了Scheduler.pause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.pause()
方法的具体详情如下:
包路径:org.robolectric.util.Scheduler
类名称:Scheduler
方法名:pause
[英]Pause the scheduler. Equivalent to setIdleState(PAUSED).
[中]暂停调度程序。相当于setIdleEstate(暂停)。
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
backgroundScheduler.pause();
runnable = new Runnable() {
@Override
public void run() {
transcript.add("background event ran");
}
};
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
transcript = new ArrayList<>();
Robolectric.getBackgroundThreadScheduler().pause();
Robolectric.getForegroundThreadScheduler().pause();
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() {
Robolectric.getForegroundThreadScheduler().pause();
Robolectric.getBackgroundThreadScheduler().pause();
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() {
Robolectric.getForegroundThreadScheduler().pause();
Robolectric.getBackgroundThreadScheduler().pause();
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
scheduler.pause();
startTime = scheduler.getCurrentTime();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void test_WhenInfiniteAnimationIsPlayed_AnimationIsOnlyPlayedOnce() throws InterruptedException {
ShadowChoreographer.setFrameInterval(100 * TimeUtils.NANOS_PER_MS);
final ValueAnimator animator = ValueAnimator.ofInt(0, 10);
animator.setDuration(200);
animator.setRepeatCount(ValueAnimator.INFINITE);
Robolectric.getForegroundThreadScheduler().pause();
animator.start();
assertThat(animator.isRunning()).isTrue();
Robolectric.flushForegroundThreadScheduler();
assertThat(animator.isRunning()).isFalse();
}
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = N, maxSdk = N_MR1) // Functionality removed in O
public void whenPaused_getPackageSizeInfo_callsBackWithConfiguredValuesAfterIdle()
throws Exception {
Robolectric.getForegroundThreadScheduler().pause();
IPackageStatsObserver packageStatsObserver = mock(IPackageStatsObserver.class);
packageManager.getPackageSizeInfo("org.robolectric", packageStatsObserver);
verifyZeroInteractions(packageStatsObserver);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
verify(packageStatsObserver).onGetStatsCompleted(packageStatsCaptor.capture(), eq(true));
assertThat(packageStatsCaptor.getValue().packageName).isEqualTo("org.robolectric");
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = N, maxSdk = N_MR1) // Functionality removed in O
public void whenPackageNotPresentAndPaused_getPackageSizeInfo_callsBackWithFailure()
throws Exception {
Robolectric.getForegroundThreadScheduler().pause();
IPackageStatsObserver packageStatsObserver = mock(IPackageStatsObserver.class);
packageManager.getPackageSizeInfo("nonexistant.package", packageStatsObserver);
verifyZeroInteractions(packageStatsObserver);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
verify(packageStatsObserver).onGetStatsCompleted(packageStatsCaptor.capture(), eq(false));
assertThat(packageStatsCaptor.getValue()).isNull();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void canceled() {
Animator animator = ViewAnimationUtils.createCircularReveal(view, 10, 10, 10f, 100f);
animator.addListener(listener);
Robolectric.getForegroundThreadScheduler().pause();
animator.start();
animator.cancel();
assertThat(listener.startCount).isEqualTo(1);
assertThat(listener.cancelCount).isEqualTo(1);
assertThat(listener.endCount).isEqualTo(1);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void pause_setsIdleState() {
scheduler.setIdleState(UNPAUSED);
scheduler.pause();
assertThat(scheduler.getIdleState()).isSameAs(PAUSED);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void doubleCanceled() {
Animator animator = ViewAnimationUtils.createCircularReveal(view, 10, 10, 10f, 100f);
animator.addListener(listener);
Robolectric.getForegroundThreadScheduler().pause();
animator.start();
animator.cancel();
animator.cancel();
assertThat(listener.startCount).isEqualTo(1);
assertThat(listener.cancelCount).isEqualTo(1);
assertThat(listener.endCount).isEqualTo(1);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void doubleEnded() {
Animator animator = ViewAnimationUtils.createCircularReveal(view, 10, 10, 10f, 100f);
animator.addListener(listener);
Robolectric.getForegroundThreadScheduler().pause();
animator.start();
animator.end();
animator.end();
assertThat(listener.startCount).isEqualTo(1);
assertThat(listener.endCount).isEqualTo(1);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldResetBackgroundSchedulerBeforeTests() throws Exception {
assertThat(Robolectric.getBackgroundThreadScheduler().isPaused()).isFalse();
Robolectric.getBackgroundThreadScheduler().pause();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldResetBackgroundSchedulerAfterTests() throws Exception {
assertThat(Robolectric.getBackgroundThreadScheduler().isPaused()).isFalse();
Robolectric.getBackgroundThreadScheduler().pause();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void reset_shouldUnPause() throws Exception {
scheduler.pause();
TestRunnable runnable = new TestRunnable();
scheduler.post(runnable);
assertThat(runnable.wasRun).isFalse();
scheduler.reset();
scheduler.post(runnable);
assertThat(runnable.wasRun).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void reset_shouldClearPendingRunnables() throws Exception {
scheduler.pause();
TestRunnable runnable1 = new TestRunnable();
scheduler.post(runnable1);
assertThat(runnable1.wasRun).isFalse();
scheduler.reset();
TestRunnable runnable2 = new TestRunnable();
scheduler.post(runnable2);
assertThat(runnable1.wasRun).isFalse();
assertThat(runnable2.wasRun).isTrue();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void removeGroup_failure() {
TestActionListener testListener = new TestActionListener();
RuntimeEnvironment.getMasterScheduler().pause();
manager.removeGroup(channel, testListener);
shadowManager.setNextActionFailure(WifiP2pManager.BUSY);
RuntimeEnvironment.getMasterScheduler().unPause();
assertThat(testListener.success).isFalse();
assertThat(testListener.reason).isEqualTo(WifiP2pManager.BUSY);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void createGroup_fail() {
TestActionListener testListener = new TestActionListener();
RuntimeEnvironment.getMasterScheduler().pause();
manager.createGroup(channel, testListener);
shadowManager.setNextActionFailure(WifiP2pManager.BUSY);
RuntimeEnvironment.getMasterScheduler().unPause();
assertThat(testListener.success).isFalse();
assertThat(testListener.reason).isEqualTo(WifiP2pManager.BUSY);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldInvokeFilter() throws Exception {
Robolectric.getForegroundThreadScheduler().pause();
AutoCompleteTextView view =
new AutoCompleteTextView(ApplicationProvider.getApplicationContext());
view.setAdapter(adapter);
view.setText("Foo");
assertThat(adapter.getCount()).isEqualTo(2);
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
// Queues and loopers are closely linked; can't easily test one without the other.
looper = newLooper();
handler = new TestHandler(looper);
queue = looper.getQueue();
shadowQueue = shadowOf(queue);
scheduler = shadowQueue.getScheduler();
scheduler.pause();
testMessage = handler.obtainMessage();
quitField = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? "mQuitting" : "mQuiting";
}
内容来源于网络,如有侵权,请联系作者删除!