3 Copyright (c) 2012 Intel Corporation.
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 * Redistributions of works must retain the original copyright notice, this list
9 of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the original copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 may be used to endorse or promote products derived from this work without
15 specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 Li, Li <li.l.li@intel.com>
30 Zoe, Zou <zoex.zou@intel.com>
31 Ma,YueX <yuex.ma@intel.com>
37 <title>Check the conversationadd method when adding a conversation with argument filter</title>
38 <script type="text/javascript" src="../resources/unitcommon.js"></script>
39 <script type="text/javascript" src="support/messaging_common.js"></script>
43 <script type="text/javascript">
44 //==== TEST: MessageConversationsChangeCallback_conversationsadded_withfilter
45 //==== LABEL check the function of conversationsadded in MessageConversationsChangeCallback by withfilter
47 //==== STEP check the function of conversationsadded in MessageConversationsChangeCallback by withfilter
48 //==== EXPECT The function runs normally
49 //==== ONLOAD_DELAY 90
50 //==== SPEC Tizen Web API:Communication:Messaging:MessageConversationsChangeCallback:conversationsadded M
51 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
52 //==== TEST_CRITERIA CBOA
53 setup({timeout: 90000});
54 var t = async_test("MessageConversationsChangeCallback_conversationsadded_withfilter", {timeout:90000}),
55 conversationChangeCB, removeSuccessCB, removeErrorCB, conversationsArrayCB, findErrorCB,
56 serviceListCB, serviceError, listenerFilter, msg, service, filter;
59 conversationChangeCB = {
60 conversationsupdated : t.step_func(function (conversations) {
61 assert_unreached("should not in conversationsupdated: " + conversations.length);
63 conversationsadded : t.step_func(function (conversations) {
64 assert_true(conversations.length > 0, "No conversation added");
67 conversationsremoved : t.step_func(function (conversations) {
68 assert_unreached("should not in conversationsremoved: " + conversations.length);
72 removeSuccessCB = t.step_func(function () {
73 //conversation deleted so add listener and send new message to trigger conversationsadded
74 listenerFilter = new tizen.AttributeFilter("to", "CONTAINS", TEST_SMS_RECIPIENT_2);
75 service.messageStorage.addConversationsChangeListener(conversationChangeCB, filter);
76 msg = new tizen.Message("messaging.sms", {plainBody : "MessageConversationsChangeCallback test.",to : [ TEST_SMS_RECIPIENT_2 ]});
78 service.sendMessage(msg);
81 removeErrorCB = t.step_func(function (error) {
82 assert_unreached("removeConversations() error callback: name:" + error.name + ", msg:" + error.message);
85 conversationsArrayCB = t.step_func(function (conversations) {
86 if (conversations.length === 0) {
89 //conversation exists so delete it first
90 service.messageStorage.removeConversations(conversations, removeSuccessCB, removeErrorCB);
94 findErrorCB = t.step_func(function (error) {
95 assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
98 serviceListCB = t.step_func(function (services) {
99 assert_true(services.length > 0, "No message service found");
100 service = services[0];
101 // precondition - find and remove conversation if already exists
102 filter = new tizen.AttributeFilter("to", "CONTAINS", TEST_SMS_RECIPIENT_2);
103 service.messageStorage.findConversations(filter, conversationsArrayCB, findErrorCB);
106 serviceError = t.step_func(function (error) {
107 assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
110 tizen.messaging.getMessageServices("messaging.sms", serviceListCB, serviceError);