Bug 1187832 - Update ril_worker and corresponding test cases. r=btseng

This commit is contained in:
Samael Wang 2015-08-04 13:58:42 +08:00
parent 4af5732933
commit 4ec7d5a754
6 changed files with 195 additions and 42 deletions

View File

@ -17,13 +17,11 @@ const TEST_DATA = [
"82028183" + // Device identities
"AC052143658709", // DTMF string
expect: {commandQualifier: 0x00}},
{command: "D013" + // Length
{command: "D011" + // Length
"8103011400" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"AC06C1CCCCCCCC2C", // DTMF string
expect: {commandQualifier: 0x00,
text: ""}},
expect: {commandQualifier: 0x00}},
{command: "D01D" + // Length
"8103011400" + // Command details
"82028183" + // Device identities
@ -66,7 +64,14 @@ const TEST_DATA = [
text: "你好"}},
];
function testSendDTMF(aCommand, aExpect) {
const TEST_CMD_NULL_ALPHA_ID =
"D013" + // Length
"8103011400" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"AC06C1CCCCCCCC2C";
function verifySendDTMF(aCommand, aExpect) {
is(aCommand.commandNumber, 0x01, "commandNumber");
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_DTMF, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
@ -84,8 +89,7 @@ function testSendDTMF(aCommand, aExpect) {
}
}
// Start tests
startTestCommon(function() {
function testSendDTMF() {
let icc = getMozIcc();
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
@ -96,12 +100,12 @@ startTestCommon(function() {
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendDTMF(aEvent.command, data.expect)));
.then((aEvent) => verifySendDTMF(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendDTMF(aMessage.command, data.expect);
verifySendDTMF(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
@ -110,4 +114,32 @@ startTestCommon(function() {
});
}
return promise;
}
function testSendDTMFNullAlphaId() {
let icc = getMozIcc();
// No "stkcommand" event should occur.
icc.addEventListener("stkcommand",
(event) => ok(false, event + " should not occur."));
// No "icc-stkcommand" system message should be sent.
workingFrame.contentWindow.navigator.mozSetMessageHandler("icc-stkcommand",
(msg) => ok(false, msg + " should not be sent."));
// If nothing happens within 3 seconds after the emulator command sent,
// treat as success.
log("send_dtmf_cmd: " + TEST_CMD_NULL_ALPHA_ID);
return sendEmulatorStkPdu(TEST_CMD_NULL_ALPHA_ID)
.then(() => new Promise(function(resolve, reject) {
setTimeout(() => resolve(), 3000);
}));
}
// Start tests
startTestCommon(function() {
return Promise.resolve()
.then(() => testSendDTMF())
.then(() => testSendDTMFNullAlphaId());
});

View File

@ -71,14 +71,12 @@ const TEST_DATA = [
"message, where the user data can be passed transparently; " +
"- A short message to be sent to the network in an " +
"SMS-SUBMIT "}},
{command: "D030" + // Length
{command: "D02E" + // Length
"8103011300" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"86099111223344556677F8" + // Address
"8B180100099110325476F840F40C54657374204D657373616765", // 3GPP-SMS TPDU
expect: {commandQualifier: 0x00,
text: ""}},
expect: {commandQualifier: 0x00}},
{command: "D055" + // Length
"8103011300" + // Command details
"82028183" + // Device identities
@ -160,7 +158,15 @@ const TEST_DATA = [
text: "82ル2"}},
];
function testSendSMS(aCommand, aExpect) {
const TEST_CMD_NULL_ALPHA_ID =
"D030" + // Length
"8103011300" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"86099111223344556677F8" + // Address
"8B180100099110325476F840F40C54657374204D657373616765"; // 3GPP-SMS TPDU
function verifySendSMS(aCommand, aExpect) {
is(aCommand.commandNumber, 0x01, "commandNumber");
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SMS, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
@ -178,8 +184,8 @@ function testSendSMS(aCommand, aExpect) {
}
}
// Start tests
startTestCommon(function() {
// Test normal cases of send SMS proactive command
function testSendSMS() {
let icc = getMozIcc();
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
@ -190,12 +196,12 @@ startTestCommon(function() {
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSMS(aEvent.command, data.expect)));
.then((aEvent) => verifySendSMS(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendSMS(aMessage.command, data.expect);
verifySendSMS(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
@ -204,4 +210,31 @@ startTestCommon(function() {
});
}
return promise;
}
function testSendSMSNullAlphaId() {
let icc = getMozIcc();
// No "stkcommand" event should occur.
icc.addEventListener("stkcommand",
(event) => ok(false, event + " should not occur."));
// No "icc-stkcommand" system message should be sent.
workingFrame.contentWindow.navigator.mozSetMessageHandler("icc-stkcommand",
(msg) => ok(false, msg + " should not be sent."));
// If nothing happens within 3 seconds after the emulator command sent,
// treat as success.
log("send_sms_cmd: " + TEST_CMD_NULL_ALPHA_ID);
return sendEmulatorStkPdu(TEST_CMD_NULL_ALPHA_ID)
.then(() => new Promise(function(resolve, reject) {
setTimeout(() => resolve(), 3000);
}));
}
// Start tests
startTestCommon(function() {
return Promise.resolve()
.then(() => testSendSMS())
.then(() => testSendSMSNullAlphaId());
});

View File

@ -39,13 +39,11 @@ const TEST_DATA = [
"SEND SS proactive command shall not be checked against " +
"those of the FDN list. Upon receiving this command, the " +
"ME shall deci"}},
{command: "D01D" + // Length
{command: "D01B" + // Length
"8103011100" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"891091AA120A214365870921436587A901FB", // SS string
expect: {commandQualifier: 0x00,
text: ""}},
expect: {commandQualifier: 0x00}},
{command: "D02B" + // Length
"8103011100" + // Command details
"82028183" + // Device identities
@ -88,7 +86,14 @@ const TEST_DATA = [
text: "你好"}},
];
function testSendSS(aCommand, aExpect) {
const TEST_CMD_NULL_ALPHA_ID =
"D01D" + // Length
"8103011100" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"891091AA120A214365870921436587A901FB"; // SS string
function verifySendSS(aCommand, aExpect) {
is(aCommand.commandNumber, 0x01, "commandNumber");
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SS, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
@ -106,8 +111,7 @@ function testSendSS(aCommand, aExpect) {
}
}
// Start tests
startTestCommon(function() {
function testSendSS() {
let icc = getMozIcc();
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
@ -118,12 +122,12 @@ startTestCommon(function() {
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSS(aEvent.command, data.expect)));
.then((aEvent) => verifySendSS(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendSS(aMessage.command, data.expect);
verifySendSS(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
@ -132,4 +136,31 @@ startTestCommon(function() {
});
}
return promise;
}
function testSendSSNullAlphaId() {
let icc = getMozIcc();
// No "stkcommand" event should occur.
icc.addEventListener("stkcommand",
(event) => ok(false, event + " should not occur."));
// No "icc-stkcommand" system message should be sent.
workingFrame.contentWindow.navigator.mozSetMessageHandler("icc-stkcommand",
(msg) => ok(false, msg + " should not be sent."));
// If nothing happens within 3 seconds after the emulator command sent,
// treat as success.
log("send_ss_cmd: " + TEST_CMD_NULL_ALPHA_ID);
return sendEmulatorStkPdu(TEST_CMD_NULL_ALPHA_ID)
.then(() => new Promise(function(resolve, reject) {
setTimeout(() => resolve(), 3000);
}));
}
// Start tests
startTestCommon(function() {
return Promise.resolve()
.then(() => testSendSS())
.then(() => testSendSSNullAlphaId());
});

View File

@ -57,15 +57,13 @@ const TEST_DATA = [
"Return Result message not containing an error has been " +
"received from the network, the ME shall inform the SIM " +
"that the command has"}},
{command: "D046" + // Length
{command: "D044" + // Length
"8103011200" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
"B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
"3B3EAF6FC564335ACD76C3E560",
expect: {commandQualifier: 0x00,
text: ""}},
expect: {commandQualifier: 0x00}},
{command: "D054" + // Length
"8103011200" + // Command details
"82028183" + // Device identities
@ -126,7 +124,16 @@ const TEST_DATA = [
text: "你好"}},
];
function testSendUSSD(aCommand, aExpect) {
const TEST_CMD_NULL_ALPHA_ID =
"D046" + // Length
"8103011200" + // Command details
"82028183" + // Device identities
"8500" + // Alpha identifier
"8A39F041E19058341E9149E592D9743EA151E9945AB55E" + // USSD string
"B1596D2B2C1E93CBE6333AAD5EB3DBEE373C2E9FD3EBF6" +
"3B3EAF6FC564335ACD76C3E560";
function verifySendUSSD(aCommand, aExpect) {
is(aCommand.commandNumber, 0x01, "commandNumber");
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_USSD, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
@ -144,8 +151,7 @@ function testSendUSSD(aCommand, aExpect) {
}
}
// Start tests
startTestCommon(function() {
function testSendUSSD() {
let icc = getMozIcc();
let promise = Promise.resolve();
for (let i = 0; i < TEST_DATA.length; i++) {
@ -156,12 +162,12 @@ startTestCommon(function() {
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendUSSD(aEvent.command, data.expect)));
.then((aEvent) => verifySendUSSD(aEvent.command, data.expect)));
// Wait icc-stkcommand system message.
promises.push(waitForSystemMessage("icc-stkcommand")
.then((aMessage) => {
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
testSendUSSD(aMessage.command, data.expect);
verifySendUSSD(aMessage.command, data.expect);
}));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
@ -170,4 +176,31 @@ startTestCommon(function() {
});
}
return promise;
}
function testSendUSSDNullAlphaId() {
let icc = getMozIcc();
// No "stkcommand" event should occur.
icc.addEventListener("stkcommand",
(event) => ok(false, event + " should not occur."));
// No "icc-stkcommand" system message should be sent.
workingFrame.contentWindow.navigator.mozSetMessageHandler("icc-stkcommand",
(msg) => ok(false, msg + " should not be sent."));
// If nothing happens within 3 seconds after the emulator command sent,
// treat as success.
log("send_ussd_cmd: " + TEST_CMD_NULL_ALPHA_ID);
return sendEmulatorStkPdu(TEST_CMD_NULL_ALPHA_ID)
.then(() => new Promise(function(resolve, reject) {
setTimeout(() => resolve(), 3000);
}));
}
// Start tests
startTestCommon(function() {
return Promise.resolve()
.then(() => testSendUSSD())
.then(() => testSendUSSDNullAlphaId());
});

View File

@ -9677,10 +9677,24 @@ StkCommandParamsFactoryObject.prototype = {
textMsg.text = ctlv.value.identifier;
}
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
textMsg,
onComplete);
// According to section 6.4.10 of |ETSI TS 102 223|:
//
// - if the alpha identifier is provided by the UICC and is a null data
// object (i.e. length = '00' and no value part), this is an indication
// that the terminal should not give any information to the user on the
// fact that the terminal is sending a short message;
//
// - if the alpha identifier is not provided by the UICC, the terminal may
// give information to the user concerning what is happening.
//
// ICCPDUHelper reads alpha id as an empty string if the length is zero,
// hence we'll notify the caller when it's not an empty string.
if (textMsg.text !== "") {
// Icon identifier is optional.
this.appendIconIfNecessary(selectedCtlvs[COMPREHENSIONTLV_TAG_ICON_ID] || null,
textMsg,
onComplete);
}
},
/**

View File

@ -751,12 +751,13 @@ add_test(function test_stk_proactive_command_search_for_selected_tags() {
let tag_test = [
0xD0,
0x3C,
0x3E,
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x31,
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x32,
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x33,
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x34,
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x35];
0x85, 0x0A, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x20, 0x69, 0x64, 0x20, 0x35,
0x85, 0x00];
for (let i = 0; i < tag_test.length; i++) {
pduHelper.writeHexOctet(tag_test[i]);
@ -780,6 +781,15 @@ add_test(function test_stk_proactive_command_search_for_selected_tags() {
tlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
equal(tlv.value.identifier, "alpha id 5");
// emulate that the alpha identifier is provided and is a null data object,
// which is converted to an empty string in ICCPDUHelper.
tlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
strictEqual(tlv.value.identifier, "");
// emulate that the alpha identifier is not provided
tlv = selectedCtlvs.retrieve(COMPREHENSIONTLV_TAG_ALPHA_ID);
strictEqual(tlv, undefined);
run_next_test();
});