Bug 1007487 - Part 2: test patch - B2G RIL: incorrect isDisplayNetworkNameRequired for not matching both HPLMN and EF_SPDI. v2. r=HsinYi.
authorShawn Ku <sku@mozilla.com>
Tue, 01 Jul 2014 11:52:17 +0800
changeset 191893 ae0542323b126cc75b187e3edd02573aa9e94260
parent 191892 1056a35af1c4ad2608f998917c72417bb743c09d
child 191894 e2a9e9dcc44ab5622e1c00ce3f664163a1b83722
push id45685
push usercbook@mozilla.com
push dateWed, 02 Jul 2014 13:09:48 +0000
treeherdermozilla-inbound@60133a85f8ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHsinYi
bugs1007487
milestone33.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 1007487 - Part 2: test patch - B2G RIL: incorrect isDisplayNetworkNameRequired for not matching both HPLMN and EF_SPDI. v2. r=HsinYi.
dom/icc/tests/marionette/test_icc_info.js
dom/system/gonk/tests/test_ril_worker_icc_SimRecordHelper.js
--- a/dom/icc/tests/marionette/test_icc_info.js
+++ b/dom/icc/tests/marionette/test_icc_info.js
@@ -57,56 +57,16 @@ taskHelper.push(function basicTest() {
     // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
     // in requestCdmaSubscription()
     is(iccInfo.prlVersion, 1);
   }
 
   taskHelper.runNext();
 });
 
