d60a572b2d390494859823170e0bad67c2912fcd
[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         Beata Koziarek <b.koziarek@samsung.com>
33 -->
34
35 <html>
36 <head>
37 <title>MessageConversationsChangeCallback_conversationsadded</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_conversationsadded
45 //==== LABEL: Check if conversationsadded callback was invoked with proper argument type.
46 //==== PRIORITY: P2
47 //==== SPEC: Tizen Web API:Communication:Messaging:MessageConversationsChangeCallback:conversationsadded 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 CBT
51 setup({timeout: 180000});
52 var t = async_test("MessageConversationsChangeCallback_conversationsadded", {timeout: 180000}),
53     serviceSuccess, serviceError, service, sendError, msg, conversationChangeCB, watchId;
54 t.step(function () {
55     add_result_callback(function () {
56         try {
57             service.messageStorage.removeChangeListener(watchId);
58         } catch (err) {
59             // do nothing in case removeChangeListener throw an exception
60         }
61     });
62
63     conversationChangeCB = {
64         conversationsadded : t.step_func(function (conversations) {
65             assert_type(conversations, "array", "type check");
66             assert_greater_than(conversations.length, 0, "Received empty conversations array");
67
68             assert_own_property(conversations[0], "id", "id not present.");
69             assert_own_property(conversations[0], "type", "type not present.");
70             assert_own_property(conversations[0], "timestamp", "timestamp not present.");
71             assert_own_property(conversations[0], "messageCount", "messageCount not present.");
72             assert_own_property(conversations[0], "unreadMessages", "unreadMessages not present.");
73             assert_own_property(conversations[0], "preview", "preview not present.");
74             assert_own_property(conversations[0], "subject", "subject not present.");
75             assert_own_property(conversations[0], "isRead", "isRead not present.");
76             assert_own_property(conversations[0], "from", "from not present.");
77             assert_own_property(conversations[0], "to", "to not present.");
78             assert_own_property(conversations[0], "cc", "cc not present.");
79             assert_own_property(conversations[0], "bcc", "bcc not present.");
80             assert_own_property(conversations[0], "lastMessageId", "lastMessageId not present.");
81
82             t.done();
83         }),
84         conversationsupdated : t.step_func(function () {
85             assert_unreached("conversations updated");
86         }),
87         conversationsremoved : t.step_func(function () {
88             assert_unreached("conversations removed");
89         })
90     };
91
92     sendError = t.step_func(function (error) {
93         assert_unreached("sendMessage() error callback: name:" + error.name + ", msg:" + error.message);
94     });
95
96     serviceSuccess = t.step_func(function (services) {
97         assert_greater_than(services.length, 0, "Received empty services array");
98         service = services[0];
99         watchId = service.messageStorage.addConversationsChangeListener(conversationChangeCB);
100         msg = new tizen.Message("messaging.email",
101             {plainBody : "test message.", to : [ TEST_EMAIL_RECIPIENT_2 ]});
102         requestMessageSending(t, service, msg, null, sendError);
103     });
104
105     serviceError = t.step_func(function (error) {
106         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
107     });
108
109     tizen.messaging.getMessageServices("messaging.email", serviceSuccess, serviceError);
110 });
111 </script>
112 </body>
113 </html>