author | Rob Wood <rwood@mozilla.com> |
Thu, 13 Dec 2012 11:38:24 -0800 | |
changeset 116306 | 2e70b718903a88355c10e2dafa32ca746ba2e9fe |
parent 116305 | 88dbe374066502e824c1840f0de3353734317a34 |
child 116307 | e18421c16c7a14b559638429c5119da3d3d7aed0 |
push id | 24045 |
push user | ryanvm@gmail.com |
push date | Tue, 18 Dec 2012 00:23:36 +0000 |
treeherder | mozilla-central@2e70b718903a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgriffin |
bugs | 811580 |
milestone | 20.0a1 |
first release with | nightly linux32
2e70b718903a
/
20.0a1
/
20121218030803
/
files
nightly linux64
2e70b718903a
/
20.0a1
/
20121218030803
/
files
nightly mac
2e70b718903a
/
20.0a1
/
20121218030803
/
files
nightly win32
2e70b718903a
/
20.0a1
/
20121218030803
/
files
nightly win64
2e70b718903a
/
20.0a1
/
20121218030803
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
20.0a1
/
20121218030803
/
pushlog to previous
nightly linux64
20.0a1
/
20121218030803
/
pushlog to previous
nightly mac
20.0a1
/
20121218030803
/
pushlog to previous
nightly win32
20.0a1
/
20121218030803
/
pushlog to previous
nightly win64
20.0a1
/
20121218030803
/
pushlog to previous
|
--- a/dom/network/tests/marionette/manifest.ini +++ b/dom/network/tests/marionette/manifest.ini @@ -5,8 +5,10 @@ qemu = true [test_mobile_networks.js] disabled = Bug 808783 [test_mobile_voice_state.js] [test_mobile_iccinfo.js] [test_mobile_operator_names.js] [test_mobile_preferred_network_type.js] disabled = Bug 808783 +[test_mobile_data_location.js] +[test_mobile_data_state.js]
new file mode 100644 --- /dev/null +++ b/dom/network/tests/marionette/test_mobile_data_location.js @@ -0,0 +1,119 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 20000; + +SpecialPowers.addPermission("mobileconnection", true, document); + +let mobileConnection = navigator.mozMobileConnection; +let emulatorStartLac = 0; +let emulatorStartCid = 0; + +function verifyInitialState() { + log("Verifying initial state."); + ok(mobileConnection instanceof MozMobileConnection, + "mobileConnection is instanceof " + mobileConnection.constructor); + testStartingCellLocation(); +} + +function testStartingCellLocation() { + // Get the current emulator data cell location + log("Getting the starting GSM location from the emulator."); + + runEmulatorCmd("gsm location", function(result) { + log("Emulator callback."); + is(result[0].substring(0,3), "lac", "lac output"); + is(result[1].substring(0,2), "ci", "ci output"); + is(result[2], "OK", "emulator ok"); + + emulatorStartLac = result[0].substring(5); + log("Emulator GSM location LAC is '" + emulatorStartLac + "'."); + emulatorStartCid = result[1].substring(4); + log("Emulator GSM location CID is '" + emulatorStartCid + "'."); + + log("mobileConnection.data.cell.gsmLocationAreaCode is '" + + mobileConnection.data.cell.gsmLocationAreaCode + "'."); + log("mobileConnection.data.cell.gsmCellId is '" + + mobileConnection.data.cell.gsmCellId + "'."); + + // Verify the mobileConnection.data.cell location matches emulator values + if (emulatorStartLac == -1) { + // Emulator initializes LAC to -1, corresponds to these values + is(mobileConnection.data.cell.gsmLocationAreaCode, + 65535, "starting LAC"); + } else { + // A previous test changed the LAC, so verify API matches emulator + is(mobileConnection.data.cell.gsmLocationAreaCode, + emulatorStartLac, "starting LAC"); + } + if (emulatorStartCid == -1) { + // Emulator initializes CID to -1, corresponds to these values + is(mobileConnection.data.cell.gsmCellId, 268435455, "starting CID"); + } else { + // A previous test changed the CID, so verify API matches emulator + is(mobileConnection.data.cell.gsmCellId, + emulatorStartCid, "starting CID"); + } + + // Now test changing the GSM location + testChangeCellLocation(emulatorStartLac, emulatorStartCid); + }); +} + +function testChangeCellLocation() { + // Change emulator GSM location and verify mobileConnection.data.cell values + let newLac = 1000; + let newCid = 2000; + let gotCallback = false; + + // Ensure values will actually be changed + if (newLac == emulatorStartLac) { newLac++; }; + if (newCid == emulatorStartCid) { newCid++; }; + + // Setup 'ondatachange' event listener + mobileConnection.addEventListener("datachange", function ondatachange() { + mobileConnection.removeEventListener("datachange", ondatachange); + log("Received 'ondatachange' event."); + log("mobileConnection.data.cell.gsmLocationAreaCode is now '" + + mobileConnection.data.cell.gsmLocationAreaCode + "'."); + log("mobileConnection.data.cell.gsmCellId is now '" + + mobileConnection.data.cell.gsmCellId + "'."); + is(mobileConnection.data.cell.gsmLocationAreaCode, newLac, + "data.cell.gsmLocationAreaCode"); + is(mobileConnection.data.cell.gsmCellId, newCid, "data.cell.gsmCellId"); + waitFor(restoreLocation, function() { + return(gotCallback); + }); + }); + + // Use emulator command to change GSM location + log("Changing emulator GSM location to '" + newLac + ", " + newCid + + "' and waiting for 'ondatachange' event."); + gotCallback = false; + runEmulatorCmd("gsm location " + newLac + " " + newCid, function(result) { + is(result[0], "OK"); + log("Emulator callback on location change."); + gotCallback = true; + }); +} + +function restoreLocation() { + // Restore the emulator GSM location back to what it was originally + log("Restoring emulator GSM location back to '" + emulatorStartLac + ", " + + emulatorStartCid + "'."); + runEmulatorCmd("gsm location " + emulatorStartLac + " " + emulatorStartCid, + function(result) { + log("Emulator callback on restore."); + is(result[0], "OK"); + cleanUp(); + }); +} + +function cleanUp() { + mobileConnection.ondatachange = null; + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +// Start the test +verifyInitialState();
new file mode 100644 --- /dev/null +++ b/dom/network/tests/marionette/test_mobile_data_state.js @@ -0,0 +1,121 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 30000; + +SpecialPowers.addPermission("mobileconnection", true, document); + +let mobileConnection = navigator.mozMobileConnection; + +function verifyInitialState() { + log("Verifying initial state."); + ok(mobileConnection instanceof MozMobileConnection, + "mobileConnection is instanceof " + mobileConnection.constructor); + // Want to start test with mobileConnection.data.state 'registered' + // This is the default state; if it is not currently this value then set it + log("Starting mobileConnection.data.state is: '" + + mobileConnection.data.state + "'."); + if (mobileConnection.data.state != "registered") { + changeDataStateAndVerify("home", "registered", testUnregistered); + } else { + testUnregistered(); + } +} + +function changeDataStateAndVerify(dataState, expected, nextFunction) { + let gotCallback = false; + + // Change the mobileConnection.data.state via 'gsm data' command + log("Changing emulator data state to '" + dataState + + "' and waiting for 'ondatachange' event."); + + // Setup 'ondatachange' event handler + mobileConnection.addEventListener("datachange", function ondatachange() { + mobileConnection.removeEventListener("datachange", ondatachange); + log("Received 'ondatachange' event."); + log("mobileConnection.data.state is now '" + + mobileConnection.data.state + "'."); + is(mobileConnection.data.state, expected, "data.state"); + waitFor(nextFunction, function() { + return(gotCallback); + }); + }); + + // Change the emulator data state + gotCallback = false; + runEmulatorCmd("gsm data " + dataState, function(result) { + is(result[0], "OK"); + log("Emulator callback complete."); + gotCallback = true; + }); +} + +function testUnregistered() { + log("Test 1: Unregistered."); + // Set emulator data state to 'unregistered' and verify + // Expect mobileConnection.data.state to be 'notsearching' + changeDataStateAndVerify("unregistered", "notSearching", testRoaming); +} + +function testRoaming() { + log("Test 2: Roaming."); + // Set emulator data state to 'roaming' and verify + // Expect mobileConnection.data.state to be 'registered' + changeDataStateAndVerify("roaming", "registered", testOff); +} + +function testOff() { + log("Test 3: Off."); + // Set emulator data state to 'off' and verify + // Expect mobileConnection.data.state to be 'notsearching' + changeDataStateAndVerify("off", "notSearching", testSearching); +} + +function testSearching() { + log("Test 4: Searching."); + // Set emulator data state to 'searching' and verify + + // Bug 819533: WebMobileConnection data/voice state incorrect when emulator + // data state is 'searching'. So until fixed, expect 'registered'. + + // changeDataStateAndVerify("searching", "searching", testDenied); + log("* When Bug 819533 is fixed, change this test to expect 'searching' *"); + changeDataStateAndVerify("searching", "registered", testDenied); +} + +function testDenied() { + log("Test 5: Denied."); + // Set emulator data state to 'denied' and verify + // Expect mobileConnection.data.state to be 'denied' + changeDataStateAndVerify("denied", "denied", testOn); +} + +function testOn() { + log("Test 6: On."); + // Set emulator data state to 'on' and verify + // Expect mobileConnection.data.state to be 'registered' + changeDataStateAndVerify("on", "registered", testOffAgain); +} + +function testOffAgain() { + log("Test 7: Off again."); + // Set emulator data state to 'off' and verify + // Expect mobileConnection.data.state to be 'notsearching' + changeDataStateAndVerify("off", "notSearching", testHome); +} + +function testHome() { + log("Test 8: Home."); + // Set emulator data state to 'home' and verify + // Expect mobileConnection.data.state to be 'registered' + changeDataStateAndVerify("home", "registered", cleanUp); +} + +function cleanUp() { + mobileConnection.ondatachange = null; + SpecialPowers.removePermission("mobileconnection", document); + finish(); +} + +// Start the test +verifyInitialState();