3 Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
19 Andrzej Krolikowski <a.krolikowsk@samsung.com>
24 <title>MessageConversationsChangeCallback_email_conversationsremoved</title>
25 <meta charset="utf-8"/>
26 <script type="text/javascript" src="../resources/unitcommon.js"></script>
27 <script type="text/javascript" src="support/messaging_common.js"></script>
33 //==== TEST: MessageConversationsChangeCallback_email_conversationsremoved
34 //==== LABEL Check if callback is called and if its arguments have proper type - MessageConversationsChangeCallback, conversationsremoved, email
35 //==== SPEC Tizen Web API:Communication:Messaging:MessageConversationsChangeCallback:conversationsremoved M
36 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
37 //==== ONLOAD_DELAY 180
39 //==== TEST_CRITERIA CBOA CBT
40 setup({ timeout: 180000 });
41 var t = async_test("MessageConversationsChangeCallback_email_conversationsremoved", {timeout: 180000}),
42 serviceSuccess, serviceError, service, message, addDraftSuccess, addDraftError,
43 conversationFilter, findConversationSuccess, findConversationError, foundConversation, removeConversationError,
44 changeCallback, listenerId;
48 add_result_callback(function () {
50 service.messageStorage.removeChangeListener(listenerId);
52 // do nothing in case removeChangeListener throw an exception
57 conversationsremoved: t.step_func(function (removedConversations) {
58 assert_type(removedConversations, "array", "Not an array.");
59 assert_equals(removedConversations.length, 1, "Incorrect length of conversations.");
60 assert_equals(removedConversations[0].id, foundConversation.id, "Incorrect id of removed conversation.");
62 assert_own_property(removedConversations[0], "id", "id not present.");
63 assert_own_property(removedConversations[0], "type", "type not present.");
64 assert_own_property(removedConversations[0], "timestamp", "timestamp not present.");
65 assert_own_property(removedConversations[0], "messageCount", "messageCount not present.");
66 assert_own_property(removedConversations[0], "unreadMessages", "unreadMessages not present.");
67 assert_own_property(removedConversations[0], "preview", "preview not present.");
68 assert_own_property(removedConversations[0], "subject", "subject not present.");
69 assert_own_property(removedConversations[0], "isRead", "isRead not present.");
70 assert_own_property(removedConversations[0], "from", "from not present.");
71 assert_own_property(removedConversations[0], "to", "to not present.");
72 assert_own_property(removedConversations[0], "cc", "cc not present.");
73 assert_own_property(removedConversations[0], "bcc", "bcc not present.");
74 assert_own_property(removedConversations[0], "lastMessageId", "lastMessageId not present.");
80 removeConversationError = t.step_func(function (error) {
81 assert_unreached("removeConversations() error callback: name:" + error.name + ", msg:" + error.message);
84 findConversationSuccess = t.step_func(function (conversations) {
85 assert_equals(conversations.length, 1, "Incorrect number of found conversations");
86 foundConversation = conversations[0];
88 listenerId = service.messageStorage.addConversationsChangeListener(changeCallback);
89 service.messageStorage.removeConversations([foundConversation], null, removeConversationError);
92 findConversationError = t.step_func(function (error) {
93 assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
96 addDraftSuccess = t.step_func(function (recipients) {
97 conversationFilter = new tizen.AttributeFilter("id", "EXACTLY", message.conversationId);
98 service.messageStorage.findConversations(conversationFilter, findConversationSuccess, findConversationError);
101 addDraftError = t.step_func(function (error) {
102 assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
105 serviceSuccess = t.step_func(function (emailService) {
106 service = emailService;
108 message = createSimpleMessageTo(TEST_EMAIL_RECIPIENT_2);
110 service.messageStorage.addDraftMessage(message, addDraftSuccess, addDraftError);
113 serviceError = t.step_func(function (error) {
114 assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
117 getEmailService(t, serviceSuccess, serviceError);