361fce071fb67e10db7ad30d253d6468e44e86d5
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 Samsung Electronics Co., Ltd.
4
5 Licensed under the Apache License, Version 2.0 (the License);
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17
18 Authors:
19         Andrzej Krolikowski <a.krolikowsk@samsung.com>
20
21 -->
22 <html>
23 <head>
24 <title>MessageStorage_email_updateMessages_without_successCallback</title>
25 <meta charset="utf-8"/>
26 <script type="text/javascript" src="support/unitcommon.js"></script>
27 <script type="text/javascript" src="support/messaging_common.js"></script>
28 </head>
29
30 <body>
31 <div id="log"></div>
32 <script>
33 //==== TEST: MessageStorage_email_updateMessages_without_successCallback
34 //==== LABEL Check if MessageStorage.updateMessages method works properly without successCallback argument (email)
35 //==== PRIORITY P1
36 //==== SPEC Tizen Web API:Communication:Messaging:MessageStorage:updateMessages M
37 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
38 //==== ONLOAD_DELAY 300
39 //==== TIMEOUT 300
40 //==== TEST_CRITERIA MR MMINA
41 setup({timeout: 90000});
42
43 var t = async_test(document.title, {timeout: 90000}), serviceSuccess, serviceError, service, mutableMessage,
44     constMessage, plainBodyToSetForMutableMessage = MESSAGE_BODY_PLAIN + "_mutable", plainBodyToSetForConstMessage = MESSAGE_BODY_PLAIN + "_const",
45     addDraftSuccess, addDraftError, addDraftSuccessCounter = 0, returnedValue;
46 t.step(function () {
47
48     addDraftSuccess = t.step_func(function () {
49         addDraftSuccessCounter++;
50         if (addDraftSuccessCounter === 2) {
51             mutableMessage.to = ["tomutableMessage1@something.com", "tomutableMessage2@something.com"];
52             mutableMessage.cc = ["ccmutableMessage1@something.com", "ccmutableMessage2@something.com"];
53             mutableMessage.bcc = ["bccmutableMessage1@something.com", "bccmutableMessage2@something.com"];
54             mutableMessage.body.plainBody = "new mutableMessage.plainBody";
55             mutableMessage.body.htmlBody = MESSAGE_BODY_HTML + "<img src='webapi-tizen-messaging-test_image.jpg'>";
56             mutableMessage.body.inlineAttachments = [
57                 new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_image.jpg", MESSAGE_ATTACHMENT_IMAGE_MIME_TYPE),
58                 new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", MESSAGE_ATTACHMENT_SOUND_MIME_TYPE)
59             ];
60             mutableMessage.isRead = true;
61             mutableMessage.isHighPriority = true;
62             mutableMessage.subject = "new mutableMessage.subject";
63             mutableMessage.attachments = [
64                 new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", MESSAGE_ATTACHMENT_SOUND_MIME_TYPE),
65                 new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_image.jpg", MESSAGE_ATTACHMENT_IMAGE_MIME_TYPE)
66             ];
67             returnedValue = service.messageStorage.updateMessages([mutableMessage, constMessage]);
68             assert_equals(returnedValue, undefined, "Incorrect returned value from updateMessages");
69             t.done();
70         }
71     });
72
73     addDraftError = t.step_func(function (error) {
74         assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
75     });
76
77     serviceSuccess = t.step_func(function (emailService) {
78         service = emailService;
79
80         mutableMessage = new tizen.Message("messaging.email", {
81             subject: generateSubject(),
82             to: [TEST_EMAIL_RECIPIENT_2],
83             plainBody: plainBodyToSetForMutableMessage,
84             htmlBody: MESSAGE_BODY_HTML,
85             isHighPriority: false
86         });
87
88         service.messageStorage.addDraftMessage(mutableMessage, addDraftSuccess, addDraftError);
89
90         constMessage = new tizen.Message("messaging.email", {
91             subject: generateSubject(),
92             to: [TEST_EMAIL_RECIPIENT_2],
93             plainBody: plainBodyToSetForConstMessage,
94             htmlBody: MESSAGE_BODY_HTML,
95             isHighPriority: false
96         });
97
98         constMessage.attachments = [
99             new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", MESSAGE_ATTACHMENT_SOUND_MIME_TYPE),
100             new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_image.jpg", MESSAGE_ATTACHMENT_IMAGE_MIME_TYPE)
101         ];
102
103         service.messageStorage.addDraftMessage(constMessage, addDraftSuccess, addDraftError);
104     });
105
106     serviceError = t.step_func(function (error) {
107         assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
108     });
109
110     getEmailService(t, serviceSuccess, serviceError);
111 });
112
113 </script>
114 </body>
115 </html>