michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 120000; michael@0: MARIONETTE_HEAD_JS = 'head.js'; michael@0: michael@0: function doTest(aAzimuth, aPitch, aRoll) { michael@0: log("Testing [azimuth, pitch, roll] = " + Array.slice(arguments)); michael@0: michael@0: return setEmulatorOrientationValues(aAzimuth, aPitch, aRoll) michael@0: .then(() => waitForWindowEvent("deviceorientation")) michael@0: .then(function(aEvent) { michael@0: is(aEvent.alpha, aAzimuth, "azimuth"); michael@0: is(aEvent.beta, aPitch, "pitch"); michael@0: is(aEvent.gamma, aRoll, "roll"); michael@0: }); michael@0: } michael@0: michael@0: function testAllPermutations() { michael@0: const angles = [-180, -90, 0, 90, 180]; michael@0: let promise = Promise.resolve(); michael@0: for (let i = 0; i < angles.length; i++) { michael@0: for (let j = 0; j < angles.length; j++) { michael@0: for (let k = 0; k < angles.length; k++) { michael@0: promise = michael@0: promise.then(doTest.bind(null, angles[i], angles[j], angles[k])); michael@0: } michael@0: } michael@0: } michael@0: return promise; michael@0: } michael@0: michael@0: startTestBase(function() { michael@0: let origValues; michael@0: michael@0: return Promise.resolve() michael@0: michael@0: // Retrieve original status. michael@0: .then(() => getEmulatorOrientationValues()) michael@0: .then(function(aValues) { michael@0: origValues = aValues; michael@0: is(typeof origValues, "object", "typeof origValues"); michael@0: is(origValues.length, 3, "origValues.length"); michael@0: }) michael@0: michael@0: // Test original status michael@0: .then(() => doTest.apply(null, origValues)) michael@0: michael@0: .then(testAllPermutations) michael@0: michael@0: // Restore original status. michael@0: .then(() => setEmulatorOrientationValues.apply(null, origValues)); michael@0: });