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_withoutfilter</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_withoutfilter
45 //==== LABEL Check if MessagesChangeCallback's messagesupdated callback works properly (listener added without filter)
47 //==== SPEC Tizen Web API:Communication:Messaging:MessagesChangeCallback:messagesupdated M
48 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
49 //==== ONLOAD_DELAY 90
50 //==== TEST_CRITERIA CBOA
51 setup({timeout: 90000});
53 var t = async_test(document.title, {timeout: 90000}), i,
54 serviceError, serviceSuccess, sendSuccess, sendError, findfilter, msg, listener, updateError,
55 findSuccess, findError, service, listenerId;
59 add_result_callback(function (res) {
61 service.messageStorage.removeChangeListener(listenerId);
63 // do nothing in case removeChangeListener throw an exception
68 messagesupdated: t.step_func(function (updatedMessages) {
69 assert_type(updatedMessages, "array", "Not an array.");
70 assert_greater_than(updatedMessages.length, 0, "Received empty messages array");
71 for (i = 0; i < updatedMessages.length; i++) {
72 assert_true(updatedMessages[i] instanceof tizen.Message, "Not a message.");
73 if (updatedMessages[i].id === msg.id) {
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, "No messages found.");
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 listenerId = service.messageStorage.addMessagesChangeListener(listener);
97 findfilter = new tizen.AttributeFilter("to", "CONTAINS", TEST_SMS_RECIPIENT_2);
98 service.messageStorage.findMessages(findfilter, findSuccess, findError);
101 sendError = t.step_func(function (error) {
102 assert_unreached("sendMessage() error callback: name:" + error.name + ", msg:" + error.message);
105 serviceSuccess = t.step_func(function (services) {
106 assert_greater_than(services.length, 0, "Received empty services array");
107 service = services[0];
108 msg = new tizen.Message("messaging.sms",
109 { plainBody: "test.", to: [ TEST_SMS_RECIPIENT_2] });
111 sendMessage(t, service, msg, sendSuccess, sendError);
114 serviceError = t.step_func(function (error) {
115 assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
118 tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);