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

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: cleanups 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
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
Inactive 2014/03/27 13:27:24 jsTestIsAsync = true;
kbalazs 2014/03/28 23:24:12 Done.
7 if (window.gamepadController)
8 {
9 function onConnected(event) {
10 debug("Gamepad connected");
Inactive 2014/03/27 13:27:24 You should probably check the event type as well,
kbalazs 2014/03/28 23:24:12 Done.
11 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
12 shouldBe("event.gamepad.buttons.length", "2");
13 shouldBe("event.gamepad.axes.length", "2");
14 shouldBe("event.gamepad.buttons[0].value", "1.0");
15 shouldBeTrue("event.gamepad.buttons[0].pressed");
16 shouldBe("event.gamepad.buttons[1].value", "0.0");
17 shouldBeFalse("event.gamepad.buttons[1].pressed");
18 shouldBe("event.gamepad.axes.length", "2");
19 shouldBe("event.gamepad.axes[0]", "0.5");
20 shouldBe("event.gamepad.axes[1]", "-1.0");
21 gamepadController.disconnect(0);
22 }
23
24 function onDisconnected(event) {
25 debug("Gamepad disconnected");
Inactive 2014/03/27 13:27:24 Should check event type, same as above.
kbalazs 2014/03/28 23:24:12 Done.
26 shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
27 shouldBe("event.gamepad.buttons.length", "2");
28 shouldBe("event.gamepad.axes.length", "2");
29 if (window.testRunner)
Inactive 2014/03/27 13:27:24 finishJSTest();
kbalazs 2014/03/28 23:24:12 Done.
30 testRunner.notifyDone();
31 }
32
33 if (window.testRunner)
Inactive 2014/03/27 13:27:24 Not needed if you do the "jsTestIsAsync = true;" a
kbalazs 2014/03/28 23:24:12 Done.
34 testRunner.waitUntilDone();
35 window.addEventListener('gamepadconnected', onConnected, false);
Inactive 2014/03/27 13:27:24 nit: ", false" is unnecessary (this is the default
kbalazs 2014/03/28 23:24:12 Done.
36 window.addEventListener('gamepaddisconnected', onDisconnected, false);
Inactive 2014/03/27 13:27:24 Done.
kbalazs 2014/03/28 23:24:12 Done.
37
38 gamepadController.connect(0);
39 gamepadController.setId(0, "MockStick 3000");
40 gamepadController.setButtonCount(0, 2);
41 gamepadController.setAxisCount(0, 2);
42 gamepadController.setButtonData(0, 0, 1);
43 gamepadController.setButtonData(0, 1, 0);
44 gamepadController.setAxisData(0, 0, .5);
45 gamepadController.setAxisData(0, 1, -1.0);
46 gamepadController.dispatchConnected(0);
47 }
48 else
49 {
50 testFailed("no gamepadController available.");
51 }
52 </script>
53 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698