4df7db0df2ea73dfa1c56c2ccfa95f51c874079c
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 Samsung Electronics Co., Ltd.
4
5 Licensed under the Apache License, Version 2.0 (the License);
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17
18 Authors:
19         Andrzej Krolikowski <a.krolikowsk@samsung.com>
20
21 -->
22 <html>
23 <head>
24 <title>MessageStorage_sms_addDraftMessage_message_invalid_obj</title>
25 <meta charset="utf-8"/>
26 <script type="text/javascript" src="support/unitcommon.js"></script>
27 <script type="text/javascript" src="support/messaging_common.js"></script>
28 </head>
29
30 <body>
31 <div id="log"></div>
32 <script>
33 //==== TEST: MessageStorage_sms_addDraftMessage_message_invalid_obj
34 //==== LABEL Check if MessageStorage.addDraftMessage method throws exception when message is invalid (sms)
35 //==== PRIORITY: P2
36 //==== SPEC Tizen Web API:Communication:Messaging:MessageStorage:addDraftMessage M
37 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
38 //==== ONLOAD_DELAY 90
39 //==== TEST_CRITERIA MTO
40 setup({timeout: 90000});
41
42 var t = async_test(document.title, {timeout: 90000}), serviceSuccess, serviceError, messageService, messageStorage,
43     fakeMessage, exceptionName = "TypeMismatchError", addDraftSuccess, addDraftError;
44 t.step(function () {
45
46     addDraftSuccess = t.step_func(function () {
47         assert_unreached("addDraftMessage success callback invoked.");
48     });
49
50     addDraftError = t.step_func(function (error) {
51         assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
52     });
53
54     serviceSuccess = t.step_func(function (services) {
55         assert_greater_than(services.length, 0, "Received empty services array");
56         messageService = services[0];
57         messageStorage = messageService.messageStorage;
58
59         fakeMessage = {
60             id: "123456",
61             conversationId: null,
62             folderId: null,
63             type: "messaging.sms",
64             timestamp: null,
65             from: null,
66             to: [ TEST_SMS_RECIPIENT ],
67             body: {
68                 messageId: "123456",
69                 loaded: true,
70                 plainBody: "Sample content"
71             },
72             isRead: false,
73             inResponseTo: null,
74             messageStatus: ""
75         };
76         assert_throws({name: exceptionName},
77         function () {
78             messageStorage.addDraftMessage(fakeMessage, addDraftSuccess, addDraftError);
79         }, exceptionName + " should be thrown - given incorrect Message");
80
81         t.done();
82     });
83
84     serviceError = t.step_func(function (error) {
85         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
86     });
87
88     tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);
89 });
90
91 </script>
92 </body>
93 </html>