dom/mobileconnection/tests/marionette/test_mobile_data_location.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/mobileconnection/tests/marionette/test_mobile_data_location.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +MARIONETTE_TIMEOUT = 60000;
     1.8 +MARIONETTE_HEAD_JS = "head.js";
     1.9 +
    1.10 +function verifyDataCellLocationInfo(aLac, aCid) {
    1.11 +  let cell = mobileConnection.data.cell;
    1.12 +  ok(cell, "location available");
    1.13 +
    1.14 +  // Initial LAC/CID. Android emulator initializes both value to
    1.15 +  // 0xffff/0xffffffff.
    1.16 +  is(cell.gsmLocationAreaCode, aLac, "data.cell.gsmLocationAreaCode");
    1.17 +  is(cell.gsmCellId, aCid, "data.cell.gsmCellId");
    1.18 +  is(cell.cdmaBaseStationId, -1, "data.cell.cdmaBaseStationId");
    1.19 +  is(cell.cdmaBaseStationLatitude, -2147483648,
    1.20 +     "data.cell.cdmaBaseStationLatitude");
    1.21 +  is(cell.cdmaBaseStationLongitude, -2147483648,
    1.22 +     "data.cell.cdmaBaseStationLongitude");
    1.23 +  is(cell.cdmaSystemId, -1, "data.cell.cdmaSystemId");
    1.24 +  is(cell.cdmaNetworkId, -1, "data.cell.cdmaNetworkId");
    1.25 +}
    1.26 +
    1.27 +/* Test Data Cell Location Info Change */
    1.28 +function testDataCellLocationUpdate(aLac, aCid) {
    1.29 +  // Set emulator's lac/cid and wait for 'ondatachange' event.
    1.30 +  log("Test cell location with lac=" + aLac + " and cid=" + aCid);
    1.31 +
    1.32 +  let promises = [];
    1.33 +  promises.push(waitForManagerEvent("datachange"));
    1.34 +  promises.push(setEmulatorGsmLocation(aLac, aCid));
    1.35 +  return Promise.all(promises)
    1.36 +    .then(() => verifyDataCellLocationInfo(aLac, aCid));
    1.37 +}
    1.38 +
    1.39 +startTestCommon(function() {
    1.40 +  return getEmulatorGsmLocation()
    1.41 +    .then(function(aResult) {
    1.42 +      log("Test initial data location info");
    1.43 +      verifyDataCellLocationInfo(aResult.lac, aResult.cid);
    1.44 +
    1.45 +      return Promise.resolve()
    1.46 +        .then(() => testDataCellLocationUpdate(100, 100))
    1.47 +        .then(() => testDataCellLocationUpdate(2000, 2000))
    1.48 +
    1.49 +        // Reset back to initial values.
    1.50 +        .then(() => testDataCellLocationUpdate(aResult.lac, aResult.cid));
    1.51 +    });
    1.52 +});

mercurial