Bug 838096 - Part 4: xpcshell tests for readPNN. r=allstars.chh
authorEdgar Chen <echen@mozilla.com>
Tue, 05 Feb 2013 18:01:27 +0800
changeset 131011 581ef9ed708d47aa28d6950d37e72a4bdd075e5c
parent 131010 6deea379453a001472b1509f359cf989bde0284d
child 131012 868939d72f574cd8bc00df250cb3b92308b4d411
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars
bugs838096
milestone21.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 838096 - Part 4: xpcshell tests for readPNN. r=allstars.chh
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
@@ -1030,16 +1030,80 @@ add_test(function test_stk_proactive_com
   let setupCall = cmdFactory.createParam(tlv.value, ctlvs);
   do_check_eq(setupCall.address, "012340123456,1,2");
   do_check_eq(setupCall.confirmMessage, "Disconnect");
   do_check_eq(setupCall.callMessage, "Message");
 
   run_next_test();
 });
 
+add_test(function test_read_pnn() {
+  let worker = newUint8Worker();
+  let helper = worker.GsmPDUHelper;
+  let record = worker.ICCRecordHelper;
+  let buf    = worker.Buf;
+  let io     = worker.ICCIOHelper;
+  let ril    = worker.RIL;
+
+  io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options) {
+    let records = [
+      // Record 1 - fullName: 'Long1', shortName: 'Short1'
+      [0x43, 0x06, 0x85, 0xCC, 0xB7, 0xFB, 0x1C, 0x03,
+       0x45, 0x07, 0x86, 0x53, 0xF4, 0x5B, 0x4E, 0x8F, 0x01,
+       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
+      // Record 2 - fullName: 'Long2'
+      [0x43, 0x06, 0x85, 0xCC, 0xB7, 0xFB, 0x2C, 0x03,
+       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
+      // Record 3 - Unused bytes
+      [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
+    ];
+
+    // Fake get response
+    options.totalRecords = records.length;
+    options.recordSize = records[0].length;
+
+    options.p1 = options.p1 || 1;
+
+    let record = records[options.p1 - 1];
+
+    // Write data size
+    buf.writeUint32(record.length * 2);
+
+    // Write record
+    for (let i = 0; i < record.length; i++) {
+      helper.writeHexOctet(record[i]);
+    }
+
+    // Write string delimiter
+    buf.writeStringDelimiter(record.length * 2);
+
+    if (options.callback) {
+      options.callback(options);
+    }
+  };
+
+  io.loadNextRecord = function fakeLoadNextRecord(options) {
+    options.p1++;
+    io.loadLinearFixedEF(options);
+  };
+
+  record.readPNN();
+
+  do_check_eq(ril.iccInfoPrivate.PNN.length, 2);
+  do_check_eq(ril.iccInfoPrivate.PNN[0].fullName, "Long1");
+  do_check_eq(ril.iccInfoPrivate.PNN[0].shortName, "Short1");
+  do_check_eq(ril.iccInfoPrivate.PNN[1].fullName, "Long2");
+  do_check_eq(ril.iccInfoPrivate.PNN[1].shortName, undefined);
+
+  run_next_test();
+});
+
 add_test(function read_network_name() {
   let worker = newUint8Worker();
   let helper = worker.GsmPDUHelper;
   let buf = worker.Buf;
 
   // Returning length of byte.
   function writeNetworkName(isUCS2, requireCi, name) {
     let codingOctet = 0x80;