Bug 978027 - Part 4: Test cases for prl version. r=allstars.chh, a=1.4+
authorEdgar Chen <echen@mozilla.com>
Mon, 07 Apr 2014 16:18:50 +0800
changeset 192892 edf9e132a957303489238e3e8380804a6d2c82e2
parent 192891 10699e69f8ca308732c28170391ae8fb8d300ff3
child 192893 1c796697dca37cb6b84204b3a2b9c353e2c87438
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars, 1
bugs978027
milestone30.0a2
Bug 978027 - Part 4: Test cases for prl version. r=allstars.chh, a=1.4+
dom/icc/tests/marionette/icc_header.js
dom/icc/tests/marionette/test_icc_info.js
--- a/dom/icc/tests/marionette/icc_header.js
+++ b/dom/icc/tests/marionette/icc_header.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
+
 SpecialPowers.addPermission("mobileconnection", true, document);
 
 let iccManager = navigator.mozIccManager;
 ok(iccManager instanceof MozIccManager,
    "iccManager is instanceof " + iccManager.constructor);
 
 // TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for
 //                    multi-sim
--- a/dom/icc/tests/marionette/test_icc_info.js
+++ b/dom/icc/tests/marionette/test_icc_info.js
@@ -26,34 +26,49 @@ function setEmulatorMccMnc(mcc, mnc) {
     ok(result[0].match(re), "MCC/MNC should be changed.");
   });
 }
 
 /* Basic test */
 taskHelper.push(function basicTest() {
   let iccInfo = icc.iccInfo;
 
-  is(iccInfo.iccType, "sim");
   // The emulator's hard coded iccid value.
   // See it here {B2G_HOME}/external/qemu/telephony/sim_card.c#L299.
   is(iccInfo.iccid, 89014103211118510720);
-  // The emulator's hard coded mcc and mnc codes.
-  // See it here {B2G_HOME}/external/qemu/telephony/android_modem.c#L2465.
-  is(iccInfo.mcc, 310);
-  is(iccInfo.mnc, 260);
-  is(iccInfo.spn, "Android");
-  // Phone number is hardcoded in MSISDN
-  // See {B2G_HOME}/external/qemu/telephony/sim_card.c, in asimcard_io()
-  is(iccInfo.msisdn, "15555215554");
+
+  if (iccInfo instanceof Ci.nsIDOMMozGsmIccInfo) {
+    log("Test Gsm IccInfo");
+    is(iccInfo.iccType, "sim");
+    is(iccInfo.spn, "Android");
+    // The emulator's hard coded mcc and mnc codes.
+    // See it here {B2G_HOME}/external/qemu/telephony/android_modem.c#L2465.
+    is(iccInfo.mcc, 310);
+    is(iccInfo.mnc, 260);
+    // Phone number is hardcoded in MSISDN
+    // See {B2G_HOME}/external/qemu/telephony/sim_card.c, in asimcard_io()
+    is(iccInfo.msisdn, "15555215554");
+  } else {
+    log("Test Cdma IccInfo");
+    is(iccInfo.iccType, "ruim");
+    // MDN is hardcoded as "8587777777".
+    // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
+    // in requestCdmaSubscription()
+    is(iccInfo.mdn, "8587777777");
+    // PRL version is hardcoded as 1.
+    // See it here {B2G_HOME}/hardware/ril/reference-ril/reference-ril.c,
+    // in requestCdmaSubscription()
+    is(iccInfo.prlVersion, 1);
+  }
 
   taskHelper.runNext();
 });
 
-/* Test display condition change */
-taskHelper.push(function testDisplayConditionChange() {
+/* 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);
@@ -69,16 +84,22 @@ taskHelper.push(function testDisplayCond
     [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 */