From: chen Date: Tue, 18 Feb 2025 03:01:35 +0000 (+0800) Subject: discover devices before create bonding X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F319788%2F1;p=test%2Ftct%2Fweb%2Fapi.git discover devices before create bonding Change-Id: I1c8e2fe42327407368d0ca3c06268187b90e6efa Signed-off-by: chen --- diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothAdapter_createBonding_deviceuuid_correct.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothAdapter_createBonding_deviceuuid_correct.html index 1c425517e..384b9823f 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothAdapter_createBonding_deviceuuid_correct.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothAdapter_createBonding_deviceuuid_correct.html @@ -85,12 +85,12 @@ t.step(function () { assert_unreached("onBondingError exception " + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice.html index d6d008329..26f81c1a6 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice.html @@ -239,12 +239,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID.html index b0ab21e83..8b1162f83 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID.html @@ -77,12 +77,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_onerror.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_onerror.html index 98f7448d0..6bd22018e 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_onerror.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_onerror.html @@ -76,12 +76,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_with_errorCallback.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_with_errorCallback.html index 8e9139083..0620a4495 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_with_errorCallback.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_with_errorCallback.html @@ -69,12 +69,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket.html index 5125febb5..099835e12 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket.html @@ -234,12 +234,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocketState_open_enum.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocketState_open_enum.html index accbb850b..672b4c91b 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocketState_open_enum.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocketState_open_enum.html @@ -85,12 +85,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_close.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_close.html index ea83ae0b8..c7aaab759 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_close.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_close.html @@ -87,12 +87,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onclose_callback.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onclose_callback.html index 19b0731ba..40eb7de66 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onclose_callback.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onclose_callback.html @@ -106,12 +106,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onmessage_callback.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onmessage_callback.html index d4b41c193..5c4fe560f 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onmessage_callback.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onmessage_callback.html @@ -99,12 +99,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_readData.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_readData.html index 0cba0a9a0..0d3a4fcbc 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_readData.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_readData.html @@ -101,12 +101,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_writeData.html b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_writeData.html index b4a91a821..856bfe67e 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_writeData.html +++ b/common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_writeData.html @@ -81,12 +81,12 @@ t.step(function () { assert_unreached("onBondingError exception:" + e.message); }); - powerOnSuccess = t.step_func(function () { + PreBondSuccess = t.step_func(function () { adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError); }); adapter = tizen.bluetooth.getDefaultAdapter(); - setPowered(t, adapter, powerOnSuccess); + setPreBond(t, adapter, PreBondSuccess); } else { t.done(); diff --git a/common/tct-bluetooth-tizen-tests/bluetooth/support/bluetooth_common.js b/common/tct-bluetooth-tizen-tests/bluetooth/support/bluetooth_common.js index 680e8e4a6..afdc7d5a9 100755 --- a/common/tct-bluetooth-tizen-tests/bluetooth/support/bluetooth_common.js +++ b/common/tct-bluetooth-tizen-tests/bluetooth/support/bluetooth_common.js @@ -71,6 +71,57 @@ function setPowered (t, adapter, powerOnSuccess) { powerOnSuccess(); } +function setPreBond (t, adapter, PreBondSuccess) { + var found = false; + discoverDevicesSuccessCallback = { + onstarted: t.step_func(function () { + }), + ondevicefound: t.step_func(function (device) { + if (device.address === REMOTE_DEVICE_ADDRESS) { + adapter.stopDiscovery(function() { + console.log("Stop discovery success"); + }, function(e) { + console.log("Error while stopDiscovery:" + e.message); + }); + PreBondSuccess(); + } + }), + ondevicedisappeared: t.step_func(function (address) { + }), + onfinished: t.step_func(function (devices) { + if (devices.length > 0) { + found = false; + for (var i = 0; i < devices.length; i++) { + if (devices[i].address === REMOTE_DEVICE_ADDRESS) { + found = true; + break; + } + } + if (found === false) { + assert_unreached("Device not found:" + REMOTE_DEVICE_ADDRESS); + } + } else { + setTimeout(stopDiscoverySuccess, 1000); + } + }) + }; + + discoverDevicesError = t.step_func(function (e) { + assert_unreached("discoverDevicesError exception:" + e.message); + }); + + stopDiscoverySuccess = t.step_func(function () { + adapter.discoverDevices(discoverDevicesSuccessCallback, discoverDevicesError); + }); + + if (!adapter.powered) + assert_unreached("Please turn on bluetooth and set visible always"); + + adapter = tizen.bluetooth.getDefaultAdapter(); + adapter.stopDiscovery(stopDiscoverySuccess, function(e) { + console.log("Failed to stopDiscovery: " + e.message + "(" + e.name + ")"); + }); +} function stopDiscovery (t, adapter, stopDiscoverySuccess) { var stopDiscoveryError = t.step_func(function (e) { assert_unreached("stopDiscoveryError exception:" + e.message); diff --git a/common/tct-bluetooth-tizen-tests/tct-bt-helper/config.xml b/common/tct-bluetooth-tizen-tests/tct-bt-helper/config.xml index 259c96615..463bd81ef 100755 --- a/common/tct-bluetooth-tizen-tests/tct-bt-helper/config.xml +++ b/common/tct-bluetooth-tizen-tests/tct-bt-helper/config.xml @@ -6,4 +6,5 @@ tct-bt-helper +