4 Copyright (c) 2013 Samsung Electronics Co., Ltd.
\r
6 Licensed under the Apache License, Version 2.0 (the License);
\r
7 you may not use this file except in compliance with the License.
\r
8 You may obtain a copy of the License at
\r
10 http://www.apache.org/licenses/LICENSE-2.0
\r
12 Unless required by applicable law or agreed to in writing, software
\r
13 distributed under the License is distributed on an "AS IS" BASIS,
\r
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 See the License for the specific language governing permissions and
\r
16 limitations under the License.
\r
21 Lukasz Bardeli <l.bardeli@samsung.com>
\r
27 <title>BluetoothDiscoverDevicesSuccessCallback_ondevicedisappeared</title>
\r
28 <script src="support/unitcommon.js"></script>
\r
29 <script src="support/bluetooth_common.js"></script>
\r
34 <div id="log"></div>
\r
36 //==== TEST: BluetoothDiscoverDevicesSuccessCallback_ondevicedisappeared
\r
37 //==== LABEL Check if BluetoothDiscoverDevicesSuccessCallback callback is called and if its ondevicedisappeared arguments have proper type
\r
39 //==== EXECUTION_TYPE manual
\r
40 //==== STEP Disable the bluetooth of the remote device after pop-up is launched on test device.
\r
41 //==== EXPECT ondevicedisappeared callback is invoked.
\r
42 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDiscoverDevicesSuccessCallback:ondevicedisappeared M
\r
43 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html
\r
44 //==== PRE The bluetooth of the remote/test device MUST be turned on and discoverable from other devices.
\r
45 //==== TEST_CRITERIA CBT CBOA
\r
46 setup({ timeout: 180000 });
\r
47 var adapter = null, t = async_test(document.title, { timeout: 180000 }),
\r
48 stopDiscoverySuccess, discoverDevicesErrorCB, discoverDevicesSuccessOneCB, discoverDevicesSuccessTwoCB, flag = false;
\r
50 t.step(function () {
\r
51 if (BT_SUPPORT) { // network.bluetooth support
\r
52 discoverDevicesErrorCB = t.step_func(function (e) {
\r
53 assert_unreached("discoverDevicesErrorCB exception:" + e.message);
\r
56 discoverDevicesSuccessTwoCB = {
\r
57 onstarted: t.step_func(function () {
\r
59 ondevicefound: t.step_func(function (device) {
\r
61 ondevicedisappeared: t.step_func(function (address) {
\r
62 assert_type(address, "string", "address has wrong type");
\r
63 if (address === REMOTE_DEVICE_ADDRESS) {
\r
67 onfinished: t.step_func(function (devices) {
\r
71 adapter.discoverDevices(discoverDevicesSuccessTwoCB, discoverDevicesErrorCB);
\r
76 discoverDevicesSuccessOneCB = {
\r
77 onstarted: t.step_func(function () {
\r
79 ondevicefound: t.step_func(function (device) {
\r
81 ondevicedisappeared: t.step_func(function (address) {
\r
83 onfinished: t.step_func(function (devices) {
\r
84 if (devices.length > 0) {
\r
86 for (var i = 0; i < devices.length; i++) {
\r
87 if (devices[i].address === REMOTE_DEVICE_ADDRESS) {
\r
92 if (found === false) {
\r
93 assert_unreached("Device not found:" + REMOTE_DEVICE_ADDRESS);
\r
95 alert("Please disable bluetooth on the other device, then close this alert");
\r
96 adapter.discoverDevices(discoverDevicesSuccessTwoCB, discoverDevicesErrorCB);
\r
98 setTimeout(stopDiscoverySuccess, 1000);
\r
103 stopDiscoverySuccess = t.step_func(function () {
\r
104 adapter.discoverDevices(discoverDevicesSuccessOneCB, discoverDevicesErrorCB);
\r
107 adapter = tizen.bluetooth.getDefaultAdapter();
\r
108 stopDiscovery(t, adapter, stopDiscoverySuccess);
\r