From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../test/marionette/test_sensor_orientation.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dom/events/test/marionette/test_sensor_orientation.js (limited to 'dom/events/test/marionette/test_sensor_orientation.js') diff --git a/dom/events/test/marionette/test_sensor_orientation.js b/dom/events/test/marionette/test_sensor_orientation.js new file mode 100644 index 000000000..70df0ccd3 --- /dev/null +++ b/dom/events/test/marionette/test_sensor_orientation.js @@ -0,0 +1,53 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 120000; +MARIONETTE_HEAD_JS = 'head.js'; + +function doTest(aAzimuth, aPitch, aRoll) { + log("Testing [azimuth, pitch, roll] = " + Array.slice(arguments)); + + return setEmulatorOrientationValues(aAzimuth, aPitch, aRoll) + .then(() => waitForWindowEvent("deviceorientation")) + .then(function(aEvent) { + is(aEvent.alpha, aAzimuth, "azimuth"); + is(aEvent.beta, aPitch, "pitch"); + is(aEvent.gamma, aRoll, "roll"); + }); +} + +function testAllPermutations() { + const angles = [-180, -90, 0, 90, 180]; + let promise = Promise.resolve(); + for (let i = 0; i < angles.length; i++) { + for (let j = 0; j < angles.length; j++) { + for (let k = 0; k < angles.length; k++) { + promise = + promise.then(doTest.bind(null, angles[i], angles[j], angles[k])); + } + } + } + return promise; +} + +startTestBase(function() { + let origValues; + + return Promise.resolve() + + // Retrieve original status. + .then(() => getEmulatorOrientationValues()) + .then(function(aValues) { + origValues = aValues; + is(typeof origValues, "object", "typeof origValues"); + is(origValues.length, 3, "origValues.length"); + }) + + // Test original status + .then(() => doTest.apply(null, origValues)) + + .then(testAllPermutations) + + // Restore original status. + .then(() => setEmulatorOrientationValues.apply(null, origValues)); +}); -- cgit v1.2.3