dom/tests/mochitest/gamepad/test_gamepad.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/gamepad/test_gamepad.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +<!-- Any copyright is dedicated to the Public Domain.
     1.5 +   - http://creativecommons.org/publicdomain/zero/1.0/ -->
     1.6 +<!DOCTYPE HTML>
     1.7 +<html>
     1.8 +<head>
     1.9 +  <title>Test gamepad</title>
    1.10 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.12 +</head>
    1.13 +<body>
    1.14 +<script type="text/javascript" src="mock_gamepad.js"></script>
    1.15 +<script class="testbody" type="text/javascript">
    1.16 +SimpleTest.waitForExplicitFinish();
    1.17 +window.addEventListener("gamepadconnected", connecthandler);
    1.18 +// Add a gamepad
    1.19 +var index = GamepadService.addGamepad("test gamepad", // id
    1.20 +                                      SpecialPowers.Ci.nsIGamepadServiceTest.STANDARD_MAPPING,
    1.21 +                                      4, // buttons
    1.22 +                                      2);// axes
    1.23 +// Press a button
    1.24 +GamepadService.newButtonEvent(index, 0, true);
    1.25 +function connecthandler(e) {
    1.26 +  is(e.gamepad.id, "test gamepad", "correct gamepad name");
    1.27 +  is(e.gamepad.mapping, "standard", "standard mapping");
    1.28 +  is(e.gamepad.buttons.length, 4, "correct number of buttons");
    1.29 +  is(e.gamepad.axes.length, 2, "correct number of axes");
    1.30 +  SimpleTest.executeSoon(function() {
    1.31 +    GamepadService.removeGamepad(index);
    1.32 +    SimpleTest.finish();
    1.33 +  });
    1.34 +}
    1.35 +</script>
    1.36 +</body>
    1.37 +</html>
    1.38 +

mercurial