2013-02-08 08:03:36 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
2014-11-06 07:09:56 +03:00
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
2013-02-08 08:03:36 +04:00
|
|
|
|
2014-11-06 07:09:56 +03:00
|
|
|
MARIONETTE_TIMEOUT = 60000;
|
|
|
|
MARIONETTE_HEAD_JS = "head.js";
|
2013-02-08 08:03:36 +04:00
|
|
|
|
2014-11-06 07:09:56 +03:00
|
|
|
const TEST_DATA = [
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D01B" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"850953656E642044544D46" + // Alpha identifier
|
|
|
|
"AC052143658709", // DTMF string
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2013-02-08 08:03:36 +04:00
|
|
|
text: "Send DTMF"}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D010" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"AC052143658709", // DTMF string
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D013" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"8500" + // Alpha identifier
|
|
|
|
"AC06C1CCCCCCCC2C", // DTMF string
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2013-02-08 08:03:36 +04:00
|
|
|
text: ""}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D01D" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"850A42617369632049636F6E" + // Alpha identifier
|
|
|
|
"AC02C1F2" + // DTMF string
|
|
|
|
"9E020001", // Icon identifier
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2014-08-25 06:32:35 +04:00
|
|
|
text: "Basic Icon",
|
|
|
|
iconSelfExplanatory: true,
|
2014-11-06 07:09:56 +03:00
|
|
|
icons: [BASIC_ICON]}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D011" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"AC02C1F2" + // DTMF string
|
|
|
|
"9E020005", // Icon identifier
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2014-08-25 06:32:35 +04:00
|
|
|
iconSelfExplanatory: true,
|
2014-11-06 07:09:56 +03:00
|
|
|
icons: [COLOR_TRANSPARENCY_ICON]}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D028" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"851980041704140420041004120421042204120423041904220415" + // Alpha identifier
|
|
|
|
"AC02C1F2", // DTMF string
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2013-02-08 08:03:36 +04:00
|
|
|
text: "ЗДРАВСТВУЙТЕ"}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D023" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"850B53656E642044544D462031" + // Alpha identifier
|
|
|
|
"AC052143658709" + // DTMF string
|
|
|
|
"D004000B00B4", // Text attribute
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2013-02-08 08:03:36 +04:00
|
|
|
text: "Send DTMF 1"}},
|
2015-02-04 12:46:27 +03:00
|
|
|
{command: "D014" + // Length
|
|
|
|
"8103011400" + // Command details
|
|
|
|
"82028183" + // Device identities
|
|
|
|
"8505804F60597D" + // Alpha identifier
|
|
|
|
"AC02C1F2", // DTMF string
|
2014-11-06 07:09:56 +03:00
|
|
|
expect: {commandQualifier: 0x00,
|
2013-02-08 08:03:36 +04:00
|
|
|
text: "你好"}},
|
|
|
|
];
|
|
|
|
|
2014-11-06 07:09:56 +03:00
|
|
|
function testSendDTMF(aCommand, aExpect) {
|
2015-02-04 12:46:27 +03:00
|
|
|
is(aCommand.commandNumber, 0x01, "commandNumber");
|
2014-11-06 07:09:56 +03:00
|
|
|
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_DTMF, "typeOfCommand");
|
|
|
|
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
|
|
|
|
|
2015-02-04 12:46:27 +03:00
|
|
|
// text is optional.
|
|
|
|
if ("text" in aExpect) {
|
2014-11-06 07:09:56 +03:00
|
|
|
is(aCommand.options.text, aExpect.text, "options.text");
|
|
|
|
}
|
|
|
|
|
2015-02-04 12:46:27 +03:00
|
|
|
// icons is optional.
|
|
|
|
if ("icons" in aExpect) {
|
2014-11-06 07:09:56 +03:00
|
|
|
isIcons(aCommand.options.icons, aExpect.icons);
|
|
|
|
is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
|
|
|
|
"options.iconSelfExplanatory");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start tests
|
|
|
|
startTestCommon(function() {
|
|
|
|
let icc = getMozIcc();
|
|
|
|
let promise = Promise.resolve();
|
|
|
|
for (let i = 0; i < TEST_DATA.length; i++) {
|
|
|
|
let data = TEST_DATA[i];
|
|
|
|
promise = promise.then(() => {
|
|
|
|
log("send_dtmf_cmd: " + data.command);
|
|
|
|
|
|
|
|
let promises = [];
|
|
|
|
// Wait onstkcommand event.
|
|
|
|
promises.push(waitForTargetEvent(icc, "stkcommand")
|
|
|
|
.then((aEvent) => testSendDTMF(aEvent.command, data.expect)));
|
2015-02-02 12:20:57 +03:00
|
|
|
// Wait icc-stkcommand system message.
|
|
|
|
promises.push(waitForSystemMessage("icc-stkcommand")
|
|
|
|
.then((aMessage) => {
|
|
|
|
is(aMessage.iccId, icc.iccInfo.iccid, "iccId");
|
|
|
|
testSendDTMF(aMessage.command, data.expect);
|
|
|
|
}));
|
2014-11-06 07:09:56 +03:00
|
|
|
// Send emulator command to generate stk unsolicited event.
|
|
|
|
promises.push(sendEmulatorStkPdu(data.command));
|
|
|
|
|
|
|
|
return Promise.all(promises);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return promise;
|
|
|
|
});
|