Bug 835802 - Part 5: xpcshells tests. r=vicamo
authorYoshi Huang <allstars.chh@mozilla.com>
Tue, 09 Apr 2013 15:34:47 +0800
changeset 130785 fe184c67d86989478d53f9dc3a263a1eeb7e7afd
parent 130784 f21652870d518c2c0e2165eac952ba558943ec30
child 130786 e9a1c44d1ca9639dda826708eeeaaa2451a7f91a
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs835802
milestone23.0a1
Bug 835802 - Part 5: xpcshells tests. r=vicamo
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
@@ -1954,27 +1954,27 @@ add_test(function test_update_adn_like()
                        "1111");
 });
 
 /**
  * Verify ICCRecordHelper.findFreeRecordId.
  */
 add_test(function test_find_free_record_id() {
   let worker = newUint8Worker();
-  let helper = worker.GsmPDUHelper;
-  let record = worker.ICCRecordHelper;
-  let buf    = worker.Buf;
-  let io     = worker.ICCIOHelper;
+  let pduHelper = worker.GsmPDUHelper;
+  let recordHelper = worker.ICCRecordHelper;
+  let buf = worker.Buf;
+  let io  = worker.ICCIOHelper;
 
   function writeRecord (record) {
     // Write data size
     buf.writeUint32(record.length * 2);
 
     for (let i = 0; i < record.length; i++) {
-      helper.writeHexOctet(record[i]);
+      pduHelper.writeHexOctet(record[i]);
     }
 
     // Write string delimiter
     buf.writeStringDelimiter(record.length * 2);
   }
 
   io.loadLinearFixedEF = function fakeLoadLinearFixedEF(options)  {
     // Some random data.
@@ -1993,17 +1993,17 @@ add_test(function test_find_free_record_
     options.p1++;
     writeRecord(record);
     if (options.callback) {
       options.callback(options);
     }
   };
 
   let fileId = 0x0000; // Dummy.
-  record.findFreeRecordId(
+  recordHelper.findFreeRecordId(
     fileId,
     function (recordId) {
       do_check_eq(recordId, 2);
       run_next_test();
     }.bind(this),
     function (errorMsg) {
       do_print(errorMsg);
       do_check_true(false);
@@ -2020,17 +2020,17 @@ add_test(function test_read_icc_contacts
   let contactHelper = worker.ICCContactHelper;
 
   // Override some functions to test.
   contactHelper.getContactFieldRecordId = function (pbr, contact, field, onsuccess, onerror) {
     onsuccess(1);
   };
 
   record.readPBR = function readPBR(onsuccess, onerror) {
-    onsuccess({adn:{}, email: {}, anr0: {}});
+    onsuccess([{adn:{}, email: {}, anr0: {}}]);
   };
 
   record.readADNLike = function readADNLike(fileId, onsuccess, onerror) {
     onsuccess([{alphaId: "name", number: "111111"}])
   };
 
   record.readEmail = function readEmail(fileId, fileType, recordNumber, onsuccess, onerror) {
     onsuccess("hello@mail.com");
@@ -2054,17 +2054,17 @@ add_test(function test_read_icc_contacts
     do_check_true(false);
     run_next_test();
   };
 
   contactHelper.readICCContacts(CARD_APPTYPE_USIM, "adn", successCb, errorCb);
 });
 
 /**
- * Verify ICCContactHelper.updateICCContact
+ * Verify ICCContactHelper.updateICCContact with appType is CARD_APPTYPE_SIM.
  */
 add_test(function test_update_icc_contact() {
   let worker = newUint8Worker();
   let record = worker.ICCRecordHelper;
   let contactHelper = worker.ICCContactHelper;
   let contactType;
 
   function do_test(aContact, aContactType, aFileId, aPin2) {
@@ -2080,16 +2080,71 @@ add_test(function test_update_icc_contac
   let contact = {recordId: 1, alphaId: "test", number: "123456"};
   do_test(contact, "adn", ICC_EF_ADN);
   do_test(contact, "fdn", ICC_EF_FDN, "1111");
 
   run_next_test();
 });
 
 /**
+ * Verify ICCContactHelper.updateICCContact with appType is CARD_APPTYPE_USIM.
+ */
+add_test(function test_update_icc_contact() {
+  let worker = newUint8Worker();
+  let recordHelper = worker.ICCRecordHelper;
+  let contactHelper = worker.ICCContactHelper;
+  const FILE_ID = 0x4f3a;
+
+  recordHelper.readPBR = function (onsuccess, onerror) {
+    onsuccess([{adn:{fileId: FILE_ID}}]);
+  };
+
+  let oldContact = {recordId: 1, alphaId: "test", number: "123456"};
+  recordHelper.updateADNLike = function (fileId, contact, pin2, onsuccess, onerror) {
+    do_check_eq(fileId, FILE_ID);
+    do_check_eq(contact.alphaId, oldContact.alphaId);
+    do_check_eq(contact.number, oldContact.number);
+
+    run_next_test();
+  };
+
+  contactHelper.updateICCContact(CARD_APPTYPE_USIM, "adn", oldContact);
+});
+
+/**
+ * Verify ICCContactHelper.findFreeICCContact
+ */
+add_test(function test_find_free_icc_contact() {
+  let worker = newUint8Worker();
+  let recordHelper = worker.ICCRecordHelper;
+  let contactHelper = worker.ICCContactHelper;
+  const RECORD_ID = 1;
+
+  recordHelper.readPBR = function (onsuccess, onerror) {
+    onsuccess([{adn:{}, email: {}, anr0: {}}]);
+  };
+
+  recordHelper.findFreeRecordId = function (fileId, onsuccess, onerror) {
+    onsuccess(RECORD_ID);
+  };
+
+  let successCb = function (recordId) {
+    do_check_eq(recordId, RECORD_ID);
+    run_next_test();
+  };
+
+  let errorCb = function (errorMsg) {
+    do_check_true(false);
+    run_next_test();
+  };
+
+  contactHelper.findFreeICCContact(CARD_APPTYPE_USIM, "adn", successCb, errorCb);
+});
+
+/**
  * Verify cardState 'corporateLocked'.
  */
 add_test(function test_card_state_corporateLocked() {
   let worker = newUint8Worker();
   let ril = worker.RIL;
   let iccStatus = {
     gsmUmtsSubscriptionAppIndex: 0,
     apps: [