b454b3448b8fdeacad57eca2f34a23d88948a965
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3
4 Copyright (c) 2013 Samsung Electronics Co., Ltd.
5
6 Licensed under the Apache License, Version 2.0 (the License);
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18
19 Authors:
20         Roman Frolow <r.frolow@samsung.com>
21
22 -->
23 <html>
24
25 <head>
26 <title>MessageConversationArraySuccessCallback_onsuccess</title>
27 <meta charset="utf-8">
28 <script type="text/javascript" src="support/unitcommon.js"></script>
29 <script type="text/javascript" src="support/messaging_common.js"></script>
30 </head>
31 <body>
32 <div id="log"></div>
33 <script type="text/javascript">
34 //==== TEST: MessageConversationArraySuccessCallback_onsuccess
35 //==== LABEL Check if method onsuccess of MessageConversationArraySuccessCallback works
36 //==== SPEC Tizen Web API:Communication:Messaging:MessageConversationArraySuccessCallback:onsuccess M
37 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
38 //==== PRIORITY P1
39 //==== ONLOAD_DELAY 300
40 //==== TIMEOUT 300
41 //==== TEST_CRITERIA CBOA CBT
42 setup({timeout: 90000});
43 var t = async_test(document.title, {timeout: 90000}), service, message,
44     serviceSuccess, serviceError, findConversationsSuccess, findConversationsError, filter,
45     addDraftSuccess, addDraftError;
46
47 t.step(function () {
48     findConversationsError = t.step_func(function (error) {
49         assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
50     });
51
52     findConversationsSuccess = t.step_func(function (conversations) {
53         assert_type(conversations, "array", "Incorrect type.");
54         assert_greater_than(conversations.length, 0, "Received empty conversations array");
55
56         assert_own_property(conversations[0], "id", "id not present.");
57         assert_own_property(conversations[0], "type", "type not present.");
58         assert_own_property(conversations[0], "timestamp", "timestamp not present.");
59         assert_own_property(conversations[0], "messageCount", "messageCount not present.");
60         assert_own_property(conversations[0], "unreadMessages", "unreadMessages not present.");
61         assert_own_property(conversations[0], "preview", "preview not present.");
62         assert_own_property(conversations[0], "subject", "subject not present.");
63         assert_own_property(conversations[0], "isRead", "isRead not present.");
64         assert_own_property(conversations[0], "from", "from not present.");
65         assert_own_property(conversations[0], "to", "to not present.");
66         assert_own_property(conversations[0], "cc", "cc not present.");
67         assert_own_property(conversations[0], "bcc", "bcc not present.");
68         assert_own_property(conversations[0], "lastMessageId", "lastMessageId not present.");
69
70         t.done();
71     });
72
73     addDraftSuccess = t.step_func(function () {
74         filter = new tizen.AttributeFilter("id", "EXACTLY", message.conversationId);
75         service.messageStorage.findConversations(filter, findConversationsSuccess, findConversationsError);
76     });
77
78     addDraftError = t.step_func(function (error) {
79         assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
80     });
81
82     serviceSuccess = t.step_func(function (emailService) {
83         service = emailService;
84
85         message = createSimpleMessageTo(TEST_EMAIL_RECIPIENT_1);
86
87         service.messageStorage.addDraftMessage(message, addDraftSuccess, addDraftError);
88     });
89
90     serviceError = t.step_func(function (error) {
91         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
92     });
93
94     getEmailService(t, serviceSuccess, serviceError);
95 });
96
97 </script>
98 </body>
99 </html>