diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/system/tests/marionette/test_proximity_init.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/system/tests/marionette/test_proximity_init.js')
-rw-r--r-- | dom/system/tests/marionette/test_proximity_init.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/dom/system/tests/marionette/test_proximity_init.js b/dom/system/tests/marionette/test_proximity_init.js new file mode 100644 index 000000000..1a56e6e46 --- /dev/null +++ b/dom/system/tests/marionette/test_proximity_init.js @@ -0,0 +1,70 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 10000; + +function testEventInit() { + let initValue = 7; + let initMin = 1; + let initMax = 30; + + // Test DeviceProximityEvent initialization + log("Verifying DeviceProximityEvent constructor."); + let event = new DeviceProximityEvent("deviceproximity", + {value: initValue, min: initMin, max: initMax}); + is(event.type, "deviceproximity", "event type"); + is(event.value, initValue, "value"); + is(event.min, initMin, "min"); + is(event.max, initMax, "max"); + if (event.value !== initValue || + event.min !== initMin || + event.max !== initMax) { + log("DeviceProximityEvent not initialized correctly."); + } + + // Test UserProximityEvent initialization + log("Verifying UserProximityEvent constructor."); + event = new UserProximityEvent("userproximity", {near: true}); + is(event.type, "userproximity", "event type"); + ok(event.near, "Initialization of UserProximityEvent"); + verifyDefaultStatus(); +} + +function verifyDefaultStatus() { + let emulatorDone = false; + + // Ensure that device proximity is enabled by default + log("Getting sensor status from emulator."); + + runEmulatorCmd("sensor status", function(result) { + log("Received sensor status (" + result[4] + ")."); + is(result[4], "proximity: enabled.", "Proximity sensor enabled by default"); + emulatorDone = true; + }); + + // Have this here so test doesn't drop out if emulator callback is slow + waitFor(getDefaultProximity, function() { + return(emulatorDone); + }); +} + +function getDefaultProximity() { + let expected = "1:0:0"; + + // Get and verify the default emulator proximity value + log("Getting device proximity from emulator."); + + runEmulatorCmd("sensor get proximity", function(result) { + let values = result[0].split(" ")[2]; + log("Received emulator proximity (" + values + ")."); + is(values, "1:0:0", "Default proximity values"); + cleanUp(); + }); +} + +function cleanUp() { + finish(); +} + +// Start the test +testEventInit(); |