f0b829e72639e761ed7b42dce148a7be82f9c532
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2012 Intel Corporation.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
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.
16
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.
27
28 Authors:
29         Li, Li <li.l.li@intel.com>
30         Zoe, Zou <zoex.zou@intel.com>
31         Ma,YueX <yuex.ma@intel.com>
32
33 -->
34
35 <html>
36 <head>
37 <title>MessageConversationsChangeCallback_conversationsupdated_withoutfilter</title>
38 <script type="text/javascript" src="../resources/unitcommon.js"></script>
39 <script type="text/javascript" src="support/messaging_common.js"></script>
40 </head>
41 <body>
42 <div id="log"></div>
43 <script type="text/javascript">
44 //==== TEST: MessageConversationsChangeCallback_conversationsupdated_withoutfilter
45 //==== LABEL check the function of conversationsupdated in MessageConversationsChangeCallback by withoutfilter
46 //==== PRIORITY P2
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
51
52 //  Check the conversationupdated method when no message updated
53 setup({timeout:90000});
54 var t = async_test("MessageConversationsChangeCallback_conversationsupdated_withoutfilter", {timeout: 90000}),
55     serviceSuccess, serviceError, service, message1, message2,
56     removeAllSuccess, sendSuccess, sendError, conversationChangeCB;
57
58 t.step(function () {
59
60     add_result_callback(function (res) {
61         try {
62             service.messageStorage.removeChangeListener(watcherId);
63         } catch (err) {
64             // do nothing in case removeChangeListener throw an exception
65         }
66     });
67
68     conversationChangeCB = {
69         conversationsupdated : t.step_func(function (conversations) {
70             assert_type(conversations, "array", "conversations");
71             assert_greater_than(conversations.length, 0, "Received empty conversations array");
72             for (var i in conversations) {
73                 if (conversations[i].id === message2.conversationId) {
74                     t.done();
75                     break;
76                 }
77             }
78         })
79     };
80
81     sendError = t.step_func(function (error) {
82         assert_unreached("sendMessage() error callback: name:" + error.name + ", msg:" + error.message);
83     });
84
85     sendSuccess = t.step_func(function () {
86         watcherId = service.messageStorage.addConversationsChangeListener(conversationChangeCB);
87
88         message2 = new tizen.Message("messaging.sms", {
89             to: [TEST_SMS_RECIPIENT],
90             plainBody: generatePlainBody()
91         });
92
93         service.sendMessage(message2, null, sendError);
94     });
95
96     removeAllSuccess = t.step_func(function () {
97         message1 = new tizen.Message("messaging.sms", smsMessageInitDict);
98
99         message1 = new tizen.Message("messaging.sms", {
100             to: [TEST_SMS_RECIPIENT],
101             plainBody: generatePlainBody()
102         });
103
104         service.sendMessage(message1, sendSuccess, sendError);
105     });
106
107     serviceSuccess = t.step_func(function (services) {
108         assert_greater_than(services.length, 0, "Received empty services array");
109         service = services[0];
110         removeAllMessages(t, service, removeAllSuccess);
111     });
112
113     serviceError = t.step_func(function (error) {
114         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
115     });
116
117     tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);
118 });
119 </script>
120 </body>
121 </html>