Index: LayoutTests/vibration/cancelVibration-during-pattern-vibrating.html |
diff --git a/LayoutTests/vibration/cancelVibration-during-pattern-vibrating.html b/LayoutTests/vibration/cancelVibration-during-pattern-vibrating.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..15eae223c7a1afecc218389b6606aee1fe6e55a8 |
--- /dev/null |
+++ b/LayoutTests/vibration/cancelVibration-during-pattern-vibrating.html |
@@ -0,0 +1,64 @@ |
+<html> |
+<head> |
+<script src="../fast/js/resources/js-test-pre.js"></script> |
+</head> |
+<body> |
+<script> |
+description('Tests the cancelVibration during pattern vibration is working.'); |
+ |
+function vibrate(pattern) { |
+ navigator.vibrate(pattern); |
+ shouldBeTrue('internals.isVibrating()'); |
+} |
+ |
+function cancelVibration(time) { |
+ setTimeout(function() { |
+ navigator.vibrate(0); |
+ shouldBeFalse('internals.isVibrating()'); |
+ doNextTest(); |
+ }, time); |
+} |
+ |
+function doNextTest() { |
+ if (count == 4) |
+ finishJSTest(); |
+ doTest(++count); |
+} |
+ |
+function doTest(num) { |
+ switch(num) { |
+ case 1: // Test that cancelling works during a vibration in a pattern. |
+ vibrate([20, 20, 20]); |
+ // Progress time by 50ms so we are in the middle of the first vibration of the pattern. |
Michael van Ouwerkerk
2013/07/10 16:10:05
Please update the time in all comments to match th
kihong
2013/07/12 11:04:13
Done.
|
+ cancelVibration(10); |
+ break; |
+ case 2: // Test that cancelling works during a pause in a pattern. |
+ vibrate([10, 10, 10]); |
+ // Progress time by 150ms so we are in the middle of the first pause of the pattern. |
+ cancelVibration(15); |
+ break; |
+ case 3: // Test that the system stops thinking that it is vibrating when the pattern ends. |
+ vibrate([10, 10, 10]); |
+ // Progress time by 350ms so the pattern ends naturally without interruptions. |
+ cancelVibration(35); |
+ break; |
+ case 4: // Test that a trailing pause is stripped so isVibrating becomes false after the last vibration in the pattern. |
+ vibrate([10, 10, 10, 10]); // Even number of array entries, the trailing pause will be stripped. |
+ // Progress time by 350ms so the pattern ends naturally without interruptions. |
+ cancelVibration(35); |
+ break; |
+ } |
+} |
+ |
+var count = 1; |
+if (window.testRunner) { |
+ window.jsTestIsAsync = true; |
+ shouldBeFalse('internals.isVibrating()'); // Before vibration test. |
+ doTest(count); |
+} else { |
+ debug('This test can not be run without the TestRunner'); |
+} |
+</script> |
+<script src="../fast/js/resources/js-test-post.js"></script> |
+</body> |
+</html> |