Bug 1087968 - Part 2: Rewrite test_stk_* with Promise. r=hsinyi

This commit is contained in:
Edgar Chen 2014-11-06 12:09:56 +08:00
Родитель 03ac5ec532
Коммит 55eb05e368
19 изменённых файлов: 1363 добавлений и 2030 удалений

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

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

@ -10,6 +10,88 @@ const DEFAULT_PIN = "0000";
// The puk code hard coded in emulator is "12345678".
const DEFAULT_PUK = "12345678";
const WHT = 0xFFFFFFFF;
const BLK = 0x000000FF;
const RED = 0xFF0000FF;
const GRN = 0x00FF00FF;
const BLU = 0x0000FFFF;
const TSP = 0;
// Basic Image, see record number 1 in EFimg.
const BASIC_ICON = {
width: 8,
height: 8,
codingScheme: "basic",
pixels: [WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT,
BLK, BLK, BLK, BLK, BLK, BLK, WHT, WHT,
WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
WHT, WHT, BLK, BLK, BLK, BLK, WHT, WHT,
WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT]
};
// Color Image, see record number 3 in EFimg.
const COLOR_ICON = {
width: 8,
height: 8,
codingScheme: "color",
pixels: [BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU,
BLU, RED, RED, RED, RED, RED, RED, BLU,
BLU, RED, GRN, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, GRN, RED, BLU,
BLU, RED, RED, RED, RED, RED, RED, BLU,
BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU]
};
// Color Image with Transparency, see record number 5 in EFimg.
const COLOR_TRANSPARENCY_ICON = {
width: 8,
height: 8,
codingScheme: "color-transparency",
pixels: [TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP,
TSP, RED, RED, RED, RED, RED, RED, TSP,
TSP, RED, GRN, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, GRN, RED, TSP,
TSP, RED, RED, RED, RED, RED, RED, TSP,
TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP]
};
/**
* Helper function for checking stk icon.
*/
function isIcons(aIcons, aExpectedIcons) {
is(aIcons.length, aExpectedIcons.length, "icons.length");
for (let i = 0; i < aIcons.length; i++) {
let icon = aIcons[i];
let expectedIcon = aExpectedIcons[i];
is(icon.width, expectedIcon.width, "icon.width");
is(icon.height, expectedIcon.height, "icon.height");
is(icon.codingScheme, expectedIcon.codingScheme, "icon.codingScheme");
is(icon.pixels.length, expectedIcon.pixels.length);
for (let j = 0; j < icon.pixels.length; j++) {
is(icon.pixels[j], expectedIcon.pixels[j], "icon.pixels[" + j + "]");
}
}
}
/**
* Helper function for checking stk text.
*/
function isStkText(aStkText, aExpectedStkText) {
is(aStkText.text, aExpectedStkText.text, "stkText.text");
if (aExpectedStkText.icons) {
is(aStkText.iconSelfExplanatory, aExpectedStkText.iconSelfExplanatory,
"stkText.iconSelfExplanatory");
isIcons(aStkText.icons, aExpectedStkText.icons);
}
}
// Emulate Promise.jsm semantics.
Promise.defer = function() { return new Deferred(); }
function Deferred() {

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

@ -1,140 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 30000;
SpecialPowers.addPermission("mobileconnection", true, document);
const WHT = 0xFFFFFFFF;
const BLK = 0x000000FF;
const RED = 0xFF0000FF;
const GRN = 0x00FF00FF;
const BLU = 0x0000FFFF;
const TSP = 0;
let iccManager = navigator.mozIccManager;
ok(iccManager instanceof MozIccManager,
"iccManager is instanceof " + iccManager.constructor);
// TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for
// multi-sim
// In single sim scenario, there is only one sim card, we can use below way to
// check iccId and get icc object. But in multi-sim, the index of iccIds may
// not map to sim slot directly, we should have a better way to handle this.
let iccIds = iccManager.iccIds;
ok(Array.isArray(iccIds), "iccIds is an array");
ok(iccIds.length > 0, "iccIds.length is " + iccIds.length);
let iccId = iccIds[0];
is(iccId, "89014103211118510720", "iccId is " + iccId);
let icc = iccManager.getIccById(iccId);
ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor);
// Basic Image, see record number 1 in EFimg.
let basicIcon = {
width: 8,
height: 8,
codingScheme: "basic",
pixels: [WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT,
BLK, BLK, BLK, BLK, BLK, BLK, WHT, WHT,
WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
WHT, BLK, BLK, WHT, WHT, BLK, BLK, WHT,
WHT, BLK, WHT, BLK, BLK, WHT, BLK, WHT,
WHT, WHT, BLK, BLK, BLK, BLK, WHT, WHT,
WHT, WHT, WHT, WHT, WHT, WHT, WHT, WHT]
};
// Color Image, see record number 3 in EFimg.
let colorIcon = {
width: 8,
height: 8,
codingScheme: "color",
pixels: [BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU,
BLU, RED, RED, RED, RED, RED, RED, BLU,
BLU, RED, GRN, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, RED, RED, BLU,
BLU, RED, RED, GRN, GRN, GRN, RED, BLU,
BLU, RED, RED, RED, RED, RED, RED, BLU,
BLU, BLU, BLU, BLU, BLU, BLU, BLU, BLU]
};
// Color Image with Transparency, see record number 5 in EFimg.
let colorTransparencyIcon = {
width: 8,
height: 8,
codingScheme: "color-transparency",
pixels: [TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP,
TSP, RED, RED, RED, RED, RED, RED, TSP,
TSP, RED, GRN, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, RED, RED, TSP,
TSP, RED, RED, GRN, GRN, GRN, RED, TSP,
TSP, RED, RED, RED, RED, RED, RED, TSP,
TSP, TSP, TSP, TSP, TSP, TSP, TSP, TSP]
};
function isIcons(icons, expectedIcons, message) {
is(icons.length, expectedIcons.length, message);
for (let i = 0; i < icons.length; i++) {
let icon = icons[i];
let expectedIcon = expectedIcons[i];
is(icon.width, expectedIcon.width, message);
is(icon.height, expectedIcon.height, message);
is(icon.codingScheme, expectedIcon.codingScheme, message);
is(icon.pixels.length, expectedIcon.pixels.length);
for (let j = 0; j < icon.pixels.length; j++) {
is(icon.pixels[j], expectedIcon.pixels[j], message);
}
}
}
function isStkText(stkText, expectedStkText, message) {
is(stkText.text, expectedStkText.text, message);
if (expectedStkText.icons) {
is(stkText.iconSelfExplanatory, expectedStkText.iconSelfExplanatory, message);
isIcons(stkText.icons, expectedStkText.icons, message);
}
}
let pendingEmulatorCmdCount = 0;
function sendStkPduToEmulator(command, func, expect) {
++pendingEmulatorCmdCount;
runEmulatorCmd(command, function(result) {
--pendingEmulatorCmdCount;
is(result[0], "OK");
});
icc.onstkcommand = function(evt) {
if (expect) {
func(evt.command, expect);
} else {
func(evt.command);
}
}
}
function runNextTest() {
let test = tests.pop();
if (!test) {
cleanUp();
return;
}
let command = "stk pdu " + test.command;
sendStkPduToEmulator(command, test.func, test.expect);
}
function cleanUp() {
if (pendingEmulatorCmdCount) {
window.setTimeout(cleanUp, 100);
return;
}
SpecialPowers.removePermission("mobileconnection", document);
finish();
}

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

