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 conversationupdated method when some message updated 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_conversationsupdated_withfilter
45 //==== LABEL check the function of conversationsupdated in MessageConversationsChangeCallback by withfilter
47 //==== ONLOAD_DELAY 90
48 //==== SPEC Tizen Web API:Communication:Messaging:MessageConversationsChangeCallback:conversationsupdated M
49 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
50 //==== TEST_CRITERIA CBOA
52 // Check the conversationupdated method when some message updated with argument filter
53 setup({timeout:90000});
54 var t = async_test("MessageConversationsChangeCallback_conversationsupdated_withfilter", {timeout: 90000}),
55 service, messageStorage, conversationChangeCB, filter, addSuccess, add2Success, serviceListCB, watchId;
57 t.step(function() { //cleanup after TC
58 add_result_callback(function () {
60 messageStorage.removeChangeListener(watchId);
62 // do nothing in case removeChangeListener throw an exception
66 conversationChangeCB = {
67 conversationsupdated: t.step_func(function(conversations) {
68 assert_true(conversations.length > 0, "conversations updated!");
71 conversationsadded: t.step_func(function(conversations) {
72 assert_unreached("should not in conversationsadded: " + conversations.length);
74 conversationsremoved: t.step_func(function(conversations) {
75 assert_unreached("should not in conversationsremoved: " + conversations.length);
79 add2Success = t.step_func(function() {
82 addSuccess = t.step_func(function() {
83 filter = new tizen.AttributeFilter("type", "EXACTLY", "messaging.sms");
84 watchId = messageStorage.addConversationsChangeListener(conversationChangeCB, filter);
85 //add next draft message to conversation and trigger conversationsupdated
86 addSMSDraft(t, service, smsMessageInitDict, add2Success);
89 serviceListCB = t.step_func(function(services) {
90 assert_true(services.length > 0, "Received empty services array");
91 service = services[0];
92 messageStorage = service.messageStorage;
93 addSMSDraft(t, service, smsMessageInitDict, addSuccess);
96 tizen.messaging.getMessageServices("messaging.sms", serviceListCB);