Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <body> | |
| 3 <script src="../resources/js-test.js"></script> | |
| 4 <script> | |
| 5 if (window.gamepadController) | |
| 6 { | |
| 7 function onConnected(event) { | |
| 8 debug("Gamepad connected"); | |
| 9 shouldBe("event.gamepad.id", "'MockStick 3000'"); | |
|
sof
2014/03/26 21:43:46
Use shouldBeString()
kbalazs
2014/03/26 23:27:13
Yes, shouldBeEqualToString :) Done.
| |
| 10 shouldBe("event.gamepad.buttons.length", "2"); | |
| 11 shouldBe("event.gamepad.axes.length", "2"); | |
| 12 shouldBe("event.gamepad.buttons[0].value", "1.0"); | |
| 13 shouldBe("event.gamepad.buttons[0].pressed", "true"); | |
|
sof
2014/03/26 21:43:46
shouldBeTrue()
kbalazs
2014/03/26 23:27:13
Done.
| |
| 14 shouldBe("event.gamepad.buttons[1].value", "0.0"); | |
| 15 shouldBe("event.gamepad.buttons[1].pressed", "false"); | |
|
sof
2014/03/26 21:43:46
shouldBeFalse()
kbalazs
2014/03/26 23:27:13
Done.
| |
| 16 shouldBe("event.gamepad.axes.length", "2"); | |
| 17 shouldBe("event.gamepad.axes[0]", "0.5"); | |
| 18 shouldBe("event.gamepad.axes[1]", "-1.0"); | |
| 19 gamepadController.disconnect(0); | |
| 20 } | |
| 21 | |
| 22 function onDisconnected(event) { | |
| 23 debug("Gamepad disconnected"); | |
| 24 shouldBe("event.gamepad.id", "'MockStick 3000'"); | |
|
sof
2014/03/26 21:43:46
shouldBeString()
kbalazs
2014/03/26 23:27:13
Done.
| |
| 25 shouldBe("event.gamepad.buttons.length", "2"); | |
| 26 shouldBe("event.gamepad.axes.length", "2"); | |
| 27 if (window.testRunner) | |
| 28 testRunner.notifyDone(); | |
| 29 } | |
| 30 | |
| 31 if (window.testRunner) | |
| 32 testRunner.waitUntilDone(); | |
| 33 window.addEventListener('gamepadconnected', onConnected, false); | |
| 34 window.addEventListener('gamepaddisconnected', onDisconnected, false); | |
| 35 | |
| 36 gamepadController.connect(0); | |
| 37 gamepadController.setId(0, "MockStick 3000"); | |
| 38 gamepadController.setButtonCount(0, 2); | |
| 39 gamepadController.setAxisCount(0, 2); | |
| 40 gamepadController.setButtonData(0, 0, 1); | |
| 41 gamepadController.setButtonData(0, 1, 0); | |
| 42 gamepadController.setAxisData(0, 0, .5); | |
| 43 gamepadController.setAxisData(0, 1, -1.0); | |
| 44 gamepadController.dispatchConnected(0); | |
| 45 } | |
| 46 else | |
| 47 { | |
| 48 console.log("FAIL: no gamepadController available.") | |
|
sof
2014/03/26 21:43:46
testFailed() seems a better fit.
kbalazs
2014/03/26 23:27:13
Done.
| |
| 49 } | |
| 50 </script> | |
| 51 <p>Basic test for 'gamepadconnected' and 'gamepaddisconnected' events.</p> | |
|
sof
2014/03/26 21:43:46
Put this in a call to description() instead, at th
kbalazs
2014/03/26 23:27:13
Done.
| |
| 52 </body> | |
| OLD | NEW |