0ec7afb173f39c650649ac765382288316e357f7
[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_mms_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_mms_updateMessages_without_successCallback
34 //==== LABEL Check if MessageStorage.updateMessages method works properly without successCallback argument (mms)
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 90
39 //==== TEST_CRITERIA MR MMINA
40 setup({timeout: 90000});
41
42 var t = async_test(document.title, {timeout: 90000}), serviceSuccess, serviceError, messageService, messageStorage,
43     currentDate = new Date(), plainBodyToSet = currentDate.getTime().toString(), mutableMessage, constMessage,
44     initDict = { subject: generateSubject(), to: [TEST_SMS_RECIPIENT], plainBody: "sample plainBody" },
45     initDictForMutableMessage = initDict, initDictForConstMessage = initDict,
46     plainBodyToSetForMutableMessage = plainBodyToSet + "_mutable",
47     plainBodyToSetForConstMessage = plainBodyToSet + "_const",
48     addDraftSuccess, addDraftError, addDraftSuccessCounter = 0,
49     returnedValue = null;
50 t.step(function () {
51
52     addDraftSuccess = t.step_func(function () {
53         addDraftSuccessCounter++;
54         if (addDraftSuccessCounter === 2) {
55             mutableMessage.to = [TEST_SMS_RECIPIENT_2];
56             mutableMessage.body.plainBody = "new mutableMessage.plainBody";
57             mutableMessage.isRead = true;
58             mutableMessage.subject = "new mutableMessage.subject";
59             mutableMessage.attachments = [new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", "audio/mp3"),
60                 new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_image.jpg", "image/jpg")];
61             returnedValue = messageStorage.updateMessages([mutableMessage, constMessage]);
62             assert_equals(returnedValue, undefined, "Incorrect returned value from updateMessages");
63             t.done();
64         }
65     });
66
67     addDraftError = t.step_func(function (error) {
68         assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
69     });
70
71     serviceSuccess = t.step_func(function (services) {
72         assert_greater_than(services.length, 0, "Received empty messaging array");
73         messageService = services[0];
74         messageStorage = messageService.messageStorage;
75
76         initDictForMutableMessage.plainBody = plainBodyToSetForMutableMessage;
77         mutableMessage = new tizen.Message("messaging.mms", initDictForMutableMessage);
78         messageStorage.addDraftMessage(mutableMessage, addDraftSuccess, addDraftError);
79
80         initDictForConstMessage.plainBody = plainBodyToSetForConstMessage;
81         constMessage = new tizen.Message("messaging.mms", initDictForConstMessage);
82         constMessage.attachments = [new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", "audio/mp3"),
83             new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_noise.mp3", "audio/mp3"), new tizen.MessageAttachment(TEST_DIR + "webapi-tizen-messaging-test_image.jpg", "image/jpg")];
84         messageStorage.addDraftMessage(constMessage, addDraftSuccess, addDraftError);
85     });
86
87     serviceError = t.step_func(function (error) {
88         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
89     });
90     tizen.messaging.getMessageServices("messaging.mms", serviceSuccess, serviceError);
91 });
92
93 </script>
94 </body>
95 </html>