Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html

Issue 18478003: Vibration cannot be canceled during pattern vibration. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for Relanding Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/vibration/cancel-vibration-during-pattern-vibrating-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html
diff --git a/LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html b/LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html
new file mode 100644
index 0000000000000000000000000000000000000000..13e23b903a70efb5baf3e63096161fe9c38eec0d
--- /dev/null
+++ b/LayoutTests/vibration/cancel-vibration-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(document)');
+}
+
+function cancelVibration(time) {
+ setTimeout(function() {
+ navigator.vibrate(0);
+ shouldBeFalse('internals.isVibrating(document)');
+ 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 10ms so we are in the middle of the first vibration of the pattern.
+ cancelVibration(10);
+ break;
+ case 2: // Test that cancelling works during a pause in a pattern.
+ vibrate([10, 10, 10]);
+ // Progress time by 15ms 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 35ms 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 35ms so the pattern ends naturally without interruptions.
+ cancelVibration(35);
+ break;
+ }
+}
+
+var count = 1;
+if (window.testRunner) {
+ window.jsTestIsAsync = true;
+ shouldBeFalse('internals.isVibrating(document)'); // 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>
« no previous file with comments | « no previous file | LayoutTests/vibration/cancel-vibration-during-pattern-vibrating-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698