当前位置: 首页>>代码示例>>Java>>正文


Java Scheduler.pause方法代码示例

本文整理汇总了Java中org.robolectric.util.Scheduler.pause方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.pause方法的具体用法?Java Scheduler.pause怎么用?Java Scheduler.pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.util.Scheduler的用法示例。


在下文中一共展示了Scheduler.pause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cancelBeforeNextLooperCycle

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void cancelBeforeNextLooperCycle() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    final AnimatorContext testContext = spy(new AnimatorContext("Test"));

    final MultiAnimator animator = MultiAnimator.animatorFor(fakeView, testContext);
    animator.translationY(0f);
    animator.start();

    verify(testContext).beginAnimation(any(String.class));

    animator.cancel();

    verify(testContext).endAnimation(any(String.class));
}
 
开发者ID:hello,项目名称:anime-android-go-99,代码行数:18,代码来源:MultiAnimatorTests.java

示例2: end

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void end() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    final AnimatorContext testContext = spy(new AnimatorContext("Test"));

    final MultiAnimator animator = MultiAnimator.animatorFor(fakeView, testContext);
    animator.translationY(100f);

    final Animator.AnimatorListener listener = mock(Animator.AnimatorListener.class);
    animator.addListener(listener);

    animator.start();

    verify(testContext).beginAnimation(any(String.class));

    animator.end();

    verify(testContext).endAnimation(any(String.class));
    verify(listener, never()).onAnimationCancel(animator);
    verify(listener).onAnimationEnd(animator);

    assertThat(fakeView.getTranslationY(), is(equalTo(100f)));
    assertThat(animator.isRunning(), is(false));
}
 
开发者ID:hello,项目名称:anime-android-go-99,代码行数:27,代码来源:MultiAnimatorTests.java

示例3: serialization

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void serialization() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    powerUpTimer.schedulePowerUp(PowerUp.SLOW_DOWN_TIME, CountUp.NUMBER_TICKS);
    assertThat(powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(true));

    final Bundle savedState = new Bundle();
    powerUpTimer.saveState(savedState);

    final PowerUpTimer restored = new PowerUpTimer(bus);
    restored.restoreState(savedState);

    assertThat(restored.isPending(PowerUp.SLOW_DOWN_TIME), is(true));
    assertThat(restored.isPending(PowerUp.MULTIPLY_SCORE), is(false));
    assertThat(restored.isPending(PowerUp.CLEAR_ALL), is(false));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:19,代码来源:PowerUpTimerTests.java

示例4: multiplyScore

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void multiplyScore() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    game.newGame();

    assertThat(game.multiplyScore(), is(false));
    game.board.addPowerUp(PowerUp.MULTIPLY_SCORE);

    assertThat(game.multiplyScore(), is(true));
    assertThat(game.multiplyScore(), is(false));
    assertThat(game.powerUpTimer.isPending(PowerUp.MULTIPLY_SCORE), is(true));
    assertThat(game.score.getMultiplier(), is(equalTo(2f)));

    scheduler.advanceBy(PowerUpTimer.TICK_DURATION_MS * PowerUpTimer.STANDARD_NUMBER_TICKS);

    assertThat(game.powerUpTimer.isPending(PowerUp.MULTIPLY_SCORE), is(false));
    assertThat(game.score.getMultiplier(), is(equalTo(1f)));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:21,代码来源:GameTests.java

示例5: slowDownTime

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void slowDownTime() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    game.newGame();

    assertThat(game.slowDownTime(), is(false));
    game.board.addPowerUp(PowerUp.SLOW_DOWN_TIME);

    assertThat(game.slowDownTime(), is(true));
    assertThat(game.slowDownTime(), is(false));
    assertThat(game.powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(true));
    assertThat(game.countUp.getTickDurationMs(), is(equalTo(2000L)));

    scheduler.advanceBy(PowerUpTimer.TICK_DURATION_MS * PowerUpTimer.STANDARD_NUMBER_TICKS);

    assertThat(game.powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(false));
    assertThat(game.countUp.getTickDurationMs(), is(not(equalTo(2000L))));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:21,代码来源:GameTests.java

