dom/system/tests/marionette/test_proximity_init.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 MARIONETTE_TIMEOUT = 10000;
michael@0 5
michael@0 6 function testEventInit() {
michael@0 7 let initValue = 7;
michael@0 8 let initMin = 1;
michael@0 9 let initMax = 30;
michael@0 10
michael@0 11 // Test DeviceProximityEvent initialization
michael@0 12 log("Verifying DeviceProximityEvent constructor.");
michael@0 13 let event = new DeviceProximityEvent("deviceproximity",
michael@0 14 {value: initValue, min: initMin, max: initMax});
michael@0 15 is(event.type, "deviceproximity", "event type");
michael@0 16 is(event.value, initValue, "value");
michael@0 17 is(event.min, initMin, "min");
michael@0 18 is(event.max, initMax, "max");
michael@0 19 if (event.value !== initValue ||
michael@0 20 event.min !== initMin ||
michael@0 21 event.max !== initMax) {
michael@0 22 log("DeviceProximityEvent not initialized correctly.");
michael@0 23 }
michael@0 24
michael@0 25 // Test UserProximityEvent initialization
michael@0 26 log("Verifying UserProximityEvent constructor.");
michael@0 27 let event = new UserProximityEvent("userproximity", {near: true});
michael@0 28 is(event.type, "userproximity", "event type");
michael@0 29 ok(event.near, "Initialization of UserProximityEvent");
michael@0 30 verifyDefaultStatus();
michael@0 31 }
michael@0 32
michael@0 33 function verifyDefaultStatus() {
michael@0 34 let emulatorDone = false;
michael@0 35
michael@0 36 // Ensure that device proximity is enabled by default
michael@0 37 log("Getting sensor status from emulator.");
michael@0 38
michael@0 39 runEmulatorCmd("sensor status", function(result) {
michael@0 40 log("Received sensor status (" + result[4] + ").");
michael@0 41 is(result[4], "proximity: enabled.", "Proximity sensor enabled by default");
michael@0 42 emulatorDone = true;
michael@0 43 });
michael@0 44
michael@0 45 // Have this here so test doesn't drop out if emulator callback is slow
michael@0 46 waitFor(getDefaultProximity, function() {
michael@0 47 return(emulatorDone);
michael@0 48 });
michael@0 49 }
michael@0 50
michael@0 51 function getDefaultProximity() {
michael@0 52 let expected = "1:0:0";
michael@0 53
michael@0 54 // Get and verify the default emulator proximity value
michael@0 55 log("Getting device proximity from emulator.");
michael@0 56
michael@0 57 runEmulatorCmd("sensor get proximity", function(result) {
michael@0 58 let values = result[0].split(" ")[2];
michael@0 59 log("Received emulator proximity (" + values + ").");
michael@0 60 is(values, "1:0:0", "Default proximity values");
michael@0 61 cleanUp();
michael@0 62 });
michael@0 63 }
michael@0 64
michael@0 65 function cleanUp() {
michael@0 66 finish();
michael@0 67 }
michael@0 68
michael@0 69 // Start the test
michael@0 70 testEventInit();

mercurial