michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 10000; michael@0: michael@0: function testEventInit() { michael@0: let initValue = 7; michael@0: let initMin = 1; michael@0: let initMax = 30; michael@0: michael@0: // Test DeviceProximityEvent initialization michael@0: log("Verifying DeviceProximityEvent constructor."); michael@0: let event = new DeviceProximityEvent("deviceproximity", michael@0: {value: initValue, min: initMin, max: initMax}); michael@0: is(event.type, "deviceproximity", "event type"); michael@0: is(event.value, initValue, "value"); michael@0: is(event.min, initMin, "min"); michael@0: is(event.max, initMax, "max"); michael@0: if (event.value !== initValue || michael@0: event.min !== initMin || michael@0: event.max !== initMax) { michael@0: log("DeviceProximityEvent not initialized correctly."); michael@0: } michael@0: michael@0: // Test UserProximityEvent initialization michael@0: log("Verifying UserProximityEvent constructor."); michael@0: let event = new UserProximityEvent("userproximity", {near: true}); michael@0: is(event.type, "userproximity", "event type"); michael@0: ok(event.near, "Initialization of UserProximityEvent"); michael@0: verifyDefaultStatus(); michael@0: } michael@0: michael@0: function verifyDefaultStatus() { michael@0: let emulatorDone = false; michael@0: michael@0: // Ensure that device proximity is enabled by default michael@0: log("Getting sensor status from emulator."); michael@0: michael@0: runEmulatorCmd("sensor status", function(result) { michael@0: log("Received sensor status (" + result[4] + ")."); michael@0: is(result[4], "proximity: enabled.", "Proximity sensor enabled by default"); michael@0: emulatorDone = true; michael@0: }); michael@0: michael@0: // Have this here so test doesn't drop out if emulator callback is slow michael@0: waitFor(getDefaultProximity, function() { michael@0: return(emulatorDone); michael@0: }); michael@0: } michael@0: michael@0: function getDefaultProximity() { michael@0: let expected = "1:0:0"; michael@0: michael@0: // Get and verify the default emulator proximity value michael@0: log("Getting device proximity from emulator."); michael@0: michael@0: runEmulatorCmd("sensor get proximity", function(result) { michael@0: let values = result[0].split(" ")[2]; michael@0: log("Received emulator proximity (" + values + ")."); michael@0: is(values, "1:0:0", "Default proximity values"); michael@0: cleanUp(); michael@0: }); michael@0: } michael@0: michael@0: function cleanUp() { michael@0: finish(); michael@0: } michael@0: michael@0: // Start the test michael@0: testEventInit();