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

Side by Side 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: incorp comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/gamepad/gamepad-api-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <body> 2 <body>
3 <script src="../resources/js-test.js"></script> 3 <script src="../resources/js-test.js"></script>
4 <script> 4 <script>
5 description("Validates the exposed Gamepad API.")
6
5 shouldBeDefined("navigator.webkitGetGamepads"); 7 shouldBeDefined("navigator.webkitGetGamepads");
6 shouldBeDefined("navigator.getGamepads"); 8 shouldBeDefined("navigator.getGamepads");
9 shouldBeDefined("GamepadEvent");
10
11 webkitGamepads = navigator.webkitGetGamepads();
12 shouldBe("webkitGamepads.length", "4");
13 shouldBeUndefined("webkitGamepads[0]");
14 shouldBeEqualToString("Object.prototype.toString.call(webkitGamepads.item)", "[object Function]")
Inactive 2014/03/29 00:26:35 shouldBe("webkitGamepads.item.__proto__", "Functio
kbalazs 2014/03/31 01:49:08 Done.
15 shouldBeNull("webkitGamepads.item(0)");
16
17 gamepads = navigator.getGamepads();
18 shouldBe("gamepads.length", "4");
19 shouldBeUndefined("gamepads[0]");
20 shouldBeEqualToString("Object.prototype.toString.call(gamepads.item)", "[obj ect Function]");
Inactive 2014/03/29 00:26:35 Ditto.
kbalazs 2014/03/31 01:49:08 Done.
21 shouldBeNull("gamepads.item(0)");
22
23 if (window.gamepadController)
24 {
25 gamepadController.connect(0);
26 gamepadController.setId(0, "MockStick 3000");
27 gamepadController.setButtonCount(0, 1);
28 gamepadController.setAxisCount(0, 1);
29
30 function checkProperties(isPrefixed) {
31 shouldBeEqualToString("Object.prototype.toString.call(gamepad.id)", "[object String]");
Inactive 2014/03/29 00:26:35 You could use __proto__ for those JS builtin types
kbalazs 2014/03/31 01:49:08 Done.
32 shouldBeEqualToString("Object.prototype.toString.call(gamepad.connec ted)", "[object Boolean]");
33 shouldBeEqualToString("Object.prototype.toString.call(gamepad.index) ", "[object Number]");
34 shouldBeEqualToString("Object.prototype.toString.call(gamepad.timest amp)", "[object Number]");
35 shouldBeEqualToString("Object.prototype.toString.call(gamepad.axes)" , "[object Array]");
36 shouldBeEqualToString("Object.prototype.toString.call(gamepad.axes[0 ])", "[object Number]");
37
38 shouldBeEqualToString("Object.prototype.toString.call(gamepad.button s)", "[object Array]");
39 if (isPrefixed) {
40 shouldBeEqualToString("Object.prototype.toString.call(gamepad.bu ttons[0])", "[object Number]");
41 } else {
42 shouldBeEqualToString("Object.prototype.toString.call(gamepad.bu ttons[0].pressed)", "[object Boolean]");
43 shouldBeEqualToString("Object.prototype.toString.call(gamepad.bu ttons[0].value)", "[object Number]");
44 }
45
46 if (!isPrefixed)
47 shouldBeEqualToString("Object.prototype.toString.call(gamepad.ma pping)", "[object String]");
48 }
49
50 gamepad = navigator.webkitGetGamepads()[0];
51 shouldBeNonNull("gamepad");
52 shouldBeTrue("gamepad.connected")
53 shouldBe("gamepad.__proto__", "WebKitGamepad.prototype");
54 checkProperties(true);
55
56 gamepad = navigator.getGamepads()[0];
57 shouldBeNonNull("gamepad");
58 shouldBeTrue("gamepad.connected");
59 shouldBe("gamepad.__proto__", "Gamepad.prototype");
60 checkProperties(false);
61 }
62 else
63 {
64 testFailed("no gamepadController available.");
65 }
7 </script> 66 </script>
8 <p>Make sure the main polling access point exists on navigator.</p>
9 </body> 67 </body>
OLDNEW
« 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