org.robolectric.util.Scheduler.isPaused()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.robolectric.util.Scheduler.isPaused()方法的一些代码示例,展示了Scheduler.isPaused()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.isPaused()方法的具体详情如下:
包路径:org.robolectric.util.Scheduler
类名称:Scheduler
方法名:isPaused

Scheduler.isPaused介绍

[英]Determine if the scheduler is paused.
[中]确定计划程序是否已暂停。

代码示例

代码示例来源:origin: robolectric/robolectric

@Override
 public void run() {
  scheduler.isPaused();
 }
};

代码示例来源:origin: robolectric/robolectric

public boolean isPaused() {
 return getScheduler().isPaused();
}

代码示例来源:origin: robolectric/robolectric

/**
 * Add a runnable to the queue to be run after a delay.
 */
public synchronized void postDelayed(Runnable runnable, long delay, TimeUnit unit) {
 long delayMillis = unit.toMillis(delay);
 if ((idleState != CONSTANT_IDLE && (isPaused() || delayMillis > 0)) || Thread.currentThread() != associatedThread) {
  runnables.add(new ScheduledRunnable(runnable, currentTime + delayMillis));
 } else {
  runOrQueueRunnable(runnable, currentTime + delayMillis);
 }
}

代码示例来源:origin: robolectric/robolectric

/**
 * Add a runnable to the head of the queue.
 *
 * @param runnable  Runnable to add.
 */
public synchronized void postAtFrontOfQueue(Runnable runnable) {
 if (isPaused() || Thread.currentThread() != associatedThread) {
  final long timeDisambiguator;
  if (runnables.isEmpty()) {
   timeDisambiguator = nextTimeDisambiguator++;
  } else {
   timeDisambiguator = runnables.peek().timeDisambiguator - 1;
  }
  runnables.add(new ScheduledRunnable(runnable, 0, timeDisambiguator));
 } else {
  runOrQueueRunnable(runnable, currentTime);
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void whenIdleStateIsPaused_isPausedReturnsTrue() {
 scheduler.setIdleState(PAUSED);
 assertThat(scheduler.isPaused()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void whenIdleStateIsConstantIdle_isPausedReturnsFalse() {
 scheduler.setIdleState(CONSTANT_IDLE);
 assertThat(scheduler.isPaused()).isFalse();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void whenIdleStateIsUnPaused_isPausedReturnsFalse() {
 scheduler.setIdleState(UNPAUSED);
 assertThat(scheduler.isPaused()).isFalse();
}

代码示例来源: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

@Override
 public void test(MethodSpec method) {
  final State state = shadowMediaPlayer.getState();
  final boolean wasPaused = scheduler.isPaused();
  scheduler.pause();
  try {
   method.invoke();
  } catch (InvocationTargetException e) {
   throw new RuntimeException("Expected <" + method
     + "> to call onError rather than throw <" + e.getTargetException()
     + "> when called from <" + state + ">", e);
  }
  Mockito.verifyZeroInteractions(errorListener);
  final State finalState = shadowMediaPlayer.getState();
  assertThat(finalState).isSameAs(ERROR);
  scheduler.unPause();
  Mockito.verify(errorListener).onError(mediaPlayer, what, extra);
  Mockito.reset(errorListener);
  if (wasPaused) {
   scheduler.pause();
  }
 }
}

代码示例来源:origin: org.robolectric/shadows-core

public boolean isPaused() {
 return getScheduler().isPaused();
}

代码示例来源:origin: org.robolectric/shadows-framework

public boolean isPaused() {
 return getScheduler().isPaused();
}

代码示例来源:origin: org.robolectric/shadows-core-v23

public boolean isPaused() {
 return getScheduler().isPaused();
}

代码示例来源:origin: org.robolectric/framework

public boolean isPaused() {
 return getScheduler().isPaused();
}

代码示例来源:origin: org.robolectric/utils

/**
 * Add a runnable to the queue to be run after a delay.
 */
public synchronized void postDelayed(Runnable runnable, long delay, TimeUnit unit) {
 long delayMillis = unit.toMillis(delay);
 if ((idleState != CONSTANT_IDLE && (isPaused() || delayMillis > 0)) || Thread.currentThread() != associatedThread) {
  runnables.add(new ScheduledRunnable(runnable, currentTime + delayMillis));
 } else {
  runOrQueueRunnable(runnable, currentTime + delayMillis);
 }
}

代码示例来源:origin: org.robolectric/robolectric-utils

/**
 * Add a runnable to the queue to be run after a delay.
 */
public synchronized void postDelayed(Runnable runnable, long delay, TimeUnit unit) {
 long delayMillis = unit.toMillis(delay);
 if ((idleState != CONSTANT_IDLE && (isPaused() || delayMillis > 0)) || Thread.currentThread() != associatedThread) {
  queueRunnableAndSort(runnable, currentTime + delayMillis);
 } else {
  runOrQueueRunnable(runnable, currentTime + delayMillis);
 }
}

代码示例来源:origin: org.robolectric/robolectric-utils

/**
 * Add a runnable to the head of the queue.
 *
 * @param runnable  Runnable to add.
 */
public synchronized void postAtFrontOfQueue(Runnable runnable) {
 if (isPaused() || Thread.currentThread() != associatedThread) {
  runnables.add(0, new ScheduledRunnable(runnable, currentTime));
 } else {
  runOrQueueRunnable(runnable, currentTime);
 }
}

代码示例来源:origin: org.robolectric/utils

/**
 * Add a runnable to the head of the queue.
 *
 * @param runnable  Runnable to add.
 */
public synchronized void postAtFrontOfQueue(Runnable runnable) {
 if (isPaused() || Thread.currentThread() != associatedThread) {
  final long timeDisambiguator;
  if (runnables.isEmpty()) {
   timeDisambiguator = nextTimeDisambiguator++;
  } else {
   timeDisambiguator = runnables.peek().timeDisambiguator - 1;
  }
  runnables.add(new ScheduledRunnable(runnable, 0, timeDisambiguator));
 } else {
  runOrQueueRunnable(runnable, currentTime);
 }
}

相关文章