Bug 1122330 - Part 2: Add Corresponding Test Case to Verify Empty String for GET INPUT. r=echen
authorBevis Tseng <btseng@mozilla.com>
Mon, 19 Jan 2015 19:56:26 +0800
changeset 242277 ffb5e1675e84ee6e58dfbf5276997160e32fc255
parent 242276 b16c66faa8bdb650052fa712de060a7cee1c55bd
child 242278 7768c66f3fef5b03906a0d697759f0161c490118
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
bugs1122330
milestone38.0a1
Bug 1122330 - Part 2: Add Corresponding Test Case to Verify Empty String for GET INPUT. 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
@@ -152,16 +152,87 @@ add_test(function test_stk_terminal_resp
     },
     input: "Mozilla",
     resultCode: STK_RESULT_OK
   };
   context.RIL.sendStkTerminalResponse(response);
 });
 
 /**
+ * Verify STK terminal response : GET INPUT with empty string.
+ *
+ * @See |TERMINAL RESPONSE: GET INPUT 1.9.1A| of 27.22.4.3.1 GET INPUT (normal)
+ *      in TS 102 384.
+ */
+add_test(function test_stk_terminal_response_get_input_empty_string() {
+  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 Size, 30 = 2 * (TLV_COMMAND_DETAILS_SIZE(5) +
+    //                      TLV_DEVICE_ID_SIZE(4) +
+    //                      TLV_RESULT_SIZE(3) +
+    //                      TEXT LENGTH(3))
+    do_check_eq(this.readInt32(), 30);
+
+    // Command Details, Type-Length-Value
+    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_GET_INPUT);
+    do_check_eq(pduHelper.readHexOctet(), 0x00);
+
+    // 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
+    do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_RESULT |
+                                          COMPREHENSIONTLV_FLAG_CR);
+    do_check_eq(pduHelper.readHexOctet(), 1);
+    do_check_eq(pduHelper.readHexOctet(), STK_RESULT_OK);
+
+    // Text
+    do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_TEXT_STRING |
+                                          COMPREHENSIONTLV_FLAG_CR);
+    do_check_eq(pduHelper.readHexOctet(), 1);
+    do_check_eq(pduHelper.readHexOctet(), STK_TEXT_CODING_GSM_8BIT);
+
+    run_next_test();
+  };
+
+  let response = {
+    command: {
+      commandNumber: 0x01,
+      typeOfCommand: STK_CMD_GET_INPUT,
+      commandQualifier: 0x00,
+      options: {
+        minLength: 0,
+        maxLength: 1,
+        defaultText: "<SEND>"
+      }
+    },
+    input: "",
+    resultCode: STK_RESULT_OK
+  };
+  context.RIL.sendStkTerminalResponse(response);
+});
+
+/**
  * Verify STK terminal response : GET_INKEY - YES/NO request
  */
 add_test(function test_stk_terminal_response_get_inkey() {
   function do_test(isYesNo) {
     let worker = newUint8SupportOutgoingIndexWorker();
     let context = worker.ContextPool._contexts[0];
     let buf = context.Buf;
     let pduHelper = context.GsmPDUHelper;