3ca82ceff87cf4dfc24c19870e4e84eaf778aa32
[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         Jakub Siewierski <j.siewierski@samsung.com>
20
21 -->
22 <html>
23 <head>
24 <title>MessageService_sms_sendMessage_errorCallback_invalid_cb</title>
25 <script src="../resources/unitcommon.js"></script>
26 <script src="support/messaging_common.js"></script>
27 </head>
28
29 <body>
30 <div id="log"></div>
31 <script>
32 //==== TEST: MessageService_sms_sendMessage_errorCallback_invalid_cb
33 //==== LABEL Check argument MessageService.sendMessage (SMS) errorCallback validation - use {onsuccess: function (){}}
34 //==== PRIORITY: P2
35 //==== SPEC Tizen Web API:Communication:Messaging:MessageService:sendMessage M
36 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
37 //==== ONLOAD_DELAY 90
38 //==== TEST_CRITERIA MTCB
39 setup({ timeout: 90000 });
40
41 var t = async_test("MessageService_sms_sendMessage_errorCallback_invalid_cb", { timeout: 90000 });
42
43 t.step(function () {
44     var messagingService, serviceSuccess, serviceError, message,
45         sendSuccess, invalidErrorCallback,
46         exceptionName = "TypeMismatchError";
47
48     invalidErrorCallback = {
49         onerror: t.step_func(function (error) {
50             assert_unreached("Invalid error callback invoked, name:" + error.name + ", msg:" + error.message);
51         })
52     };
53
54     sendSuccess = t.step_func(function (recipients) {
55         assert_unreached("Success callback invoked.");
56     });
57
58     serviceSuccess = t.step_func(function (services) {
59         assert_true(services.length > 0, "Received empty services array");
60         messagingService = services[0];
61
62         message = new tizen.Message("messaging.sms");
63         assert_throws(
64             { name: exceptionName },
65             function () {
66                 messagingService.sendMessage(message, sendSuccess, invalidErrorCallback);
67             },
68             exceptionName + " should be thrown - invalid error callback."
69         );
70
71         t.done();
72     });
73
74     serviceError = t.step_func(function (error) {
75         assert_unreached("getMessageServices() error callback: name:" + error.name + ", msg:" + error.message);
76     });
77
78     tizen.messaging.getMessageServices("messaging.sms", serviceSuccess, serviceError);
79 });
80
81 </script>
82 </body>
83 </html>