Bug 908554 - Part3: Add STK Set Up Menu xpcshell test. r=yoshi
authorGeorgia Wang <gwang@mozilla.com>
Fri, 08 Nov 2013 11:04:10 +0800
changeset 172877 fa30b62f33c39ef80af648fa3eb1019ad21d26c0
parent 172876 34e1cbfc6b64436175b0d3412357041b835e8065
child 172878 d1b79eede8cd9e9843b4eb3365c2486eba4d32af
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoshi
bugs908554
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 908554 - Part3: Add STK Set Up Menu xpcshell test. r=yoshi
dom/system/gonk/tests/test_ril_worker_stk.js
--- a/dom/system/gonk/tests/test_ril_worker_stk.js
+++ b/dom/system/gonk/tests/test_ril_worker_stk.js
@@ -653,16 +653,186 @@ add_test(function test_stk_proactive_com
   do_check_eq(tlv.value.commandNumber, 0x01);
   do_check_eq(tlv.value.typeOfCommand, STK_CMD_MORE_TIME);
   do_check_eq(tlv.value.commandQualifier, 0x00);
 
   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
  */
 add_test(function test_stk_proactive_command_set_up_call() {
   let worker = newUint8Worker();
   let pduHelper = worker.GsmPDUHelper;
   let berHelper = worker.BerTlvHelper;
   let stkHelper = worker.StkProactiveCmdHelper;
   let cmdFactory = worker.StkCommandParamsFactory;