mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 811583 - Develop WebAPI tests for proximity sensor API, update manifest. r=davehunt
This commit is contained in:
parent
b70a1cf2a8
commit
27ab5f7b53
7
dom/system/tests/marionette/manifest.ini
Normal file
7
dom/system/tests/marionette/manifest.ini
Normal file
@ -0,0 +1,7 @@
|
||||
[DEFAULT]
|
||||
b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_proximity_init.js]
|
||||
[test_proximity_change.js]
|
83
dom/system/tests/marionette/test_proximity_change.js
Normal file
83
dom/system/tests/marionette/test_proximity_change.js
Normal file
@ -0,0 +1,83 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
let receivedEvent = false;
|
||||
let 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");
|
||||
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() {
|
||||
// Turn proximity event listener and handler off
|
||||
window.removeEventListener('deviceproximity', listener);
|
||||
window.ondeviceproximity = null;
|
||||
finish();
|
||||
}
|
||||
|
||||
// Start the test
|
||||
enableProximityListener();
|
70
dom/system/tests/marionette/test_proximity_init.js
Normal file
70
dom/system/tests/marionette/test_proximity_init.js
Normal file
@ -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.");
|
||||
let 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();
|
@ -18,6 +18,7 @@ skip = false
|
||||
[include:../../../../../dom/network/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/icc/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/system/tests/marionette/manifest.ini]
|
||||
|
||||
; marionette unit tests
|
||||
[include:unit/unit-tests.ini]
|
||||
|
Loading…
Reference in New Issue
Block a user