示例6: basicCountDown

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void basicCountDown() {
    final CountUp countUp = new CountUp(bus);

    assertThat(countUp.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    countUp.start();

    scheduler.advanceBy(CountUp.DEFAULT_TICK_DURATION_MS * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    scheduler.advanceBy(CountUp.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:19,代码来源:CountUpTests.java

示例7: pause

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void pause() {
    final CountUp countUp = new CountUp(bus);

    assertThat(countUp.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    countUp.start();

    scheduler.advanceBy(CountUp.DEFAULT_TICK_DURATION_MS * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    countUp.pause();
    assertThat(countUp.isRunning(), is(true));

    scheduler.advanceBy(CountUp.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    countUp.resume();
    scheduler.advanceBy(CountUp.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:27,代码来源:CountUpTests.java

示例8: basicCountUp

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void basicCountUp() {
    assertThat(timer.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    timer.start();

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:17,代码来源:TimerTests.java

示例9: pause

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void pause() {
    assertThat(timer.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    timer.start();

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    timer.pause();
    assertThat(timer.isRunning(), is(true));

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    timer.resume();
    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 6);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:25,代码来源:TimerTests.java

示例10: setTickDuration

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void setTickDuration() {
    assertThat(timer.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    timer.setTickDurationMs(200L);
    timer.start();

    scheduler.advanceBy(200L * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    scheduler.advanceBy(400L * 6);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:18,代码来源:TimerTests.java

示例11: setNumberOfTicks

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void setNumberOfTicks() {
    assertThat(timer.isRunning(), is(false));

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();
    timer.setNumberOfTicks(12);
    timer.start();

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 4);
    assertThat(counter, is(equalTo(5)));
    assertThat(completed, is(false));

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 5);
    assertThat(counter, is(equalTo(10)));
    assertThat(completed, is(false));

    scheduler.advanceBy(Timer.DEFAULT_TICK_DURATION_MS * 3);
    assertThat(counter, is(equalTo(12)));
    assertThat(completed, is(true));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:22,代码来源:TimerTests.java

示例12: assertAnimateLayouts

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:30,代码来源:BaseFragmentActivityTest.java

示例13: idleTasks

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void idleTasks() throws Exception {
    final AtomicBoolean taskWasRun = new AtomicBoolean(false);
    final Runnable task = new Runnable() {
        @Override
        public void run() {
            taskWasRun.set(true);
        }
    };

    animatorContext.runWhenIdle(task);
    assertThat(taskWasRun.get(), is(true));

    taskWasRun.set(false);

    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();

    animatorContext.beginAnimation("Test animation");
    animatorContext.runWhenIdle(task);
    assertThat(taskWasRun.get(), is(false));

    // Otherwise the animator context's Handler will
    // execute anything sent to it immediately.
    scheduler.pause();
    animatorContext.endAnimation("Test animation");
    assertThat(taskWasRun.get(), is(false));

    animatorContext.beginAnimation("Test animation");
    assertThat(taskWasRun.get(), is(false));

    animatorContext.endAnimation("Test animation");
    scheduler.advanceToLastPostedRunnable();
    assertThat(taskWasRun.get(), is(true));
}
 
开发者ID:hello,项目名称:anime-android-go-99,代码行数:35,代码来源:AnimatorContextTests.java

示例14: schedule

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void schedule() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    powerUpTimer.schedulePowerUp(PowerUp.SLOW_DOWN_TIME,
                                 PowerUpTimer.STANDARD_NUMBER_TICKS);
    assertThat(powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(true));

    scheduler.advanceBy(PowerUpTimer.TICK_DURATION_MS * PowerUpTimer.STANDARD_NUMBER_TICKS + 100L);
    assertThat(events.size(), is(equalTo(2)));
    assertThat(events, hasItem(new PowerUpTimer.PowerUpScheduled(PowerUp.SLOW_DOWN_TIME)));
    assertThat(events, hasItem(new PowerUpTimer.PowerUpExpired(PowerUp.SLOW_DOWN_TIME)));
    assertThat(powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(false));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:16,代码来源:PowerUpTimerTests.java

示例15: stop

import org.robolectric.util.Scheduler; //导入方法依赖的package包/类
@Test
public void stop() {
    final Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
    scheduler.pause();

    powerUpTimer.schedulePowerUp(PowerUp.SLOW_DOWN_TIME,
                                 PowerUpTimer.STANDARD_NUMBER_TICKS);
    assertThat(powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(true));
    powerUpTimer.stop();

    scheduler.advanceBy(PowerUpTimer.TICK_DURATION_MS * PowerUpTimer.STANDARD_NUMBER_TICKS + 100L);
    assertThat(events.size(), is(equalTo(1)));
    assertThat(powerUpTimer.isPending(PowerUp.SLOW_DOWN_TIME), is(false));
}
 
开发者ID:decarbonization,项目名称:android-fonz,代码行数:15,代码来源:PowerUpTimerTests.java


注:本文中的org.robolectric.util.Scheduler.pause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。