dom/mobilemessage/tests/marionette/test_thread_subject.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/mobilemessage/tests/marionette/test_thread_subject.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +MARIONETTE_TIMEOUT = 60000;
     1.8 +MARIONETTE_HEAD_JS = 'head.js';
     1.9 +
    1.10 +const PHONE_NUMBER = "+1234567890";
    1.11 +
    1.12 +// Have a long long subject causes the send fails, so we don't need
    1.13 +// networking here.
    1.14 +const MMS_MAX_LENGTH_SUBJECT = 40;
    1.15 +function genMmsSubject(sep) {
    1.16 +  return "Hello " + (new Array(MMS_MAX_LENGTH_SUBJECT).join(sep)) + " World!";
    1.17 +}
    1.18 +
    1.19 +function testSms(aProgressStr, aText) {
    1.20 +  log("Testing thread subject: " + aProgressStr);
    1.21 +
    1.22 +  return sendSmsWithSuccess(PHONE_NUMBER, aText)
    1.23 +    .then(function(message) {
    1.24 +      log("  SMS sent, retrieving thread of id " + message.threadId);
    1.25 +      return getThreadById(message.threadId);
    1.26 +    })
    1.27 +    .then(function(thread) {
    1.28 +      log("  Got thread.lastMessageSubject = '" + thread.lastMessageSubject + "'");
    1.29 +      is(thread.lastMessageSubject, "", "thread.lastMessageSubject");
    1.30 +    });
    1.31 +}
    1.32 +
    1.33 +function testMms(aProgressStr, aSubject) {
    1.34 +  log("Testing thread subject: " + aProgressStr);
    1.35 +
    1.36 +  let mmsParameters = {
    1.37 +    receivers: [PHONE_NUMBER],
    1.38 +    subject: aSubject,
    1.39 +    attachments: [],
    1.40 +  };
    1.41 +
    1.42 +  // We use a long long message subject so it will always fail.
    1.43 +  return sendMmsWithFailure(mmsParameters)
    1.44 +    .then(function(result) {
    1.45 +      log("  MMS sent, retrieving thread of id " + result.message.threadId);
    1.46 +      return getThreadById(result.message.threadId);
    1.47 +    })
    1.48 +    .then(function(thread) {
    1.49 +      log("  Got thread.lastMessageSubject = '" + thread.lastMessageSubject + "'");
    1.50 +      is(thread.lastMessageSubject, aSubject, "thread.lastMessageSubject");
    1.51 +    });
    1.52 +}
    1.53 +
    1.54 +startTestCommon(function testCaseMain() {
    1.55 +  return testSms("SMS", "text")
    1.56 +    .then(testMms.bind(null, "SMS..MMS", genMmsSubject(" ")))
    1.57 +    .then(testSms.bind(null, "SMS..MMS..SMS", "text"))
    1.58 +    .then(deleteAllMessages)
    1.59 +    .then(testMms.bind(null, "MMS", genMmsSubject(" ")))
    1.60 +    .then(testSms.bind(null, "MMS..SMS", "text"))
    1.61 +    .then(testMms.bind(null, "MMS..SMS..MMS", genMmsSubject(" ")))
    1.62 +    .then(deleteAllMessages)
    1.63 +    .then(testSms.bind(null, "SMS", "1"))
    1.64 +    .then(testSms.bind(null, "SMS..SMS", "2"))
    1.65 +    .then(testSms.bind(null, "SMS..SMS..SMS", "3"))
    1.66 +    .then(deleteAllMessages)
    1.67 +    .then(testMms.bind(null, "MMS", genMmsSubject("a")))
    1.68 +    .then(testMms.bind(null, "MMS..MMS", genMmsSubject("b")))
    1.69 +    .then(testMms.bind(null, "MMS..MMS..MMS", genMmsSubject("c")));
    1.70 +});

mercurial