|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 60000; |
|
5 MARIONETTE_HEAD_JS = "head.js"; |
|
6 |
|
7 function verifyVoiceCellLocationInfo(aLac, aCid) { |
|
8 let cell = mobileConnection.voice.cell; |
|
9 ok(cell, "location available"); |
|
10 |
|
11 // Initial LAC/CID. Android emulator initializes both value to |
|
12 // 0xffff/0xffffffff. |
|
13 is(cell.gsmLocationAreaCode, aLac, "check voice.cell.gsmLocationAreaCode"); |
|
14 is(cell.gsmCellId, aCid, "check voice.cell.gsmCellId"); |
|
15 is(cell.cdmaBaseStationId, -1, "check voice.cell.cdmaBaseStationId"); |
|
16 is(cell.cdmaBaseStationLatitude, -2147483648, |
|
17 "check voice.cell.cdmaBaseStationLatitude"); |
|
18 is(cell.cdmaBaseStationLongitude, -2147483648, |
|
19 "check voice.cell.cdmaBaseStationLongitude"); |
|
20 is(cell.cdmaSystemId, -1, "check voice.cell.cdmaSystemId"); |
|
21 is(cell.cdmaNetworkId, -1, "check voice.cell.cdmaNetworkId"); |
|
22 } |
|
23 |
|
24 /* Test Voice Cell Location Info Change */ |
|
25 function testVoiceCellLocationUpdate(aLac, aCid) { |
|
26 // Set emulator's lac/cid and wait for 'onvoicechange' event. |
|
27 log("Test cell location with lac=" + aLac + " and cid=" + aCid); |
|
28 |
|
29 let promises = []; |
|
30 promises.push(waitForManagerEvent("voicechange")); |
|
31 promises.push(setEmulatorGsmLocation(aLac, aCid)); |
|
32 return Promise.all(promises) |
|
33 .then(() => verifyVoiceCellLocationInfo(aLac, aCid)); |
|
34 } |
|
35 |
|
36 startTestCommon(function() { |
|
37 return getEmulatorGsmLocation() |
|
38 .then(function(aResult) { |
|
39 log("Test initial voice location info"); |
|
40 verifyVoiceCellLocationInfo(aResult.lac, aResult.cid); |
|
41 |
|
42 return Promise.resolve() |
|
43 .then(() => testVoiceCellLocationUpdate(100, 100)) |
|
44 .then(() => testVoiceCellLocationUpdate(2000, 2000)) |
|
45 |
|
46 // Reset back to initial values. |
|
47 .then(() => testVoiceCellLocationUpdate(aResult.lac, aResult.cid)); |
|
48 }); |
|
49 }); |