c7d088d32bafe00e4c83f9a55d30b8d5df9ae4b1
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2016 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         Xiaoyan Qian <xy.qian@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>RemoteAppControlService_launchAppControl_with_errorCallback</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 </head>
27 <body>
28 <div id="log"></div>
29 <script>
30 //==== TEST: RemoteAppControlService_launchAppControl_with_errorCallback
31 //==== LABEL Check if RemoteAppControlService launchAppControl method with all optional arguments works properly
32 //==== SPEC Tizen Web API:TBD:Convergence:RemoteAppControlService:launchAppControl M
33 //==== SPEC_URL TBD
34 //==== PRIORITY P1
35 //==== TEST_CRITERIA MOA MR
36
37 setup({timeout: 30000});
38
39 var t = async_test(document.title, {timeout: 30000}), discoveryCallback, errorCallback, i, onconnected, retVal = null, requestAppControl, launchsuccess, launcherror;
40
41 t.step(function () {
42     requestAppControl = new tizen.ApplicationControl(
43         "http://tizen.org/appcontrol/operation/view",
44         null,
45         "image/jpeg",
46         null);
47
48     launchsuccess = t.step_func(function (data) {
49         assert_equals(retVal, undefined, "launchAppControl should return undefined");
50         service.disconnect();
51         t.done();
52     });
53
54     launcherror = t.step_func(function (error) {
55        assert_unreached("launchAppControl() error callback was invoked: " + error.name + " msg: " + error.message);
56     });
57
58
59     onconnected = t.step_func(function (service) {
60         retVal = service.launchAppControl(requestAppControl, null, launchsuccess, launcherror);
61         assert_equals(retVal, undefined, "launchAppControl should return undefined");
62         service.disconnect();
63         t.done();
64     });
65
66     discoveryCallback = {
67         onfound : t.step_func(function (device) {
68         assert_greater_than(device.services.length, 0, "service item is not found");
69         for (i = 0; i < device.services.length; i++) {
70             if (device.services[i] instanceof RemoteAppControlService && device.services[i].connectionState != "CONNECTED")  {
71                 break;
72             }
73         }
74         device.services[i].connect(onconnected);
75         tizen.convergence.stopDiscovery();
76         }),
77
78         onfinished : t.step_func(function (foundDevices) {
79
80         })
81     };
82
83     errorCallback = t.step_func(function (error) {
84        assert_unreached("startDiscovery() error callback was invoked: " + error.name + " msg: " + error.message);
85     });
86
87     tizen.convergence.startDiscovery(discoveryCallback, errorCallback, 60*60);
88 });
89
90 </script>
91 </body>
92 </html>