Bug 756607 - Rewrite SMS tests. r=jgriffin DONTBUILD because NPOTB
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Tue, 29 May 2012 17:41:44 -0700
changeset 97434 1c1318dbdf552c87406d38a1097ab55cbab9610b
parent 97433 013b22ee36b7568865e1aa6b9ceb8fb27e5b561f
child 97435 4b57d0e8425563c39d9ec61754a56c4a1592d7b8
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs756607
milestone15.0a1
Bug 756607 - Rewrite SMS tests. r=jgriffin DONTBUILD because NPOTB
dom/sms/tests/manifest.ini
dom/sms/tests/marionette/manifest.ini
dom/sms/tests/marionette/test_between_emulators.py
dom/sms/tests/marionette/test_incoming.js
dom/sms/tests/test_emulators.py
testing/marionette/client/marionette/tests/unit-tests.ini
rename from dom/sms/tests/manifest.ini
rename to dom/sms/tests/marionette/manifest.ini
--- a/dom/sms/tests/manifest.ini
+++ b/dom/sms/tests/marionette/manifest.ini
@@ -1,6 +1,7 @@
 [DEFAULT]
 b2g = true
 browser = false
 qemu = true
 
-[test_emulators.py]
+[test_between_emulators.py]
+[test_incoming.js]
rename from dom/sms/tests/test_emulators.py
rename to dom/sms/tests/marionette/test_between_emulators.py
new file mode 100644
--- /dev/null
+++ b/dom/sms/tests/marionette/test_incoming.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+const WHITELIST_PREF = "dom.sms.whitelist";
+let uriPrePath = window.location.protocol + "//" + window.location.host;
+SpecialPowers.setCharPref(WHITELIST_PREF, uriPrePath);
+
+let sms = window.navigator.mozSms;
+let sender = "5555552368";
+let body = "Hello SMS world!";
+let now = Date.now();
+
+let completed = false;
+runEmulatorCmd("sms send " + sender + " " + body, function(result) {
+  log("Sent fake SMS: " + result);
+  is(result[0], "OK");
+  completed = true;
+});
+
+sms.onreceived = function onreceived(event) {
+  log("Received an SMS!");
+
+  let message = event.message;
+  ok(message instanceof MozSmsMessage);
+
+  is(message.delivery, "received");
+  is(message.sender, sender);
+  is(message.receiver, null);
+  is(message.body, body);
+  ok(message.timestamp instanceof Date);
+  ok(message.timestamp.getTime() > now);
+
+  cleanUp();
+};
+
+function cleanUp() {
+  if (!completed) {
+    window.setTimeout(cleanUp, 100);
+    return;
+  }
+
+  SpecialPowers.clearUserPref(WHITELIST_PREF);
+  finish();
+}
--- a/testing/marionette/client/marionette/tests/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit-tests.ini
@@ -9,12 +9,12 @@ browser = true
 b2g = true
 
 ; true if the test should be skipped
 skip = false
 
 ; webapi tests
 [include:../../../../../dom/telephony/test/marionette/manifest.ini]
 [include:../../../../../dom/battery/test/marionette/manifest.ini]
-[include:../../../../../dom/sms/tests/manifest.ini]
+[include:../../../../../dom/sms/tests/marionette/manifest.ini]
 
 ; marionette unit tests
 [include:unit/unit-tests.ini]