|
1 from marionette_test import * |
|
2 |
|
3 |
|
4 class SMSTest(MarionetteTestCase): |
|
5 |
|
6 @unittest.expectedFailure |
|
7 def test_sms_between_emulators(self): |
|
8 # Tests always have one emulator available as self.marionette; we'll |
|
9 # use this for the receiving emulator. We'll also launch a second |
|
10 # emulator to use as the sender. |
|
11 sender = self.get_new_emulator() |
|
12 receiver = self.marionette |
|
13 |
|
14 self.set_up_test_page(sender, "test.html", ["sms"]) |
|
15 self.set_up_test_page(receiver, "test.html", ["sms"]) |
|
16 |
|
17 # Setup the event listsener on the receiver, which should store |
|
18 # a global variable when an SMS is received. |
|
19 message = 'hello world!' |
|
20 self.assertTrue(receiver.execute_script("return window.navigator.mozMobileMessage != null;")) |
|
21 receiver.execute_script(""" |
|
22 global.smsreceived = null; |
|
23 window.navigator.mozMobileMessage.addEventListener("received", function(e) { |
|
24 global.smsreceived = e.message.body; |
|
25 }); |
|
26 """, new_sandbox=False) |
|
27 |
|
28 # Send the SMS from the sender. |
|
29 sender.execute_script(""" |
|
30 window.navigator.mozMobileMessage.send("%d", "%s"); |
|
31 """ % (receiver.emulator.port, message)) |
|
32 |
|
33 # On the receiver, wait up to 10s for an SMS to be received, by |
|
34 # checking the value of the global var that the listener will change. |
|
35 receiver.set_script_timeout(0) # TODO no timeout for now since the test fails |
|
36 received = receiver.execute_async_script(""" |
|
37 waitFor(function () { |
|
38 marionetteScriptFinished(global.smsreceived); |
|
39 }, function () { |
|
40 return global.smsreceived |
|
41 }); |
|
42 """, new_sandbox=False) |
|
43 self.assertEqual(received, message) |