|
1 <!-- Any copyright is dedicated to the Public Domain. |
|
2 - http://creativecommons.org/publicdomain/zero/1.0/ --> |
|
3 <!DOCTYPE HTML> |
|
4 <html> |
|
5 <head> |
|
6 <title>Test gamepad</title> |
|
7 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
9 </head> |
|
10 <body> |
|
11 <script type="text/javascript" src="mock_gamepad.js"></script> |
|
12 <script class="testbody" type="text/javascript"> |
|
13 SimpleTest.waitForExplicitFinish(); |
|
14 window.addEventListener("gamepadconnected", connecthandler); |
|
15 // Add a gamepad |
|
16 var index = GamepadService.addGamepad("test gamepad", // id |
|
17 SpecialPowers.Ci.nsIGamepadServiceTest.STANDARD_MAPPING, |
|
18 4, // buttons |
|
19 2);// axes |
|
20 // Press a button |
|
21 GamepadService.newButtonEvent(index, 0, true); |
|
22 function connecthandler(e) { |
|
23 is(e.gamepad.id, "test gamepad", "correct gamepad name"); |
|
24 is(e.gamepad.mapping, "standard", "standard mapping"); |
|
25 is(e.gamepad.buttons.length, 4, "correct number of buttons"); |
|
26 is(e.gamepad.axes.length, 2, "correct number of axes"); |
|
27 SimpleTest.executeSoon(function() { |
|
28 GamepadService.removeGamepad(index); |
|
29 SimpleTest.finish(); |
|
30 }); |
|
31 } |
|
32 </script> |
|
33 </body> |
|
34 </html> |
|
35 |