Bug 899484 - Part 2: Add marionette tests for roaming preference. r=hsinyi

This commit is contained in:
Edgar Chen 2013-07-30 17:18:24 +08:00
parent 431a6df64d
commit 0c54840e85
2 changed files with 99 additions and 0 deletions

View File

@ -13,5 +13,6 @@ disabled = Bug 808783
[test_mobile_data_location.js]
[test_mobile_data_state.js]
[test_mobile_mmi.js]
[test_mobile_roaming_preference.js]
[test_call_barring_get_option.js]
[test_call_barring_set_error.js]

View File

@ -0,0 +1,98 @@
/* 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);
function failedToSetRoamingPreference(mode, expectedErrorMessage, callback) {
let request = connection.setRoamingPreference(mode);
ok(request instanceof DOMRequest,
"request instanceof " + request.constructor);
request.onsuccess = function onsuccess() {
ok(false, "Should not be here !!");
callback();
}
request.onerror = function onerror() {
is(request.error.name, expectedErrorMessage);
callback();
}
}
function testSetRoamingPreferenceWithNullValue() {
log("test setRoamingPreference(null)");
failedToSetRoamingPreference(null, "InvalidParameter", runNextTest);
}
function testSetRoamingPreferenceWithInvalidValue() {
log("test setRoamingPreference(\"InvalidValue\")");
failedToSetRoamingPreference("InvalidValue", "InvalidParameter", runNextTest);
}
function testSetRoamingPreferenceToHome() {
log("test setRoamingPreference(\"home\")");
// TODO: Bug 896394.
// Currently emulator run as GSM mode by default. So we expect to get a
// 'RequestNotSupported' error here.
failedToSetRoamingPreference("home", "RequestNotSupported", runNextTest);
}
function testGetRoamingPreference() {
log("test getRoamingPreference()");
// TODO: Bug 896394.
// Currently emulator run as GSM mode by default. So we expect to get a
// 'RequestNotSupported' error here.
let request = connection.getRoamingPreference();
ok(request instanceof DOMRequest,
"request instanceof " + request.constructor);
request.onsuccess = function onsuccess() {
ok(false, "Should not be here !!");
runNextTest();
}
request.onerror = function onerror() {
is(request.error.name, "RequestNotSupported");
runNextTest();
}
}
let tests = [
testSetRoamingPreferenceWithNullValue,
testSetRoamingPreferenceWithInvalidValue,
testSetRoamingPreferenceToHome,
testGetRoamingPreference
];
function runNextTest() {
let test = tests.shift();
if (!test) {
cleanUp();
return;
}
test();
}
function cleanUp() {
SpecialPowers.removePermission("mobileconnection", document);
finish();
}
runNextTest();