dom/icc/tests/marionette/icc_header.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/icc/tests/marionette/icc_header.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
     1.8 +
     1.9 +SpecialPowers.addPermission("mobileconnection", true, document);
    1.10 +
    1.11 +let iccManager = navigator.mozIccManager;
    1.12 +ok(iccManager instanceof MozIccManager,
    1.13 +   "iccManager is instanceof " + iccManager.constructor);
    1.14 +
    1.15 +// TODO: Bug 932650 - B2G RIL: WebIccManager API - add marionette tests for
    1.16 +//                    multi-sim
    1.17 +// In single sim scenario, there is only one sim card, we can use below way to
    1.18 +// check iccId and get icc object. But in multi-sim, the index of iccIds may
    1.19 +// not map to sim slot directly, we should have a better way to handle this.
    1.20 +let iccIds = iccManager.iccIds;
    1.21 +ok(Array.isArray(iccIds), "iccIds is an array");
    1.22 +ok(iccIds.length > 0, "iccIds.length is " + iccIds.length);
    1.23 +
    1.24 +let iccId = iccIds[0];
    1.25 +is(iccId, "89014103211118510720", "iccId is " + iccId);
    1.26 +
    1.27 +let icc = iccManager.getIccById(iccId);
    1.28 +ok(icc instanceof MozIcc, "icc is instanceof " + icc.constructor);
    1.29 +
    1.30 +/* Remove permission and execute finish() */
    1.31 +let cleanUp = function() {
    1.32 +  SpecialPowers.removePermission("mobileconnection", document);
    1.33 +  finish();
    1.34 +};
    1.35 +
    1.36 +/* Helper for tasks */
    1.37 +let taskHelper = {
    1.38 +  tasks: [],
    1.39 +
    1.40 +  push: function(task) {
    1.41 +    this.tasks.push(task);
    1.42 +  },
    1.43 +
    1.44 +  runNext: function() {
    1.45 +    let task = this.tasks.shift();
    1.46 +    if (!task) {
    1.47 +      cleanUp();
    1.48 +      return;
    1.49 +    }
    1.50 +
    1.51 +    if (typeof task === "function") {
    1.52 +      task();
    1.53 +    }
    1.54 +  },
    1.55 +};
    1.56 +
    1.57 +/* Helper for emulator console command */
    1.58 +let emulatorHelper = {
    1.59 +  pendingCommandCount: 0,
    1.60 +
    1.61 +  sendCommand: function(cmd, callback) {
    1.62 +    this.pendingCommandCount++;
    1.63 +    runEmulatorCmd(cmd, function(result) {
    1.64 +      this.pendingCommandCount--;
    1.65 +      is(result[result.length - 1], "OK");
    1.66 +
    1.67 +      if (callback && typeof callback === "function") {
    1.68 +        callback(result);
    1.69 +      }
    1.70 +    });
    1.71 +  },
    1.72 +};

mercurial