Chromium Code Reviews| Index: LayoutTests/gamepad/gamepad-events-basic.html |
| diff --git a/LayoutTests/gamepad/gamepad-events-basic.html b/LayoutTests/gamepad/gamepad-events-basic.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9a8dc772d776e661cc10b3f9e146fc55b33048f2 |
| --- /dev/null |
| +++ b/LayoutTests/gamepad/gamepad-events-basic.html |
| @@ -0,0 +1,52 @@ |
| +<!DOCTYPE html> |
| +<body> |
| +<script src="../resources/js-test.js"></script> |
| +<script> |
| + if (window.gamepadController) |
| + { |
| + function onConnected(event) { |
| + debug("Gamepad connected"); |
| + 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.
|
| + shouldBe("event.gamepad.buttons.length", "2"); |
| + shouldBe("event.gamepad.axes.length", "2"); |
| + shouldBe("event.gamepad.buttons[0].value", "1.0"); |
| + shouldBe("event.gamepad.buttons[0].pressed", "true"); |
|
sof
2014/03/26 21:43:46
shouldBeTrue()
kbalazs
2014/03/26 23:27:13
Done.
|
| + shouldBe("event.gamepad.buttons[1].value", "0.0"); |
| + shouldBe("event.gamepad.buttons[1].pressed", "false"); |
|
sof
2014/03/26 21:43:46
shouldBeFalse()
kbalazs
2014/03/26 23:27:13
Done.
|
| + shouldBe("event.gamepad.axes.length", "2"); |
| + shouldBe("event.gamepad.axes[0]", "0.5"); |
| + shouldBe("event.gamepad.axes[1]", "-1.0"); |
| + gamepadController.disconnect(0); |
| + } |
| + |
| + function onDisconnected(event) { |
| + debug("Gamepad disconnected"); |
| + shouldBe("event.gamepad.id", "'MockStick 3000'"); |
|
sof
2014/03/26 21:43:46
shouldBeString()
kbalazs
2014/03/26 23:27:13
Done.
|
| + shouldBe("event.gamepad.buttons.length", "2"); |
| + shouldBe("event.gamepad.axes.length", "2"); |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| + } |
| + |
| + if (window.testRunner) |
| + testRunner.waitUntilDone(); |
| + window.addEventListener('gamepadconnected', onConnected, false); |
| + window.addEventListener('gamepaddisconnected', onDisconnected, false); |
| + |
| + gamepadController.connect(0); |
| + gamepadController.setId(0, "MockStick 3000"); |
| + gamepadController.setButtonCount(0, 2); |
| + gamepadController.setAxisCount(0, 2); |
| + gamepadController.setButtonData(0, 0, 1); |
| + gamepadController.setButtonData(0, 1, 0); |
| + gamepadController.setAxisData(0, 0, .5); |
| + gamepadController.setAxisData(0, 1, -1.0); |
| + gamepadController.dispatchConnected(0); |
| + } |
| + else |
| + { |
| + 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.
|
| + } |
| +</script> |
| +<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.
|
| +</body> |