Bug 814618 - Part 3: marionette test for Display Text with GSM 7 bit encoding. r=vicamo
authorYoshi Huang <allstars.chh@mozilla.com>
Wed, 05 Dec 2012 15:58:07 +0800
changeset 120765 cd845cbfc76ea496ca593ca1d3cc9d6ce8528ddb
parent 120764 0def12e6e4a764ab16228f24c42e9c5ce53bee5a
child 120766 bfb0857b27516052ff175fdf86dbf6cbdcb86aac
push idunknown
push userunknown
push dateunknown
reviewersvicamo
bugs814618
milestone20.0a1
Bug 814618 - Part 3: marionette test for Display Text with GSM 7 bit encoding. r=vicamo
dom/icc/Makefile.in
dom/icc/tests/Makefile.in
dom/icc/tests/marionette/manifest.ini
dom/icc/tests/marionette/test_stk_proactive_command.js
testing/marionette/client/marionette/tests/unit-tests.ini
--- a/dom/icc/Makefile.in
+++ b/dom/icc/Makefile.in
@@ -6,9 +6,11 @@ DEPTH            = @DEPTH@
 topsrcdir        = @top_srcdir@
 srcdir           = @srcdir@
 VPATH            = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 PARALLEL_DIRS = interfaces src
 
+TEST_DIRS += tests
+
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/icc/tests/Makefile.in
@@ -0,0 +1,16 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DEPTH            = @DEPTH@
+topsrcdir        = @top_srcdir@
+srcdir           = @srcdir@
+VPATH            = @srcdir@
+
+relativesrcdir   = @relativesrcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = test_dom_icc
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/icc/tests/marionette/manifest.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+b2g = true
+browser = false
+qemu = true
+
+[test_stk_proactive_command.js]
new file mode 100644
--- /dev/null
+++ b/dom/icc/tests/marionette/test_stk_proactive_command.js
@@ -0,0 +1,60 @@
+/* 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 testDisplayTextGsm7BitEncoding(cmd) {
+  log("STK CMD " + JSON.stringify(cmd));
+  is(cmd.typeOfCommand, icc.STK_CMD_DISPLAY_TEXT);
+  is(cmd.options.userClear, true);
+  is(cmd.options.text, "Saldo 2.04 E. Validez 20/05/13. ");
+
+  runNextTest();
+}
+
+let tests = [
+  {command: "d0288103012180820281020d1d00d3309bfc06c95c301aa8e80259c3ec34b9ac07c9602f58ed159bb940",
+   func: testDisplayTextGsm7BitEncoding},
+];
+
+let pendingEmulatorCmdCount = 0;
+function sendStkPduToEmulator(cmd, func) {
+  ++pendingEmulatorCmdCount;
+
+  runEmulatorCmd(cmd, function (result) {
+    --pendingEmulatorCmdCount;
+    is(result[0], "OK");
+  });
+
+  icc.onstkcommand = function (evt) {
+    func(evt.command);
+  }
+}
+
+function runNextTest() {
+  let test = tests.pop();
+  if (!test) {
+    cleanUp();
+    return;
+  }
+
+  let cmd = "stk pdu " + test.command;
+  sendStkPduToEmulator(cmd, test.func)
+}
+
+function cleanUp() {
+  if (pendingEmulatorCmdCount) {
+    window.setTimeout(cleanUp, 100);
+    return;
+  }
+
+  SpecialPowers.removePermission("mobileconnection", document);
+  finish();
+}
+
+runNextTest();
--- a/testing/marionette/client/marionette/tests/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit-tests.ini
@@ -12,11 +12,12 @@ b2g = true
 skip = false
 
 ; webapi tests
 [include:../../../../../dom/telephony/test/marionette/manifest.ini]
 [include:../../../../../dom/battery/test/marionette/manifest.ini]
 [include:../../../../../dom/sms/tests/marionette/manifest.ini]
 [include:../../../../../dom/network/tests/marionette/manifest.ini]
 [include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
+[include:../../../../../dom/icc/tests/marionette/manifest.ini]
 
 ; marionette unit tests
 [include:unit/unit-tests.ini]