Bug 908554 - Part3: Add STK Set Up Menu xpcshell test. r=yoshi

This commit is contained in:
Georgia Wang 2013-11-08 11:04:10 +08:00
parent adec9e0aae
commit a2a0264953

View File

@ -657,6 +657,176 @@ add_test(function test_stk_proactive_command_more_time() {
run_next_test();
});
/**
* Verify Proactive Command : Select Item
*/
add_test(function test_stk_proactive_command_select_item() {
let worker = newUint8Worker();
let pduHelper = worker.GsmPDUHelper;
let berHelper = worker.BerTlvHelper;
let stkHelper = worker.StkProactiveCmdHelper;
let stkFactory = worker.StkCommandParamsFactory;
let select_item_1 = [
0xD0,
0x33,
0x81, 0x03, 0x01, 0x24, 0x00,
0x82, 0x02, 0x81, 0x82,
0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65,
0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31,
0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32,
0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33,
0x18, 0x03, 0x10, 0x15, 0x20,
0x90, 0x01, 0x01
];
for(let i = 0 ; i < select_item_1.length; i++) {
pduHelper.writeHexOctet(select_item_1[i]);
}
let berTlv = berHelper.decode(select_item_1.length);
let ctlvs = berTlv.value;
let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
do_check_eq(tlv.value.commandNumber, 0x01);
do_check_eq(tlv.value.typeOfCommand, STK_CMD_SELECT_ITEM);
do_check_eq(tlv.value.commandQualifier, 0x00);
let menu = stkFactory.createParam(tlv.value, ctlvs);
do_check_eq(menu.title, "Title");
do_check_eq(menu.items[0].identifier, 1);
do_check_eq(menu.items[0].text, "item 1");
do_check_eq(menu.items[1].identifier, 2);
do_check_eq(menu.items[1].text, "item 2");
do_check_eq(menu.items[2].identifier, 3);
do_check_eq(menu.items[2].text, "item 3");
do_check_eq(menu.nextActionList[0], STK_CMD_SET_UP_CALL);
do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER);
do_check_eq(menu.nextActionList[2], STK_CMD_PLAY_TONE);
do_check_eq(menu.defaultItem, 0x00);
let select_item_2 = [
0xD0,
0x33,
0x81, 0x03, 0x01, 0x24, 0x00,
0x82, 0x02, 0x81, 0x82,
0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65,
0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31,
0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32,
0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33,
0x18, 0x03, 0x00, 0x15, 0x81,
0x90, 0x01, 0x03
];
for(let i = 0 ; i < select_item_2.length; i++) {
pduHelper.writeHexOctet(select_item_2[i]);
}
berTlv = berHelper.decode(select_item_2.length);
ctlvs = berTlv.value;
tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
do_check_eq(tlv.value.commandNumber, 0x01);
do_check_eq(tlv.value.typeOfCommand, STK_CMD_SELECT_ITEM);
do_check_eq(tlv.value.commandQualifier, 0x00);
menu = stkFactory.createParam(tlv.value, ctlvs);
do_check_eq(menu.title, "Title");
do_check_eq(menu.items[0].identifier, 1);
do_check_eq(menu.items[0].text, "item 1");
do_check_eq(menu.items[1].identifier, 2);
do_check_eq(menu.items[1].text, "item 2");
do_check_eq(menu.items[2].identifier, 3);
do_check_eq(menu.items[2].text, "item 3");
do_check_eq(menu.nextActionList[0], STK_NEXT_ACTION_NULL);
do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER);
do_check_eq(menu.nextActionList[2], STK_NEXT_ACTION_END_PROACTIVE_SESSION);
do_check_eq(menu.defaultItem, 0x02);
run_next_test();
});
/**
* Verify Proactive Command : Set Up Menu
*/
add_test(function test_stk_proactive_command_set_up_menu() {
let worker = newUint8Worker();
let pduHelper = worker.GsmPDUHelper;
let berHelper = worker.BerTlvHelper;
let stkHelper = worker.StkProactiveCmdHelper;
let stkFactory = worker.StkCommandParamsFactory;
let set_up_menu_1 = [
0xD0,
0x30,
0x81, 0x03, 0x01, 0x25, 0x00,
0x82, 0x02, 0x81, 0x82,
0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65,
0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31,
0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32,
0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33,
0x18, 0x03, 0x10, 0x15, 0x20
];
for(let i = 0 ; i < set_up_menu_1.length; i++) {
pduHelper.writeHexOctet(set_up_menu_1[i]);
}
let berTlv = berHelper.decode(set_up_menu_1.length);
let ctlvs = berTlv.value;
let tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
do_check_eq(tlv.value.commandNumber, 0x01);
do_check_eq(tlv.value.typeOfCommand, STK_CMD_SET_UP_MENU);
do_check_eq(tlv.value.commandQualifier, 0x00);
let menu = stkFactory.createParam(tlv.value, ctlvs);
do_check_eq(menu.title, "Title");
do_check_eq(menu.items[0].identifier, 1);
do_check_eq(menu.items[0].text, "item 1");
do_check_eq(menu.items[1].identifier, 2);
do_check_eq(menu.items[1].text, "item 2");
do_check_eq(menu.items[2].identifier, 3);
do_check_eq(menu.items[2].text, "item 3");
do_check_eq(menu.nextActionList[0], STK_CMD_SET_UP_CALL);
do_check_eq(menu.nextActionList[1], STK_CMD_LAUNCH_BROWSER);
do_check_eq(menu.nextActionList[2], STK_CMD_PLAY_TONE);
let set_up_menu_2 = [
0xD0,
0x30,
0x81, 0x03, 0x01, 0x25, 0x00,
0x82, 0x02, 0x81, 0x82,
0x85, 0x05, 0x54, 0x69, 0x74, 0x6C, 0x65,
0x8F, 0x07, 0x01, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x31,
0x8F, 0x07, 0x02, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x32,
0x8F, 0x07, 0x03, 0x69, 0x74, 0x65, 0x6D, 0x20, 0x33,
0x18, 0x03, 0x81, 0x00, 0x00
];
for(let i = 0 ; i < set_up_menu_2.length; i++) {
pduHelper.writeHexOctet(set_up_menu_2[i]);
}
berTlv = berHelper.decode(set_up_menu_2.length);
ctlvs = berTlv.value;
tlv = stkHelper.searchForTag(COMPREHENSIONTLV_TAG_COMMAND_DETAILS, ctlvs);
do_check_eq(tlv.value.commandNumber, 0x01);
do_check_eq(tlv.value.typeOfCommand, STK_CMD_SET_UP_MENU);
do_check_eq(tlv.value.commandQualifier, 0x00);
let menu = stkFactory.createParam(tlv.value, ctlvs);
do_check_eq(menu.title, "Title");
do_check_eq(menu.items[0].identifier, 1);
do_check_eq(menu.items[0].text, "item 1");
do_check_eq(menu.items[1].identifier, 2);
do_check_eq(menu.items[1].text, "item 2");
do_check_eq(menu.items[2].identifier, 3);
do_check_eq(menu.items[2].text, "item 3");
do_check_eq(menu.nextActionList[0], STK_NEXT_ACTION_END_PROACTIVE_SESSION);
do_check_eq(menu.nextActionList[1], STK_NEXT_ACTION_NULL);
do_check_eq(menu.nextActionList[2], STK_NEXT_ACTION_NULL);
run_next_test();
});
/**
* Verify Proactive Command : Set Up Call
*/