Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3473717d
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3473717d
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9922 【xts】【master】蓝牙内存泄露问题修改
Merge pull request !9922 from 权力/myfeature1
上级
d0e2e525
add0aefa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
77 deletion
+62
-77
communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js
...ion/bluetooth_gatt/src/main/js/test/BtGattManager.test.js
+10
-17
communication/bluetooth_gatt/src/main/js/test/BtManagerGattManager.test.js
...etooth_gatt/src/main/js/test/BtManagerGattManager.test.js
+39
-50
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
...n/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
+2
-2
communication/btmanager_switchoff/src/main/js/test/btManagerSwitchOff003.test.js
..._switchoff/src/main/js/test/btManagerSwitchOff003.test.js
+11
-8
未找到文件。
communication/bluetooth_gatt/src/main/js/test/BtGattManager.test.js
浏览文件 @
3473717d
...
...
@@ -63,6 +63,7 @@ describe('btGattManagerTest', function() {
})
afterAll
(
async
function
(
done
)
{
console
.
info
(
'
afterAll called
'
)
gattServer
.
close
();
gattClient
.
close
();
done
()
})
...
...
@@ -136,7 +137,7 @@ describe('btGattManagerTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_GETRSSIVALUE_0100
'
,
0
,
async
function
(
done
)
{
gattClient
.
connect
();
try
{
await
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] BLE read rssi:
'
+
JSON
.
stringify
(
data
));
let
rssiLength
=
Object
.
keys
(
data
).
length
;
expect
(
rssiLength
).
assertEqual
(
0
);
...
...
@@ -207,7 +208,7 @@ describe('btGattManagerTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_GETDEVICENAME_0100
'
,
0
,
async
function
(
done
)
{
try
{
gattClient
.
connect
();
await
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name
'
+
JSON
.
stringify
(
data
))
expect
(
true
).
assertEqual
(
data
!=
null
);
done
();
...
...
@@ -260,7 +261,7 @@ describe('btGattManagerTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_GETSERVICE_0100
'
,
0
,
async
function
(
done
)
{
try
{
gattClient
.
connect
();
await
gattClient
.
getServices
().
then
((
GattService
)
=>
{
gattClient
.
getServices
().
then
((
GattService
)
=>
{
console
.
info
(
'
[bluetooth_js] getServices successfully:
'
+
JSON
.
stringify
(
GattService
));
expect
(
GattService
).
assertNull
();
done
();
...
...
@@ -469,11 +470,9 @@ describe('btGattManagerTest', function() {
console
.
info
(
'
[bluetooth_js] sendResponse ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
characteristicRead
"
,
ReadCharacteristicReq
);
await
gattServer
.
off
(
"
characteristicRead
"
);
gattServer
.
close
();
done
()
done
();
})
/**
...
...
@@ -565,11 +564,9 @@ describe('btGattManagerTest', function() {
'
serviceUuid:
'
+
DescriptorReadReq
.
serviceUuid
);
expect
(
true
).
assertEqual
(
DescriptorReadReq
!=
null
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
descriptorRead
"
,
ReadDescriptorReq
);
await
gattServer
.
off
(
"
descriptorRead
"
);
gattServer
.
close
();
done
()
done
();
})
/**
...
...
@@ -639,11 +636,9 @@ describe('btGattManagerTest', function() {
console
.
info
(
'
[bluetooth_js] sendResponse ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
characteristicWrite
"
,
WriteCharacteristicReq
);
gattServer
.
off
(
"
characteristicWrite
"
);
gattServer
.
close
();
done
()
done
();
})
/**
...
...
@@ -711,11 +706,9 @@ describe('btGattManagerTest', function() {
needRsp
+
'
isPrep:
'
+
isPrep
);
expect
(
true
).
assertEqual
(
DescriptorWriteReq
!=
null
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
descriptorWrite
"
,
WriteDescriptorReq
);
gattServer
.
off
(
"
descriptorWrite
"
);
gattServer
.
close
();
done
()
done
();
})
/**
...
...
@@ -857,8 +850,8 @@ describe('btGattManagerTest', function() {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_GATTCLOSE_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
close
();
let
gattClient
s
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
s
.
close
();
console
.
info
(
'
[bluetooth_js] gattClient close ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
true
);
done
();
...
...
communication/bluetooth_gatt/src/main/js/test/BtManagerGattManager.test.js
浏览文件 @
3473717d
...
...
@@ -65,6 +65,7 @@ describe('btManagerGattManagerTest', function() {
console
.
info
(
'
afterAll called
'
)
await
sleep
(
6000
);
gattClient
.
close
();
gattServer
.
close
();
done
()
})
...
...
@@ -133,8 +134,6 @@ describe('btManagerGattManagerTest', function() {
await
gattClient
.
on
(
'
BLEConnectionStateChange
'
,
ConnectStateChanged
);
gattClient
.
connect
();
gattClient
.
disconnect
();
await
sleep
(
2000
);
await
gattClient
.
off
(
"
BLEConnectionStateChange
"
);
done
()
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GattConnect_0300 failed, code is
${
error
.
code
}
,
...
...
@@ -142,6 +141,8 @@ describe('btManagerGattManagerTest', function() {
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
done
()
}
await
gattClient
.
off
(
"
BLEConnectionStateChange
"
);
done
();
})
/**
...
...
@@ -153,7 +154,6 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GETRSSIVALUE_0100
'
,
0
,
async
function
(
done
)
{
try
{
let
gattRssi
=
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] gattRssi:
'
+
gattRssi
);
console
.
info
(
'
[bluetooth_js] gattRssi data:
'
+
JSON
.
stringify
(
data
));
...
...
@@ -194,7 +194,8 @@ describe('btManagerGattManagerTest', function() {
});
});
}
await
getRssi
();
getRssi
();
done
();
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GetRssiValue_0200 error, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
...
...
@@ -211,18 +212,22 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GETDEVICENAME_0100
'
,
0
,
async
function
(
done
)
{
try
{
await
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name:
'
+
JSON
.
stringify
(
data
))
expect
(
true
).
assertEqual
(
data
!=
null
);
}).
catch
(
err
=>
{
console
.
error
(
'
[bluetooth_js] bluetooth getDeviceName has error:
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
2900099
);
});
gattClient
.
connect
();
let
deviceName
=
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] getDeviceName data info:
'
+
JSON
.
stringify
(
data
));
})
console
.
info
(
'
[bluetooth_js] deviceName:
'
+
deviceName
);
// }).catch(err => {
// console.error('[bluetooth_js] bluetooth getDeviceName has error: '+ JSON.stringify(err));
// expect(err.code).assertEqual(2900099);
// done();
// });
done
();
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GetDeviceName_0100 failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
}
done
();
done
();
})
/**
...
...
@@ -234,18 +239,16 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GETDEVICENAME_0200
'
,
0
,
async
function
(
done
)
{
try
{
gattClient
.
connect
();
gattClient
.
getDeviceName
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getname1 failed
'
);
}
console
.
info
(
'
[bluetooth_js]getname value:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
!=
null
);
});
done
();
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GetDeviceName_0200 failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
done
();
}
done
();
})
...
...
@@ -259,19 +262,19 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GETSERVICE_0100
'
,
0
,
async
function
(
done
)
{
try
{
await
gattClient
.
getServices
().
then
((
GattService
)
=>
{
console
.
info
(
'
[bluetooth_js] getServices successfully:
'
+
JSON
.
stringify
(
GattService
));
expect
(
GattService
).
assertNull
();
done
();
}).
catch
(
err
=>
{
console
.
error
(
'
[bluetooth_js] getServices has error:
'
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertEqual
(
true
);
gattClient
.
connect
();
gattClient
.
getServices
().
then
(
result
=>
{
console
.
info
(
"
getServices successfully:
"
+
JSON
.
stringify
(
result
));
done
();
});
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GetService_0100 failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
done
();
// expect(true).assertEqual(error.code == '2900099' || error.code == 2900099);
if
(
error
.
code
==
'
2900099
'
)
{
expect
(
error
.
code
).
assertEqual
(
'
2900099
'
);
}
else
{
expect
(
error
.
code
).
assertEqual
(
2900099
);
}
}
done
();
})
...
...
@@ -285,6 +288,7 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GETSERVICE_0200
'
,
0
,
async
function
(
done
)
{
try
{
gattClient
.
connect
();
gattClient
.
getServices
((
code
,
data
)
=>
{
if
(
code
.
code
==
0
)
{
console
.
info
(
"
bluetooth services size is
"
,
data
.
length
);
...
...
@@ -519,18 +523,15 @@ describe('btManagerGattManagerTest', function() {
let
serverResponse
=
{
deviceId
:
deviceId
,
transId
:
transId
,
status
:
0
,
offset
:
offset
,
value
:
arrayBufferCCC
};
gattServer
.
sendResponse
(
serverResponse
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
}
await
gattServer
.
on
(
"
characteristicRead
"
,
ReadCharacteristicReq
);
await
gattServer
.
off
(
"
characteristicRead
"
);
gattServer
.
close
();
done
()
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]readDescrValue21 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
expect
(
true
).
assertFalse
();
done
()
}
}
done
();
})
...
...
@@ -630,18 +631,14 @@ describe('btManagerGattManagerTest', function() {
'
serviceUuid:
'
+
DescriptorReadReq
.
serviceUuid
);
expect
(
true
).
assertEqual
(
DescriptorReadReq
!=
null
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
descriptorRead
"
,
ReadDescriptorReq
);
await
gattServer
.
off
(
"
descriptorRead
"
);
gattServer
.
close
();
done
()
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]readDescrValue15 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
expect
(
true
).
assertFalse
();
done
()
}
done
();
})
/**
...
...
@@ -703,17 +700,14 @@ describe('btManagerGattManagerTest', function() {
status
:
0
,
offset
:
offset
,
value
:
arrayBufferCCC
};
gattServer
.
sendResponse
(
serverResponse
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
characteristicWrite
"
,
WriteCharacteristicReq
);
gattServer
.
off
(
"
characteristicWrite
"
);
gattServer
.
close
();
done
()
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]writeCharacteristicValue20 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
expect
(
true
).
assertFalse
();
done
()
}
done
();
})
/**
...
...
@@ -773,10 +767,8 @@ describe('btManagerGattManagerTest', function() {
needRsp
+
'
isPrep:
'
+
isPrep
);
expect
(
true
).
assertEqual
(
DescriptorWriteReq
!=
null
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
descriptorWrite
"
,
WriteDescriptorReq
);
gattServer
.
off
(
"
descriptorWrite
"
);
gattServer
.
close
();
done
()
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]writeDescriptorValue12 failed, code is
${
error
.
code
}
,
...
...
@@ -904,15 +896,12 @@ describe('btManagerGattManagerTest', function() {
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
gattClient
.
setNotifyCharacteristicChanged
(
characteristic
,
false
);
gattClient
.
off
(
'
BLECharacteristicChange
'
);
expect
(
true
).
assertFalse
();
done
();
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]setNotifyCharacteristicChanged14 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
console
.
error
(
`[bluetooth_js]setNotifyCharacteristicChanged14 failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
401
'
);
done
()
}
}
gattClient
.
off
(
'
BLECharacteristicChange
'
);
done
();
})
/**
...
...
@@ -924,8 +913,8 @@ describe('btManagerGattManagerTest', function() {
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_GATTCLOSE_0100
'
,
0
,
async
function
(
done
)
{
try
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
gattClient
.
close
();
let
gattClient
s
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
gattClient
s
.
close
();
done
();
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GattClose_0100 failed, code is
${
error
.
code
}
,
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
浏览文件 @
3473717d
...
...
@@ -125,7 +125,7 @@ describe('btHfpConnTest', function () {
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
hfpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
let
conn
=
hfpSrc
.
connect
(
'
11:22:33:44:55:66
'
);
await
sleep
(
6
000
);
await
sleep
(
5
000
);
console
.
info
(
'
[bluetooth_js]hfp connect result:
'
+
JSON
.
stringify
(
conn
));
expect
(
conn
).
assertFalse
();
hfpSrc
.
off
(
'
connectionStateChange
'
,
StateChangeParam
);
...
...
@@ -147,7 +147,7 @@ describe('btHfpConnTest', function () {
}
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
hfpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
await
sleep
(
6
000
);
await
sleep
(
5
000
);
let
conn
=
hfpSrc
.
disconnect
(
'
11:22:33:44:55:66
'
);
console
.
info
(
'
[bluetooth_js]hfp disconnect result:
'
+
JSON
.
stringify
(
conn
));
expect
(
conn
).
assertFalse
();
...
...
communication/btmanager_switchoff/src/main/js/test/btManagerSwitchOff003.test.js
浏览文件 @
3473717d
...
...
@@ -804,6 +804,11 @@ describe('btManagerError003Test', function() {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BTMANAGER_BLESCAN_0800
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
=
0
);
}
try
{
let
state
=
bluetoothManager
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off1:
'
+
JSON
.
stringify
(
state
));
...
...
@@ -814,11 +819,7 @@ describe('btManagerError003Test', function() {
console
.
info
(
'
[bluetooth_js] getState4 off =
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_OFF
);
}
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
=
0
);
}
console
.
info
(
'
[bluetooth_js] BLE BLEDeviceFind on start!
'
);
bluetoothManager
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetoothManager
.
BLE
.
startBLEScan
(
[{}],
...
...
@@ -829,17 +830,19 @@ describe('btManagerError003Test', function() {
}
);
await
sleep
(
1000
);
expect
(
true
).
assertFalse
();
//
expect(true).assertFalse();
console
.
info
(
'
[bluetooth_js] BLE scan off8
'
);
bluetoothManager
.
BLE
.
off
(
'
BLEDeviceFind
'
,
onReceiveEvent
);
bluetoothManager
.
BLE
.
stopBLEScan
();
done
();
}
catch
(
error
)
{
console
.
error
(
'
[bluetooth_js]Scan_0800 error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
expect
(
error
.
code
).
assertEqual
(
'
2900003
'
);
done
()
}
console
.
info
(
'
[bluetooth_js] BLE BLEDeviceFind off start!
'
);
bluetoothManager
.
BLE
.
off
(
'
BLEDeviceFind
'
,
onReceiveEvent
);
await
sleep
(
2000
);
done
();
})
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录