discover devices before create bonding 88/319788/1
authorchen <chen89.chen@samsung.com>
Tue, 18 Feb 2025 03:01:35 +0000 (11:01 +0800)
committerchen <chen89.chen@samsung.com>
Tue, 18 Feb 2025 03:01:41 +0000 (11:01 +0800)
Change-Id: I1c8e2fe42327407368d0ca3c06268187b90e6efa
Signed-off-by: chen <chen89.chen@samsung.com>
14 files changed:
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothAdapter_createBonding_deviceuuid_correct.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_onerror.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothDevice_connectToServiceByUUID_with_errorCallback.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocketState_open_enum.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_close.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onclose_callback.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_onmessage_callback.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_readData.html
common/tct-bluetooth-tizen-tests/bluetooth/BluetoothSocket_writeData.html
common/tct-bluetooth-tizen-tests/bluetooth/support/bluetooth_common.js
common/tct-bluetooth-tizen-tests/tct-bt-helper/config.xml

index 1c425517eb3b674f0c121544ee0ae5c560747e8d..384b9823f17cad86c36231dc8c8b40c90a02789b 100755 (executable)
@@ -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();
index d6d0083296c13afc9c173e508aca5440fc6b78e6..26f81c1a66c75c6711421c8875074cde7d51acd2 100755 (executable)
@@ -239,12 +239,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index b0ab21e83e175ff3cde2667f4a455bbc0ca98a0b..8b1162f83fcbbfb495e922db49259e55f5d56ac6 100755 (executable)
@@ -77,12 +77,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index 98f7448d02f702f05c1ff7b4c85d34be95353136..6bd22018eddb6e9040c887e8579460b0b63fb701 100755 (executable)
@@ -76,12 +76,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index 8e913908387e1f81a6c0c82cfce1d9ac22f79519..0620a44956f044cc2ba702146717275c6abf9422 100755 (executable)
@@ -69,12 +69,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index 5125febb5910e884e87fd8b3f531c22830ad7415..099835e129cb0d53dde4770aa791f693637e25b9 100755 (executable)
@@ -234,12 +234,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index accbb850b9e627f570775d1ac10b5e0abfb6286f..672b4c91b0304bc67c8d089bf2f0501262491e94 100755 (executable)
@@ -85,12 +85,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index ea83ae0b8d9ae4ca306b31eed8f6e69b0779a321..c7aaab75962711b34ef94f84fce16c933e3e2f82 100755 (executable)
@@ -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();
index 19b0731bacd17ee0e6393d8750a7b92c190f51e5..40eb7de66cd67ae8fd8748e7d3ffd0a31e2582f4 100755 (executable)
@@ -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();
index d4b41c1936a4bb85beaf11ee32d922439b2b1e8a..5c4fe560f7c5178655920aa24af4726b5d57cd31 100755 (executable)
@@ -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();
index 0cba0a9a02aa3d1d62b25025287988f588b06b86..0d3a4fcbcf0bd13e16b925cff1b7c2e061fe32f8 100755 (executable)
@@ -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();
index b4a91a821520a4d23f6e64854988227b8339f41f..856bfe67e0051ba757f58e158d99f85fd6e40697 100755 (executable)
@@ -81,12 +81,12 @@ t.step(function () {
             assert_unreached("onBondingError exception:" + e.message);\r
         });\r
 \r
-        powerOnSuccess = t.step_func(function () {\r
+        PreBondSuccess = t.step_func(function () {\r
             adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
         });\r
 \r
         adapter = tizen.bluetooth.getDefaultAdapter();\r
-        setPowered(t, adapter, powerOnSuccess);\r
+        setPreBond(t, adapter, PreBondSuccess);\r
 \r
     } else {\r
         t.done();\r
index 680e8e4a68b0ea2b99f79c8d60b373073759f5f6..afdc7d5a977c92d647c43bf02b7a7cd597c49ee7 100755 (executable)
@@ -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);
index 259c9661592d1848cf707e325ea3e027e642f0f2..463bd81ef6674e18afd45587c5fa657f50fc83de 100755 (executable)
@@ -6,4 +6,5 @@
     <name>tct-bt-helper</name>
     <tizen:privilege name="http://tizen.org/privilege/bluetooth"/>
     <tizen:privilege name="http://tizen.org/privilege/telephony"/>
+    <tizen:setting pointing-device-support="enable"/>
 </widget>