1 package org.robolectric.shadows; 2 3 import android.os.CountDownTimer; 4 import org.robolectric.annotation.Implementation; 5 import org.robolectric.annotation.Implements; 6 import org.robolectric.annotation.RealObject; 7 8 @Implements(CountDownTimer.class) 9 public class ShadowCountDownTimer { 10 private boolean started; 11 private long countDownInterval; 12 private long millisInFuture; 13 14 @RealObject CountDownTimer countDownTimer; 15 16 @Implementation 17 public void __constructor__(long millisInFuture, long countDownInterval) { 18 this.countDownInterval = countDownInterval; 19 this.millisInFuture = millisInFuture; 20 this.started = false; 21 } 22 23 @Implementation 24 public final synchronized CountDownTimer start() { 25 started = true; 26 return countDownTimer; 27 } 28 29 @Implementation 30 public final void cancel() { 31 started = false; 32 } 33 34 public void invokeTick(long millisUntilFinished) { 35 countDownTimer.onTick(millisUntilFinished); 36 } 37 38 public void invokeFinish() { 39 countDownTimer.onFinish(); 40 } 41 42 public boolean hasStarted() { 43 return started; 44 } 45 46 public long getCountDownInterval() { 47 return countDownInterval; 48 } 49 50 public long getMillisInFuture() { 51 return millisInFuture; 52 } 53 } 54