@ -1,58 +1,65 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testBipCommand(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, expect.typeOfCommand, expect.name);
is(command.options.text, expect.text, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
// Open channel.
{command: "d04f81030140018202818205074f70656e204944350702030403041f0239020578470a065465737447700272730d08f4557365724c6f670d08f4557365725077643c0301ad9c3e0521010101019e020007",
func: testBipCommand,
expect: {name: "open_channel_1",
typeOfCommand: iccManager.STK_CMD_OPEN_CHANNEL,
expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
text: "Open ID",
iconSelfExplanatory: true,
icons: [colorIcon, colorTransparencyIcon]}},
icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
{command: "d0448103014001820281820500350702030403041f0239020578470a065465737447700272730d08f4557365724c6f670d08f4557365725077643c0301ad9c3e052101010101",
func: testBipCommand,
expect: {name: "open_channel_2",
typeOfCommand: iccManager.STK_CMD_OPEN_CHANNEL,
expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
text: ""}},
{command: "d05381030140018202818205094f70656e2049442031350702030403041f0239020578470a065465737447700272730d08f4557365724c6f670d08f4557365725077643c0301ad9c3e052101010101d004000900b4",
func: testBipCommand,
expect: {name: "open_channel_3",
typeOfCommand: iccManager.STK_CMD_OPEN_CHANNEL,
expect: {typeOfCommand: MozIccManager.STK_CMD_OPEN_CHANNEL,
text: "Open ID 1"}},
// Close channel.
{command: "d01b810301410082028121850a436c6f73652049442031d004000a00b4",
func: testBipCommand,
expect: {name: "close_channel_1",
typeOfCommand: iccManager.STK_CMD_CLOSE_CHANNEL,
expect: {typeOfCommand: MozIccManager.STK_CMD_CLOSE_CHANNEL,
text: "Close ID 1"}},
// Recive data.
{command: "d022810301420082028121850e5265636569766520446174612031b701c8d004000e00b4",
func: testBipCommand,
expect: {name: "receive_data_1",
typeOfCommand: iccManager.STK_CMD_RECEIVE_DATA,
expect: {typeOfCommand: MozIccManager.STK_CMD_RECEIVE_DATA,
text: "Receive Data 1"}},
// Send data.
{command: "d026810301430182028121850b53656e6420446174612031b6080001020304050607d004000b00b4",
func: testBipCommand,
expect: {name: "send_data_1",
typeOfCommand: iccManager.STK_CMD_SEND_DATA,
expect: {typeOfCommand: MozIccManager.STK_CMD_SEND_DATA,
text: "Send Data 1"}},
];
runNextTest();
function testBipCommand(aCommand, aExpect) {
is(aCommand.typeOfCommand, aExpect.typeOfCommand, "typeOfCommand");
is(aCommand.options.text, aExpect.text, "options.text");
if (aExpect.icons) {
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("bip_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testBipCommand(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,119 +1,69 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testDisplayText(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_DISPLAY_TEXT, expect.name);
is(command.options.text, expect.text, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.userClear, expect.userClear, expect.name);
is(command.options.isHighPriority, expect.isHighPriority, expect.name);
let duration = command.options.duration;
if (duration) {
is(duration.timeUnit, expect.duration.timeUnit, expect.name);
is(duration.timeInterval, expect.duration.timeInterval, expect.name);
}
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d01a8103012180820281028d0f04546f6f6c6b697420546573742031",
func: testDisplayText,
expect: {name: "display_text_cmd_1",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "Toolkit Test 1",
userClear: true}},
{command: "d01a8103012181820281028d0f04546f6f6c6b697420546573742032",
func: testDisplayText,
expect: {name: "display_text_cmd_2",
commandQualifier: 0x81,
expect: {commandQualifier: 0x81,
text: "Toolkit Test 2",
isHighPriority: true,
userClear: true}},
{command: "d0198103012180820281028d0e00d4f79bbd4ed341d4f29c0e9a01",
func: testDisplayText,
expect: {name: "display_text_cmd_3",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "Toolkit Test 3",
userClear: true}},
{command: "d01a8103012100820281028d0f04546f6f6c6b697420546573742034",
func: testDisplayText,
expect: {name: "display_text_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test 4"}},
{command: "d081ad8103012180820281028d81a1045468697320636f6d6d616e6420696e7374727563747320746865204d4520746f20646973706c617920612074657874206d6573736167652e20497420616c6c6f7773207468652053494d20746f20646566696e6520746865207072696f72697479206f662074686174206d6573736167652c20616e6420746865207465787420737472696e6720666f726d61742e2054776f207479706573206f66207072696f",
func: testDisplayText,
expect: {name: "display_text_cmd_5",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "This command instructs the ME to display a text message. It allows the SIM to define the priority of that message, and the text string format. Two types of prio",
userClear: true}},
{command: "d01a8103012180820281028d0f043c474f2d4241434b57415244533e",
func: testDisplayText,
expect: {name: "display_text_cmd_6",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "<GO-BACKWARDS>",
userClear: true}},
{command: "d0248103012180820281028d1908041704140420041004120421042204120423041904220415",
func: testDisplayText,
expect: {name: "display_text_cmd_7",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "ЗДРАВСТВУЙТЕ",
userClear: true}},
{command: "d0108103012180820281028d05084f60597d",
func: testDisplayText,
expect: {name: "display_text_cmd_8",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "你好",
userClear: true}},
{command: "d0128103012180820281028d07080038003030eb",
func: testDisplayText,
expect: {name: "display_text_cmd_9",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "80ル",
userClear: true}},
{command: "d0288103012180820281020d1d00d3309bfc06c95c301aa8e80259c3ec34b9ac07c9602f58ed159bb940",
func: testDisplayText,
expect: {name: "display_text_cmd_10",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "Saldo 2.04 E. Validez 20/05/13. ",
userClear: true}},
{command: "d0198103012180820281028D0A043130205365636F6E648402010A",
func: testDisplayText,
expect: {name: "display_text_cmd_11",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "10 Second",
userClear: true,
duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND,
duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
timeInterval: 0x0A}}},
{command: "d01a8103012180820281028d0b0442617369632049636f6e9e020001",
func: testDisplayText,
expect: {name: "display_text_cmd_12",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
text: "Basic Icon",
userClear: true,
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "D026810301210082028102" +
"8D" +
"1B" +
"00" + // 7BIT
"D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
"0E8687C158A09B304905",
func: testDisplayText,
expect: {name: "display_text_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x00, 7BIT"}},
{command: "D029810301210082028102" +
"8D" +
@ -121,9 +71,7 @@ let tests = [
"04" + // 8BIT
"546F6F6C6B697420546573742047524F" +
"55503A307830302C2038424954",
func: testDisplayText,
expect: {name: "display_text_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x00, 8BIT"}},
{command: "D046810301210082028102" +
"8D" +
@ -133,9 +81,7 @@ let tests = [
"0054006500730074002000470052004F" +
"00550050003A0030007800300030002C" +
"00200055004300530032",
func: testDisplayText,
expect: {name: "display_text_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x00, UCS2"}},
{command: "D026810301210082028102" +
"8D" +
@ -143,9 +89,7 @@ let tests = [
"12" + // 7BIT + Class 2
"D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
"0E868FC158A09B304905",
func: testDisplayText,
expect: {name: "display_text_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x10, 7BIT"}},
{command: "D029810301210082028102" +
"8D" +
@ -153,9 +97,7 @@ let tests = [
"16" + // 8BIT + Class 2
"546F6F6C6B697420546573742047524F" +
"55503A307831302C2038424954",
func: testDisplayText,
expect: {name: "display_text_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x10, 8BIT"}},
{command: "D046810301210082028102" +
"8D" +
@ -165,9 +107,7 @@ let tests = [
"0054006500730074002000470052004F" +
"00550050003A0030007800310030002C" +
"00200055004300530032",
func: testDisplayText,
expect: {name: "display_text_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0x10, UCS2"}},
{command: "D026810301210082028102" +
"8D" +
@ -175,9 +115,7 @@ let tests = [
"F2" + // 7BIT + Class 2
"D4F79BBD4ED341D4F29C0E3A4A9F55A8" +
"0E8637C258A09B304905",
func: testDisplayText,
expect: {name: "display_text_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0xF0, 7BIT"}},
{command: "D029810301210082028102" +
"8D" +
@ -185,9 +123,7 @@ let tests = [
"F6" + // 8BIT + Class 2
"546F6F6C6B697420546573742047524F" +
"55503A307846302C2038424954",
func: testDisplayText,
expect: {name: "display_text_cmd_20",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test GROUP:0xF0, 8BIT"}},
// Bug 1088573: this test case is to ensure that we provide |length| argument
// in |integer| format to GsmPDUHelper.readSeptetsToString().
@ -214,9 +150,7 @@ let tests = [
"0C8287E5207619346D1E73A0783D0D9A" +
"9FCA733A885C96BFEBEC32280C9A6689" +
"CE621654768382D529551A64268B2E",
func: testDisplayText,
expect: {name: "display_text_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Ce message se compose de 273 caracteres en mode " +
"compresse. Ce message est affiche sur plusieurs " +
"ecrans et ne doit pas etre tronque. 273 est le " +
@ -225,4 +159,48 @@ let tests = [
"deroule a SYDNEY en AUSTRALIE."}},
];
runNextTest();
function testDisplayText(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_DISPLAY_TEXT,
"typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.text, aExpect.text, "options.text");
is(aCommand.options.userClear, aExpect.userClear, "options.userClear");
is(aCommand.options.isHighPriority, aExpect.isHighPriority,
"options.isHighPriority");
if (aExpect.duration) {
let duration = aCommand.options.duration;
is(duration.timeUnit, aExpect.duration.timeUnit,
"options.duration.timeUnit");
is(duration.timeInterval, aExpect.duration.timeInterval,
"options.duration.timeInterval");
}
if (aExpect.icons) {
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("display_text_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testDisplayText(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,115 +1,106 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testGetInKey(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_GET_INKEY, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.text, expect.name);
is(command.options.isAlphabet, expect.isAlphabet, expect.name);
is(command.options.isUCS2, expect.isUCS2, expect.name);
is(command.options.isYesNoRequested, expect.isYesNoRequested, expect.name);
let duration = command.options.duration;
if (duration) {
is(duration.timeUnit, expect.duration.timeUnit, expect.name);
is(duration.timeInterval, expect.duration.timeInterval, expect.name);
}
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d0158103012200820281828d0a04456e74657220222b22",
func: testGetInKey,
expect: {name: "get_inkey_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter \"+\""}},
{command: "d0148103012200820281828d09004537bd2c07896022",
func: testGetInKey,
expect: {name: "get_inkey_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter \"0\""}},
{command: "d01a8103012200820281828d0f043c474f2d4241434b57415244533e",
func: testGetInKey,
expect: {name: "get_inkey_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<GO-BACKWARDS>"}},
{command: "d0138103012200820281828d08043c41424f52543e",
func: testGetInKey,
expect: {name: "get_inkey_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<ABORT>"}},
{command: "d0158103012201820281828d0a04456e74657220227122",
func: testGetInKey,
expect: {name: "get_inkey_cmd_5",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
text: "Enter \"q\"",
isAlphabet: true}},
{command: "d081ad8103012201820281828d81a104456e746572202278222e205468697320636f6d6d616e6420696e7374727563747320746865204d4520746f20646973706c617920746578742c20616e6420746f2065787065637420746865207573657220746f20656e74657220612073696e676c65206368617261637465722e20416e7920726573706f6e736520656e7465726564206279207468652075736572207368616c6c206265207061737365642074",
func: testGetInKey,
expect: {name: "get_inkey_cmd_6",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
text: "Enter \"x\". This command instructs the ME to display text, and to expect the user to enter a single character. Any response entered by the user shall be passed t",
isAlphabet: true}},
{command: "d0168103012200820281828d0b043c54494d452d4f55543e",
func: testGetInKey,
expect: {name: "get_inkey_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<TIME-OUT>"}},
{command: "d0248103012200820281828d1908041704140420041004120421042204120423041904220415",
func: testGetInKey,
expect: {name: "get_inkey_cmd_8",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d081998103012200820281828d818d080417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419042204150417041404200410041204210422041204230419",
func: testGetInKey,
expect: {name: "get_inkey_cmd_9",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ"}},
{command: "d0118103012203820281828d0604456e746572",
func: testGetInKey,
expect: {name: "get_inkey_cmd_10",
commandQualifier: 0x03,
expect: {commandQualifier: 0x03,
text: "Enter",
isAlphabet: true,
isUCS2: true}},
{command: "d0158103012204820281828d0a04456e74657220594553",
func: testGetInKey,
expect: {name: "get_inkey_cmd_11",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
text: "Enter YES",
isYesNoRequested: true}},
{command: "d0148103012204820281828d0904456e746572204e4f",
func: testGetInKey,
expect: {name: "get_inkey_cmd_12",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
text: "Enter NO",
isYesNoRequested: true}},
{command: "d0198103012200820281828d0a043c4e4f2d49434f4e3e1e020002",
func: testGetInKey,
expect: {name: "get_inkey_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
// The record number 02 in EFimg is not defined, so no icon will be
// shown, but the text string should still be displayed.
text: "<NO-ICON>"}},
{command: "D0198103012200820281828D0A04456E74657220222B228402010A",
func: testGetInKey,
expect: {name: "get_inkey_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter \"+\"",
duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND,
duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
timeInterval: 0x0A}}},
];
runNextTest();
function testGetInKey(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_GET_INKEY, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.text, aExpect.text, "options.text");
is(aCommand.options.isAlphabet, aExpect.isAlphabet, "options.isAlphabet");
is(aCommand.options.isUCS2, aExpect.isUCS2, "options.isUCS2");
is(aCommand.options.isYesNoRequested, aExpect.isYesNoRequested,
"options.isYesNoRequested");
if (aExpect.duration) {
let duration = aCommand.options.duration;
is(duration.timeUnit, aExpect.duration.timeUnit,
"options.duration.timeUnit");
is(duration.timeInterval, aExpect.duration.timeInterval,
"options.duration.timeInterval");
}
if (aExpect.icons) {
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("get_inkey_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInKey(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,183 +1,169 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testGetInput(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_GET_INPUT, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.text, expect.name);
is(command.options.minLength, expect.minLength, expect.name);
is(command.options.maxLength, expect.maxLength, expect.name);
if (command.options.defaultText) {
is(command.options.defaultText, expect.defaultText, expect.name);
}
if (command.options.isAlphabet) {
is(command.options.isAlphabet, expect.isAlphabet, expect.name);
}
if (command.options.isUCS2) {
is(command.options.isUCS2, expect.isUCS2, expect.name);
}
if (command.options.isPacked) {
is(command.options.isPacked, expect.isPacked, expect.name);
}
if (command.options.hideInput) {
is(command.options.hideInput, expect.hideInput, expect.name);
}
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d01b8103012300820281828d0c04456e74657220313233343591020505",
func: testGetInput,
expect: {name: "get_input_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter 12345",
minLength: 5,
maxLength: 5}},
{command: "d01a8103012308820281828d0b004537bd2c07d96eaad10a91020505",
func: testGetInput,
expect: {name: "get_input_cmd_2",
commandQualifier: 0x08,
expect: {commandQualifier: 0x08,
text: "Enter 67*#+",
minLength: 5,
maxLength: 5,
isPacked: true}},
{command: "d01b8103012301820281828d0c04456e74657220416243644591020505",
func: testGetInput,
expect: {name: "get_input_cmd_3",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
text: "Enter AbCdE",
minLength: 5,
maxLength: 5,
isAlphabet: true}},
{command: "d0278103012304820281828d180450617373776f726420313c53454e443e3233343536373891020408",
func: testGetInput,
expect: {name: "get_input_cmd_4",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
text: "Password 1<SEND>2345678",
minLength: 4,
maxLength: 8,
hideInput: true}},
{command: "d0248103012300820281828d1504456e74657220312e2e392c302e2e392c3028312991020114",
func: testGetInput,
expect: {name: "get_input_cmd_5",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter 1..9,0..9,0(1)",
minLength: 1,
maxLength: 20}},
{command: "d01e8103012300820281828d0f043c474f2d4241434b57415244533e91020008",
func: testGetInput,
expect: {name: "get_input_cmd_6",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<GO-BACKWARDS>",
minLength: 0,
maxLength: 8}},
{command: "d0178103012300820281828d08043c41424f52543e91020008",
func: testGetInput,
expect: {name: "get_input_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<ABORT>",
minLength: 0,
maxLength: 8}},
{command: "d081b18103012300820281828d81a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a303030303030303030302323239102a0a0",
func: testGetInput,
expect: {name: "get_input_cmd_8",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###",
minLength: 160,
maxLength: 160}},
{command: "d0168103012300820281828d07043c53454e443e91020001",
func: testGetInput,
expect: {name: "get_input_cmd_9",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<SEND>",
minLength: 0,
maxLength: 1}},
{command: "d01a8103012300820281828d0b043c54494d452d4f55543e9102000a",
func: testGetInput,
expect: {name: "get_input_cmd_10",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<TIME-OUT>",
minLength: 0,
maxLength: 10}},
{command: "d0288103012301820281828d190804170414042004100412042104220412042304190422041591020505",
func: testGetInput,
expect: {name: "get_input_cmd_11",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
text: "ЗДРАВСТВУЙТЕ",
minLength: 5,
maxLength: 5,
isAlphabet: true}},
{command: "d0819d8103012301820281828d818d08041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041904220415041704140420041004120421042204120423041991020505",
func: testGetInput,
expect: {name: "get_input_cmd_12",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
text: "ЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙТЕЗДРАВСТВУЙ",
minLength: 5,
maxLength: 5,
isAlphabet: true}},
{command: "d01b8103012303820281828d0c04456e7465722048656c6c6f91020c0c",
func: testGetInput,
expect: {name: "get_input_cmd_13",
commandQualifier: 0x03,
expect: {commandQualifier: 0x03,
text: "Enter Hello",
minLength: 12,
maxLength: 12,
isAlphabet: true,
isUCS2: true}},
{command: "d01b8103012303820281828d0c04456e7465722048656c6c6f910205ff",
func: testGetInput,
expect: {name: "get_input_cmd_14",
commandQualifier: 0x03,
expect: {commandQualifier: 0x03,
text: "Enter Hello",
minLength: 5,
maxLength: 0xFF,
isAlphabet: true,
isUCS2: true}},
{command: "d0238103012300820281828d0c04456e746572203132333435910205051706043132333435",
func: testGetInput,
expect: {name: "get_input_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter 12345",
minLength: 5,
maxLength: 5,
defaultText: "12345"}},
{command: "d081ba8103012300820281828d0704456e7465723a9102a0a01781a1042a2a2a313131313131313131312323232a2a2a323232323232323232322323232a2a2a333333333333333333332323232a2a2a343434343434343434342323232a2a2a353535353535353535352323232a2a2a363636363636363636362323232a2a2a373737373737373737372323232a2a2a383838383838383838382323232a2a2a393939393939393939392323232a2a2a30303030303030303030232323",
func: testGetInput,
expect: {name: "get_input_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Enter:",
minLength: 160,
maxLength: 160,
defaultText: "***1111111111###***2222222222###***3333333333###***4444444444###***5555555555###***6666666666###***7777777777###***8888888888###***9999999999###***0000000000###"}},
{command: "d01d8103012300820281828d0a043c4e4f2d49434f4e3e9102000a1e020002",
func: testGetInput,
expect: {name: "get_input_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
// The record number 02 in EFimg is not defined, so no icon will be
// shown, but the text string should still be displayed.
text: "<NO-ICON>",
minLength: 0,
maxLength: 10}},
{command: "d0208103012300820281828d0d043c42415349432d49434f4e3e9102000a1e020101",
func: testGetInput,
expect: {name: "get_input_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "<BASIC-ICON>",
minLength: 0,
maxLength: 10,
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
];
runNextTest();
function testGetInput(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_GET_INPUT, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.text, aExpect.text, "options.text");
is(aCommand.options.minLength, aExpect.minLength, "options.minLength");
is(aCommand.options.maxLength, aExpect.maxLength, "options.maxLength");
if (aExpect.defaultText) {
is(aCommand.options.defaultText, aExpect.defaultText, "options.defaultText");
}
if (aExpect.isAlphabet) {
is(aCommand.options.isAlphabet, aExpect.isAlphabet, "options.isAlphabet");
}
if (aExpect.isUCS2) {
is(aCommand.options.isUCS2, aExpect.isUCS2, "options.isUCS2");
}
if (aExpect.isPacked) {
is(aCommand.options.isPacked, aExpect.isPacked, "options.isPacked");
}
if (aExpect.hideInput) {
is(aCommand.options.hideInput, aExpect.hideInput, "options.hideInput");
}
if (aExpect.icons) {
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("get_input_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testGetInput(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,267 +1,208 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testLaunchBrowser(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_LAUNCH_BROWSER, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.url, expect.url, expect.name);
if (expect.confirmMessage) {
isStkText(command.options.confirmMessage, expect.confirmMessage, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d0188103011500820281823100050b44656661756c742055524c",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL" }}},
{command: "d01f8103011500820281823112687474703a2f2f7878782e7979792e7a7a7a0500",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "http://xxx.yyy.zzz",
confirmMessage: { text: "" }}},
{command: "d00e8103011500820281823001003100",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: ""}},
{command: "d0208103011500820281823100320103" +
"0d10046162632e6465662e6768692e6a6b6c", // "0D" String TLV is useless for Launch Browser.
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: ""}},
{command: "d0188103011502820281823100050b44656661756c742055524c",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_5",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "Default URL" }}},
{command: "d0188103011503820281823100050b44656661756c742055524c",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_6",
commandQualifier: 0x03,
expect: {commandQualifier: 0x03,
url: "",
confirmMessage: { text: "Default URL"}}},
{command: "d00b8103011500820281823100",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: ""}},
{command: "d0268103011502820281823100051980041704140420041004120421042204120423041904220415",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_8",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "ЗДРАВСТВУЙТЕ" }}},
{command: "d021810301150282028182310005104e6f742073656c66206578706c616e2e1e020101",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_9",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "Not self explan.",
iconSelfExplanatory: false,
icons : [basicIcon] }
icons : [BASIC_ICON] }
}},
{command: "d01d8103011502820281823100050c53656c66206578706c616e2e1e020001",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_10",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "Self explan.",
iconSelfExplanatory: true,
icons : [basicIcon] }
icons : [BASIC_ICON] }
}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_11",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2032",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_12",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d01b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2032",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d02b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2032",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d04b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_17",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d04b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d08b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_20",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d08b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_22",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d10b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_23",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d10b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_24",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_25",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d20b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_26",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d20b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_27",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_28",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d40b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_29",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d40b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_30",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_31",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d80b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_32",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d80b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2032d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_33",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2033",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_34",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 3" }}},
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d00b4",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_35",
commandQualifier: 0x00,
{command: "d0208103011500820281823100050d44656661756c742055524c2031d004000d00b4",
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 1" }}},
{command: "d01a8103011500820281823100050d44656661756c742055524c2032",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_36",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { text: "Default URL 2" }}},
{command: "d01281030115028202818231000505804f60597d",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_37",
commandQualifier: 0x02,
{command: "d01281030115028202818231000505804f60597d",
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "你好" }}},
{command: "d010810301150282028182310005038030eb",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_38",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
url: "",
confirmMessage: { text: "ル" }}},
{command: "d01281030115008202818230010031001e020001",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_39",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { iconSelfExplanatory: true,
icons: [basicIcon] }}},
icons: [BASIC_ICON] }}},
{command: "d01281030115008202818230010031001e020003",
func: testLaunchBrowser,
expect: {name: "launch_browser_cmd_40",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
url: "",
confirmMessage: { iconSelfExplanatory: true,
icons: [colorIcon] }}},
icons: [COLOR_ICON] }}},
];
runNextTest();
function testLaunchBrowser(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_LAUNCH_BROWSER,
"typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.url, aExpect.url, "options.url");
if (aExpect.confirmMessage) {
isStkText(aCommand.options.confirmMessage, aExpect.confirmMessage,
"options.confirmMessage");
}
}
// 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("launch_browser_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testLaunchBrowser(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,21 +1,37 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testPollOff(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_POLL_OFF, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d009810301040082028182",
func: testPollOff,
expect: {name: "pull_off_cmd_1",
commandQualifier: 0x00}}
expect: {commandQualifier: 0x00}}
];
runNextTest();
function testPollOff(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_POLL_OFF, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
}
// 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("pull_off_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testPollOff(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,25 +1,39 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testRefresh(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_REFRESH, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d0108103010101820281829205013f002fe2",
func: testRefresh,
expect: {name: "refresh_cmd_1",
commandQualifier: 0x01}},
expect: {commandQualifier: 0x01}},
{command: "d009810301010482028182",
func: testRefresh,
expect: {name: "refresh_cmd_2",
commandQualifier: 0x04}}
expect: {commandQualifier: 0x04}}
];
runNextTest();
function testRefresh(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_REFRESH, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
}
// 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("refresh_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testRefresh(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,347 +1,270 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSelectItem(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SELECT_ITEM, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.title, expect.title, expect.name);
for (let index in command.options.items) {
is(command.options.items[index].identifier, expect.items[index].identifier, expect.name);
is(command.options.items[index].text, expect.items[index].text, expect.name);
let itemIcons = command.options.items[index].icons;
if (itemIcons) {
isIcons(itemIcons, expect.items[index].icons, expect.name);
let iconSelfExplanatory = command.options.items[index].iconSelfExplanatory;
is(iconSelfExplanatory, expect.items[index].iconSelfExplanatory, expect.name);
}
}
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
let length = command.options.nextActionList ? command.options.nextActionList.length : 0;
for (let i = 0; i < length; i++) {
is(command.options.nextActionList[i], expect.nextActionList[i], expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d03d810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
func: testSelectItem,
expect: {name: "select_item_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
{command: "d081fc810301240082028182850a4c617267654d656e75318f05505a65726f8f044f4f6e658f044e54776f8f064d54687265658f054c466f75728f054b466976658f044a5369788f0649536576656e8f064845696768748f05474e696e658f0646416c7068618f0645427261766f8f0844436861726c69658f064344656c74618f05424563686f8f0941466f782d74726f748f0640426c61636b8f063f42726f776e8f043e5265648f073d4f72616e67658f073c59656c6c6f778f063b477265656e8f053a426c75658f073956696f6c65748f0538477265798f063757686974658f06366d696c6c698f06356d6963726f8f05346e616e6f8f05337069636f",
func: testSelectItem,
expect: {name: "select_item_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "LargeMenu1",
items: [{identifier: 80, text: "Zero"}, {identifier: 79, text: "One"}, {identifier: 78, text: "Two"}, {identifier: 77, text: "Three"}, {identifier: 76, text: "Four"}, {identifier: 75, text: "Five"}, {identifier: 74, text: "Six"}, {identifier: 73, text: "Seven"}, {identifier: 72, text: "Eight"}, {identifier: 71, text: "Nine"}, {identifier: 70, text: "Alpha"}, {identifier: 69, text: "Bravo"}, {identifier: 68, text: "Charlie"}, {identifier: 67, text: "Delta"}, {identifier: 66, text: "Echo"}, {identifier: 65, text: "Fox-trot"}, {identifier: 64, text: "Black"}, {identifier: 63, text: "Brown"}, {identifier: 62, text: "Red"}, {identifier: 61, text: "Orange"}, {identifier: 60, text: "Yellow"}, {identifier: 59, text: "Green"}, {identifier: 58, text: "Blue"}, {identifier: 57, text: "Violet"}, {identifier: 56, text: "Grey"}, {identifier: 55, text: "White"}, {identifier: 54, text: "milli"}, {identifier: 53, text: "micro"}, {identifier: 52, text: "nano"}, {identifier: 51, text: "pico"}]}},
{command: "d081fb810301240082028182850a4c617267654d656e75328f1eff43616c6c20466f7277617264696e6720556e636f6e646974696f6e616c8f1dfe43616c6c20466f7277617264696e67204f6e205573657220427573798f1cfd43616c6c20466f7277617264696e67204f6e204e6f205265706c798f26fc43616c6c20466f7277617264696e67204f6e2055736572204e6f7420526561636861626c658f1efb42617272696e67204f6620416c6c204f7574676f696e672043616c6c738f2cfa42617272696e67204f6620416c6c204f7574676f696e6720496e7465726e6174696f6e616c2043616c6c738f11f9434c492050726573656e746174696f6e",
func: testSelectItem,
expect: {name: "select_item_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "LargeMenu2",
items: [{identifier: 255, text: "Call Forwarding Unconditional"}, {identifier: 254, text: "Call Forwarding On User Busy"}, {identifier: 253, text: "Call Forwarding On No Reply"}, {identifier: 252, text: "Call Forwarding On User Not Reachable"}, {identifier: 251, text: "Barring Of All Outgoing Calls"}, {identifier: 250, text: "Barring Of All Outgoing International Calls"}, {identifier: 249, text: "CLI Presentation"}]}},
{command: "d022810301240082028182850b53656c656374204974656d8f04114f6e658f041254776f",
func: testSelectItem,
expect: {name: "select_item_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Select Item",
items: [{identifier: 17, text: "One"}, {identifier: 18, text: "Two"}]}},
{command: "d081fd8103012400820281828581ed5468652053494d207368616c6c20737570706c79206120736574206f66206974656d732066726f6d207768696368207468652075736572206d61792063686f6f7365206f6e652e2045616368206974656d20636f6d70726973657320612073686f7274206964656e74696669657220287573656420746f20696e646963617465207468652073656c656374696f6e2920616e642061207465787420737472696e672e204f7074696f6e616c6c79207468652053494d206d617920696e636c75646520616e20616c706861206964656e7469666965722e2054686520616c706861206964656e74696669657220698f020159",
func: testSelectItem,
expect: {name: "select_item_cmd_5",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "The SIM shall supply a set of items from which the user may choose one. Each item comprises a short identifier (used to indicate the selection) and a text string. Optionally the SIM may include an alpha identifier. The alpha identifier i",
items: [{identifier: 1, text: "Y"}]}},
{command: "d081f3810301240082028182850a304c617267654d656e758f1dff312043616c6c20466f727761726420556e636f6e646974696f6e616c8f1cfe322043616c6c20466f7277617264204f6e205573657220427573798f1bfd332043616c6c20466f7277617264204f6e204e6f205265706c798f25fc342043616c6c20466f7277617264204f6e2055736572204e6f7420526561636861626c658f20fb352042617272696e67204f6620416c6c204f7574676f696e672043616c6c738f24fa362042617272696e67204f6620416c6c204f7574676f696e6720496e742043616c6c738f13f93720434c492050726573656e746174696f6e",
func: testSelectItem,
expect: {name: "select_item_cmd_6",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "0LargeMenu",
items: [{identifier: 255, text: "1 Call Forward Unconditional"}, {identifier: 254, text: "2 Call Forward On User Busy"}, {identifier: 253, text: "3 Call Forward On No Reply"}, {identifier: 252, text: "4 Call Forward On User Not Reachable"}, {identifier: 251, text: "5 Barring Of All Outgoing Calls"}, {identifier: 250, text: "6 Barring Of All Outgoing Int Calls"}, {identifier: 249, text: "7 CLI Presentation"}]}},
{command: "d039810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20331803131026",
func: testSelectItem,
expect: {name: "select_item_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}],
nextActionList: [iccManager.STK_CMD_SEND_SMS, iccManager.STK_CMD_SET_UP_CALL, iccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
nextActionList: [MozIccManager.STK_CMD_SEND_SMS, MozIccManager.STK_CMD_SET_UP_CALL, MozIccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
{command: "d037810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033900102",
func: testSelectItem,
expect: {name: "select_item_cmd_8",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d034810301248082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
func: testSelectItem,
expect: {name: "select_item_cmd_9",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d03e810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20339e0201019f0401030303",
func: testSelectItem,
expect: {name: "select_item_cmd_10",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
iconSelfExplanatory: false,
icons: [basicIcon],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: false, icons: [colorIcon]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: false, icons: [colorIcon]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: false, icons: [colorIcon]}]}},
icons: [BASIC_ICON],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: false, icons: [COLOR_ICON]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: false, icons: [COLOR_ICON]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: false, icons: [COLOR_ICON]}]}},
{command: "d03e810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20339e0200019f0400050505",
func: testSelectItem,
expect: {name: "select_item_cmd_11",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
iconSelfExplanatory: true,
icons: [basicIcon],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [colorTransparencyIcon]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [colorTransparencyIcon]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [colorTransparencyIcon]}]}},
icons: [BASIC_ICON],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]}]}},
{command: "d034810301240382028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
func: testSelectItem,
expect: {name: "select_item_cmd_12",
commandQualifier: 0x03,
expect: {commandQualifier: 0x03,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d034810301240182028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d2033",
func: testSelectItem,
expect: {name: "select_item_cmd_13",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d02b810301240482028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d2032",
func: testSelectItem,
expect: {name: "select_item_cmd_14",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d030810301240082028182850a3c54494d452d4f55543e8f07014974656d20318f07024974656d20328f07034974656d2033",
func: testSelectItem,
expect: {name: "select_item_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "<TIME-OUT>",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
func: testSelectItem,
expect: {name: "select_item_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001001b4d108000601b4000601b4",
func: testSelectItem,
expect: {name: "select_item_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
func: testSelectItem,
expect: {name: "select_item_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001002b4d108000602b4000602b4",
func: testSelectItem,
expect: {name: "select_item_cmd_20",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
func: testSelectItem,
expect: {name: "select_item_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001004b4d108000604b4000604b4",
func: testSelectItem,
expect: {name: "select_item_cmd_22",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_23",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_24",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001008b4d108000608b4000608b4",
func: testSelectItem,
expect: {name: "select_item_cmd_25",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_26",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_27",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001010b4d108000610b4000610b4",
func: testSelectItem,
expect: {name: "select_item_cmd_28",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_29",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_30",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001020b4d108000620b4000620b4",
func: testSelectItem,
expect: {name: "select_item_cmd_31",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_32",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_33",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001040b4d108000640b4000640b4",
func: testSelectItem,
expect: {name: "select_item_cmd_34",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_35",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_36",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001080b4d108000680b4000680b4",
func: testSelectItem,
expect: {name: "select_item_cmd_37",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_38",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420338f07014974656d20358f07024974656d2036",
func: testSelectItem,
expect: {name: "select_item_cmd_39",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 3",
items: [{identifier: 1, text: "Item 5"}, {identifier: 2, text: "Item 6"}]}},
{command: "d03d8103012400820281828510546f6f6c6b69742053656c65637420318f07014974656d20318f07024974656d2032d004001000b4d108000600b4000600b4",
func: testSelectItem,
expect: {name: "select_item_cmd_40",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d02d8103012400820281828510546f6f6c6b69742053656c65637420328f07014974656d20338f07024974656d2034",
func: testSelectItem,
expect: {name: "select_item_cmd_41",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select 2",
items: [{identifier: 1, text: "Item 3"}, {identifier: 2, text: "Item 4"}]}},
{command: "d07e8103012400820281828519800417041404200410041204210422041204230419042204158f1c018004170414042004100412042104220412042304190422041500318f1c028004170414042004100412042104220412042304190422041500328f1c03800417041404200410041204210422041204230419042204150033",
func: testSelectItem,
expect: {name: "select_item_cmd_42",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
{command: "d053810301240082028182850f810c089794a09092a1a292a399a2958f1101810d089794a09092a1a292a399a295318f1102810d089794a09092a1a292a399a295328f1103810d089794a09092a1a292a399a29533",
func: testSelectItem,
expect: {name: "select_item_cmd_43",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
{command: "d0578103012400820281828510820c04108784908082919282938992858f1201820d0410878490808291928293899285318f1202820d0410878490808291928293899285328f1203820d041087849080829192829389928533",
func: testSelectItem,
expect: {name: "select_item_cmd_44",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}]}},
{command: "d03e810301240082028182850b805de551777bb1900962e98f080180987976ee4e008f080280987976ee4e8c8f080380987976ee4e098f080480987976ee56db",
func: testSelectItem,
expect: {name: "select_item_cmd_45",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "工具箱选择",
items: [{identifier: 1, text: "项目一"}, {identifier: 2, text: "项目二"}, {identifier: 3, text: "项目三"}, {identifier: 4, text: "项目四"}]}},
{command: "d0388103012400820281828509800038003030eb00308f0a01800038003030eb00318f0a02800038003030eb00328f0a03800038003030eb0033",
func: testSelectItem,
expect: {name: "select_item_cmd_46",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "80ル0",
items: [{identifier: 1, text: "80ル1"}, {identifier: 2, text: "80ル2"}, {identifier: 3, text: "80ル3"}]}},
{command: "d03081030124008202818285078104613831eb308f08018104613831eb318f08028104613831eb328f08038104613831eb33",
func: testSelectItem,
expect: {name: "select_item_cmd_47",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "81ル0",
items: [{identifier: 1, text: "81ル1"}, {identifier: 2, text: "81ル2"}, {identifier: 3, text: "81ル3"}]}},
{command: "d0348103012400820281828508820430a03832cb308f0901820430a03832cb318f0902820430a03832cb328f0903820430a03832cb33",
func: testSelectItem,
expect: {name: "select_item_cmd_48",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "82ル0",
items: [{identifier: 1, text: "82ル1"}, {identifier: 2, text: "82ル2"}, {identifier: 3, text: "82ル3"}]}},
{command: "d039810301240082028182850e546f6f6c6b69742053656c6563748f07014974656d20318f07024974656d20328f07034974656d20331803000081",
func: testSelectItem,
expect: {name: "select_item_cmd_49",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Select",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}],
nextActionList: [iccManager.STK_NEXT_ACTION_NULL, iccManager.STK_NEXT_ACTION_NULL, iccManager.STK_NEXT_ACTION_END_PROACTIVE_SESSION]}},
nextActionList: [MozIccManager.STK_NEXT_ACTION_NULL, MozIccManager.STK_NEXT_ACTION_NULL, MozIccManager.STK_NEXT_ACTION_END_PROACTIVE_SESSION]}},
];
runNextTest();
function testSelectItem(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SELECT_ITEM, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.title, aExpect.title, "options.title");
for (let index in aExpect.items) {
let item = aCommand.options.items[index];
let itemExpect = aExpect.items[index];
is(item.identifier, itemExpect.identifier,
"options.items[" + index + "].identifier");
is(item.text, itemExpect.text,
"options.items[" + index + "].text");
if (itemExpect.icons) {
isIcons(item.icons, itemExpect.icons);
is(item.iconSelfExplanatory, itemExpect.iconSelfExplanatory,
"options.items[" + index + "].iconSelfExplanatory");
}
}
if (aExpect.icons) {
isIcons(aCommand.options.icons, aExpect.icons);
is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
"options.iconSelfExplanatory");
}
if (aExpect.nextActionList) {
for (let index in aExpect.nextActionList) {
is(aCommand.options.nextActionList[index], aExpect.nextActionList[index],
"options.nextActionList[" + index + "]");
}
}
}
// 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("select_item_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSelectItem(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,195 +1,138 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSendDTMF(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SEND_DTMF, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.text, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d01b810301140082028183850953656e642044544d46ac052143658709",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_1_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF"}},
{command: "d010810301140082028183ac052143658709",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_1_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0138103011400820281838500ac06c1cccccccc2c",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_2_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: ""}},
{command: "d011810301140082028183ac06c1cccccccc2c",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_2_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d01d810301140082028183850a42617369632049636f6eac02c1f29e020001",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_3_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Basic Icon",
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d011810301140082028183ac02c1f29e020005",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_3_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [colorTransparencyIcon]}},
icons: [COLOR_TRANSPARENCY_ICON]}},
{command: "d01c810301140082028183850953656e642044544d46ac02c1f29e020101",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_4_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF",
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d011810301140082028183ac02c1f29e020105",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_4_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: false,
icons: [colorTransparencyIcon]}},
icons: [COLOR_TRANSPARENCY_ICON]}},
{command: "d028810301140082028183851980041704140420041004120421042204120423041904220415ac02c1f2",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_5_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d00d810301140082028183ac02c1f2",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_5_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b00b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_6_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b00b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_6_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d01d810301140082028183850b53656e642044544d462032ac052143658709",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_7_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 2"}},
// send_dtmf_cmd_7_without_alpha_identifier has the same pdu as
// send_dtmf_cmd_1_without_alpha_identifier.
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b01b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_8_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b01b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_8_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d00400b002b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_9_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d00400b002b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_9_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b04b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_10_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b04b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_10_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462032ac052143658709d004000b00b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_11_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 2"}},
// send_dtmf_cmd_11_without_alpha_identifier has the same pdu as
// send_dtmf_cmd_6_without_alpha_identifier.
{command: "d01d810301140082028183850b53656e642044544d462033ac052143658709",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_12_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 3"}},
// send_dtmf_cmd_12_without_alpha_identifier has the same pdu as
// send_dtmf_cmd_1_without_alpha_identifier.
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b08b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_13_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b08b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_13_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b10b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_14_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b10b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_14_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b20b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_15_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b20b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_15_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b40b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_16_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b40b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_16_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d023810301140082028183850b53656e642044544d462031ac052143658709d004000b80b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_17_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Send DTMF 1"}},
{command: "d016810301140082028183ac052143658709d004000b80b4",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_17_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0148103011400820281838505804f60597dac02c1f2",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_18_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "你好"}},
// send_dtmf_cmd_18_without_alpha_identifier has the same pdu as
// send_dtmf_cmd_5_without_alpha_identifier.
{command: "d01281030114008202818385038030ebac02c1f2",
func: testSendDTMF,
expect: {name: "send_dtmf_cmd_19_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "ル"}}
// send_dtmf_cmd_19_without_alpha_identifier has the same pdu as
// send_dtmf_cmd_5_without_alpha_identifier.
];
runNextTest();
function testSendDTMF(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_DTMF, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
if (aExpect.text) {
is(aCommand.options.text, aExpect.text, "options.text");
}
if (aExpect.icons) {
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)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,281 +1,185 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSendSMS(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SEND_SMS, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.title, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d037810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
func: testSendSMS,
expect: {name: "send_sms_cmd_1_with_alpha_identifier",
commandQualifier: 0x00,
title: "Send SM"}},
expect: {commandQualifier: 0x00,
text: "Send SM"}},
{command: "d02e81030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
func: testSendSMS,
expect: {name: "send_sms_cmd_1_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d032810301130182028183850753656e6420534d86099111223344556677f88b130100099110325476f840f40753656e6420534d",
func: testSendSMS,
expect: {name: "send_sms_cmd_2_with_alpha_identifier",
commandQualifier: 0x01,
title: "Send SM"}},
expect: {commandQualifier: 0x01,
text: "Send SM"}},
{command: "d02981030113018202818386099111223344556677f88b130100099110325476f840f40753656e6420534d",
func: testSendSMS,
expect: {name: "send_sms_cmd_2_without_alpha_identifier",
commandQualifier: 0x01}},
expect: {commandQualifier: 0x01}},
{command: "d03d810301130082028183850d53686f7274204d65737361676586099111223344556677f88b180100099110325476f840f00d53f45b4e0735cbf379f85c06",
func: testSendSMS,
expect: {name: "send_sms_cmd_3_with_alpha_identifier",
commandQualifier: 0x00,
title: "Short Message"}},
expect: {commandQualifier: 0x00,
text: "Short Message"}},
{command: "d02e81030113008202818386099111223344556677f88b180100099110325476f840f00d53f45b4e0735cbf379f85c06",
func: testSendSMS,
expect: {name: "send_sms_cmd_3_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d081fd810301130182028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052501144657374696e6174696f6e114164647265737386099111223344556677f88b81ac0100099110325476f840f4a054776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e7370",
func: testSendSMS,
expect: {name: "send_sms_cmd_4_with_alpha_identifier",
commandQualifier: 0x01,
title: "The address data object holds the RP_Destination_Address"}},
expect: {commandQualifier: 0x01,
text: "The address data object holds the RP_Destination_Address"}},
{command: "d081c381030113018202818386099111223344556677f88b81ac0100099110325476f840f4a054776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e7370",
func: testSendSMS,
expect: {name: "send_sms_cmd_4_without_alpha_identifier",
commandQualifier: 0x01}},
expect: {commandQualifier: 0x01}},
{command: "d081e9810301130082028183853854686520616464726573732064617461206f626a65637420686f6c6473207468652052502044657374696e6174696f6e204164647265737386099111223344556677f88b81980100099110325476f840f0a0d4fb1b44cfc3cb7350585e0691cbe6b4bb4cd6815aa020688e7ecbe9a076793e0f9fcb20fa1b242e83e665371d447f83e8e832c85da6dfdff23528ed0685dda06973da9a5685cd2415d42ecfe7e17399057acb41613768da9cb686cf6633e82482dae5f93c7c2eb3407774595e06d1d165507d5e9683c8617a18340ebb41e232081e9ecfcb64105d1e76cfe1",
func: testSendSMS,
expect: {name: "send_sms_cmd_5_with_alpha_identifier",
commandQualifier: 0x00,
title: "The address data object holds the RP Destination Address"}},
expect: {commandQualifier: 0x00,
text: "The address data object holds the RP Destination Address"}},
{command: "d081af81030113008202818386099111223344556677f88b81980100099110325476f840f0a0d4fb1b44cfc3cb7350585e0691cbe6b4bb4cd6815aa020688e7ecbe9a076793e0f9fcb20fa1b242e83e665371d447f83e8e832c85da6dfdff23528ed0685dda06973da9a5685cd2415d42ecfe7e17399057acb41613768da9cb686cf6633e82482dae5f93c7c2eb3407774595e06d1d165507d5e9683c8617a18340ebb41e232081e9ecfcb64105d1e76cfe1",
func: testSendSMS,
expect: {name: "send_sms_cmd_5_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d081fd8103011300820281838581e654776f2074797065732061726520646566696e65643a202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954206d6573736167652c206f7220616e20534d532d434f4d4d414e44206d6573736167652c20776865726520746865207573657220646174612063616e20626520706173736564207472616e73706172656e746c793b202d20412073686f7274206d65737361676520746f2062652073656e7420746f20746865206e6574776f726b20696e20616e20534d532d5355424d4954208b09010002911040f00120",
func: testSendSMS,
expect: {name: "send_sms_cmd_6_with_alpha_identifier",
commandQualifier: 0x00,
title: "Two types are defined: - A short message to be sent to the network in an SMS-SUBMIT message, or an SMS-COMMAND message, where the user data can be passed transparently; - A short message to be sent to the network in an SMS-SUBMIT "}},
expect: {commandQualifier: 0x00,
text: "Two types are defined: - A short message to be sent to the network in an SMS-SUBMIT message, or an SMS-COMMAND message, where the user data can be passed transparently; - A short message to be sent to the network in an SMS-SUBMIT "}},
{command: "d0148103011300820281838b09010002911040f00120",
func: testSendSMS,
expect: {name: "send_sms_cmd_6_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d030810301130082028183850086099111223344556677f88b180100099110325476f840f40c54657374204d657373616765",
func: testSendSMS,
expect: {name: "send_sms_cmd_7_with_alpha_identifier",
commandQualifier: 0x00,
title: ""}},
// send_sms_cmd_7_without_alpha_identifier has the same pdu as
// send_sms_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: ""}},
{command: "d05581030113008202818385198004170414042004100412042104220412042304190422041586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
func: testSendSMS,
expect: {name: "send_sms_cmd_8_with_alpha_identifier",
commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ"}},
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d03a81030113008202818386099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
func: testSendSMS,
expect: {name: "send_sms_cmd_8_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d04b810301130082028183850f810c089794a09092a1a292a399a29586099111223344556677f88b240100099110325476f8400818041704140420041004120421042204120423041904220415",
func: testSendSMS,
expect: {name: "send_sms_cmd_9_with_alpha_identifier",
commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ"}},
// send_sms_cmd_9_without_alpha_identifier has the same pdu as
// send_sms_cmd_8_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d03b81030113008202818385074e4f2049434f4e86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167659e020002",
func: testSendSMS,
expect: {name: "send_sms_cmd_10_with_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
// The record number 02 in EFimg is not defined, so no icon will be
// shown, but the text string should still be displayed.
title: "NO ICON"}},
text: "NO ICON"}},
{command: "d03281030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d6573736167659e020001",
func: testSendSMS,
expect: {name: "send_sms_cmd_10_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d03b810301130082028183850753656e6420534d86099111223344556677f88b180100099110325476f840f40c54657374204d6573736167651e020101",
func: testSendSMS,
expect: {name: "send_sms_cmd_11_with_alpha_identifier",
commandQualifier: 0x00,
title: "Send SM",
expect: {commandQualifier: 0x00,
text: "Send SM",
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d03281030113008202818386099111223344556677f88b180100099110325476f840f40c54657374204d6573736167651e020101",
func: testSendSMS,
expect: {name: "send_sms_cmd_11_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001000b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_12_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001000b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_12_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0268103011300820281838510546578742041747472696275746520328b09010002911040f00120",
func: testSendSMS,
expect: {name: "send_sms_cmd_13_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_sms_cmd_18_without_alpha_identifier has the same pdu as
// send_sms_cmd_6_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001001b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_14_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001001b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_14_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001002b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_15_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001002b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_15_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001004b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_16_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001004b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_16_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520328b09010002911040f00120d004001000b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_17_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_sms_cmd_17_without_alpha_identifier has the same pdu as
// send_sms_cmd_12_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d0268103011300820281838510546578742041747472696275746520338b09010002911040f00120",
func: testSendSMS,
expect: {name: "send_sms_cmd_18_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 3"}},
// send_sms_cmd_18_without_alpha_identifier has the same pdu as
// send_sms_cmd_6_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 3"}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001008b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_19_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001008b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_19_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001010b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_20_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001010b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_20_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001020b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_21_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001020b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_21_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001040b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_22_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001040b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_22_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02c8103011300820281838510546578742041747472696275746520318b09010002911040f00120d004001080b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_23_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d01a8103011300820281838b09010002911040f00120d004001080b4",
func: testSendSMS,
expect: {name: "send_sms_cmd_23_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02d8103011300820281838505804e2d4e0086099111223344556677f88b100100099110325476f84008044e2d4e00",
func: testSendSMS,
expect: {name: "send_sms_cmd_24_with_alpha_identifier",
commandQualifier: 0x00,
title: "中一"}},
expect: {commandQualifier: 0x00,
text: "中一"}},
{command: "d02681030113008202818386099111223344556677f88b100100099110325476f84008044e2d4e00",
func: testSendSMS,
expect: {name: "send_sms_cmd_24_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02d810301130082028183850581029cad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
func: testSendSMS,
expect: {name: "send_sms_cmd_25_with_alpha_identifier",
commandQualifier: 0x00,
title: "中一"}},
// send_sms_cmd_25_without_alpha_identifier has the same pdu as
// send_sms_cmd_24_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "中一"}},
{command: "d02e810301130082028183850682024e00ad8086099111223344556677f88b100100099110325476f84008044e2d4e00",
func: testSendSMS,
expect: {name: "send_sms_cmd_26_with_alpha_identifier",
commandQualifier: 0x00,
title: "中一"}},
// send_sms_cmd_26_without_alpha_identifier has the same pdu as
// send_sms_cmd_24_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "中一"}},
{command: "d0358103011300820281838509800038003030eb003086099111223344556677f88b140100099110325476f84008080038003030eb0031",
func: testSendSMS,
expect: {name: "send_sms_cmd_27_with_alpha_identifier",
commandQualifier: 0x00,
title: "80ル0"}},
expect: {commandQualifier: 0x00,
text: "80ル0"}},
{command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0031",
func: testSendSMS,
expect: {name: "send_sms_cmd_27_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d03381030113008202818385078104613831eb3186099111223344556677f88b140100099110325476f84008080038003030eb0032",
func: testSendSMS,
expect: {name: "send_sms_cmd_28_with_alpha_identifier",
commandQualifier: 0x00,
title: "81ル1"}},
expect: {commandQualifier: 0x00,
text: "81ル1"}},
{command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0032",
func: testSendSMS,
expect: {name: "send_sms_cmd_28_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0348103011300820281838508820430a03832cb3286099111223344556677f88b140100099110325476f84008080038003030eb0033",
func: testSendSMS,
expect: {name: "send_sms_cmd_29_with_alpha_identifier",
commandQualifier: 0x00,
title: "82ル2"}},
expect: {commandQualifier: 0x00,
text: "82ル2"}},
{command: "d02a81030113008202818386099111223344556677f88b140100099110325476f84008080038003030eb0033",
func: testSendSMS,
expect: {name: "send_sms_cmd_29_without_alpha_identifier",
commandQualifier: 0x00}}
expect: {commandQualifier: 0x00}}
];
runNextTest();
function testSendSMS(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SMS, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
if (aExpect.text) {
is(aCommand.options.text, aExpect.text, "options.text");
}
if (aExpect.icons) {
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_sms_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSMS(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,222 +1,155 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSendSS(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SEND_SS, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.title, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d029810301110082028183850c43616c6c20466f7277617264891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_1_with_alpha_identifier",
commandQualifier: 0x00,
title: "Call Forward"}},
expect: {commandQualifier: 0x00,
text: "Call Forward"}},
{command: "d01b810301110082028183891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_1_without_alpha_identifier",
commandQualifier: 0x00}},
{command: "d02d810301110082028183850c43616c6c20466f7277617264891491aa120a21436587092143658709214365a711fb",
func: testSendSS,
expect: {name: "send_ss_cmd_2_with_alpha_identifier",
commandQualifier: 0x00,
title: "Call Forward"}},
text: "Call Forward"}},
{command: "d01f810301110082028183891491aa120a21436587092143658709214365a711fb",
func: testSendSS,
expect: {name: "send_ss_cmd_2_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d081fd8103011100820281838581eb4576656e20696620746865204669786564204469616c6c696e67204e756d626572207365727669636520697320656e61626c65642c2074686520737570706c656d656e74617279207365727669636520636f6e74726f6c20737472696e6720696e636c7564656420696e207468652053454e442053532070726f61637469766520636f6d6d616e64207368616c6c206e6f7420626520636865636b656420616761696e73742074686f7365206f66207468652046444e206c6973742e2055706f6e20726563656976696e67207468697320636f6d6d616e642c20746865204d45207368616c6c20646563698904ffba13fb",
func: testSendSS,
expect: {name: "send_ss_cmd_3_with_alpha_identifier",
commandQualifier: 0x00,
title: "Even if the Fixed Dialling Number service is enabled, the supplementary service control string included in the SEND SS proactive command shall not be checked against those of the FDN list. Upon receiving this command, the ME shall deci"}},
expect: {commandQualifier: 0x00,
text: "Even if the Fixed Dialling Number service is enabled, the supplementary service control string included in the SEND SS proactive command shall not be checked against those of the FDN list. Upon receiving this command, the ME shall deci"}},
{command: "d00f8103011100820281838904ffba13fb",
func: testSendSS,
expect: {name: "send_ss_cmd_3_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d01d8103011100820281838500891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_4_with_alpha_identifier",
commandQualifier: 0x00,
title: ""}},
// send_ss_cmd_4_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: ""}},
{command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020001",
func: testSendSS,
expect: {name: "send_ss_cmd_5_with_alpha_identifier",
commandQualifier: 0x00,
title: "Basic Icon",
expect: {commandQualifier: 0x00,
text: "Basic Icon",
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020001",
func: testSendSS,
expect: {name: "send_ss_cmd_5_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d02c810301110082028183850b436f6c6f75722049636f6e891091aa120a214365870921436587a901fb9e020003",
func: testSendSS,
expect: {name: "send_ss_cmd_6_with_alpha_identifier",
commandQualifier: 0x00,
title: "Colour Icon",
expect: {commandQualifier: 0x00,
text: "Colour Icon",
iconSelfExplanatory: true,
icons: [colorIcon]}},
icons: [COLOR_ICON]}},
{command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020003",
func: testSendSS,
expect: {name: "send_ss_cmd_6_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [colorIcon]}},
icons: [COLOR_ICON]}},
{command: "d02b810301110082028183850a42617369632049636f6e891091aa120a214365870921436587a901fb9e020101",
func: testSendSS,
expect: {name: "send_ss_cmd_7_with_alpha_identifier",
commandQualifier: 0x00,
title: "Basic Icon",
expect: {commandQualifier: 0x00,
text: "Basic Icon",
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d01f810301110082028183891091aa120a214365870921436587a901fb9e020101",
func: testSendSS,
expect: {name: "send_ss_cmd_7_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d036810301110082028183851980041704140420041004120421042204120423041904220415891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_8_with_alpha_identifier",
commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ"}},
// send_ss_cmd_8_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001000b4",
func: testSendSS,
expect: {name: "send_ss_cmd_9_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001000b4",
func: testSendSS,
expect: {name: "send_ss_cmd_9_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02d810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_10_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_ss_cmd_10_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001001b4",
func: testSendSS,
expect: {name: "send_ss_cmd_11_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001001b4",
func: testSendSS,
expect: {name: "send_ss_cmd_11_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001002b4",
func: testSendSS,
expect: {name: "send_ss_cmd_12_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001002b4",
func: testSendSS,
expect: {name: "send_ss_cmd_12_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001004b4",
func: testSendSS,
expect: {name: "send_ss_cmd_13_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001004b4",
func: testSendSS,
expect: {name: "send_ss_cmd_13_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652032891091aa120a214365870921436587a901fbd004001000b4",
func: testSendSS,
expect: {name: "send_ss_cmd_14_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_ss_cmd_14_without_alpha_identifier has the same pdu as
// send_ss_cmd_9_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d02d810301110082028183851054657874204174747269627574652033891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_15_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 3"}},
// send_ss_cmd_15_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 3"}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001008b4",
func: testSendSS,
expect: {name: "send_ss_cmd_16_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001008b4",
func: testSendSS,
expect: {name: "send_ss_cmd_16_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001010b4",
func: testSendSS,
expect: {name: "send_ss_cmd_17_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001010b4",
func: testSendSS,
expect: {name: "send_ss_cmd_17_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001020b4",
func: testSendSS,
expect: {name: "send_ss_cmd_18_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001020b4",
func: testSendSS,
expect: {name: "send_ss_cmd_18_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001040b4",
func: testSendSS,
expect: {name: "send_ss_cmd_19_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001040b4",
func: testSendSS,
expect: {name: "send_ss_cmd_19_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d033810301110082028183851054657874204174747269627574652031891091aa120a214365870921436587a901fbd004001080b4",
func: testSendSS,
expect: {name: "send_ss_cmd_20_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d021810301110082028183891091aa120a214365870921436587a901fbd004001080b4",
func: testSendSS,
expect: {name: "send_ss_cmd_20_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0228103011100820281838505804f60597d891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_21_with_alpha_identifier",
commandQualifier: 0x00,
title: "你好"}},
// send_ss_cmd_21_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "你好"}},
{command: "d02081030111008202818385038030eb891091aa120a214365870921436587a901fb",
func: testSendSS,
expect: {name: "send_ss_cmd_22_with_alpha_identifier",
commandQualifier: 0x00,
title: "ル"}},
// send_ss_cmd_22_without_alpha_identifier has the same pdu as
// send_ss_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "ル"}},
];
runNextTest();
function testSendSS(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_SS, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
if (aExpect.text) {
is(aCommand.options.text, aExpect.text, "options.text");
}
if (aExpect.icons) {
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_ss_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendSS(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,229 +1,156 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSendUSSD(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SEND_USSD, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.title, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d050810301120082028183850a372d62697420555353448a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_1_with_alpha_identifier",
commandQualifier: 0x00,
title: "7-bit USSD"}},
expect: {commandQualifier: 0x00,
text: "7-bit USSD"}},
{command: "d0448103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_1_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d058810301120082028183850a382d62697420555353448a41444142434445464748494a4b4c4d4e4f505152535455565758595a2d6162636465666768696a6b6c6d6e6f707172737475767778797a2d31323334353637383930",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_2_with_alpha_identifier",
commandQualifier: 0x00,
title: "8-bit USSD"}},
expect: {commandQualifier: 0x00,
text: "8-bit USSD"}},
{command: "d04c8103011200820281838a41444142434445464748494a4b4c4d4e4f505152535455565758595a2d6162636465666768696a6b6c6d6e6f707172737475767778797a2d31323334353637383930",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_2_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d02f81030112008202818385095543533220555353448a1948041704140420041004120421042204120423041904220415",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_3_with_alpha_identifier",
commandQualifier: 0x00,
title: "UCS2 USSD"}},
expect: {commandQualifier: 0x00,
text: "UCS2 USSD"}},
{command: "d0248103011200820281838a1948041704140420041004120421042204120423041904220415",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_3_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d081fd8103011200820281838581b66f6e636520612052454c4541534520434f4d504c455445206d65737361676520636f6e7461696e696e672074686520555353442052657475726e20526573756c74206d657373616765206e6f7420636f6e7461696e696e6720616e206572726f7220686173206265656e2072656365697665642066726f6d20746865206e6574776f726b2c20746865204d45207368616c6c20696e666f726d207468652053494d20746861742074686520636f6d6d616e64206861738a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_4_with_alpha_identifier",
commandQualifier: 0x00,
title: "once a RELEASE COMPLETE message containing the USSD Return Result message not containing an error has been received from the network, the ME shall inform the SIM that the command has"}},
// send_ussd_cmd_4_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "once a RELEASE COMPLETE message containing the USSD Return Result message not containing an error has been received from the network, the ME shall inform the SIM that the command has"}},
{command: "d04681030112008202818385008a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_5_with_alpha_identifier",
commandQualifier: 0x00,
title: ""}},
// send_ussd_cmd_5_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: ""}},
{command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020001",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_6_with_alpha_identifier",
commandQualifier: 0x00,
title: "Basic Icon",
expect: {commandQualifier: 0x00,
text: "Basic Icon",
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020001",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_6_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d054810301120082028183850a436f6c6f722049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020003",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_7_with_alpha_identifier",
commandQualifier: 0x00,
title: "Color Icon",
expect: {commandQualifier: 0x00,
text: "Color Icon",
iconSelfExplanatory: true,
icons: [colorIcon]}},
icons: [COLOR_ICON]}},
{command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020003",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_7_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: true,
icons: [colorIcon]}},
icons: [COLOR_ICON]}},
{command: "d054810301120082028183850a42617369632049636f6e8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_8_with_alpha_identifier",
commandQualifier: 0x00,
title: "Basic Icon",
expect: {commandQualifier: 0x00,
text: "Basic Icon",
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d0488103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e5609e020101",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_8_without_alpha_identifier",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
iconSelfExplanatory: false,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d05f8103011200820281838519800417041404200410041204210422041204230419042204158a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_9_with_alpha_identifier",
commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ"}},
// send_ussd_cmd_9_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_10_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_10_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d0568103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_11_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_ussd_cmd_11_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_12_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001001b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_12_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_13_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001002b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_13_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_14_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001004b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_14_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520328a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001000b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_15_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 2"}},
// send_ussd_cmd_15_without_alpha_identifier has the same pdu as
// send_ussd_cmd_10_with_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 2"}},
{command: "d0568103011200820281838510546578742041747472696275746520338a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_16_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 3"}},
// send_ussd_cmd_16_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "Text Attribute 3"}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_17_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001008b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_17_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001010b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_18_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001010b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_18_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001020b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_19_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001020b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_19_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001040b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_20_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001040b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_20_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d05c8103011200820281838510546578742041747472696275746520318a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001080b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_21_with_alpha_identifier",
commandQualifier: 0x00,
title: "Text Attribute 1"}},
expect: {commandQualifier: 0x00,
text: "Text Attribute 1"}},
{command: "d04a8103011200820281838a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560d004001080b4",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_21_without_alpha_identifier",
commandQualifier: 0x00}},
expect: {commandQualifier: 0x00}},
{command: "d04b8103011200820281838505804f60597d8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_22_with_alpha_identifier",
commandQualifier: 0x00,
title: "你好"}},
// send_ussd_cmd_22_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "你好"}},
{command: "d04981030112008202818385038030eb8a39f041e19058341e9149e592d9743ea151e9945ab55eb1596d2b2c1e93cbe6333aad5eb3dbee373c2e9fd3ebf63b3eaf6fc564335acd76c3e560",
func: testSendUSSD,
expect: {name: "send_ussd_cmd_23_with_alpha_identifier",
commandQualifier: 0x00,
title: "ル"}},
// send_ussd_cmd_23_without_alpha_identifier has the same pdu as
// send_ussd_cmd_1_without_alpha_identifier.
expect: {commandQualifier: 0x00,
text: "ル"}},
];
runNextTest();
function testSendUSSD(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SEND_USSD, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
if (aExpect.text) {
is(aCommand.options.text, aExpect.text, "options.text");
}
if (aExpect.icons) {
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_ussd_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSendUSSD(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,376 +1,301 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSetupCall(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_CALL, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.address, expect.address, expect.name);
if (expect.confirmMessage) {
isStkText(command.options.confirmMessage, expect.confirmMessage, expect.name);
}
if (expect.callMessage) {
isStkText(command.options.callMessage, expect.callMessage, expect.name);
}
let duration = command.options.duration;
if (duration) {
is(duration.timeUnit, expect.duration.timeUnit, expect.name);
is(duration.timeInterval, expect.duration.timeInterval, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d01e81030110008202818385084e6f7420627573798609911032042143651c2c",
func: testSetupCall,
expect: {name: "setup_call_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Not busy" },
address: "+012340123456,1,2"}},
{command: "d01d81030110028202818385074f6e20686f6c648609911032042143651c2c",
func: testSetupCall,
expect: {name: "setup_call_cmd_2",
commandQualifier: 0x02,
expect: {commandQualifier: 0x02,
confirmMessage: { text: "On hold" },
address: "+012340123456,1,2"}},
{command: "d020810301100482028183850a446973636f6e6e6563748609911032042143651c2c",
func: testSetupCall,
expect: {name: "setup_call_cmd_3",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
confirmMessage: { text: "Disconnect" },
address: "+012340123456,1,2"}},
{command: "d02b81030110008202818385114361706162696c69747920636f6e6669678609911032042143651c2c870201a0",
func: testSetupCall,
expect: {name: "setup_call_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Capability config" },
address: "+012340123456,1,2"}},
{command: "d01c81030110018202818386119110325476981032547698103254769810",
func: testSetupCall,
expect: {name: "setup_call_cmd_5",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
address: "+01234567890123456789012345678901"}},
{command: "d081fd8103011001820281838581ed54687265652074797065732061726520646566696e65643a202d2073657420757020612063616c6c2c20627574206f6e6c79206966206e6f742063757272656e746c792062757379206f6e20616e6f746865722063616c6c3b202d2073657420757020612063616c6c2c2070757474696e6720616c6c206f746865722063616c6c732028696620616e7929206f6e20686f6c643b202d2073657420757020612063616c6c2c20646973636f6e6e656374696e6720616c6c206f746865722063616c6c732028696620616e79292066697273742e20466f722065616368206f662074686573652074797065732c2086029110",
func: testSetupCall,
expect: {name: "setup_call_cmd_6",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
confirmMessage: { text: "Three types are defined: - set up a call, but only if not currently busy on another call; - set up a call, putting all other calls (if any) on hold; - set up a call, disconnecting all other calls (if any) first. For each of these types, " },
address: "+01"}},
{command: "d02b810301100082028183850c43616c6c65642070617274798609911032042143651c2c880780509595959595",
func: testSetupCall,
expect: {name: "setup_call_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Called party" },
address: "+012340123456,1,2"}},
{command: "d02281030110018202818385084475726174696f6e8609911032042143651c2c8402010a",
func: testSetupCall,
expect: {name: "setup_call_cmd_8",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
confirmMessage: { text: "Duration" },
address: "+012340123456,1,2",
duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND,
duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
timeInterval: 0x0A}}},
{command: "d028810301100082028183850c434f4e4649524d4154494f4e8609911032042143651c2c850443414c4c",
func: testSetupCall,
expect: {name: "setup_call_cmd_9",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION" },
callMessage: { text: "CALL" },
address: "+012340123456,1,2"}},
{command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e312e318609911032042143651c2c9e020101",
func: testSetupCall,
expect: {name: "setup_call_cmd_10",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Set up call Icon 3.1.1",
iconSelfExplanatory: false,
icons: [basicIcon] },
icons: [BASIC_ICON] },
address: "+012340123456,1,2"}},
{command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e322e318609911032042143651c2c9e020001",
func: testSetupCall,
expect: {name: "setup_call_cmd_11",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Set up call Icon 3.2.1",
iconSelfExplanatory: true,
icons: [basicIcon] },
icons: [BASIC_ICON] },
address: "+012340123456,1,2"}},
{command: "d03081030110008202818385165365742075702063616c6c2049636f6e20332e332e318609911032042143651c2c9e020103",
func: testSetupCall,
expect: {name: "setup_call_cmd_12",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Set up call Icon 3.3.1",
iconSelfExplanatory: false,
icons: [colorIcon] },
icons: [COLOR_ICON] },
address: "+012340123456,1,2"}},
{command: "d04c81030110008202818385165365742075702063616c6c2049636f6e20332e342e318609911032042143651c2c9e02000185165365742075702063616c6c2049636f6e20332e342e329e020001",
func: testSetupCall,
expect: {name: "setup_call_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Set up call Icon 3.4.1",
iconSelfExplanatory: true,
icons: [basicIcon] },
icons: [BASIC_ICON] },
callMessage: { text: "Set up call Icon 3.4.2" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
func: testSetupCall,
expect: {name: "setup_call_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e01b4d004000601b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
func: testSetupCall,
expect: {name: "setup_call_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e02b4d004000602b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
func: testSetupCall,
expect: {name: "setup_call_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e04b4d004000604b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_20",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_22",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e08b4d004000608b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_23",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_24",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_25",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e10b4d004000610b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_26",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_27",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_28",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e20b4d004000620b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_29",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_30",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_31",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e40b4d004000640b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_32",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_33",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_34",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e80b4d004000680b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_35",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032d004000e00b4d004000600b4",
func: testSetupCall,
expect: {name: "setup_call_cmd_36",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20338609911032042143651c2c850643414c4c2033",
func: testSetupCall,
expect: {name: "setup_call_cmd_37",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 3" },
callMessage: { text: "CALL 3" },
address: "+012340123456,1,2"}},
{command: "d038810301100082028183850e434f4e4649524d4154494f4e20318609911032042143651c2c850643414c4c2031d004000e00b4d0040006004b",
func: testSetupCall,
expect: {name: "setup_call_cmd_38",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 1" },
callMessage: { text: "CALL 1" },
address: "+012340123456,1,2"}},
{command: "d02c810301100082028183850e434f4e4649524d4154494f4e20328609911032042143651c2c850643414c4c2032",
func: testSetupCall,
expect: {name: "setup_call_cmd_39",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "CONFIRMATION 2" },
callMessage: { text: "CALL 2" },
address: "+012340123456,1,2"}},
{command: "d02d810301100082028183851980041704140420041004120421042204120423041904220415860791103204214365",
func: testSetupCall,
expect: {name: "setup_call_cmd_40",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "ЗДРАВСТВУЙТЕ" },
address: "+012340123456"}},
{command: "d04c810301100082028183851b800417041404200410041204210422041204230419042204150031860791103204214365851b800417041404200410041204210422041204230419042204150032",
func: testSetupCall,
expect: {name: "setup_call_cmd_41",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "ЗДРАВСТВУЙТЕ1" },
callMessage: { text: "ЗДРАВСТВУЙТЕ2" },
address: "+012340123456"}},
{command: "d0198103011000820281838505804e0d5fd9860791103204214365",
func: testSetupCall,
expect: {name: "setup_call_cmd_42",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "不忙" },
address: "+012340123456"}},
{command: "d022810301100082028183850580786e5b9a860791103204214365850780625375358bdd",
func: testSetupCall,
expect: {name: "setup_call_cmd_43",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "确定" },
callMessage: { text: "打电话" },
address: "+012340123456"}},
{command: "d01781030110008202818385038030eb860791103204214365",
func: testSetupCall,
expect: {name: "setup_call_cmd_44",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "ル" },
address: "+012340123456"}},
{command: "d02081030110008202818385058030eb003186079110320421436585058030eb0032",
func: testSetupCall,
expect: {name: "setup_call_cmd_45",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "ル1" },
callMessage: { text: "ル2" },
address: "+012340123456"}},
{command: "d029810301100482028182050a446973636f6e6e6563748609811032042143651c2c05074d657373616765",
func: testSetupCall,
expect: {name: "setup_call_cmd_46",
commandQualifier: 0x04,
expect: {commandQualifier: 0x04,
confirmMessage: { text: "Disconnect" },
address: "012340123456,1,2",
callMessage: { text: "Message"}}},
{command: "d02281030110008202818385084E6F7420627573798609911032042143651C2C8402010A",
func: testSetupCall,
expect: {name: "setup_call_cmd_47",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Not busy" },
address: "+012340123456,1,2",
duration: {timeUnit: iccManager.STK_TIME_UNIT_SECOND,
duration: {timeUnit: MozIccManager.STK_TIME_UNIT_SECOND,
timeInterval: 0x0A}}},
{command: "d04c81030110008202818385165365742075702063616c6c2049636f6e20332e352e318609911032042143651c2c9e02000185165365742075702063616c6c2049636f6e20332e352e329e020103",
func: testSetupCall,
expect: {name: "setup_call_cmd_48",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { text: "Set up call Icon 3.5.1",
iconSelfExplanatory: true,
icons: [basicIcon] },
icons: [BASIC_ICON] },
callMessage: { text: "Set up call Icon 3.5.2",
iconSelfExplanatory: false,
icons: [colorIcon] },
icons: [COLOR_ICON] },
address: "+012340123456,1,2"}},
{command: "d01c8103011000820281838609911032042143651c2c9e0200019e020103",
func: testSetupCall,
expect: {name: "setup_call_cmd_49",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
confirmMessage: { iconSelfExplanatory: true,
icons: [basicIcon] },
icons: [BASIC_ICON] },
callMessage: { iconSelfExplanatory: false,
icons: [colorIcon] },
icons: [COLOR_ICON] },
address: "+012340123456,1,2"}},
];
runNextTest();
function testSetupCall(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_CALL,
"typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier,
"commandQualifier");
is(aCommand.options.address, aExpect.address,
"options.address");
if (aExpect.confirmMessage) {
isStkText(aCommand.options.confirmMessage, aExpect.confirmMessage);
}
if (aExpect.callMessage) {
isStkText(aCommand.options.callMessage, aExpect.callMessage);
}
let duration = aCommand.options.duration;
if (duration) {
is(duration.timeUnit, aExpect.duration.timeUnit, "duration.timeUnit");
is(duration.timeInterval, aExpect.duration.timeInterval,
"duration.timeInterval");
}
}
// 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("setup_call_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupCall(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,50 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSetupEventList(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_EVENT_LIST, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
for (let index in command.options.eventList) {
is(command.options.eventList[index], expect.eventList[index], expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d00c810301050082028182990104",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: [4]}},
{command: "d00d81030105008202818299020507",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: [5, 7]}},
{command: "d00c810301050082028182990107",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: [7]}},
{command: "d00c810301050082028182990107",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: [7]}},
{command: "d00b8103010500820281829900",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_5",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: null}},
{command: "d00c810301050082028182990107",
func: testSetupEventList,
expect: {name: "setup_event_list_cmd_6",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
eventList: [7]}}
];
runNextTest();
function testSetupEventList(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_EVENT_LIST,
"typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
for (let index in aExpect.eventList) {
is(aCommand.options.eventList[index], aExpect.eventList[index],
"options.eventList[" + index + "]");
}
}
// 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("setup_event_list_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupEventList(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,207 +1,154 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSetupIdleModeText(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_IDLE_MODE_TEXT, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.text, expect.text, expect.name);
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d01a8103012800820281828d0f0449646c65204d6f64652054657874",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text"}},
{command: "d0188103012800820281828d0d04546f6f6c6b69742054657374",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Toolkit Test"}},
{command: "d081fd8103012800820281828d81f100547419344d3641737498cd06cdeb70383b0f0a83e8653c1d34a7cbd3ee330b7447a7c768d01c1d66b341e232889c9ec3d9e17c990c12e741747419d42c82c27350d80d4a93d96550fb4d2e83e8653c1d943683e8e832a85904a5e7a0b0985d06d1df20f21b94a6bba8e832082e2fcfcb6e7a989e7ebb41737a9e5d06a5e72076d94c0785e7a0b01b946ec3d9e576d94d0fd3d36f37885c1ea7e7e9b71b447f83e8e832a85904b5c3eeba393ca6d7e565b90b444597416932bb0c6abfc96510bd8ca783e6e8309b0d129741e4f41cce0ee7cb6450da0d0a83da61b7bb2c07d1d1613aa8ec9ed7e5e539888e0ed341ee32",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "The SIM shall supply a text string, which shall be displayed by the ME as an idle mode text if the ME is able to do it.The presentation style is left as an implementation decision to the ME manufacturer. The idle mode text shall be displayed in a manner that ensures that ne"}},
{command: "d0198103012800820281828d0a0449646c6520746578749e020001",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle text",
iconSelfExplanatory: true,
icons: [basicIcon]}},
icons: [BASIC_ICON]}},
{command: "d0198103012800820281828d0a0449646c6520746578749e020105",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_5",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle text",
iconSelfExplanatory: false,
icons: [colorTransparencyIcon]}},
icons: [COLOR_TRANSPARENCY_ICON]}},
{command: "d0198103012800820281828d0a0449646c6520746578749e020007",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_6",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle text",
iconSelfExplanatory: true,
icons: [colorIcon, colorTransparencyIcon]}},
icons: [COLOR_ICON, COLOR_TRANSPARENCY_ICON]}},
{command: "d0248103012800820281828d1908041704140420041004120421042204120423041904220415",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "ЗДРАВСТВУЙТЕ"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_8",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_9",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001001b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_10",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_11",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001002b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_12",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001004b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001008b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001010b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_20",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_22",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001020b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_23",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_24",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_25",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001040b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_26",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_27",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_28",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001080b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_29",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742032d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_30",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742033",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_31",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 3"}},
{command: "d0228103012800820281828d110449646c65204d6f646520546578742031d004001000b4",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_32",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 1"}},
{command: "d01c8103012800820281828d110449646c65204d6f646520546578742032",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_33",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "Idle Mode Text 2"}},
{command: "d0108103012800820281828d05084f60597d",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_34",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "你好"}},
{command: "d0148103012800820281828d09080038003030eb0030",
func: testSetupIdleModeText,
expect: {name: "setup_idle_mode_text_cmd_35",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
text: "80ル0"}},
];
runNextTest();
function testSetupIdleModeText(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_IDLE_MODE_TEXT,
"typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.text, aExpect.text, "options.text");
if (aExpect.icons) {
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("setup_idle_mode_text_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupIdleModeText(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});

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

@ -1,269 +1,216 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_HEAD_JS = "stk_helper.js";
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function testSetupMenu(command, expect) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_MENU, expect.name);
is(command.commandQualifier, expect.commandQualifier, expect.name);
is(command.options.title, expect.title, expect.name);
for (let index in command.options.items) {
is(command.options.items[index].identifier, expect.items[index].identifier, expect.name);
is(command.options.items[index].text, expect.items[index].text, expect.name);
let itemIcons = command.options.items[index].icons;
if (itemIcons) {
isIcons(itemIcons, expect.items[index].icons, expect.name);
let iconSelfExplanatory = command.options.items[index].iconSelfExplanatory;
is(iconSelfExplanatory, expect.items[index].iconSelfExplanatory, expect.name);
}
}
let icons = command.options.icons;
if (icons) {
isIcons(icons, expect.icons, expect.name);
let iconSelfExplanatory = command.options.iconSelfExplanatory;
is(iconSelfExplanatory, expect.iconSelfExplanatory, expect.name);
}
let length = command.options.nextActionList ? command.options.nextActionList.length : 0;
for (let i = 0; i < length; i++) {
is(command.options.nextActionList[i], expect.nextActionList[i], expect.name);
}
runNextTest();
}
function isFirstMenuItemNull(command) {
return (command.options.items.length == 1 && !(command.options.items[0]));
}
function testInitialSetupMenu(command) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_MENU);
is(isFirstMenuItemNull(command), false);
runNextTest();
}
function testRemoveSetupMenu(command) {
log("STK CMD " + JSON.stringify(command));
is(command.typeOfCommand, iccManager.STK_CMD_SET_UP_MENU);
is(isFirstMenuItemNull(command), true);
runNextTest();
}
let tests = [
const TEST_DATA = [
{command: "d03b810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_1",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
{command: "d023810301250082028182850c546f6f6c6b6974204d656e758f04114f6e658f041254776f",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_2",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 17, text: "One"}, {identifier: 18, text: "Two"}]}},
{command: "d081fc810301250082028182850a4c617267654d656e75318f05505a65726f8f044f4f6e658f044e54776f8f064d54687265658f054c466f75728f054b466976658f044a5369788f0649536576656e8f064845696768748f05474e696e658f0646416c7068618f0645427261766f8f0844436861726c69658f064344656c74618f05424563686f8f0941466f782d74726f748f0640426c61636b8f063f42726f776e8f043e5265648f073d4f72616e67658f073c59656c6c6f778f063b477265656e8f053a426c75658f073956696f6c65748f0538477265798f063757686974658f06366d696c6c698f06356d6963726f8f05346e616e6f8f05337069636f",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_3",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "LargeMenu1",
items: [{identifier: 80, text: "Zero"}, {identifier: 79, text: "One"}, {identifier: 78, text: "Two"}, {identifier: 77, text: "Three"}, {identifier: 76, text: "Four"}, {identifier: 75, text: "Five"}, {identifier: 74, text: "Six"}, {identifier: 73, text: "Seven"}, {identifier: 72, text: "Eight"}, {identifier: 71, text: "Nine"}, {identifier: 70, text: "Alpha"}, {identifier: 69, text: "Bravo"}, {identifier: 68, text: "Charlie"}, {identifier: 67, text: "Delta"}, {identifier: 66, text: "Echo"}, {identifier: 65, text: "Fox-trot"}, {identifier: 64, text: "Black"}, {identifier: 63, text: "Brown"}, {identifier: 62, text: "Red"}, {identifier: 61, text: "Orange"}, {identifier: 60, text: "Yellow"}, {identifier: 59, text: "Green"}, {identifier: 58, text: "Blue"}, {identifier: 57, text: "Violet"}, {identifier: 56, text: "Grey"}, {identifier: 55, text: "White"}, {identifier: 54, text: "milli"}, {identifier: 53, text: "micro"}, {identifier: 52, text: "nano"}, {identifier: 51, text: "pico"}]}},
{command: "d081f3810301250082028182850a4c617267654d656e75328f1dff312043616c6c20466f727761726420556e636f6e646974696f6e616c8f1cfe322043616c6c20466f7277617264204f6e205573657220427573798f1bfd332043616c6c20466f7277617264204f6e204e6f205265706c798f25fc342043616c6c20466f7277617264204f6e2055736572204e6f7420526561636861626c658f20fb352042617272696e67204f6620416c6c204f7574676f696e672043616c6c738f24fa362042617272696e67204f6620416c6c204f7574676f696e6720496e742043616c6c738f13f93720434c492050726573656e746174696f6e",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_4",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "LargeMenu2",
items: [{identifier: 255, text: "1 Call Forward Unconditional"}, {identifier: 254, text: "2 Call Forward On User Busy"}, {identifier: 253, text: "3 Call Forward On No Reply"}, {identifier: 252, text: "4 Call Forward On User Not Reachable"}, {identifier: 251, text: "5 Barring Of All Outgoing Calls"}, {identifier: 250, text: "6 Barring Of All Outgoing Int Calls"}, {identifier: 249, text: "7 CLI Presentation"}]}},
{command: "d081fc8103012500820281828581ec5468652053494d207368616c6c20737570706c79206120736574206f66206d656e75206974656d732c207768696368207368616c6c20626520696e7465677261746564207769746820746865206d656e752073797374656d20286f72206f74686572204d4d4920666163696c6974792920696e206f7264657220746f206769766520746865207573657220746865206f70706f7274756e69747920746f2063686f6f7365206f6e65206f66207468657365206d656e75206974656d7320617420686973206f776e2064697363726574696f6e2e2045616368206974656d20636f6d70726973657320612073688f020159",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_5",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "The SIM shall supply a set of menu items, which shall be integrated with the menu system (or other MMI facility) in order to give the user the opportunity to choose one of these menu items at his own discretion. Each item comprises a sh",
items: [{identifier: 1, text: "Y"}]}},
{command: "d03b810301258082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_6",
commandQualifier: 0x80,
expect: {commandQualifier: 0x80,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
{command: "d041810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034180413101526",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_7",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}],
nextActionList: [iccManager.STK_CMD_SEND_SMS, iccManager.STK_CMD_SET_UP_CALL, iccManager.STK_CMD_LAUNCH_BROWSER, iccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
nextActionList: [MozIccManager.STK_CMD_SEND_SMS, MozIccManager.STK_CMD_SET_UP_CALL, MozIccManager.STK_CMD_LAUNCH_BROWSER, MozIccManager.STK_CMD_PROVIDE_LOCAL_INFO]}},
{command: "d03c810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20339e0201019f0401030303",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_8",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
iconSelfExplanatory: false,
icons: [basicIcon],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: false, icons: [colorIcon]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: false, icons: [colorIcon]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: false, icons: [colorIcon]}]}},
icons: [BASIC_ICON],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: false, icons: [COLOR_ICON]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: false, icons: [COLOR_ICON]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: false, icons: [COLOR_ICON]}]}},
{command: "d03c810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20339e0200019f0400050505",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_9",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
iconSelfExplanatory: true,
icons: [basicIcon],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [colorTransparencyIcon]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [colorTransparencyIcon]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [colorTransparencyIcon]}]}},
icons: [BASIC_ICON],
items: [{identifier: 1, text: "Item 1", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
{identifier: 2, text: "Item 2", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]},
{identifier: 3, text: "Item 3", iconSelfExplanatory: true, icons: [COLOR_TRANSPARENCY_ICON]}]}},
{command: "d029810301250182028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d2032",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_10",
commandQualifier: 0x01,
expect: {commandQualifier: 0x01,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e00b4d10c000600b4000600b4000600b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_11",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_12",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 2",
items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e01b4d10c000601b4000601b4000601b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_13",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_14",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 2",
items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e02b4d10c000602b4000602b4000602b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_15",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d034810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_16",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 2",
items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e04b4d10c000604b4000604b4000604b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_17",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520328f07044974656d20348f07054974656d20358f07064974656d2036d004000e00b4d10c000600b4000600b4000600b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_18",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 2",
items: [{identifier: 4, text: "Item 4"}, {identifier: 5, text: "Item 5"}, {identifier: 6, text: "Item 6"}]}},
{command: "d034810301250082028182850e546f6f6c6b6974204d656e7520338f07074974656d20378f07084974656d20388f07094974656d2039",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_19",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 3",
items: [{identifier: 7, text: "Item 7"}, {identifier: 8, text: "Item 8"}, {identifier: 9, text: "Item 9"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e08b4d10c000608b4000608b4000608b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_20",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e10b4d10c000610b4000610b4000610b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_21",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e20b4d10c000620b4000620b4000620b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_22",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e40b4d10c000640b4000640b4000640b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_23",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d048810301250082028182850e546f6f6c6b6974204d656e7520318f07014974656d20318f07024974656d20328f07034974656d2033d004000e80b4d10c000680b4000680b4000680b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_24",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu 1",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d046810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d2033d004000c00b4d10c000600b4000600b4000600b4",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_25",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}]}},
{command: "d0819c8103012500820281828519800417041404200410041204210422041204230419042204158f1c018004170414042004100412042104220412042304190422041500318f1c028004170414042004100412042104220412042304190422041500328f1c038004170414042004100412042104220412042304190422041500338f1c04800417041404200410041204210422041204230419042204150034",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_26",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
items: [{identifier: 1, text: "ЗДРАВСТВУЙТЕ1"}, {identifier: 2, text: "ЗДРАВСТВУЙТЕ2"}, {identifier: 3, text: "ЗДРАВСТВУЙТЕ3"}, {identifier: 4, text: "ЗДРАВСТВУЙТЕ4"}]}},
{command: "d0608103012500820281828519800417041404200410041204210422041204230419042204158f1c118004170414042004100412042104220412042304190422041500358f1c12800417041404200410041204210422041204230419042204150036",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_27",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "ЗДРАВСТВУЙТЕ",
items: [{identifier: 17, text: "ЗДРАВСТВУЙТЕ5"}, {identifier: 18, text: "ЗДРАВСТВУЙТЕ6"}]}},
{command: "d03c8103012500820281828509805de551777bb153558f080180987976ee4e008f080280987976ee4e8c8f080380987976ee4e098f080480987976ee56db",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_28",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "工具箱单",
items: [{identifier: 1, text: "项目一"}, {identifier: 2, text: "项目二"}, {identifier: 3, text: "项目三"}, {identifier: 4, text: "项目四"}]}},
{command: "d0208103012500820281828509805de551777bb153558f0411804e008f0412804e8c",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_29",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "工具箱单",
items: [{identifier: 17, text: "一"}, {identifier: 18, text: "二"}]}},
{command: "d0448103012500820281828509800038003030eb00308f0a01800038003030eb00318f0a02800038003030eb00328f0a03800038003030eb00338f0a04800038003030eb0034",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_30",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "80ル0",
items: [{identifier: 1, text: "80ル1"}, {identifier: 2, text: "80ル2"}, {identifier: 3, text: "80ル3"}, {identifier: 4, text: "80ル4"}]}},
{command: "d02c8103012500820281828509800038003030eb00308f0a11800038003030eb00358f0a12800038003030eb0036",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_31",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "80ル0",
items: [{identifier: 17, text: "80ル5"}, {identifier: 18, text: "80ル6"}]}},
{command: "d041810301250082028182850c546f6f6c6b6974204d656e758f07014974656d20318f07024974656d20328f07034974656d20338f07044974656d2034180481000000",
func: testSetupMenu,
expect: {name: "setup_menu_cmd_32",
commandQualifier: 0x00,
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}],
nextActionList: [iccManager.STK_NEXT_ACTION_END_PROACTIVE_SESSION, iccManager.STK_NEXT_ACTION_NULL, iccManager.STK_NEXT_ACTION_NULL, iccManager.STK_NEXT_ACTION_NULL]}},
{command: "D00D81030125008202818285008F00",
func: testRemoveSetupMenu},
nextActionList: [MozIccManager.STK_NEXT_ACTION_END_PROACTIVE_SESSION, MozIccManager.STK_NEXT_ACTION_NULL, MozIccManager.STK_NEXT_ACTION_NULL, MozIccManager.STK_NEXT_ACTION_NULL]}},
{command:"D03B810301250082028182850C546F6F6C6B6974204D656E758F07014974656D20318F07024974656D20328F07034974656D20338F07044974656D2034",
func: testInitialSetupMenu},
expect: {commandQualifier: 0x00,
title: "Toolkit Menu",
items: [{identifier: 1, text: "Item 1"}, {identifier: 2, text: "Item 2"}, {identifier: 3, text: "Item 3"}, {identifier: 4, text: "Item 4"}]}},
// Test remove setup menu.
{command: "D00D81030125008202818285008F00",
expect: {commandQualifier: 0x00,
title: "",
items: [null]}},
];
runNextTest();
function testSetupMenu(aCommand, aExpect) {
is(aCommand.typeOfCommand, MozIccManager.STK_CMD_SET_UP_MENU, "typeOfCommand");
is(aCommand.commandQualifier, aExpect.commandQualifier, "commandQualifier");
is(aCommand.options.title, aExpect.title, "options.title");
for (let index in aExpect.items) {
let item = aCommand.options.items[index];
let itemExpect = aExpect.items[index];
if (!itemExpect) {
is(item, itemExpect, "options.items[" + index + "]");
} else {
is(item.identifier, itemExpect.identifier,
"options.items[" + index + "].identifier");
is(item.text, itemExpect.text,
"options.items[" + index + "].text");
if (itemExpect.icons) {
isIcons(item.icons, itemExpect.icons);
is(item.iconSelfExplanatory, itemExpect.iconSelfExplanatory,
"options.items[" + index + "].iconSelfExplanatory");
}
}
}
if (aExpect.icons) {
isIcons(aCommand.options.icons, aExpect.icons);
is(aCommand.options.iconSelfExplanatory, aExpect.iconSelfExplanatory,
"options.iconSelfExplanatory");
}
if (aExpect.nextActionList) {
for (let index in aExpect.nextActionList) {
is(aCommand.options.nextActionList[index], aExpect.nextActionList[index],
"options.nextActionList[" + index + "]");
}
}
}
// 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("setup_menu_cmd: " + data.command);
let promises = [];
// Wait onstkcommand event.
promises.push(waitForTargetEvent(icc, "stkcommand")
.then((aEvent) => testSetupMenu(aEvent.command, data.expect)));
// Send emulator command to generate stk unsolicited event.
promises.push(sendEmulatorStkPdu(data.command));
return Promise.all(promises);
});
}
return promise;
});