e54ef4b9e4f21e1ab5ee754ee033a11e077be2e4
[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>MessageConversationArraySuccessCallback_onsuccess_exist</title>
38 <script type="text/javascript" src="support/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: MessageConversationArraySuccessCallback_onsuccess_exist
45 //==== LABEL Check if MessageConversationArraySuccessCallback.onsuccess callback works properly
46 //==== ONLOAD_DELAY 90
47 //==== SPEC Tizen Web API:Communication:Messaging:MessageConversationArraySuccessCallback:onsuccess M
48 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
49 //==== TEST_CRITERIA CBOA
50 setup({timeout: 90000});
51 var t = async_test(document.title, {timeout: 90000}),
52     serviceSuccess, serviceError, message, datetime, service, messageStorage, filter,
53     sendSuccess, sendError, findConversationsSuccess, findConversationsError;
54
55 t.step(function () {
56     findConversationsError = t.step_func(function (error) {
57         assert_unreached("findConversations() error callback: name:" + error.name + ", msg:" + error.message);
58     });
59
60     findConversationsSuccess = t.step_func(function (conversations) {
61         assert_greater_than(conversations.length, 0, "Received empty conversations array");
62
63         assert_own_property(conversations[0], "id", "No id attribute in conversation");
64         assert_own_property(conversations[0], "type", "No type attribute in conversation");
65         assert_own_property(conversations[0], "timestamp", "No timestamp attribute in conversation");
66         assert_own_property(conversations[0], "messageCount", "No messageCount attribute in conversation");
67         assert_own_property(conversations[0], "unreadMessages", "No unreadMessages attribute in conversation");
68         assert_own_property(conversations[0], "preview", "No preview attribute in conversation");
69         assert_own_property(conversations[0], "isRead", "No isRead attribute in conversation");
70         assert_own_property(conversations[0], "from", "No from attribute in conversation");
71         assert_own_property(conversations[0], "to", "No to attribute in conversation");
72         assert_own_property(conversations[0], "lastMessageId", "No lastMessageId attribute in conversation");
73
74         t.done();
75     });
76
77     sendSuccess = t.step_func(function () {
78         filter = new tizen.AttributeFilter("type", "EXACTLY", "messaging.sms");
79         service.messageStorage.findConversations(filter, findConversationsSuccess, findConversationsError);
80     });
81
82     sendError = t.step_func(function (error) {
83         assert_unreached("sendMessage() error callback: name:" + error.name + ", msg:" + error.message);
84     });
85
86     serviceSuccess = t.step_func(function (services) {
87         assert_greater_than(services.length, 0, "Received empty services array");
88         service = services[0];
89         messageStorage = service.messageStorage;
90
91         datetime = new Date().getTime().toString();
92         message = new tizen.Message("messaging.sms", {
93             plainBody: datetime,
94             to: [ TEST_SMS_RECIPIENT ]
95         });
96
97         service.sendMessage(message, sendSuccess, sendError);
98     });
99
100     serviceError = t.step_func(function (error) {
101         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
102     });
103
104     tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);
105 });
106
107 </script>
108 </body>
109 </html>