Bug 1070831 - Part 7: Update related testcases. r=aknow

This commit is contained in:
Ben Hsu 2014-12-21 17:38:00 +01:00
Родитель 42d775afda
Коммит 8f62417347
6 изменённых файлов: 0 добавлений и 309 удалений

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

@ -14,10 +14,6 @@ qemu = true
[test_mobile_data_connection.js]
[test_mobile_data_location.js]
[test_mobile_data_state.js]
[test_mobile_mmi.js]
[test_mobile_mmi_change_pin.js]
[test_mobile_mmi_call_forwarding.js]
[test_mobile_mmi_unlock_puk.js]
[test_mobile_roaming_preference.js]
[test_call_barring_get_option.js]
[test_call_barring_set_error.js]

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

@ -1,46 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testGettingIMEI() {
log("Test *#06# ...");
let MMI_CODE = "*#06#";
return sendMMI(MMI_CODE)
.then(function resolve(aResult) {
ok(true, MMI_CODE + " success");
is(aResult.serviceCode, "scImei", "Service code IMEI");
// IMEI is hardcoded as "000000000000000".
// See it here {B2G_HOME}/external/qemu/telephony/android_modem.c
// (The result of +CGSN).
is(aResult.statusMessage, "000000000000000", "Emulator IMEI");
is(aResult.additionalInformation, undefined, "No additional information");
}, function reject() {
ok(false, MMI_CODE + " should not fail");
});
}
function testInvalidMMICode() {
log("Test invalid MMI code ...");
let MMI_CODE = "InvalidMMICode";
return sendMMI(MMI_CODE)
.then(function resolve() {
ok(false, MMI_CODE + " should not success");
}, function reject(aError) {
ok(true, MMI_CODE + " fail");
is(aError.name, "emMmiError", "MMI error name");
is(aError.message, "", "No message");
is(aError.serviceCode, "scUssd", "Service code USSD");
is(aError.additionalInformation, null, "No additional information");
});
}
// Start test
startTestCommon(function() {
return Promise.resolve()
.then(() => testGettingIMEI())
.then(() => testInvalidMMICode());
});

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

@ -1,144 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
const TEST_DATA = [
{
reason: MozMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL,
number: "+886912345678",
serviceClass: MozMobileConnection.ICC_SERVICE_CLASS_VOICE,
timeSeconds: 5
}, {
reason: MozMobileConnection.CALL_FORWARD_REASON_MOBILE_BUSY,
number: "0912345678",
serviceClass: MozMobileConnection.ICC_SERVICE_CLASS_VOICE,
timeSeconds: 10
}, {
reason: MozMobileConnection.CALL_FORWARD_REASON_NO_REPLY,
number: "+886987654321",
serviceClass: MozMobileConnection.ICC_SERVICE_CLASS_VOICE,
timeSeconds: 15
}, {
reason: MozMobileConnection.CALL_FORWARD_REASON_NOT_REACHABLE,
number: "+0987654321",
serviceClass: MozMobileConnection.ICC_SERVICE_CLASS_VOICE,
timeSeconds: 20
}
];
// Please see TS 22.030 Annex B
const CF_REASON_TO_MMI = {
/* CALL_FORWARD_REASON_UNCONDITIONAL */
0: "21",
/* CALL_FORWARD_REASON_MOBILE_BUSY */
1: "67",
/* CALL_FORWARD_REASON_NO_REPLY */
2: "61",
/* CALL_FORWARD_REASON_NOT_REACHABLE */
3: "62",
/* CALL_FORWARD_REASON_ALL_CALL_FORWARDING */
4: "002",
/* CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING */
5: "004"
};
// Please see TS 22.030 Annex C
const SERVICE_CLASS_TO_MMI = {
/* ICC_SERVICE_CLASS_VOICE */
1: "11"
};
function testSetCallForwarding(aData) {
// Registration: **SC*SIA*SIB*SIC#
let MMI_CODE = "**" + CF_REASON_TO_MMI[aData.reason] + "*" + aData.number +
"*" + SERVICE_CLASS_TO_MMI[aData.serviceClass] +
"*" + aData.timeSeconds + "#";
log("Test " + MMI_CODE);
let promises = [];
// Check cfstatechange event.
promises.push(waitForManagerEvent("cfstatechange").then(function(aEvent) {
is(aEvent.action, MozMobileConnection.CALL_FORWARD_ACTION_REGISTRATION,
"check action");
is(aEvent.reason, aData.reason, "check reason");
is(aEvent.number, aData.number, "check number");
is(aEvent.timeSeconds, aData.timeSeconds, "check timeSeconds");
is(aEvent.serviceClass, aData.serviceClass, "check serviceClass");
}));
// Check DOMRequest's result.
promises.push(sendMMI(MMI_CODE)
.then(function resolve(aResult) {
is(aResult.serviceCode, "scCallForwarding", "Check service code");
is(aResult.statusMessage, "smServiceRegistered", "Check status message");
is(aResult.additionalInformation, undefined, "Check additional information");
}, function reject(aError) {
ok(false, "got '" + aError.name + "' error");
}));
return Promise.all(promises);
}
function testGetCallForwarding(aExpectedData) {
// Interrogation: *#SC#
let MMI_CODE = "*#" + CF_REASON_TO_MMI[aExpectedData.reason] + "#";
log("Test " + MMI_CODE);
return sendMMI(MMI_CODE)
.then(function resolve(aResult) {
is(aResult.serviceCode, "scCallForwarding", "Check service code");
is(aResult.statusMessage, "smServiceInterrogated", "Check status message");
is(Array.isArray(aResult.additionalInformation), true,
"additionalInformation should be an array");
for (let i = 0; i < aResult.additionalInformation.length; i++) {
let result = aResult.additionalInformation[i];
// Only need to check the result containing the serviceClass that we are
// interested in.
if (!(result.serviceClass & aExpectedData.serviceClass)) {
continue;
}
is(result.active, true, "check active");
is(result.reason, aExpectedData.reason, "check reason");
is(result.number, aExpectedData.number, "check number");
is(result.timeSeconds, aExpectedData.timeSeconds, "check timeSeconds");
}
}, function reject(aError) {
ok(false, MMI_CODE + " got error: " + aError.name);
});
}
function clearAllCallForwardingSettings() {
log("Clear all call forwarding settings");
let promise = Promise.resolve();
for (let reason = MozMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL;
reason <= MozMobileConnection.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING;
reason++) {
let options = {
reason: reason,
action: MozMobileConnection.CALL_FORWARD_ACTION_ERASURE
};
// Emulator doesn't support CALL_FORWARD_REASON_ALL_* yet, we catch the
// reject here in order to avoid impact the test result.
promise =
promise.then(() => setCallForwardingOption(options).then(null, () => {}));
}
return promise;
}
// Start tests
startTestCommon(function() {
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
let data = TEST_DATA[i];
promise = promise.then(() => testSetCallForwarding(data))
.then(() => testGetCallForwarding(data));
}
// reset call forwarding settings.
return promise.then(null, () => { ok(false, "promise reject during test"); })
.then(() => clearAllCallForwardingSettings());
});

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

