summaryrefslogtreecommitdiffstats
path: root/dom/system/tests/marionette
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/system/tests/marionette
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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')
-rw-r--r--dom/system/tests/marionette/manifest.ini5
-rw-r--r--dom/system/tests/marionette/test_proximity_change.js83
-rw-r--r--dom/system/tests/marionette/test_proximity_init.js70
3 files changed, 158 insertions, 0 deletions
diff --git a/dom/system/tests/marionette/manifest.ini b/dom/system/tests/marionette/manifest.ini
new file mode 100644
index 000000000..a8458c450
--- /dev/null
+++ b/dom/system/tests/marionette/manifest.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+run-if = buildapp == 'b2g'
+
+[test_proximity_init.js]
+[test_proximity_change.js]
diff --git a/dom/system/tests/marionette/test_proximity_change.js b/dom/system/tests/marionette/test_proximity_change.js
new file mode 100644
index 000000000..a4c54f12b
--- /dev/null
+++ b/dom/system/tests/marionette/test_proximity_change.js
@@ -0,0 +1,83 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+var receivedEvent = false;
+var expectedEvent;
+
+function enableProximityListener() {
+ // Setup device proximity event listener, expect defaults
+ log("Enabling 'deviceproximity' event listener.");
+
+ // Bug 814043: Device proximity event 'min' and 'max' attributes incorrect
+ // Until that is fixed, expect 1:0:1 instead of 1:0:0
+ // expectedEvent = new DeviceProximityEvent("deviceproximity",
+ // {value:1, min:0, max:0});
+ expectedEvent = new DeviceProximityEvent("deviceproximity",
+ {value:1, min:0, max:1});
+
+ window.addEventListener('deviceproximity', listener);
+ log("Waiting for device proximity event.");
+ waitFor(changeProximity, function() {
+ return(receivedEvent);
+ });
+}
+
+function listener(event) {
+ // Received proximity update
+ log("Received 'deviceproximity' event via listener (value:"
+ + event.value + " min:" + event.min + " max:" + event.max + ").");
+ // Verify event values are as expected
+ is(event.value, expectedEvent.value, "value");
+ is(event.min, expectedEvent.min, "min");
+ is(event.max, expectedEvent.max, "max");
+ receivedEvent = true;
+}
+
+function changeProximity() {
+ // Change emulator's proximity and verify event attributes
+ let newValue = "7:3:15";
+
+ // Bug 814043: Device proximity event 'min' and 'max' attributes won't change
+ // Until fixed, expect proximity event min to be '0' and max to be '1' always
+ // expectedEvent = new DeviceProximityEvent("deviceproximity",
+ // {value: 7, min: 3, max: 15});
+ expectedEvent = new DeviceProximityEvent("deviceproximity",
+ {value:7, min:0, max:1});
+
+ // Setup handler and verify 'ondeviceproximity' event
+ window.ondeviceproximity = function(event) {
+ log("Received 'ondeviceproximity' event via handler (value:"
+ + event.value + " min:" + event.min + " max:"
+ + event.max + ").");
+ is(event.value, expectedEvent.value, "value");
+ is(event.min, expectedEvent.min, "min");
+ is(event.max, expectedEvent.max, "max");
+ // Turn off event handler and listener
+ window.ondeviceproximity = null;
+ window.removeEventListener('deviceproximity', listener);
+ restoreProximity();
+ };
+
+ log("Sending emulator command to fake proximity change (" + newValue + ").");
+ runEmulatorCmd("sensor set proximity " + newValue, function(result) {
+ log("Emulator callback.");
+ });
+}
+
+function restoreProximity() {
+ // Set the emulator's proximity value back to original
+ newValue = "1:0:0";
+ log("Sending emulator command to restore proximity (" + newValue + ").");
+ runEmulatorCmd("sensor set proximity " + newValue, function(result) {
+ cleanUp();
+ });
+}
+
+function cleanUp() {
+ finish();
+}
+
+// Start the test
+enableProximityListener();
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();