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

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

mercurial