@ -1,111 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
// PIN is hardcoded as "0000" by default.
// See it here {B2G_HOME}/external/qemu/telephony/sim_card.c,
// in asimcard_create().
const TEST_DATA = [
// Test passing no pin.
{
pin: "",
newPin: "0000",
newPinAgain: "1111",
expectedError: {
name: "emMmiError",
additionalInformation: null
}
},
// Test passing no newPin.
{
pin: "0000",
newPin: "",
newPinAgain: "",
expectedError: {
name: "emMmiError",
additionalInformation: null
}
},
// Test passing mismatched newPin.
{
pin: "0000",
newPin: "0000",
newPinAgain: "1111",
expectedError: {
name: "emMmiErrorMismatchPin",
additionalInformation: null
}
},
// Test passing invalid pin (< 4 digit).
{
pin: "000",
newPin: "0000",
newPinAgain: "0000",
expectedError: {
name: "emMmiErrorInvalidPin",
additionalInformation: null
}
},
// Test passing invalid newPin (> 8 digit).
{
pin: "0000",
newPin: "000000000",
newPinAgain: "000000000",
expectedError: {
name: "emMmiErrorInvalidPin",
additionalInformation: null
}
},
// Test passing incorrect pin.
{
pin: "1234",
newPin: "0000",
newPinAgain: "0000",
expectedError: {
name: "emMmiErrorBadPin",
// The default pin retries is 3, failed once becomes to 2
additionalInformation: 2
}
},
// Test changing pin successfully (Reset the retries).
{
pin: "0000",
newPin: "0000",
newPinAgain: "0000"
}
];
function testChangePin(aPin, aNewPin, aNewPinAgain, aExpectedError) {
let MMI_CODE = "**04*" + aPin + "*" + aNewPin + "*" + aNewPinAgain + "#";
log("Test " + MMI_CODE);
return sendMMI(MMI_CODE)
.then(function resolve(aResult) {
ok(!aExpectedError, MMI_CODE + " success");
is(aResult.serviceCode, "scPin", "Check service code");
is(aResult.statusMessage, "smPinChanged", "Check status message");
is(aResult.additionalInformation, undefined, "Check additional information");
}, function reject(aError) {
ok(aExpectedError, MMI_CODE + " fail");
is(aError.name, aExpectedError.name, "Check name");
is(aError.message, "", "Check message");
is(aError.serviceCode, "scPin", "Check service code");
is(aError.additionalInformation, aExpectedError.additionalInformation,
"Chech additional information");
});
}
// Start test
startTestCommon(function() {
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
let data = TEST_DATA[i];
promise = promise.then(() => testChangePin(data.pin,
data.newPin,
data.newPinAgain,
data.expectedError));
}
return promise;
});

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

@ -49,8 +49,6 @@ if (!SpecialPowers.hasPermission("mobileconnection", document)) {
is("getRoamingPreference" in mobileConnection, true, "getRoamingPreference");
is("setVoicePrivacyMode" in mobileConnection, true, "setVoicePrivacyMode");
is("getVoicePrivacyMode" in mobileConnection, true, "getVoicePrivacyMode");
is("sendMMI" in mobileConnection, true, "sendMMI");
is("cancelMMI" in mobileConnection, true, "cancelMMI");
is("setCallForwardingOption" in mobileConnection, true, "setCallForwardingOption");
is("getCallForwardingOption" in mobileConnection, true, "getCallForwardingOption");
is("setCallBarringOption" in mobileConnection, true, "setCallBarringOption");

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

@ -49,8 +49,6 @@ if (!SpecialPowers.hasPermission("mobilenetwork", document)) {
is("getRoamingPreference" in mobileConnection, false, "getRoamingPreference");
is("setVoicePrivacyMode" in mobileConnection, false, "setVoicePrivacyMode");
is("getVoicePrivacyMode" in mobileConnection, false, "getVoicePrivacyMode");
is("sendMMI" in mobileConnection, false, "sendMMI");
is("cancelMMI" in mobileConnection, false, "cancelMMI");
is("setCallForwardingOption" in mobileConnection, false, "setCallForwardingOption");
is("getCallForwardingOption" in mobileConnection, false, "getCallForwardingOption");
is("setCallBarringOption" in mobileConnection, false, "setCallBarringOption");