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

Unified 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 side-by-side diff with in-line comments
Download patch
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..fe718803721cb37711a1466284f7fa6a5f6ff870
--- /dev/null
+++ b/LayoutTests/gamepad/gamepad-events-basic.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+ description("Basic test for 'gamepadconnected' and 'gamepaddisconnected' events.");
+
Inactive 2014/03/27 13:27:24 jsTestIsAsync = true;
kbalazs 2014/03/28 23:24:12 Done.
+ if (window.gamepadController)
+ {
+ function onConnected(event) {
+ 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.
+ shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
+ shouldBe("event.gamepad.buttons.length", "2");
+ shouldBe("event.gamepad.axes.length", "2");
+ shouldBe("event.gamepad.buttons[0].value", "1.0");
+ shouldBeTrue("event.gamepad.buttons[0].pressed");
+ shouldBe("event.gamepad.buttons[1].value", "0.0");
+ shouldBeFalse("event.gamepad.buttons[1].pressed");
+ 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");
Inactive 2014/03/27 13:27:24 Should check event type, same as above.
kbalazs 2014/03/28 23:24:12 Done.
+ shouldBeEqualToString("event.gamepad.id", "MockStick 3000");
+ shouldBe("event.gamepad.buttons.length", "2");
+ shouldBe("event.gamepad.axes.length", "2");
+ if (window.testRunner)
Inactive 2014/03/27 13:27:24 finishJSTest();
kbalazs 2014/03/28 23:24:12 Done.
+ testRunner.notifyDone();
+ }
+
+ 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.
+ testRunner.waitUntilDone();
+ 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.
+ window.addEventListener('gamepaddisconnected', onDisconnected, false);
Inactive 2014/03/27 13:27:24 Done.
kbalazs 2014/03/28 23:24:12 Done.
+
+ 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
+ {
+ testFailed("no gamepadController available.");
+ }
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698