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>MessagesChangeCallback_messagesupdated_withfilter</title>
38 <script type="text/javascript" src="support/unitcommon.js"></script>
39 <script type="text/javascript" src="support/messaging_common.js"></script>
43 <script type="text/javascript">
44 //==== TEST: MessagesChangeCallback_messagesupdated_withfilter
45 //==== LABEL Check if MessagesChangeCallback's messagesupdated callback works properly (listener added with filter)
47 //==== ONLOAD_DELAY 90
48 //==== SPEC Tizen Web API:Communication:Messaging:MessagesChangeCallback:messagesupdated M
49 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
50 //==== TEST_CRITERIA CBOA
51 setup({timeout: 90000});
53 var t = async_test(document.title, {timeout: 90000}),
54 serviceError, serviceSuccess, sendSuccess, sendError, findfilter, msg, listener, updateError,
55 findSuccess, findError, service, listenerfilter, listenerId;
59 add_result_callback(function (res) {
61 service.messageStorage.removeChangeListener(listenerId);
63 // do nothing in case removeChangeListener throw an exception
68 messagesadded: t.step_func(function (messages) {
69 assert_unreached("Should not enter messagesadded: " + messages.length);
71 messagesupdated: t.step_func(function (messages) {
72 assert_greater_than(messages.length, 0, "Received empty messages array in messagesupdated");
76 messagesremoved: t.step_func(function (messages) {
77 assert_unreached("Should not enter messagesremoved: " + messages.length);
81 updateError = t.step_func(function (error) {
82 assert_unreached("updateMessages() error callback: name:" + error.name + ", msg:" + error.message);
85 findSuccess = t.step_func(function (messages) {
86 assert_greater_than(messages.length, 0, "Received empty messages array after findMessages()");
87 messages[0].isRead = !messages[0].isRead;
88 service.messageStorage.updateMessages(messages, null, updateError);
91 findError = t.step_func(function (error) {
92 assert_unreached("findMessages() error callback: name:" + error.name + ", msg:" + error.message);
95 sendSuccess = t.step_func(function () {
96 listenerfilter = new tizen.AttributeFilter("type", "EXACTLY", "messaging.sms");
97 listenerId = service.messageStorage.addMessagesChangeListener(listener, listenerfilter);
98 findfilter = new tizen.AttributeFilter("to", "CONTAINS", TEST_SMS_RECIPIENT_2);
99 service.messageStorage.findMessages(findfilter, findSuccess, findError);
102 sendError = t.step_func(function (error) {
103 assert_unreached("sendMessage() error callback: name:" + error.name + ", msg:" + error.message);
106 serviceSuccess = t.step_func(function (services) {
107 assert_greater_than(services.length, 0, "Received empty services array");
108 service = services[0];
109 msg = new tizen.Message("messaging.sms",
110 { plainBody: "test.", to: [ TEST_SMS_RECIPIENT_2 ] });
112 sendMessage(t, service, msg, sendSuccess, sendError);
115 serviceError = t.step_func(function (error) {
116 assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
119 tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);