Bug 1117609 - Part 2: Add Test case to verify additional information inside TR. r=echen
authorBevis Tseng <btseng@mozilla.com>
Mon, 05 Jan 2015 17:17:50 +0800
changeset 242275 ee6a7811ff8c722d4520a4872878f02d44a2d309
parent 242274 a558364e10212b5e74b46f53af116009abb25bed
child 242276 b16c66faa8bdb650052fa712de060a7cee1c55bd
push id7677
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 18:11:24 +0000
treeherdermozilla-aurora@f531d838c055 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1117609
milestone38.0a1
Bug 1117609 - Part 2: Add Test case to verify additional information inside TR. r=echen
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
@@ -200,18 +200,16 @@ add_test(function test_stk_terminal_resp
       do_check_eq(pduHelper.readHexOctet(), STK_RESULT_OK);
 
       // Yes/No response
       do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_TEXT_STRING |
                                             COMPREHENSIONTLV_FLAG_CR);
       do_check_eq(pduHelper.readHexOctet(), 2);
       do_check_eq(pduHelper.readHexOctet(), STK_TEXT_CODING_GSM_8BIT);
       do_check_eq(pduHelper.readHexOctet(), isYesNo ? 0x01 : 0x00);
-
-      run_next_test();
     };
 
     let response = {
       command: {
         commandNumber: 0x01,
         typeOfCommand: STK_CMD_GET_INKEY,
         commandQualifier: 0x04,
         options: {
@@ -224,16 +222,83 @@ add_test(function test_stk_terminal_resp
 
     context.RIL.sendStkTerminalResponse(response);
   };
 
   // Test "Yes" response
   do_test(true);
   // Test "No" response
   do_test(false);
+
+  run_next_test();
+});
+
+/**
+ * Verify STK terminal response with additional information.
+ */
+add_test(function test_stk_terminal_response_with_additional_info() {
+  function do_test(aInfo) {
+    let worker = newUint8SupportOutgoingIndexWorker();
+    let context = worker.ContextPool._contexts[0];
+    let buf = context.Buf;
+    let pduHelper = context.GsmPDUHelper;
+
+    buf.sendParcel = function() {
+      // Type
+      do_check_eq(this.readInt32(), REQUEST_STK_SEND_TERMINAL_RESPONSE);
+
+      // Token : we don't care
+      this.readInt32();
+
+      // Data Length 26 = 2 * (TLV_COMMAND_DETAILS_SIZE(5) +
+      //                       TLV_DEVICE_ID_SIZE(4) +
+      //                       TLV_RESULT_SIZE(4))
+      do_check_eq(this.readInt32(), 26);
+
+      // Command Details, Type-Length-Value(commandNumber, typeOfCommand, commandQualifier)
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_COMMAND_DETAILS |
+                                            COMPREHENSIONTLV_FLAG_CR);
+      do_check_eq(pduHelper.readHexOctet(), 3);
+      do_check_eq(pduHelper.readHexOctet(), 0x01);
+      do_check_eq(pduHelper.readHexOctet(), STK_CMD_DISPLAY_TEXT);
+      do_check_eq(pduHelper.readHexOctet(), 0x01);
+
+      // Device Identifies, Type-Length-Value(Source ID-Destination ID)
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID);
+      do_check_eq(pduHelper.readHexOctet(), 2);
+      do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME);
+      do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM);
+
+      // Result, Type-Length-Value(General result, Additional information on result)
+      do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_RESULT |
+                                            COMPREHENSIONTLV_FLAG_CR);
+      do_check_eq(pduHelper.readHexOctet(), 2);
+      do_check_eq(pduHelper.readHexOctet(), STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS);
+      do_check_eq(pduHelper.readHexOctet(), aInfo);
+    };
+
+    let response = {
+      command: {
+        commandNumber: 0x01,
+        typeOfCommand: STK_CMD_DISPLAY_TEXT,
+        commandQualifier: 0x01,
+        options: {
+          isHighPriority: true
+        }
+      },
+      resultCode: STK_RESULT_TERMINAL_CRNTLY_UNABLE_TO_PROCESS,
+      additionalInformation: aInfo
+    };
+
+    context.RIL.sendStkTerminalResponse(response);
+  };
+
+  do_test(0x01); // 'Screen is busy'
+
+  run_next_test();
 });
 
 // Test ComprehensionTlvHelper
 
 /**
  * Verify ComprehensionTlvHelper.writeLocationInfoTlv
  */
 add_test(function test_write_location_info_tlv() {