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

Unified Diff: LayoutTests/gamepad/gamepad-api.html

Issue 212813008: Gamepad API: tests for gamepad events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: check prototypes Created 6 years, 9 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/gamepad/gamepad-api-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/gamepad/gamepad-api.html
diff --git a/LayoutTests/gamepad/gamepad-api.html b/LayoutTests/gamepad/gamepad-api.html
index cac387458fd9b2b3557679591b14e090ed6d366a..30a082d381ad97829aea12db104aa9820a1215a9 100644
--- a/LayoutTests/gamepad/gamepad-api.html
+++ b/LayoutTests/gamepad/gamepad-api.html
@@ -2,8 +2,66 @@
<body>
<script src="../resources/js-test.js"></script>
<script>
+ description("Validates the exposed Gamepad API.")
+
shouldBeDefined("navigator.webkitGetGamepads");
shouldBeDefined("navigator.getGamepads");
+ shouldBeDefined("GamepadEvent");
+
+ webkitGamepads = navigator.webkitGetGamepads();
+ shouldBe("webkitGamepads.length", "4");
+ shouldBeUndefined("webkitGamepads[0]");
+ shouldBe("webkitGamepads.item.__proto__", "Function.prototype")
+ shouldBeNull("webkitGamepads.item(0)");
+
+ gamepads = navigator.getGamepads();
+ shouldBe("gamepads.length", "4");
+ shouldBeUndefined("gamepads[0]");
+ shouldBe("gamepads.item.__proto__", "Function.prototype")
+ shouldBeNull("gamepads.item(0)");
+
+ if (window.gamepadController)
+ {
+ gamepadController.connect(0);
+ gamepadController.setId(0, "MockStick 3000");
+ gamepadController.setButtonCount(0, 1);
+ gamepadController.setAxisCount(0, 1);
+
+ function checkProperties(isPrefixed) {
+ shouldBe("gamepad.id.__proto__", "String.prototype");
+ shouldBe("gamepad.connected.__proto__", "Boolean.prototype");
+ shouldBe("gamepad.index.__proto__", "Number.prototype");
+ shouldBe("gamepad.timestamp.__proto__", "Number.prototype");
+ shouldBe("gamepad.axes.__proto__", "Array.prototype");
+ shouldBe("gamepad.axes[0].__proto__", "Number.prototype");
+
+ shouldBe("gamepad.buttons.__proto__", "Array.prototype");
+ if (isPrefixed) {
+ shouldBe("gamepad.buttons[0].__proto__", "Number.prototype");
+ } else {
+ shouldBe("gamepad.buttons[0].pressed.__proto__", "Boolean.prototype");
+ shouldBe("gamepad.buttons[0].value.__proto__", "Number.prototype");
+ }
+
+ if (!isPrefixed)
+ shouldBe("gamepad.mapping.__proto__", "String.prototype");
+ }
+
+ gamepad = navigator.webkitGetGamepads()[0];
+ shouldBeNonNull("gamepad");
+ shouldBeTrue("gamepad.connected");
+ shouldBe("gamepad.__proto__", "WebKitGamepad.prototype");
+ checkProperties(true);
+
+ gamepad = navigator.getGamepads()[0];
+ shouldBeNonNull("gamepad");
+ shouldBeTrue("gamepad.connected");
+ shouldBe("gamepad.__proto__", "Gamepad.prototype");
+ checkProperties(false);
+ }
+ else
+ {
+ testFailed("no gamepadController available.");
+ }
</script>
-<p>Make sure the main polling access point exists on navigator.</p>
</body>
« no previous file with comments | « no previous file | LayoutTests/gamepad/gamepad-api-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698