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

Side by Side Diff: LayoutTests/gamepad/gamepad-events-basic.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, 8 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <body>
3 <script src="../resources/js-test.js"></script>
4 <script>
5 description("Basic test for 'gamepadconnected' and 'gamepaddisconnected' eve nts.");
6
7 jsTestIsAsync = true;
8
9 if (window.gamepadController)
10 {
11 function onConnected(event) {
12 debug("Gamepad connected");
13 shouldBe("event.__proto__", "GamepadEvent.prototype");
14 shouldBe("event.__proto__.__proto__", "Event.prototype");
15 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
16 shouldBe("event.gamepad.buttons.length", "2");
17 shouldBe("event.gamepad.axes.length", "2");
18 shouldBe("event.gamepad.buttons[0].value", "1.0");
19 shouldBeTrue("event.gamepad.buttons[0].pressed");
20 shouldBe("event.gamepad.buttons[1].value", "0.0");
21 shouldBeFalse("event.gamepad.buttons[1].pressed");
22 shouldBe("event.gamepad.axes.length", "2");
23 shouldBe("event.gamepad.axes[0]", "0.5");
24 shouldBe("event.gamepad.axes[1]", "-1.0");
25 gamepadController.disconnect(0);
26 }
27
28 function onDisconnected(event) {
29 debug("Gamepad disconnected");
30 shouldBe("event.__proto__", "GamepadEvent.prototype");
31 shouldBe("event.__proto__.__proto__", "Event.prototype");
32 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
33 shouldBe("event.gamepad.buttons.length", "2");
34 shouldBe("event.gamepad.axes.length", "2");
35 finishJSTest();
36 }
37
38 window.addEventListener('gamepadconnected', onConnected);
39 window.addEventListener('gamepaddisconnected', onDisconnected);
40
41 gamepadController.connect(0);
42 gamepadController.setId(0, "MockStick 3000");
43 gamepadController.setButtonCount(0, 2);
44 gamepadController.setAxisCount(0, 2);
45 gamepadController.setButtonData(0, 0, 1);
46 gamepadController.setButtonData(0, 1, 0);
47 gamepadController.setAxisData(0, 0, .5);
48 gamepadController.setAxisData(0, 1, -1.0);
49 gamepadController.dispatchConnected(0);
50 }
51 else
52 {
53 testFailed("no gamepadController available.");
54 }
55 </script>
56 </body>
OLDNEW
« no previous file with comments | « LayoutTests/gamepad/gamepad-api-expected.txt ('k') | LayoutTests/gamepad/gamepad-events-basic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698