-/* Test Gsm display condition change */
-taskHelper.push(function testGsmDisplayConditionChange() {
-  function testSPN(mcc, mnc, expectedIsDisplayNetworkNameRequired,
-                   expectedIsDisplaySpnRequired, callback) {
-    icc.addEventListener("iccinfochange", function handler() {
-      icc.removeEventListener("iccinfochange", handler);
-      is(icc.iccInfo.isDisplayNetworkNameRequired,
-         expectedIsDisplayNetworkNameRequired);
-      is(icc.iccInfo.isDisplaySpnRequired,
-         expectedIsDisplaySpnRequired);
-      // operatorchange will be ignored if we send commands too soon.
-      window.setTimeout(callback, 100);
-    });
-    // Send emulator command to change network mcc and mnc.
-    setEmulatorMccMnc(mcc, mnc);
-  }
-
-  let testCases = [
-    // [MCC, MNC, isDisplayNetworkNameRequired, isDisplaySpnRequired]
-    [123, 456, false, true], // Not in HPLMN.
-    [234, 136,  true, true], // Not in HPLMN, but in PLMN specified in SPDI.
-    [123, 456, false, true], // Not in HPLMN. Triggering iccinfochange
-    [466,  92,  true, true], // Not in HPLMN, but in another PLMN specified in SPDI.
-    [123, 456, false, true], // Not in HPLMN. Triggering iccinfochange
-    [310, 260,  true, true], // inside HPLMN.
-  ];
-
-  // Ignore this test if device is not in gsm mode.
-  if (!(icc.iccInfo instanceof Ci.nsIDOMMozGsmIccInfo)) {
-    taskHelper.runNext();
-    return;
-  }
-
-  (function do_call(index) {
-    let next = index < (testCases.length - 1) ? do_call.bind(null, index + 1) : taskHelper.runNext.bind(taskHelper);
-    testCases[index].push(next);
-    testSPN.apply(null, testCases[index]);
-  })(0);
-});
-
 /* Test iccInfo when card becomes undetected */
 taskHelper.push(function testCardIsNotReady() {
   // Turn off radio.
   setRadioEnabled(false);
   icc.addEventListener("iccinfochange", function oniccinfochange() {
     // Expect iccInfo changes to null
     if (icc.iccInfo === null) {
       icc.removeEventListener("iccinfochange", oniccinfochange);
--- a/dom/system/gonk/tests/test_ril_worker_icc_SimRecordHelper.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc_SimRecordHelper.js
@@ -481,9 +481,124 @@ add_test(function test_read_new_sms_on_s
     do_check_eq("How are you?", postedMessage.body);
   }
 
   do_test();
 
   run_next_test();
 });
 
+/**
+ * Verify the result of updateDisplayCondition after reading EF_SPDI | EF_SPN.
+ */
+add_test(function test_update_display_condition() {
+  let worker = newUint8Worker();
+  let context = worker.ContextPool._contexts[0];
+  let record = context.SimRecordHelper;
+  let helper = context.GsmPDUHelper;
+  let ril    = context.RIL;
+  let buf    = context.Buf;
+  let io     = context.ICCIOHelper;
 
+  function do_test_spdi() {
+    // No EF_SPN, but having EF_SPDI.
+    // It implies "ril.iccInfoPrivate.spnDisplayCondition = undefined;".
+    io.loadTransparentEF = function fakeLoadTransparentEF(options) {
+      // PLMN lists are : 234-136 and 466-92.
+      let spdi = [0xA3, 0x0B, 0x80, 0x09, 0x32, 0x64, 0x31, 0x64, 0x26, 0x9F,
+                  0xFF, 0xFF, 0xFF];
+
+      // Write data size.
+      buf.writeInt32(spdi.length * 2);
+
+      // Write data.
+      for (let i = 0; i < spdi.length; i++) {
+        helper.writeHexOctet(spdi[i]);
+      }
+
+      // Write string delimiter.
+      buf.writeStringDelimiter(spdi.length * 2);
+
+      if (options.callback) {
+        options.callback(options);
+      }
+    };
+
+    record.readSPDI();
+
+    do_check_eq(ril.iccInfo.isDisplayNetworkNameRequired, true);
+    do_check_eq(ril.iccInfo.isDisplaySpnRequired, false);
+  }
+
+  function do_test_spn(displayCondition,
+                       expectedPlmnNameDisplay,
+                       expectedSpnDisplay) {
+    io.loadTransparentEF = function fakeLoadTransparentEF(options) {
+      // "Android" as Service Provider Name.
+      let spn = [0x41, 0x6E, 0x64, 0x72, 0x6F, 0x69, 0x64];
+      if (typeof displayCondition === 'number') {
+        spn.unshift(displayCondition);
+      }
+
+      // Write data size.
+      buf.writeInt32(spn.length * 2);
+
+      // Write data.
+      for (let i = 0; i < spn.length; i++) {
+        helper.writeHexOctet(spn[i]);
+      }
+
+      // Write string delimiter.
+      buf.writeStringDelimiter(spn.length * 2);
+
+      if (options.callback) {
+        options.callback(options);
+      }
+    };
+
+    record.readSPN();
+
+    do_check_eq(ril.iccInfo.isDisplayNetworkNameRequired, expectedPlmnNameDisplay);
+    do_check_eq(ril.iccInfo.isDisplaySpnRequired, expectedSpnDisplay);
+  }
+
+  // Create empty operator object.
+  ril.operator = {};
+  // Setup SIM MCC-MNC to 310-260 as home network.
+  ril.iccInfo.mcc = 310;
+  ril.iccInfo.mnc = 260;
+
+  do_test_spdi();
+
+  // No network.
+  do_test_spn(0x00, true, true);
+  do_test_spn(0x01, true, true);
+  do_test_spn(0x02, true, false);
+  do_test_spn(0x03, true, false);
+
+  // Home network.
+  ril.operator.mcc = 310;
+  ril.operator.mnc = 260;
+  do_test_spn(0x00, false, true);
+  do_test_spn(0x01, true, true);
+  do_test_spn(0x02, false, true);
+  do_test_spn(0x03, true, true);
+
+  // Not HPLMN but in PLMN list.
+  ril.iccInfoPrivate.SPDI = [{"mcc":"234","mnc":"136"},{"mcc":"466","mnc":"92"}];
+  ril.operator.mcc = 466;
+  ril.operator.mnc = 92;
+  do_test_spn(0x00, false, true);
+  do_test_spn(0x01, true, true);
+  do_test_spn(0x02, false, true);
+  do_test_spn(0x03, true, true);
+  ril.iccInfoPrivate.SPDI = null; // reset SPDI to null;
+
+  // Non-Home network.
+  ril.operator.mcc = 466;
+  ril.operator.mnc = 01;
+  do_test_spn(0x00, true, true);
+  do_test_spn(0x01, true, true);
+  do_test_spn(0x02, true, false);
+  do_test_spn(0x03, true, false);
+
+  run_next_test();
+});