Bug 785988 - Part 2: test scripts, r=marshall_law

This commit is contained in:
Vicamo Yang 2012-09-11 12:23:12 +08:00
Родитель d07c88bd66
Коммит ed8da5c11e
2 изменённых файлов: 82 добавлений и 11 удалений

Просмотреть файл

@ -1,15 +1,9 @@
[DEFAULT]
b2g = true
browser = false
qemu = true
[test_mobile_networks.js]
b2g = true
browser = false
qemu = true
[test_mobile_voice_state.js]
b2g = true
browser = false
qemu = true
[test_mobile_iccinfo.js]
b2g = true
browser = false
qemu = true
[test_mobile_operator_names.js]

Просмотреть файл

@ -0,0 +1,77 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
SpecialPowers.addPermission("mobileconnection", true, document);
let connection = navigator.mozMobileConnection;
ok(connection instanceof MozMobileConnection,
"connection is instanceof " + connection.constructor);
let voice = connection.voice;
ok(voice, "voice connection valid");
let network = voice.network;
ok(network, "voice network info valid");
let emulatorCmdPendingCount = 0;
function setEmulatorOperatorNames(longName, shortName) {
emulatorCmdPendingCount++;
let cmd = "operator set 0 " + longName + "," + shortName;
runEmulatorCmd(cmd, function (result) {
emulatorCmdPendingCount--;
let re = new RegExp("^" + longName + "," + shortName + ",");
ok(result[0].match(re), "Long/short name should be changed.");
});
}
function checkValidMccMnc() {
is(network.mcc, 310, "network.mcc");
is(network.mnc, 260, "network.mnc");
}
function doTestMobileOperatorNames(longName, shortName, callback) {
log("Testing '" + longName + "', '" + shortName + "':");
checkValidMccMnc();
connection.addEventListener("voicechange", function onvoicechange() {
connection.removeEventListener("voicechange", onvoicechange);
is(network.longName, longName, "network.longName");
is(network.shortName, shortName, "network.shortName");
checkValidMccMnc();
setTimeout(callback, 0);
});
setEmulatorOperatorNames(longName, shortName);
}
function testMobileOperatorNames() {
doTestMobileOperatorNames("Mozilla", "B2G", function () {
doTestMobileOperatorNames("Mozilla", "", function () {
doTestMobileOperatorNames("", "B2G", function () {
doTestMobileOperatorNames("", "", function () {
doTestMobileOperatorNames("Android", "Android", cleanUp);
});
});
});
});
}
function cleanUp() {
if (emulatorCmdPendingCount > 0) {
setTimeout(cleanUp, 100);
return;
}
SpecialPowers.removePermission("mobileconnection", document);
finish();
}
testMobileOperatorNames();