4 Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
10 http://www.apache.org/licenses/LICENSE-2.0
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.
19 Beata Koziarek <b.koziarek@samsung.com>
24 <title>MessageStorage_addConversationsChangeListener_with_filter</title>
25 <script type="text/javascript" src="support/unitcommon.js"></script>
26 <script type="text/javascript" src="support/messaging_common.js"></script>
30 <script type="text/javascript">
31 //==== TEST: MessageStorage_addConversationsChangeListener_with_filter
32 //==== LABEL Check if MessageStorage.addConversationsChangeListener method works properly with filter (email)
34 //==== SPEC: Tizen Web API:Communication:Messaging:MessageStorage:addConversationsChangeListener M
35 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
36 //==== ONLOAD_DELAY 180
38 //==== TEST_CRITERIA MOA MAST
39 setup({timeout: 180000});
41 var t = async_test(document.title, {timeout: 180000}), addDraftError,
42 service, serviceSuccess, serviceError, message, conversationChangeCB, filter, watchId;
45 add_result_callback(function () {
47 service.messageStorage.removeChangeListener(watchId);
49 // do nothing in case removeChangeListener throws an exception
53 conversationChangeCB = {
54 conversationsadded: t.step_func(function (conversations) {
55 assert_greater_than(conversations.length, 0, "Received empty conversations array");
57 for (var i in conversations) {
58 if (conversations[i].id === message.conversationId) {
66 addDraftError = t.step_func(function (error) {
67 assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
70 serviceSuccess = t.step_func(function (emailService) {
71 service = emailService;
73 message = createSimpleMessageTo(TEST_EMAIL_RECIPIENT_2);
75 filter = new tizen.AttributeFilter("to", "EXACTLY", message.to);
76 watchId = service.messageStorage.addConversationsChangeListener(conversationChangeCB, filter);
78 service.messageStorage.addDraftMessage(message, null, addDraftError);
81 serviceError = t.step_func(function (error) {
82 assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
85 getEmailService(t, serviceSuccess, serviceError);