Permalink
Browse files

Added isVibrating()

  • Loading branch information...
1 parent 331338e commit aa1062defbe38956a7ff51abf077ab93b0911f0a Logdog82 committed Apr 12, 2012
@@ -7,25 +7,33 @@
@Implements(Vibrator.class)
public class ShadowVibrator {
+ private boolean vibrating;
private boolean cancelled;
private long milliseconds;
private long[] pattern;
private int repeat;
@Implementation
public void vibrate(long milliseconds) {
+ vibrating = true;
this.milliseconds = milliseconds;
}
@Implementation
public void vibrate(long[] pattern, int repeat) {
+ vibrating = true;
this.pattern = pattern;
this.repeat = repeat;
}
@Implementation
public void cancel() {
cancelled = true;
+ vibrating = false;
+ }
+
+ public boolean isVibrating() {
+ return vibrating;
}
public boolean isCancelled() {
@@ -30,6 +30,7 @@ public void before() {
public void vibrateMilliseconds() {
vibrator.vibrate(5000);
+ assertThat(shadowVibrator.isVibrating(), is(true));
assertThat(shadowVibrator.getMilliseconds(), equalTo(5000L));
}
@@ -38,14 +39,19 @@ public void vibratePattern() {
long[] pattern = new long[] { 0, 200 };
vibrator.vibrate(pattern, 2);
+ assertThat(shadowVibrator.isVibrating(), is(true));
assertThat(shadowVibrator.getPattern(), equalTo(pattern));
assertThat(shadowVibrator.getRepeat(), equalTo(2));
}
@Test
public void cancelled() {
+ vibrator.vibrate(5000);
+ assertThat(shadowVibrator.isVibrating(), is(true));
assertThat(shadowVibrator.isCancelled(), is(false));
vibrator.cancel();
+
+ assertThat(shadowVibrator.isVibrating(), is(false));
assertThat(shadowVibrator.isCancelled(), is(true));
}
}

0 comments on commit aa1062d

Please sign in to comment.