OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../fast/js/resources/js-test-pre.js"></script> |
| 4 </head> |
| 5 <body> |
| 6 <script> |
| 7 description('Tests the cancelVibration during pattern vibration is working.'); |
| 8 |
| 9 function vibrate(pattern) { |
| 10 navigator.vibrate(pattern); |
| 11 shouldBeTrue('internals.isVibrating(document)'); |
| 12 } |
| 13 |
| 14 function cancelVibration(time) { |
| 15 setTimeout(function() { |
| 16 navigator.vibrate(0); |
| 17 shouldBeFalse('internals.isVibrating(document)'); |
| 18 doNextTest(); |
| 19 }, time); |
| 20 } |
| 21 |
| 22 function doNextTest() { |
| 23 if (count == 4) |
| 24 finishJSTest(); |
| 25 doTest(++count); |
| 26 } |
| 27 |
| 28 function doTest(num) { |
| 29 switch(num) { |
| 30 case 1: // Test that cancelling works during a vibration in a pattern. |
| 31 vibrate([20, 20, 20]); |
| 32 // Progress time by 10ms so we are in the middle of the first vibration
of the pattern. |
| 33 cancelVibration(10); |
| 34 break; |
| 35 case 2: // Test that cancelling works during a pause in a pattern. |
| 36 vibrate([10, 10, 10]); |
| 37 // Progress time by 15ms so we are in the middle of the first pause of t
he pattern. |
| 38 cancelVibration(15); |
| 39 break; |
| 40 case 3: // Test that the system stops thinking that it is vibrating when the
pattern ends. |
| 41 vibrate([10, 10, 10]); |
| 42 // Progress time by 35ms so the pattern ends naturally without interrupt
ions. |
| 43 cancelVibration(35); |
| 44 break; |
| 45 case 4: // Test that a trailing pause is stripped so isVibrating becomes fal
se after the last vibration in the pattern. |
| 46 vibrate([10, 10, 10, 10]); // Even number of array entries, the trailing
pause will be stripped. |
| 47 // Progress time by 35ms so the pattern ends naturally without interrupt
ions. |
| 48 cancelVibration(35); |
| 49 break; |
| 50 } |
| 51 } |
| 52 |
| 53 var count = 1; |
| 54 if (window.testRunner) { |
| 55 window.jsTestIsAsync = true; |
| 56 shouldBeFalse('internals.isVibrating(document)'); // Before vibration test. |
| 57 doTest(count); |
| 58 } else { |
| 59 debug('This test can not be run without the TestRunner'); |
| 60 } |
| 61 </script> |
| 62 <script src="../fast/js/resources/js-test-post.js"></script> |
| 63 </body> |
| 64 </html> |
OLD | NEW |