Bug 908083 - Part3: browser termination envelop event xpcshell test. r=yoshi
authorGeorgia Wang <gwang@mozilla.com>
Wed, 04 Sep 2013 11:34:45 +0800
changeset 151584 dcab3b214724f662f0dd9b005a607ca6f60cbe0e
parent 151583 f5dbf24ff1f203c1ae8e184dea6c0b8aea33ea92
child 151585 db80d2993a269c37f8262fb32c9915570e50ff4f
push id25502
push userkwierso@gmail.com
push dateTue, 22 Oct 2013 22:00:08 +0000
treeherdermozilla-central@a7c3da1f3af7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoshi
bugs908083
milestone27.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 908083 - Part3: browser termination envelop event 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
@@ -968,8 +968,65 @@ add_test(function test_stk_event_downloa
 
   let event = {
     eventType: STK_EVENT_TYPE_IDLE_SCREEN_AVAILABLE
   };
   worker.RIL.sendStkEventDownload({
     event: event
   });
 });
+
+/**
+ * Verify Event Downloaded Command :Browser Termination
+ */
+add_test(function test_stk_event_download_browser_termination() {
+  let worker = newUint8SupportOutgoingIndexWorker();
+  let buf = worker.Buf;
+  let pduHelper = worker.GsmPDUHelper;
+
+  buf.sendParcel = function () {
+    // Type
+    do_check_eq(this.readInt32(), REQUEST_STK_SEND_ENVELOPE_COMMAND);
+
+    // Token : we don't care
+    this.readInt32();
+
+    // Data Size, 24 = 2 * ( 2+TLV_DEVICE_ID(4)+TLV_EVENT_LIST_SIZE(3)
+    //                        +TLV_BROWSER_TERMINATION_CAUSE(3) )
+    do_check_eq(this.readInt32(), 24);
+
+    // BER tag
+    do_check_eq(pduHelper.readHexOctet(), BER_EVENT_DOWNLOAD_TAG);
+
+    // BER length, 10 = TLV_DEVICE_ID(4)+TLV_EVENT_LIST_SIZE(3)
+    //                  ++TLV_BROWSER_TERMINATION_CAUSE(3)
+    do_check_eq(pduHelper.readHexOctet(), 10);
+
+    // Device Identities, Type-Length-Value(Source ID-Destination ID)
+    do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_DEVICE_ID |
+                                          COMPREHENSIONTLV_FLAG_CR);
+    do_check_eq(pduHelper.readHexOctet(), 2);
+    do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_ME);
+    do_check_eq(pduHelper.readHexOctet(), STK_DEVICE_ID_SIM);
+
+    // Event List, Type-Length-Value
+    do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_EVENT_LIST |
+                                          COMPREHENSIONTLV_FLAG_CR);
+    do_check_eq(pduHelper.readHexOctet(), 1);
+    do_check_eq(pduHelper.readHexOctet(), STK_EVENT_TYPE_BROWSER_TERMINATION);
+
+    // Browser Termination Case, Type-Length-Value
+    do_check_eq(pduHelper.readHexOctet(), COMPREHENSIONTLV_TAG_BROWSER_TERMINATION_CAUSE |
+                                          COMPREHENSIONTLV_FLAG_CR);
+    do_check_eq(pduHelper.readHexOctet(), 1);
+    do_check_eq(pduHelper.readHexOctet(), STK_BROWSER_TERMINATION_CAUSE_USER);
+
+    run_next_test();
+  };
+
+  let event = {
+    eventType: STK_EVENT_TYPE_BROWSER_TERMINATION,
+    terminationCause: STK_BROWSER_TERMINATION_CAUSE_USER
+  };
+  worker.RIL.sendStkEventDownload({
+    event: event
+  });
+});