f42457f15c022e5f3f2f95563608ba6daad88643
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 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 Authors:
18         Zhao Dong<dong82.zhao@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>MessageStorage_email_addFoldersChangeListener_updatedata</title>
24 <meta charset="utf-8"/>
25 <script type="text/javascript" src="support/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>
31 //==== TEST: MessageStorage_email_addFoldersChangeListener_updatedata
32 //==== LABEL Check if MessageStorage::addFoldersChangeListener method works properly when update data
33 //==== PRIORITY: P1
34 //==== SPEC Tizen Web API:Communication:Messaging:MessageStorage:addFoldersChangeListener M
35 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/messaging.html
36 //==== ONLOAD_DELAY 90
37 //==== TEST_CRITERIA MR MAST
38
39 setup({timeout: 90000});
40
41 var t = async_test(document.title, {timeout: 90000}),
42     serviceSuccess, serviceError, foldersChangeCallback, watchId, filter, addDraftError, i;
43
44 t.step(function () {
45
46     foldersChangeCallback = {
47         foldersupdated: t.step_func(function (updatedFolders) {
48         }),
49         foldersadded: t.step_func(function (addedFolders) {
50             assert_type(addedFolders, "object", "type check");
51             assert_greater_than(addedFolders.length, 0, "Received empty folders array");
52             for (i = 0; i < addedFolders.length; i++) {
53                 if (addedFolders[i].name= "abc") {
54                     alert("please remove the folder just added");
55                     t.done();
56                     break;
57                 }
58             }
59         }),
60         foldersremoved: t.step_func(function (removedFolders) {
61         })
62     };
63
64     serviceSuccess = t.step_func(function (service) {
65         filter = new tizen.AttributeFilter("serviceId", "EXACTLY", service.id);
66         watchId = service.messageStorage.addFoldersChangeListener(foldersChangeCallback, filter);
67         assert_type(watchId, "long", "Incorrect returned type");
68         alert("add a folder in the email named 'abc' manually");
69     });
70
71     addDraftError = t.step_func(function (error) {
72         assert_unreached("addDraftMessage() error callback: name:" + error.name + ", msg:" + error.message);
73     });
74
75     serviceError = t.step_func(function (error) {
76         assert_unreached("getEmailService() error callback: name:" + error.name + ", msg:" + error.message);
77     });
78
79     getEmailService(t, serviceSuccess, serviceError);
80 });
81
82 </script>
83 </body>
84 </html>