Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9e58b0af
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看板
提交
9e58b0af
编写于
10月 27, 2022
作者:
Q
quanli
提交者:
权力
10月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
10312669
from
https://gitee.com/quanli125/xts_acts/pulls/6166
quanli1@huawei.com Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
e9bcfb6d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
45 addition
and
57 deletion
+45
-57
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+5
-26
communication/bluetooth_ble/src/main/js/test/BleService.test.js
...ication/bluetooth_ble/src/main/js/test/BleService.test.js
+5
-22
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+8
-4
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
...luetooth_standard/src/main/js/test/BRSetLocalName.test.js
+21
-0
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
..._standard/src/main/js/default/test/GetCountryCode.test.js
+6
-5
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
浏览文件 @
9e58b0af
...
@@ -52,7 +52,7 @@ describe('bluetoothBLETest', function() {
...
@@ -52,7 +52,7 @@ describe('bluetoothBLETest', function() {
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
})
})
beforeEach
(
async
function
(
done
)
{
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
...
@@ -77,7 +77,6 @@ describe('bluetoothBLETest', function() {
...
@@ -77,7 +77,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GattConnect_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GattConnect_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
await
sleep
(
2000
);
await
sleep
(
2000
);
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
...
@@ -120,7 +119,6 @@ describe('bluetoothBLETest', function() {
...
@@ -120,7 +119,6 @@ describe('bluetoothBLETest', function() {
console
.
info
(
'
[bluetooth_js] state changed
'
+
connectState
)
console
.
info
(
'
[bluetooth_js] state changed
'
+
connectState
)
expect
(
true
).
assertEqual
(
connectState
!=
null
);
expect
(
true
).
assertEqual
(
connectState
!=
null
);
}
}
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
on
(
'
BLEConnectionStateChange
'
,
ConnectStateChanged
);
await
gattClient
.
on
(
'
BLEConnectionStateChange
'
,
ConnectStateChanged
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
...
@@ -140,7 +138,6 @@ describe('bluetoothBLETest', function() {
...
@@ -140,7 +138,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getrssi2 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getrssi2 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
...
@@ -170,7 +167,6 @@ describe('bluetoothBLETest', function() {
...
@@ -170,7 +167,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getRssi connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getRssi connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
...
@@ -197,7 +193,6 @@ describe('bluetoothBLETest', function() {
...
@@ -197,7 +193,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getname2 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getname2 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
...
@@ -227,7 +222,6 @@ describe('bluetoothBLETest', function() {
...
@@ -227,7 +222,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gattClient getname1 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js] gattClient getname1 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
...
@@ -252,7 +246,6 @@ describe('bluetoothBLETest', function() {
...
@@ -252,7 +246,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js]gattClient getservices1 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js]gattClient getservices1 connect
'
+
JSON
.
stringify
(
ret
))
expect
(
ret
).
assertTrue
();
expect
(
ret
).
assertTrue
();
...
@@ -280,7 +273,6 @@ describe('bluetoothBLETest', function() {
...
@@ -280,7 +273,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_GetService_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js]gattClient getservices2 connect
'
+
JSON
.
stringify
(
ret
))
console
.
info
(
'
[bluetooth_js]gattClient getservices2 connect
'
+
JSON
.
stringify
(
ret
))
gattClient
.
getServices
((
code
,
data
)
=>
{
gattClient
.
getServices
((
code
,
data
)
=>
{
...
@@ -308,7 +300,6 @@ describe('bluetoothBLETest', function() {
...
@@ -308,7 +300,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 1
* @tc.level Level 1
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
100
);
let
ret
=
gattClient
.
setBLEMtuSize
(
100
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -324,7 +315,6 @@ describe('bluetoothBLETest', function() {
...
@@ -324,7 +315,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
22
);
let
ret
=
gattClient
.
setBLEMtuSize
(
22
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -340,7 +330,6 @@ describe('bluetoothBLETest', function() {
...
@@ -340,7 +330,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
21
);
let
ret
=
gattClient
.
setBLEMtuSize
(
21
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -356,7 +345,6 @@ describe('bluetoothBLETest', function() {
...
@@ -356,7 +345,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 1
* @tc.level Level 1
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
512
);
let
ret
=
gattClient
.
setBLEMtuSize
(
512
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -372,7 +360,6 @@ describe('bluetoothBLETest', function() {
...
@@ -372,7 +360,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
513
);
let
ret
=
gattClient
.
setBLEMtuSize
(
513
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize 128bit ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -401,7 +388,6 @@ describe('bluetoothBLETest', function() {
...
@@ -401,7 +388,6 @@ describe('bluetoothBLETest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
...
@@ -449,7 +435,6 @@ describe('bluetoothBLETest', function() {
...
@@ -449,7 +435,6 @@ describe('bluetoothBLETest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptor
};
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptor
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
readCharacteristicValue
(
characteristic
,
readCcc
);
await
gattClient
.
readCharacteristicValue
(
characteristic
,
readCcc
);
done
()
done
()
})
})
...
@@ -482,6 +467,7 @@ describe('bluetoothBLETest', function() {
...
@@ -482,6 +467,7 @@ describe('bluetoothBLETest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
characteristicRead
"
,
ReadCharacteristicReq
);
await
gattServer
.
on
(
"
characteristicRead
"
,
ReadCharacteristicReq
);
await
gattServer
.
off
(
"
characteristicRead
"
);
await
gattServer
.
off
(
"
characteristicRead
"
);
gattServer
.
close
();
done
()
done
()
})
})
...
@@ -500,7 +486,6 @@ describe('bluetoothBLETest', function() {
...
@@ -500,7 +486,6 @@ describe('bluetoothBLETest', function() {
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
console
.
error
(
'
readDescriptorValue promise object:
'
+
JSON
.
stringify
(
object
));
console
.
error
(
'
readDescriptorValue promise object:
'
+
JSON
.
stringify
(
object
));
...
@@ -542,7 +527,6 @@ describe('bluetoothBLETest', function() {
...
@@ -542,7 +527,6 @@ describe('bluetoothBLETest', function() {
desValue
[
0
]
=
11
;
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
done
()
done
()
})
})
...
@@ -580,6 +564,7 @@ describe('bluetoothBLETest', function() {
...
@@ -580,6 +564,7 @@ describe('bluetoothBLETest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
descriptorRead
"
,
ReadDescriptorReq
);
await
gattServer
.
on
(
"
descriptorRead
"
,
ReadDescriptorReq
);
await
gattServer
.
off
(
"
descriptorRead
"
);
await
gattServer
.
off
(
"
descriptorRead
"
);
gattServer
.
close
();
done
()
done
()
})
})
...
@@ -605,7 +590,6 @@ describe('bluetoothBLETest', function() {
...
@@ -605,7 +590,6 @@ describe('bluetoothBLETest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
characteristic
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
characteristic
);
console
.
info
(
'
[bluetooth_js] writeCharacteristicValue ret :
'
+
ret
);
console
.
info
(
'
[bluetooth_js] writeCharacteristicValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -620,7 +604,6 @@ describe('bluetoothBLETest', function() {
...
@@ -620,7 +604,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
"
123
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
"
123
"
);
console
.
info
(
'
[bluetooth_js] invaild writeCharacteristicValue ret :
'
+
ret
);
console
.
info
(
'
[bluetooth_js] invaild writeCharacteristicValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -657,6 +640,7 @@ describe('bluetoothBLETest', function() {
...
@@ -657,6 +640,7 @@ describe('bluetoothBLETest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
characteristicWrite
"
,
WriteCharacteristicReq
);
gattServer
.
on
(
"
characteristicWrite
"
,
WriteCharacteristicReq
);
gattServer
.
off
(
"
characteristicWrite
"
);
gattServer
.
off
(
"
characteristicWrite
"
);
gattServer
.
close
();
done
()
done
()
})
})
...
@@ -674,7 +658,6 @@ describe('bluetoothBLETest', function() {
...
@@ -674,7 +658,6 @@ describe('bluetoothBLETest', function() {
desValue
[
0
]
=
11
;
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeDescriptorValue
(
descriptor
);
let
ret
=
gattClient
.
writeDescriptorValue
(
descriptor
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -689,7 +672,6 @@ describe('bluetoothBLETest', function() {
...
@@ -689,7 +672,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
'
,
0
,
function
()
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
'
,
0
,
function
()
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
writeDescriptorValue
(
""
);
let
ret
=
gattClient
.
writeDescriptorValue
(
""
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -733,6 +715,7 @@ describe('bluetoothBLETest', function() {
...
@@ -733,6 +715,7 @@ describe('bluetoothBLETest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
.
on
(
"
descriptorWrite
"
,
WriteDescriptorReq
);
gattServer
.
on
(
"
descriptorWrite
"
,
WriteDescriptorReq
);
gattServer
.
off
(
"
descriptorWrite
"
);
gattServer
.
off
(
"
descriptorWrite
"
);
gattServer
.
close
();
done
()
done
()
})
})
...
@@ -745,7 +728,6 @@ describe('bluetoothBLETest', function() {
...
@@ -745,7 +728,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -782,7 +764,6 @@ describe('bluetoothBLETest', function() {
...
@@ -782,7 +764,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -819,7 +800,6 @@ describe('bluetoothBLETest', function() {
...
@@ -819,7 +800,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
setNotifyCharacteristicChanged
(
null
,
false
);
let
ret
=
gattClient
.
setNotifyCharacteristicChanged
(
null
,
false
);
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged is null ret:
'
+
ret
);
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged is null ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
expect
(
ret
).
assertEqual
(
false
);
...
@@ -835,7 +815,6 @@ describe('bluetoothBLETest', function() {
...
@@ -835,7 +815,6 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400
'
,
0
,
async
function
(
done
)
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
function
CharacteristicChange
(
CharacteristicChangeReq
)
{
function
CharacteristicChange
(
CharacteristicChangeReq
)
{
let
serviceUuid
=
CharacteristicChangeReq
.
serviceUuid
;
let
serviceUuid
=
CharacteristicChangeReq
.
serviceUuid
;
let
characteristicUuid
=
CharacteristicChangeReq
.
characteristicUuid
;
let
characteristicUuid
=
CharacteristicChangeReq
.
characteristicUuid
;
...
...
communication/bluetooth_ble/src/main/js/test/BleService.test.js
浏览文件 @
9e58b0af
...
@@ -52,7 +52,7 @@ describe('bluetoothBLETest1', function() {
...
@@ -52,7 +52,7 @@ describe('bluetoothBLETest1', function() {
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
})
})
beforeEach
(
async
function
(
done
)
{
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
...
@@ -85,10 +85,7 @@ describe('bluetoothBLETest1', function() {
...
@@ -85,10 +85,7 @@ describe('bluetoothBLETest1', function() {
+
'
deviceId:
'
+
deviceId
+
'
status:
'
+
status
);
+
'
deviceId:
'
+
deviceId
+
'
status:
'
+
status
);
expect
(
true
).
assertEqual
(
BLEConnectChangedState
!=
null
);
expect
(
true
).
assertEqual
(
BLEConnectChangedState
!=
null
);
}
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
connectStateChange
"
,
Connected
);
await
gattServer
.
on
(
"
connectStateChange
"
,
Connected
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
let
ret
=
gattClient
.
connect
();
let
ret
=
gattClient
.
connect
();
await
sleep
(
2000
);
await
sleep
(
2000
);
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
console
.
info
(
'
[bluetooth_js] gattClient connect
'
+
ret
)
...
@@ -106,7 +103,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -106,7 +103,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
service
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
service
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
isPrimary
:
true
,
includeServices
:
[]};
isPrimary
:
true
,
includeServices
:
[]};
let
ret
=
gattServer
.
addService
(
service
);
let
ret
=
gattServer
.
addService
(
service
);
...
@@ -129,7 +125,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -129,7 +125,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 1
* @tc.level Level 1
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0200
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -168,7 +163,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -168,7 +163,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0300
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -211,7 +205,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -211,7 +205,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0400
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0400
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
characteristics
=
[];
let
characteristics
=
[];
let
arrayBufferC
=
new
ArrayBuffer
(
8
);
let
arrayBufferC
=
new
ArrayBuffer
(
8
);
let
cccV
=
new
Uint8Array
(
arrayBufferC
);
let
cccV
=
new
Uint8Array
(
arrayBufferC
);
...
@@ -242,7 +235,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -242,7 +235,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0500
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0500
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -281,7 +273,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -281,7 +273,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0600
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0600
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -326,7 +317,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -326,7 +317,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0700
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0700
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -365,7 +355,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -365,7 +355,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0800
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0800
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -404,7 +393,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -404,7 +393,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0900
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0900
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -443,7 +431,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -443,7 +431,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1000
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1000
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -482,7 +469,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -482,7 +469,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1100
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -519,7 +505,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -519,7 +505,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1200
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -557,7 +542,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -557,7 +542,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattService
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
gattService
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
isPrimary
:
true
,
includeServices
:[]};
isPrimary
:
true
,
includeServices
:[]};
let
gattService1
=
{
serviceUuid
:
'
00001888-0000-1000-8000-00805f9b34fb
'
,
let
gattService1
=
{
serviceUuid
:
'
00001888-0000-1000-8000-00805f9b34fb
'
,
...
@@ -569,7 +553,7 @@ describe('bluetoothBLETest1', function() {
...
@@ -569,7 +553,7 @@ describe('bluetoothBLETest1', function() {
console
.
info
(
'
[bluetooth_js] bluetooth addService2 result :
'
+
retN
);
console
.
info
(
'
[bluetooth_js] bluetooth addService2 result :
'
+
retN
);
expect
(
retN
).
assertTrue
();
expect
(
retN
).
assertTrue
();
await
sleep
(
1000
);
await
sleep
(
1000
);
let
ret1
=
gattServer
.
removeService
(
'
000018
88-0000-1000-8000-00805f9b34fb
'
);
let
ret1
=
gattServer
.
removeService
(
'
000018
10-0000-1000-8000-00805F9B34FB
'
);
console
.
info
(
'
[bluetooth_js]removeService ret:
'
+
ret1
);
console
.
info
(
'
[bluetooth_js]removeService ret:
'
+
ret1
);
expect
(
ret1
).
assertTrue
();
expect
(
ret1
).
assertTrue
();
done
();
done
();
...
@@ -584,7 +568,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -584,7 +568,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
ret1
=
gattServer
.
removeService
(
'
00001800-0000-1000-8000-00805f9b3442
'
);
let
ret1
=
gattServer
.
removeService
(
'
00001800-0000-1000-8000-00805f9b3442
'
);
console
.
info
(
'
[bluetooth_js]removeService ret:
'
+
ret1
);
console
.
info
(
'
[bluetooth_js]removeService ret:
'
+
ret1
);
expect
(
ret1
).
assertFalse
();
expect
(
ret1
).
assertFalse
();
...
@@ -600,7 +583,6 @@ describe('bluetoothBLETest1', function() {
...
@@ -600,7 +583,6 @@ describe('bluetoothBLETest1', function() {
* @tc.level Level 3
* @tc.level Level 3
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300
'
,
0
,
async
function
(
done
)
{
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
let
descV
=
new
Uint8Array
(
arrayBuffer
);
...
@@ -629,7 +611,7 @@ describe('bluetoothBLETest1', function() {
...
@@ -629,7 +611,7 @@ describe('bluetoothBLETest1', function() {
expect
(
ret1
).
assertTrue
();
expect
(
ret1
).
assertTrue
();
let
ret2
=
gattServer
.
removeService
(
'
00001810-0000-1000-8000-00805F9B34FB
'
);
let
ret2
=
gattServer
.
removeService
(
'
00001810-0000-1000-8000-00805F9B34FB
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js]removeService ret:
'
+
ret2
);
console
.
info
(
'
[bluetooth_js]removeService
1
ret:
'
+
ret2
);
expect
(
ret2
).
assertFalse
();
expect
(
ret2
).
assertFalse
();
done
();
done
();
})
})
...
@@ -753,3 +735,4 @@ describe('bluetoothBLETest1', function() {
...
@@ -753,3 +735,4 @@ describe('bluetoothBLETest1', function() {
})
})
}
}
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
9e58b0af
...
@@ -75,8 +75,9 @@ describe('bluetoothhostTest2', function() {
...
@@ -75,8 +75,9 @@ describe('bluetoothhostTest2', function() {
*/
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0100
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
await
sleep
(
12000
);
console
.
info
(
"
[bluetooth_js] onStartpair001 ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] onStartpair001 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assert
Fals
e
();
expect
(
result
).
assert
Tru
e
();
done
()
done
()
})
})
...
@@ -190,7 +191,7 @@ describe('bluetoothhostTest2', function() {
...
@@ -190,7 +191,7 @@ describe('bluetoothhostTest2', function() {
console
.
info
(
'
[bluetooth_js] getRemoteDeviceClass ret2 :
'
+
JSON
.
stringify
(
DeviceClass
)
console
.
info
(
'
[bluetooth_js] getRemoteDeviceClass ret2 :
'
+
JSON
.
stringify
(
DeviceClass
)
+
'
majorClass:
'
+
DeviceClass
.
majorClass
+
'
majorMinorClass:
'
+
DeviceClass
.
majorMinorClass
+
'
majorClass:
'
+
DeviceClass
.
majorClass
+
'
majorMinorClass:
'
+
DeviceClass
.
majorMinorClass
+
'
classOfDevice:
'
+
DeviceClass
.
classOfDevice
);
+
'
classOfDevice:
'
+
DeviceClass
.
classOfDevice
);
expect
(
DeviceClass
.
majorClass
).
assertEqual
(
0
);
expect
(
DeviceClass
.
majorClass
).
assertEqual
(
7936
);
done
();
done
();
})
})
...
@@ -242,8 +243,9 @@ describe('bluetoothhostTest2', function() {
...
@@ -242,8 +243,9 @@ describe('bluetoothhostTest2', function() {
}
}
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
await
sleep
(
12000
);
console
.
info
(
"
[bluetooth_js] onStartpair007 ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] onStartpair007 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assert
Fals
e
();
expect
(
result
).
assert
Tru
e
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
done
()
})
})
...
@@ -264,8 +266,9 @@ describe('bluetoothhostTest2', function() {
...
@@ -264,8 +266,9 @@ describe('bluetoothhostTest2', function() {
}
}
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
await
sleep
(
12000
);
console
.
info
(
"
[bluetooth_js] onStartpair008 ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] onStartpair008 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assert
Fals
e
();
expect
(
result
).
assert
Tru
e
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
done
()
})
})
...
@@ -304,3 +307,4 @@ describe('bluetoothhostTest2', function() {
...
@@ -304,3 +307,4 @@ describe('bluetoothhostTest2', function() {
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
浏览文件 @
9e58b0af
...
@@ -96,6 +96,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -96,6 +96,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0100
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
LETTERS_TEST
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
LETTERS_TEST
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0100 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0100 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
LETTERS_TEST
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
LETTERS_TEST
==
getNewName
);
...
@@ -114,6 +115,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -114,6 +115,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0200
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
CHINESES_TEST
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
CHINESES_TEST
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
CHINESES_TEST
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
CHINESES_TEST
==
getNewName
);
...
@@ -132,6 +134,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -132,6 +134,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0300
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0300 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0300 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
NUM_TEST
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
NUM_TEST
==
getNewName
);
...
@@ -150,6 +153,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -150,6 +153,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0400
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0400
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
SYMBOL_TEST
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
SYMBOL_TEST
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0400 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0400 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
SYMBOL_TEST
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
SYMBOL_TEST
==
getNewName
);
...
@@ -169,6 +173,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -169,6 +173,7 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
my bluetooth
'
;
let
newName
=
'
my bluetooth
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0500 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0500 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
...
@@ -188,6 +193,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -188,6 +193,7 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
bluetooth1234ABCDEFGH
'
;
let
newName
=
'
bluetooth1234ABCDEFGH
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0600 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0600 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
...
@@ -207,6 +213,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -207,6 +213,7 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
蓝牙设备bluetooth
'
;
let
newName
=
'
蓝牙设备bluetooth
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0700 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0700 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
...
@@ -225,6 +232,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -225,6 +232,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0800
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0800
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES4
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES4
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0800 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0800 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES4
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES4
==
getNewName
);
...
@@ -243,6 +251,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -243,6 +251,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0900
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_0900
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES2
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES2
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0900 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_0900 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES2
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES2
==
getNewName
);
...
@@ -261,6 +270,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -261,6 +270,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1000
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1000
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES3
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES3
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1000 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1000 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES3
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES3
==
getNewName
);
...
@@ -280,6 +290,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -280,6 +290,7 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
蓝牙设备123
'
;
let
newName
=
'
蓝牙设备123
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1100 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1100 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
...
@@ -299,6 +310,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -299,6 +310,7 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
蓝牙设备bluetooth12
'
;
let
newName
=
'
蓝牙设备bluetooth12
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName1200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName1200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
...
@@ -317,6 +329,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -317,6 +329,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1300
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES6
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES6
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1300 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1300 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES6
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES6
==
getNewName
);
...
@@ -335,6 +348,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -335,6 +348,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1400
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1400
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1400 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1400 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES
==
getNewName
);
...
@@ -354,6 +368,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -354,6 +368,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1500
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1500
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES5
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES5
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1500 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1500 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
MIXES5
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
MIXES5
==
getNewName
);
...
@@ -372,6 +387,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -372,6 +387,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1600
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1600
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST1
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST1
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1600 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1600 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
NUM_TEST1
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
NUM_TEST1
==
getNewName
);
...
@@ -390,6 +406,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -390,6 +406,7 @@ describe('bluetoothhostTest1', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1700
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_LocalName_1700
'
,
0
,
async
function
(
done
)
{
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES7
);
let
result
=
bluetooth
.
setLocalName
(
Btname
.
MIXES7
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1700 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1700 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
false
).
assertEqual
(
Btname
.
MIXES7
==
getNewName
);
expect
(
false
).
assertEqual
(
Btname
.
MIXES7
==
getNewName
);
...
@@ -409,6 +426,7 @@ describe('bluetoothhostTest1', function() {
...
@@ -409,6 +426,7 @@ describe('bluetoothhostTest1', function() {
let
name
=
bluetooth
.
getLocalName
();
let
name
=
bluetooth
.
getLocalName
();
let
set
=
bluetooth
.
setLocalName
(
''
);
let
set
=
bluetooth
.
setLocalName
(
''
);
expect
(
set
).
assertFalse
();
expect
(
set
).
assertFalse
();
await
sleep
(
1000
);
let
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
localName
==
name
);
expect
(
true
).
assertTrue
(
localName
==
name
);
console
.
info
(
'
[bluetooth_js] getLocalName1800=
'
+
JSON
.
stringify
(
localName
));
console
.
info
(
'
[bluetooth_js] getLocalName1800=
'
+
JSON
.
stringify
(
localName
));
...
@@ -431,11 +449,13 @@ describe('bluetoothhostTest1', function() {
...
@@ -431,11 +449,13 @@ describe('bluetoothhostTest1', function() {
let
newName
=
'
bluetoothtest
'
;
let
newName
=
'
bluetoothtest
'
;
let
result
=
bluetooth
.
setLocalName
(
newName
);
let
result
=
bluetooth
.
setLocalName
(
newName
);
expect
(
result
).
assertTrue
();
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_1900 NewName =
'
+
JSON
.
stringify
(
getNewName
));
console
.
info
(
'
[bluetooth_js] LocalName_1900 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
expect
(
true
).
assertEqual
(
newName
==
getNewName
);
let
result1
=
bluetooth
.
setLocalName
(
localName
);
let
result1
=
bluetooth
.
setLocalName
(
localName
);
expect
(
result1
).
assertTrue
();
expect
(
result1
).
assertTrue
();
await
sleep
(
1000
);
let
getLocalName
=
bluetooth
.
getLocalName
();
let
getLocalName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalNam1900 localName =
'
+
JSON
.
stringify
(
getLocalName
));
console
.
info
(
'
[bluetooth_js] LocalNam1900 localName =
'
+
JSON
.
stringify
(
getLocalName
));
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
expect
(
true
).
assertEqual
(
localName
==
getLocalName
);
...
@@ -446,3 +466,4 @@ describe('bluetoothhostTest1', function() {
...
@@ -446,3 +466,4 @@ describe('bluetoothhostTest1', function() {
}
}
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
浏览文件 @
9e58b0af
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
bundle
from
'
@ohos.bundle
'
...
@@ -97,7 +98,7 @@ describe('geolocationTest_4', function () {
...
@@ -97,7 +98,7 @@ describe('geolocationTest_4', function () {
* @tc.level since 9
* @tc.level since 9
*/
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0100
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
getCountryCode
().
then
((
result
)
=>
{
await
geolocation
m
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] country :
"
+
result
.
country
);
console
.
info
(
"
[lbs_js] country :
"
+
result
.
country
);
console
.
info
(
"
[lbs_js] type:
"
+
result
.
type
);
console
.
info
(
"
[lbs_js] type:
"
+
result
.
type
);
...
@@ -122,7 +123,7 @@ describe('geolocationTest_4', function () {
...
@@ -122,7 +123,7 @@ describe('geolocationTest_4', function () {
it
(
'
SUB_HSS_LocationSystem_CountryCode_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0200
'
,
0
,
async
function
(
done
)
{
function
getCountryCodeCallback
()
{
function
getCountryCodeCallback
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocation
.
getCountryCode
((
err
,
data
)
=>
{
geolocation
m
.
getCountryCode
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
console
.
info
(
"
getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
return
console
.
info
(
"
getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -146,17 +147,17 @@ describe('geolocationTest_4', function () {
...
@@ -146,17 +147,17 @@ describe('geolocationTest_4', function () {
*/
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0300
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]countryCodeChange
"
);
console
.
info
(
"
[lbs_js]countryCodeChange
"
);
geolocation
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
geolocation
m
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
});
});
await
geolocation
.
getCountryCode
().
then
((
result
)
=>
{
await
geolocation
m
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
expect
().
assertFail
();
});
});
geolocation
.
off
(
'
countryCodeChange
'
,
function
(
data
)
{
geolocation
m
.
off
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
));
done
();
done
();
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录