1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/mobilemessage/tests/marionette/test_between_emulators.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +from marionette_test import * 1.5 + 1.6 + 1.7 +class SMSTest(MarionetteTestCase): 1.8 + 1.9 + @unittest.expectedFailure 1.10 + def test_sms_between_emulators(self): 1.11 + # Tests always have one emulator available as self.marionette; we'll 1.12 + # use this for the receiving emulator. We'll also launch a second 1.13 + # emulator to use as the sender. 1.14 + sender = self.get_new_emulator() 1.15 + receiver = self.marionette 1.16 + 1.17 + self.set_up_test_page(sender, "test.html", ["sms"]) 1.18 + self.set_up_test_page(receiver, "test.html", ["sms"]) 1.19 + 1.20 + # Setup the event listsener on the receiver, which should store 1.21 + # a global variable when an SMS is received. 1.22 + message = 'hello world!' 1.23 + self.assertTrue(receiver.execute_script("return window.navigator.mozMobileMessage != null;")) 1.24 + receiver.execute_script(""" 1.25 +global.smsreceived = null; 1.26 +window.navigator.mozMobileMessage.addEventListener("received", function(e) { 1.27 + global.smsreceived = e.message.body; 1.28 +}); 1.29 +""", new_sandbox=False) 1.30 + 1.31 + # Send the SMS from the sender. 1.32 + sender.execute_script(""" 1.33 +window.navigator.mozMobileMessage.send("%d", "%s"); 1.34 +""" % (receiver.emulator.port, message)) 1.35 + 1.36 + # On the receiver, wait up to 10s for an SMS to be received, by 1.37 + # checking the value of the global var that the listener will change. 1.38 + receiver.set_script_timeout(0) # TODO no timeout for now since the test fails 1.39 + received = receiver.execute_async_script(""" 1.40 + waitFor(function () { 1.41 + marionetteScriptFinished(global.smsreceived); 1.42 + }, function () { 1.43 + return global.smsreceived 1.44 + }); 1.45 + """, new_sandbox=False) 1.46 + self.assertEqual(received, message)