diff --git a/dom/sms/tests/manifest.ini b/dom/sms/tests/marionette/manifest.ini similarity index 51% rename from dom/sms/tests/manifest.ini rename to dom/sms/tests/marionette/manifest.ini index 9d559065ef8..e6fed6e3e40 100644 --- a/dom/sms/tests/manifest.ini +++ b/dom/sms/tests/marionette/manifest.ini @@ -3,4 +3,5 @@ b2g = true browser = false qemu = true -[test_emulators.py] +[test_between_emulators.py] +[test_incoming.js] diff --git a/dom/sms/tests/test_emulators.py b/dom/sms/tests/marionette/test_between_emulators.py similarity index 100% rename from dom/sms/tests/test_emulators.py rename to dom/sms/tests/marionette/test_between_emulators.py diff --git a/dom/sms/tests/marionette/test_incoming.js b/dom/sms/tests/marionette/test_incoming.js new file mode 100644 index 00000000000..2f3a87ad5c5 --- /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(); +} diff --git a/testing/marionette/client/marionette/tests/unit-tests.ini b/testing/marionette/client/marionette/tests/unit-tests.ini index ab267b42661..95df86fb59d 100644 --- a/testing/marionette/client/marionette/tests/unit-tests.ini +++ b/testing/marionette/client/marionette/tests/unit-tests.ini @@ -14,7 +14,7 @@ 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]