Bug 797296 - Part 2: Test STK Poll Off. r=yoshi
authorJohn Shih <jshih@mozilla.com>
Thu, 07 Feb 2013 15:58:49 +0800
changeset 124589 a999b78a26bd63109d6575d9ca3c86b3e1c66de3
parent 124588 df8f39f4e92716fd52ab5c4f18fa7294fe837789
child 124590 deef21121046a67acea6bb1200674614ea445b79
push id24427
push useremorley@mozilla.com
push dateWed, 13 Mar 2013 12:28:55 +0000
treeherdermozilla-central@072b936973fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoshi
bugs797296
milestone22.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 797296 - Part 2: Test STK Poll Off. r=yoshi
dom/icc/tests/marionette/manifest.ini
dom/icc/tests/marionette/test_stk_poll_off.js
--- a/dom/icc/tests/marionette/manifest.ini
+++ b/dom/icc/tests/marionette/manifest.ini
@@ -1,7 +1,8 @@
 [DEFAULT]
 b2g = true
 browser = false
 qemu = true
 
 [test_stk_proactive_command.js]
 [test_stk_refresh.js]
+[test_stk_poll_off.js]
new file mode 100644
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_poll_off.js
@@ -0,0 +1,61 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 30000;
+
+SpecialPowers.addPermission("mobileconnection", true, document);
+
+let icc = navigator.mozMobileConnection.icc;
+ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
+
+function testPollOff(command, expect) {
+  log("STK CMD " + JSON.stringify(command));
+  is(command.typeOfCommand, icc.STK_CMD_POLL_OFF, expect.name);
+  is(command.commandQualifier, expect.commandQualifier, expect.name);
+
+  runNextTest();
+}
+
+let tests = [
+  {command: "d009810301040082028182",
+   func: testPollOff,
+   expect: {name: "pull_off_cmd_1",
+            commandQualifier: 0x00}}
+];
+
+let pendingEmulatorCmdCount = 0;
+function sendStkPduToEmulator(command, func, expect) {
+  ++pendingEmulatorCmdCount;
+
+  runEmulatorCmd(command, function (result) {
+    --pendingEmulatorCmdCount;
+    is(result[0], "OK");
+  });
+
+  icc.onstkcommand = function (evt) {
+    func(evt.command, expect);
+  }
+}
+
+function runNextTest() {
+  let test = tests.pop();
+  if (!test) {
+    cleanUp();
+    return;
+  }
+
+  let command = "stk pdu " + test.command;
+  sendStkPduToEmulator(command, test.func, test.expect)
+}
+
+function cleanUp() {
+  if (pendingEmulatorCmdCount) {
+    window.setTimeout(cleanUp, 100);
+    return;
+  }
+
+  SpecialPowers.removePermission("mobileconnection", document);
+  finish();
+}
+
+runNextTest();