Bug 895960 - Part 2: Test cases for reading PBR. r=hsinyi
authorYoshi Huang <allstars.chh@mozilla.com>
Tue, 30 Jul 2013 17:33:00 +0800
changeset 152995 85b55d36686f72652e719ce83b19433834beea40
parent 152994 d2c1d22cc67668dcb1112fe3994291502fb6f3f9
child 152996 daf9df1e2cd2f04144281790e961756a8a90c9bd
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs895960
milestone25.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 895960 - Part 2: Test cases for reading PBR. r=hsinyi
dom/system/gonk/tests/test_ril_worker_icc.js
--- a/dom/system/gonk/tests/test_ril_worker_icc.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc.js
@@ -1786,16 +1786,74 @@ add_test(function test_load_linear_fixed
     do_check_true(false);
     run_next_test();
   };
 
   io.loadLinearFixedEF({});
 });
 
 /**
+ * Verify ICCRecordHelper.readPBR
+ */
+add_test(function test_read_pbr() {
+  let worker = newUint8Worker();
+  let helper = worker.GsmPDUHelper;
+  let record = worker.ICCRecordHelper;
+  let buf    = worker.Buf;
+  let io     = worker.ICCIOHelper;
+
+  io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
+    let pbr_1 = [
+      0xa8, 0x05, 0xc0, 0x03, 0x4f, 0x3a, 0x01
+    ];
+
+    // Write data size
+    buf.writeUint32(pbr_1.length * 2);
+
+    // Write pbr
+    for (let i = 0; i < pbr_1.length; i++) {
+      helper.writeHexOctet(pbr_1[i]);
+    }
+
+    // Write string delimiter
+    buf.writeStringDelimiter(pbr_1.length * 2);
+
+    options.totalRecords = 2;
+    if (options.callback) {
+      options.callback(options);
+    }
+  };
+
+  io.loadNextRecord = function fakeLoadNextRecord(options) {
+    let pbr_2 = [
+      0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+    ];
+
+    options.p1++;
+    if (options.callback) {
+      options.callback(options);
+    }
+  };
+
+  let successCb = function successCb(pbrs) {
+    do_check_eq(pbrs[0].adn.fileId, 0x4f3a);
+    do_check_eq(pbrs.length, 1);
+    run_next_test();
+  };
+
+  let errorCb = function errorCb(errorMsg) {
+    do_print("Reading EF_PBR failed, msg = " + errorMsg);
+    do_check_true(false);
+    run_next_test();
+  };
+
+  record.readPBR(successCb, errorCb);
+});
+
+/**
  * Verify ICCRecordHelper.readEmail
  */
 add_test(function test_read_email() {
   let worker = newUint8Worker();
   let helper = worker.GsmPDUHelper;
   let record = worker.ICCRecordHelper;
   let buf    = worker.Buf;
   let io     = worker.ICCIOHelper;