a30a780e41cb88f426fa8283dedf6e6e20c037bb
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2015 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         Lei Tang <lei312.tang@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>BluetoothLEDevice_disconnect_errorCallback_invalid_cb</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 <script src="support/bluetooth_common.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script>
31 //==== TEST: BluetoothLEDevice_disconnect_errorCallback_invalid_cb
32 //==== LABEL Check disconnect() argument errorCallback validation - use simple function
33 //==== EXECUTION_TYPE manual
34 //==== PRE The bluetooth of the remote/test device MUST support BLE and be turned on and discoverable from other devices.
35 //==== PRIORITY P2
36 //==== ONLOAD_DELAY 180
37 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothLEDevice:disconnect M
38 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html
39 //==== TEST_CRITERIA MTCB
40
41 setup({timeout: 180000});
42
43 var adapter = null, t = async_test(document.title, {timeout: 180000}), SuccessCB, onconnected, ondisconnectsuccess, ondisconnecterror, onerror,
44     device = null, flag = false;
45
46 t.step(function () {
47     ondisconnecterror = {
48         onerror: t.step_func(function (error) {
49             assert_unreached("Invalid errorCallback invoked: " + error.name + ": " + error.message);
50         })
51     };
52
53     ondisconnectsuccess = t.step_func(function (e) {
54         assert_unreached("Method disconnect shouldn't end successfully.");
55     });
56
57     onconnected = t.step_func(function () {
58         assert_throws(TYPE_MISMATCH_EXCEPTION,
59             function () {
60                 device.disconnect(ondisconnectsuccess, ondisconnecterror);
61             }, "Given incorrect errorCallback.");
62         device.disconnect();
63         t.done();
64     });
65
66     onerror = t.step_func(function (e) {
67         assert_unreached("connect errorCallback exception:" + e.message);
68     });
69
70     SuccessCB = t.step_func(function (bledevice) {
71         if (bledevice.address == REMOTE_BLE_DEVICE_ADDRESS && device == null) {
72             adapter.stopScan();
73             device = bledevice;
74             if (flag == false) {
75                 device.connect(onconnected, onerror);
76                 flag = true;
77             }
78         }
79     });
80
81     adapter = tizen.bluetooth.getLEAdapter();
82     adapter.stopScan();
83     adapter.startScan(SuccessCB);
84 });
85
86 </script>
87 </body>
88 </html>