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

Unified Diff: LayoutTests/vibration/vibration-patterns.html

Issue 40443002: Add Vibration API layout tests that inspect internal state. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Address review comments. 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
Index: LayoutTests/vibration/vibration-patterns.html
diff --git a/LayoutTests/vibration/vibration-patterns.html b/LayoutTests/vibration/vibration-patterns.html
new file mode 100644
index 0000000000000000000000000000000000000000..22b845e28108df9bfeb8cccdbef7fb364a6f152f
--- /dev/null
+++ b/LayoutTests/vibration/vibration-patterns.html
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="vibration-utils.js"></script>
+</head>
+<body>
+<script>
+description('Tests for how patterns are handled in the Vibration API.');
+
+// A trailing pause is discarded from a pattern i.e. patterns of even
+// non-zero length are truncated by 1.
+shouldBeTrue("navigator.vibrate(newPattern(1, 4))");
+shouldBeTrue("areArraysEqual(internals.pendingVibrationPattern(document), newPattern(1, 3))");
+shouldBeTrue("internals.isVibrating(document)");
+stopVibration();
+
+// Maximum pattern length.
+shouldBeTrue("navigator.vibrate(newPattern(1, 99))");
+shouldBeTrue("areArraysEqual(internals.pendingVibrationPattern(document), newPattern(1, 99))");
+shouldBeTrue("internals.isVibrating(document)");
+stopVibration();
+
+// The pattern is longer than supported. It is truncated and execution proceeds.
+shouldBeTrue("navigator.vibrate(newPattern(1, 200))");
+shouldBeTrue("areArraysEqual(internals.pendingVibrationPattern(document), newPattern(1, 99))");
+shouldBeTrue("internals.isVibrating(document)");
+stopVibration();
+
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
« no previous file with comments | « LayoutTests/vibration/vibration-exceptions-expected.txt ('k') | LayoutTests/vibration/vibration-patterns-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698