1f711502691f23dc878e5ddbda3d1518d9e36b7e
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3
4 Copyright (c) 2013 Samsung Electronics Co., Ltd.
5
6 Licensed under the Apache License, Version 2.0 (the License);
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10     http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18 Authors:
19         Beata Koziarek <b.koziarek@samsung.com>
20 -->
21
22 <html>
23 <head>
24 <title>MessageStorage_addConversationsChangeListener_filter_TypeMismatch</title>
25 <script type="text/javascript" src="../resources/unitcommon.js"></script>
26 <script type="text/javascript" src="support/messaging_common.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script type="text/javascript">
31 //==== TEST: MessageStorage_addConversationsChangeListener_filter_TypeMismatch
32 //==== LABEL: Check argument filter conversions exception for addConversationsChangeListener method.
33 //==== PRIORITY: P2
34 //==== SPEC: Tizen Web API:Communication:Messaging:MessageStorage:addConversationsChangeListener M
35 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
36 //==== ONLOAD_DELAY 180
37 //==== TIMEOUT 180
38 //==== TEST_CRITERIA MC
39 setup({timeout: 180000});
40
41 var t = async_test("MessageStorage_addConversationsChangeListener_filter_TypeMismatch", {timeout: 180000}),
42     serviceSuccess, serviceError, service, conversationChangeCB, filter,
43     exceptionName, conversionTable, i, watchId;
44
45 t.step(function () {
46     add_result_callback(function () {
47         try {
48             service.messageStorage.removeChangeListener(watchId);
49         } catch (err) {
50             // do nothing in case removeChangeListener throws an exception
51         }
52     });
53
54     conversationChangeCB = {
55         conversationsadded: t.step_func(function (conversations) {
56             assert_unreached("conversations added");
57         }),
58         conversationsupdated: t.step_func(function (conversations) {
59             assert_unreached("conversations updated");
60         }),
61         conversationsremoved: t.step_func(function (conversations) {
62             assert_unreached("conversations removed");
63         })
64     };
65
66     serviceSuccess = t.step_func(function (emailService) {
67         service = emailService;
68
69         conversionTable = getTypeConversionExceptions("object", true);
70
71         for (i = 0; i < conversionTable.length; i++) {
72             filter = conversionTable[i][0];
73             exceptionName = conversionTable[i][1];
74
75             assert_throws({
76                 name: exceptionName
77             }, function () {
78                 watchId = service.messageStorage.addConversationsChangeListener(conversationChangeCB, filter);
79             }, exceptionName + " should be thrown - given incorrect filter: " + filter);
80         }
81
82         t.done();
83     });
84
85     serviceError = t.step_func(function (error) {
86         assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
87     });
88
89     getEmailService(t, serviceSuccess, serviceError);
90 });
91
92 </script>
93 </body>
94 </html>