|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 120000; |
|
5 MARIONETTE_HEAD_JS = 'head.js'; |
|
6 |
|
7 function doTest(aAzimuth, aPitch, aRoll) { |
|
8 log("Testing [azimuth, pitch, roll] = " + Array.slice(arguments)); |
|
9 |
|
10 return setEmulatorOrientationValues(aAzimuth, aPitch, aRoll) |
|
11 .then(() => waitForWindowEvent("deviceorientation")) |
|
12 .then(function(aEvent) { |
|
13 is(aEvent.alpha, aAzimuth, "azimuth"); |
|
14 is(aEvent.beta, aPitch, "pitch"); |
|
15 is(aEvent.gamma, aRoll, "roll"); |
|
16 }); |
|
17 } |
|
18 |
|
19 function testAllPermutations() { |
|
20 const angles = [-180, -90, 0, 90, 180]; |
|
21 let promise = Promise.resolve(); |
|
22 for (let i = 0; i < angles.length; i++) { |
|
23 for (let j = 0; j < angles.length; j++) { |
|
24 for (let k = 0; k < angles.length; k++) { |
|
25 promise = |
|
26 promise.then(doTest.bind(null, angles[i], angles[j], angles[k])); |
|
27 } |
|
28 } |
|
29 } |
|
30 return promise; |
|
31 } |
|
32 |
|
33 startTestBase(function() { |
|
34 let origValues; |
|
35 |
|
36 return Promise.resolve() |
|
37 |
|
38 // Retrieve original status. |
|
39 .then(() => getEmulatorOrientationValues()) |
|
40 .then(function(aValues) { |
|
41 origValues = aValues; |
|
42 is(typeof origValues, "object", "typeof origValues"); |
|
43 is(origValues.length, 3, "origValues.length"); |
|
44 }) |
|
45 |
|
46 // Test original status |
|
47 .then(() => doTest.apply(null, origValues)) |
|
48 |
|
49 .then(testAllPermutations) |
|
50 |
|
51 // Restore original status. |
|
52 .then(() => setEmulatorOrientationValues.apply(null, origValues)); |
|
53 }); |