dom/mobilemessage/tests/marionette/test_thread_subject.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 60000;
     5 MARIONETTE_HEAD_JS = 'head.js';
     7 const PHONE_NUMBER = "+1234567890";
     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 }
    16 function testSms(aProgressStr, aText) {
    17   log("Testing thread subject: " + aProgressStr);
    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 }
    30 function testMms(aProgressStr, aSubject) {
    31   log("Testing thread subject: " + aProgressStr);
    33   let mmsParameters = {
    34     receivers: [PHONE_NUMBER],
    35     subject: aSubject,
    36     attachments: [],
    37   };
    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 }
    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 });

mercurial