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

Side by Side Diff: LayoutTests/gamepad/gamepad-events-basic.html

Issue 280393004: Update Gamepad.axes / GamepadButton.value to match the latest specification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add back #ifdefs Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/gamepad/gamepad-events-basic-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("Basic test for 'gamepadconnected' and 'gamepaddisconnected' eve nts."); 5 description("Basic test for 'gamepadconnected' and 'gamepaddisconnected' eve nts.");
6 6
7 jsTestIsAsync = true; 7 jsTestIsAsync = true;
8 8
9 if (window.gamepadController) 9 if (window.gamepadController)
10 { 10 {
11 function onConnected(event) { 11 function onConnected(event) {
12 debug("Gamepad connected"); 12 debug("Gamepad connected");
13 shouldBe("event.__proto__", "GamepadEvent.prototype"); 13 shouldBe("event.__proto__", "GamepadEvent.prototype");
14 shouldBe("event.__proto__.__proto__", "Event.prototype"); 14 shouldBe("event.__proto__.__proto__", "Event.prototype");
15 shouldBeEqualToString("event.gamepad.id", "MockStick 3000"); 15 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
16 shouldBe("event.gamepad.buttons.length", "2"); 16 shouldBe("event.gamepad.buttons.length", "3");
17 shouldBe("event.gamepad.axes.length", "2"); 17 shouldBe("event.gamepad.axes.length", "3");
18 shouldBe("event.gamepad.buttons[0].value", "1.0"); 18 shouldBe("event.gamepad.buttons[0].value", "1.0");
19 shouldBeTrue("event.gamepad.buttons[0].pressed"); 19 shouldBeTrue("event.gamepad.buttons[0].pressed");
20 shouldBe("event.gamepad.buttons[1].value", "0.0"); 20 shouldBe("event.gamepad.buttons[1].value", "0.0");
21 shouldBeFalse("event.gamepad.buttons[1].pressed"); 21 shouldBeFalse("event.gamepad.buttons[1].pressed");
22 shouldBe("event.gamepad.axes.length", "2"); 22 shouldBe("event.gamepad.axes.length", "3");
23 shouldBe("event.gamepad.buttons[2].value", "0.333333");
24 shouldBeTrue("event.gamepad.buttons[2].pressed");
23 shouldBe("event.gamepad.axes[0]", "0.5"); 25 shouldBe("event.gamepad.axes[0]", "0.5");
24 shouldBe("event.gamepad.axes[1]", "-1.0"); 26 shouldBe("event.gamepad.axes[1]", "-1.0");
27 shouldBe("event.gamepad.axes[2]", "0.333333");
25 gamepadController.disconnect(0); 28 gamepadController.disconnect(0);
26 } 29 }
27 30
28 function onDisconnected(event) { 31 function onDisconnected(event) {
29 debug("Gamepad disconnected"); 32 debug("Gamepad disconnected");
30 shouldBe("event.__proto__", "GamepadEvent.prototype"); 33 shouldBe("event.__proto__", "GamepadEvent.prototype");
31 shouldBe("event.__proto__.__proto__", "Event.prototype"); 34 shouldBe("event.__proto__.__proto__", "Event.prototype");
32 shouldBeEqualToString("event.gamepad.id", "MockStick 3000"); 35 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
33 shouldBe("event.gamepad.buttons.length", "2"); 36 shouldBe("event.gamepad.buttons.length", "3");
34 shouldBe("event.gamepad.axes.length", "2"); 37 shouldBe("event.gamepad.axes.length", "3");
35 finishJSTest(); 38 finishJSTest();
36 } 39 }
37 40
38 window.addEventListener('gamepadconnected', onConnected); 41 window.addEventListener('gamepadconnected', onConnected);
39 window.addEventListener('gamepaddisconnected', onDisconnected); 42 window.addEventListener('gamepaddisconnected', onDisconnected);
40 43
41 gamepadController.connect(0); 44 gamepadController.connect(0);
42 gamepadController.setId(0, "MockStick 3000"); 45 gamepadController.setId(0, "MockStick 3000");
43 gamepadController.setButtonCount(0, 2); 46 gamepadController.setButtonCount(0, 3);
44 gamepadController.setAxisCount(0, 2); 47 gamepadController.setAxisCount(0, 3);
45 gamepadController.setButtonData(0, 0, 1); 48 gamepadController.setButtonData(0, 0, 1);
46 gamepadController.setButtonData(0, 1, 0); 49 gamepadController.setButtonData(0, 1, 0);
50 gamepadController.setButtonData(0, 2, 0.333333);
47 gamepadController.setAxisData(0, 0, .5); 51 gamepadController.setAxisData(0, 0, .5);
48 gamepadController.setAxisData(0, 1, -1.0); 52 gamepadController.setAxisData(0, 1, -1.0);
53 gamepadController.setAxisData(0, 2, 0.333333);
49 gamepadController.dispatchConnected(0); 54 gamepadController.dispatchConnected(0);
50 } 55 }
51 else 56 else
52 { 57 {
53 testFailed("no gamepadController available."); 58 testFailed("no gamepadController available.");
54 } 59 }
55 </script> 60 </script>
56 </body> 61 </body>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/gamepad/gamepad-events-basic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698