|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 60000; |
|
5 MARIONETTE_HEAD_JS = 'head.js'; |
|
6 |
|
7 const PHONE_NUMBER = "+1234567890"; |
|
8 |
|
9 // Have a long long subject causes the send fails, so we don't need |
|
10 // networking here. |
|
11 const MMS_MAX_LENGTH_SUBJECT = 40; |
|
12 function genMmsSubject(sep) { |
|
13 return "Hello " + (new Array(MMS_MAX_LENGTH_SUBJECT).join(sep)) + " World!"; |
|
14 } |
|
15 |
|
16 function testSms(aProgressStr, aText) { |
|
17 log("Testing thread subject: " + aProgressStr); |
|
18 |
|
19 return sendSmsWithSuccess(PHONE_NUMBER, aText) |
|
20 .then(function(message) { |
|
21 log(" SMS sent, retrieving thread of id " + message.threadId); |
|
22 return getThreadById(message.threadId); |
|
23 }) |
|
24 .then(function(thread) { |
|
25 log(" Got thread.lastMessageSubject = '" + thread.lastMessageSubject + "'"); |
|
26 is(thread.lastMessageSubject, "", "thread.lastMessageSubject"); |
|
27 }); |
|
28 } |
|
29 |
|
30 function testMms(aProgressStr, aSubject) { |
|
31 log("Testing thread subject: " + aProgressStr); |
|
32 |
|
33 let mmsParameters = { |
|
34 receivers: [PHONE_NUMBER], |
|
35 subject: aSubject, |
|
36 attachments: [], |
|
37 }; |
|
38 |
|
39 // We use a long long message subject so it will always fail. |
|
40 return sendMmsWithFailure(mmsParameters) |
|
41 .then(function(result) { |
|
42 log(" MMS sent, retrieving thread of id " + result.message.threadId); |
|
43 return getThreadById(result.message.threadId); |
|
44 }) |
|
45 .then(function(thread) { |
|
46 log(" Got thread.lastMessageSubject = '" + thread.lastMessageSubject + "'"); |
|
47 is(thread.lastMessageSubject, aSubject, "thread.lastMessageSubject"); |
|
48 }); |
|
49 } |
|
50 |
|
51 startTestCommon(function testCaseMain() { |
|
52 return testSms("SMS", "text") |
|
53 .then(testMms.bind(null, "SMS..MMS", genMmsSubject(" "))) |
|
54 .then(testSms.bind(null, "SMS..MMS..SMS", "text")) |
|
55 .then(deleteAllMessages) |
|
56 .then(testMms.bind(null, "MMS", genMmsSubject(" "))) |
|
57 .then(testSms.bind(null, "MMS..SMS", "text")) |
|
58 .then(testMms.bind(null, "MMS..SMS..MMS", genMmsSubject(" "))) |
|
59 .then(deleteAllMessages) |
|
60 .then(testSms.bind(null, "SMS", "1")) |
|
61 .then(testSms.bind(null, "SMS..SMS", "2")) |
|
62 .then(testSms.bind(null, "SMS..SMS..SMS", "3")) |
|
63 .then(deleteAllMessages) |
|
64 .then(testMms.bind(null, "MMS", genMmsSubject("a"))) |
|
65 .then(testMms.bind(null, "MMS..MMS", genMmsSubject("b"))) |
|
66 .then(testMms.bind(null, "MMS..MMS..MMS", genMmsSubject("c"))); |
|
67 }); |