Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5ea9ccfc
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看板
提交
5ea9ccfc
编写于
2月 26, 2022
作者:
Q
q00313334
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
3516quanli1@huawei.com
Signed-off-by:
N
q00313334
<
quanli1@huawei.com
>
上级
a8edc778
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
220 addition
and
274 deletion
+220
-274
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
...uetooth_ble/src/main/js/default/test/BluetoothBle.test.js
+153
-138
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
...bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
+15
-31
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
...tooth_standard/src/main/js/default/test/Bluetooth.test.js
+52
-105
未找到文件。
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
浏览文件 @
5ea9ccfc
...
...
@@ -17,16 +17,16 @@ import bluetooth from '@ohos.bluetooth';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
SppType
=
{
let
SppType
=
{
SPP_RFCOMM
:
0
}
var
MatchMode
=
{
let
MatchMode
=
{
MATCH_MODE_AGGRESSIVE
:
1
,
MATCH_MODE_STICKY
:
2
}
var
MajorClass
=
{
let
MajorClass
=
{
MAJOR_MISC
:
0x0000
,
MAJOR_COMPUTER
:
0x0100
,
MAJOR_PHONE
:
0x0200
,
...
...
@@ -40,10 +40,11 @@ var MajorClass = {
MAJOR_UNCATEGORIZED
:
0x1F00
}
describe
(
'
bluetoothhostTest
'
,
function
()
{
var
gattServer
=
null
;
var
gattClient
=
null
;
let
gattServer
=
null
;
let
gattClient
=
null
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
@@ -65,15 +66,13 @@ describe('bluetoothhostTest', function() {
}
async
function
tryToEnableBt
()
{
var
sta
=
bluetooth
.
getState
();
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
var
enable
=
bluetooth
.
enableBluetooth
();
expect
(
enable
).
assertTrue
();
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
case
1
:
expect
(
JSON
.
stringify
(
sta
)).
assertTrue
(
1
);
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
...
...
@@ -81,8 +80,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] state is On:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
var
enable
=
bluetooth
.
enableBluetooth
();
console
.
info
(
'
[bluetooth_js] enable0 =
'
+
JSON
.
stringify
(
enable
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
default
:
...
...
@@ -94,7 +92,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -102,7 +99,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_ENABLE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] enable start
'
);
await
tryToEnableBt
();
var
state
=
bluetooth
.
getState
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
2
);
done
();
...
...
@@ -113,7 +110,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001
* @tc.name testGetConnectedBLEDevices
* @tc.desc Test getConnectedBLEDevices api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -121,7 +117,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] getConnectedBLEDevices test start ...
'
);
await
tryToEnableBt
();
var
result
=
bluetooth
.
BLE
.
getConnectedBLEDevices
();
let
result
=
bluetooth
.
BLE
.
getConnectedBLEDevices
();
console
.
info
(
"
[bluetooth_js] getConnDev:
"
+
JSON
.
stringify
(
result
)
+
"
length:
"
+
result
.
length
);
expect
(
result
.
length
).
assertEqual
(
0
);
done
();
...
...
@@ -132,7 +128,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001
* @tc.name testCreateGattServer
* @tc.desc Test CreateGattServer api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -140,8 +135,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetoothble_CREATE_GATT_SERVER_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] createGattServer test start ...
'
);
await
tryToEnableBt
();
var
result
=
bluetooth
.
BLE
.
createGattServer
();
var
resultLength
=
Object
.
keys
(
result
).
length
;
let
result
=
bluetooth
.
BLE
.
createGattServer
();
let
resultLength
=
Object
.
keys
(
result
).
length
;
console
.
info
(
"
[bluetooth_js] createGattServer:
"
+
JSON
.
stringify
(
result
)
+
"
length:
"
+
resultLength
);
expect
(
resultLength
).
assertEqual
(
1
);
done
();
...
...
@@ -152,7 +147,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -160,19 +154,19 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE advertising start
'
);
await
tryToEnableBt
();
var
manufactureValueBuffer
=
new
Uint8Array
(
4
);
let
manufactureValueBuffer
=
new
Uint8Array
(
4
);
manufactureValueBuffer
[
0
]
=
1
;
manufactureValueBuffer
[
1
]
=
2
;
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
var
serviceValueBuffer
=
new
Uint8Array
(
4
);
let
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
promise
=
new
Promise
((
resolve
)
=>
{
var
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
var
start
=
gattServer
.
startAdvertising
({
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
start
=
gattServer
.
startAdvertising
({
interval
:
150
,
txPower
:
60
,
connectable
:
true
,
...
...
@@ -209,7 +203,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001
* @tc.name testStopAdvertising
* @tc.desc Test StopAdvertising api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -217,8 +210,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE stop advertising start
'
);
await
tryToEnableBt
();
var
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
var
stop
=
gattServer
.
stopAdvertising
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
stop
=
gattServer
.
stopAdvertising
();
expect
(
stop
).
assertNull
();
done
();
})
...
...
@@ -227,7 +220,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -246,7 +238,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_CALLBACK
* @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -255,7 +246,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE get rssi1 start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
var
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getRssiValue
((
err
,
data
)
=>
{
console
.
info
(
'
[bluetooth_js] rssi err:
'
+
JSON
.
stringify
(
err
)
+
'
value:
'
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertNull
();
...
...
@@ -271,7 +262,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_PROMISE_0001
* @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -280,13 +270,13 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE get rssi start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
var
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getRssiValue
().
then
((
data
)
=>
{
if
(
data
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js] BLE read rssi
'
+
JSON
.
stringify
(
data
));
var
rssiLength
=
Object
.
keys
(
data
).
length
;
let
rssiLength
=
Object
.
keys
(
data
).
length
;
expect
(
rssiLength
).
assertEqual
(
0
);
}
}).
catch
(
err
=>
{
...
...
@@ -304,7 +294,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_PROMISE_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -313,7 +302,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE get device name promise start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
var
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name
'
+
JSON
.
stringify
(
data
))
expect
(
data
).
assertNull
();
...
...
@@ -329,7 +318,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.name testGetServices
* @tc.desc Test GetServices api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -337,19 +325,23 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] getServices callback start
'
);
await
tryToEnableBt
();
var
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
promise
=
new
Promise
((
resolve
)
=>
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getServices
((
err
,
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name err1
'
+
JSON
.
stringify
(
err
)
+
'
name1
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
err
.
code
==
-
1
);
done
();
})
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001
* @tc.name testGetServices
* @tc.desc Test GetServices api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -357,8 +349,9 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] getServices promise start
'
);
await
tryToEnableBt
();
var
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
await
gattClient
.
getServices
().
then
((
object
)
=>
{
let
promise
=
new
Promise
((
resolve
)
=>
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getServices
().
then
((
object
)
=>
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
...
...
@@ -371,13 +364,16 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
true
);
done
();
});
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001
* @tc.name testReadCharacteristicValue
* @tc.desc Test ReadCharacteristicValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -385,6 +381,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readCharacteristicValue start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
...
@@ -398,6 +395,7 @@ describe('bluetoothhostTest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -411,13 +409,16 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
true
);
done
();
});
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -425,11 +426,13 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readDescriptorValue start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -443,13 +446,17 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
true
);
done
();
});
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
* @tc.name testWriteCharacteristicValue
* @tc.desc Test WriteCharacteristicValue api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -457,6 +464,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] writeCharacteristicValue start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
...
@@ -470,17 +478,21 @@ describe('bluetoothhostTest', function() {
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
writeCharacteristicValue
(
characteristic
);
console
.
info
(
'
[bluetooth_js] writeCharacteristicValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001
* @tc.name testWriteDescriptorValue
* @tc.desc Test WriteDescriptorValue api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -488,22 +500,27 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_WRITE_DESC_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] writeDescriptorValue start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
writeDescriptorValue
(
descriptor
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -511,6 +528,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] setBLEMtuSize start
'
);
await
tryToEnableBt
();
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
setBLEMtuSize
(
128
);
console
.
info
(
'
[bluetooth_js] bluetooth setBLEMtuSize ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -521,7 +539,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -529,6 +546,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_SET_NOTIFY_CHARA_CHANGED_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] setNotifyCharacteristicChanged start
'
);
await
tryToEnableBt
();
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
...
@@ -560,7 +578,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -568,7 +585,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_ADD_SERVICE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] addService start
'
);
await
tryToEnableBt
();
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
...
...
@@ -598,7 +615,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001
* @tc.name testRemoveService
* @tc.desc Test RemoveService api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -606,7 +622,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_REMOVE_SERVICE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] removeService start
'
);
await
tryToEnableBt
();
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
ret
=
gattServer
.
removeService
(
'
00001810-0000-1000-8000-008000000000
'
);
console
.
info
(
'
[bluetooth_js] removeService ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -617,7 +633,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001
* @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -625,6 +640,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_NOTIFY_CHARA_CHANGED_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] notifyCharacteristicChanged start
'
);
await
tryToEnableBt
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
descriptors
=
[];
let
arrayBufferDesc
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBufferDesc
);
...
...
@@ -657,7 +673,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001
* @tc.name testSendResponse
* @tc.desc Test SendResponse api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -665,6 +680,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_SEND_RESPONSE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] sendResponse start
'
);
await
tryToEnableBt
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
value
=
new
Uint8Array
(
arrayBuffer
);
value
[
0
]
=
1
;
...
...
@@ -682,7 +698,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_GATTSERVER_CLOSE_0001
* @tc.name testBlePeripheralManagerClose
* @tc.desc Test BlePeripheralManagerClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -691,7 +706,8 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] GattserverClose test start ...
'
);
await
tryToEnableBt
();
try
{
var
result
=
gattServer
.
close
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
result
=
gattServer
.
close
();
console
.
info
(
"
[bluetooth_js] GattserverClose res:
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
}
catch
(
error
){
...
...
@@ -705,7 +721,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
* @tc.desc Test DisConnect api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -713,6 +728,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] gatt disconnect start
'
);
await
tryToEnableBt
();
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
disconnect
();
console
.
info
(
'
[bluetooth_js] gatt disconnect ret:
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
...
...
@@ -723,7 +739,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose
* @tc.desc Test GattClientClose api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -732,7 +747,8 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] GattclientClose test start ...
'
);
await
tryToEnableBt
();
try
{
var
result
=
gattClient
.
close
();
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
result
=
gattClient
.
close
();
console
.
info
(
"
[bluetooth_js] GattclientClose result:
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
}
catch
(
error
){
...
...
@@ -743,4 +759,3 @@ describe('bluetoothhostTest', function() {
})
})
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
浏览文件 @
5ea9ccfc
...
...
@@ -16,7 +16,7 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
MajorMinorClass
=
{
let
MajorMinorClass
=
{
COMPUTER_UNCATEGORIZED
:
0x0100
,
COMPUTER_DESKTOP
:
0x0104
,
COMPUTER_SERVER
:
0x0108
,
...
...
@@ -106,10 +106,11 @@ var MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
};
describe
(
'
bluetoothhostTest
'
,
function
()
{
var
gattServer
=
null
;
var
gattClient
=
null
;
let
gattServer
=
null
;
let
gattClient
=
null
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
@@ -131,11 +132,10 @@ describe('bluetoothhostTest', function() {
}
async
function
tryToEnableBt
()
{
var
sta
=
bluetooth
.
getState
();
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
var
enable
=
bluetooth
.
enableBluetooth
();
console
.
info
(
'
[bluetooth_js] enable0 =
'
+
JSON
.
stringify
(
enable
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
case
1
:
...
...
@@ -146,8 +146,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] state is On:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
var
enable
=
bluetooth
.
enableBluetooth
();
console
.
info
(
'
[bluetooth_js] enable0 =
'
+
JSON
.
stringify
(
enable
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
default
:
...
...
@@ -159,7 +158,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -174,7 +172,7 @@ describe('bluetoothhostTest', function() {
}
}
await
tryToEnableBt
();
var
state
=
bluetooth
.
getState
();
let
state
=
bluetooth
.
getState
();
expect
(
state
).
assertEqual
(
2
);
await
bluetooth
.
off
(
'
stateChange
'
,
result
=>
{
expect
(
true
).
assertEqual
(
result
==
null
);
...
...
@@ -187,7 +185,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -215,7 +212,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -236,7 +232,7 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
result
==
null
);
done
();
});
var
result
=
bluetooth
.
BLE
.
stopBLEScan
();
let
result
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[bluetooth_js] BLE scan start end
'
);
resolve
()
...
...
@@ -250,7 +246,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -264,7 +259,7 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
var
enable
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
let
enable3
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
result
=>
{
console
.
info
(
"
[bluetooth_js] pinRequired off:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
...
...
@@ -276,7 +271,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -290,7 +284,7 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
});
var
enable
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
let
enable4
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
expect
(
bluetooth
.
BondState
.
BOND_STATE_INVALID
==
0
).
assertTrue
();
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDING
==
1
).
assertTrue
();
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDED
==
2
).
assertTrue
();
...
...
@@ -305,7 +299,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen
* @tc.desc Test SppListen api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -332,7 +325,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001
* @tc.name testonCharacteristicReadOn
* @tc.desc Test CharacteristicReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -345,14 +337,14 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] CharRedReq deviceId:
'
+
data
.
deviceId
+
'
transId:
'
+
data
.
transId
+
'
offset:
'
+
data
.
offset
+
'
charUuid:
'
+
data
.
characteristicUuid
+
'
serviceUuid:
'
+
data
.
serviceUuid
);
var
serverResponse
=
{
let
serverResponse
=
{
"
deviceId
"
:
data
.
deviceId
,
"
transId
"
:
data
.
transId
,
"
status
"
:
0
,
"
offset
"
:
data
.
offset
,
"
value
"
:
str2ab
(
"
characteristic read response
"
,
data
.
offset
),
};
var
result
=
gattServer
.
sendResponse
(
serverResponse
);
let
result
=
gattServer
.
sendResponse
(
serverResponse
);
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
"
true
"
);
});
}
catch
(
e
)
{
...
...
@@ -375,7 +367,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn
* @tc.desc Test CharacteristicwriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -397,14 +388,14 @@ describe('bluetoothhostTest', function() {
return
;
}
console
.
log
(
`data.value is ArraryBuffer:
${
ab2hex
(
data
.
value
)}
`
)
var
serverResponse
=
{
let
serverResponse
=
{
"
deviceId
"
:
data
.
deviceId
,
"
transId
"
:
data
.
transId
,
"
status
"
:
0
,
"
offset
"
:
data
.
offset
,
"
value
"
:
data
.
value
,
};
var
result
=
gattServer
.
sendResponse
(
serverResponse
);
let
result
=
gattServer
.
sendResponse
(
serverResponse
);
expect
(
JSON
.
stringify
(
result
)).
assertContain
(
"
true
"
);
});
}
catch
(
e
)
{
...
...
@@ -427,7 +418,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn
* @tc.desc Test DescriptorReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -464,7 +454,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn
* @tc.desc Test DescriptorWriteOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -501,7 +490,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn
* @tc.desc Test ConnectStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -536,7 +524,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn
* @tc.desc Test BLECharacteristicChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -570,7 +557,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn
* @tc.desc Test BLEConnectionStateChangeOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -605,7 +591,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -635,4 +620,3 @@ describe('bluetoothhostTest', function() {
})
})
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
浏览文件 @
5ea9ccfc
...
...
@@ -17,7 +17,7 @@ import bluetooth from '@ohos.bluetooth';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
Btname
=
{
let
Btname
=
{
NUM_TEST
:
'
012345678901234567890123456789012345678901234567890123
'
+
'
45678901234567890123456789012345678901234567890123456789012345678901234567
'
,
NUM_TEST1
:
'
01234567890123456789012345678901234567890123456
'
...
...
@@ -59,11 +59,10 @@ describe('bluetoothhostTest', function() {
}
async
function
tryToEnableBt
()
{
var
sta
=
bluetooth
.
getState
();
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
var
enable
=
bluetooth
.
enableBluetooth
();
console
.
info
(
'
[bluetooth_js] enable0 =
'
+
JSON
.
stringify
(
enable
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
case
1
:
...
...
@@ -74,8 +73,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] state is On:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
var
enable
=
bluetooth
.
enableBluetooth
();
console
.
info
(
'
[bluetooth_js] enable0 =
'
+
JSON
.
stringify
(
enable
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
default
:
...
...
@@ -85,52 +83,33 @@ describe('bluetoothhostTest', function() {
/**
* @tc.number SUB_COMMUNACATION_bluetooth_
ENABL
E_0001
* @tc.number SUB_COMMUNACATION_bluetooth_
GET_STAT
E_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_ENABLE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] enable start
'
);
await
tryToEnableBt
();
var
state
=
bluetooth
.
getState
();
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
expect
(
bluetooth
.
BluetoothState
.
STATE_OFF
==
0
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_ON
==
1
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_OFF
==
3
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_ON
==
4
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_ON
==
5
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_OFF
==
6
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_STATE_0001
* @tc.name testGetState
* @tc.desc Test GetState api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GET_STATE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get
s
tate start
'
);
console
.
info
(
'
[bluetooth_js] get
S
tate start
'
);
await
tryToEnableBt
();
var
state
=
bluetooth
.
getState
();
console
.
info
(
'
get bluetooth state end
'
);
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] get bluetooth state result =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
expect
(
bluetooth
.
BluetoothState
.
STATE_OFF
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_OFF
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_OFF
!=
state
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001
* @tc.name testClassicSetLocalName
* @tc.desc Test ClassicSetLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -138,7 +117,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] set localname start
'
);
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
'
bluetooth_test
'
);
let
name
=
bluetooth
.
setLocalName
(
'
bluetooth_test
'
);
console
.
info
(
'
[bluetooth_js] appInfoTest enable bluetooth result =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertEqual
(
true
);
done
();
...
...
@@ -148,7 +127,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_PAIR_0001
* @tc.name testStartpair
* @tc.desc Test Startpair api by promise.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -156,7 +134,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_START_PAIR_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] Startpair test start ...
'
);
await
tryToEnableBt
();
var
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
console
.
info
(
"
[bluetooth_js] onStartpair ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertFalse
();
done
();
...
...
@@ -166,7 +144,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001
* @tc.name testClassicGetLocalName
* @tc.desc Test ClassicGetLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -174,7 +151,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get localName start
'
);
await
tryToEnableBt
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] get local Name result =
'
+
JSON
.
stringify
(
localName
));
expect
(
localName
).
assertEqual
(
'
bluetooth_test
'
);
done
();
...
...
@@ -184,7 +161,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicSetBluetoothScanMode
* @tc.desc Test ClassicSetBluetoothScanMode api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -192,7 +168,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] set scan mode start
'
);
await
tryToEnableBt
();
var
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
...
...
@@ -204,7 +180,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicGetBluetoothScanMode
* @tc.desc Test ClassicGetBluetoothScanMode api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -212,9 +187,9 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get scan mode start
'
);
await
tryToEnableBt
();
var
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
result
).
assertEqual
(
true
);
var
scanMode
=
bluetooth
.
getBluetoothScanMode
();
let
scanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] get scan mode result2 =
'
+
JSON
.
stringify
(
scanMode
));
expect
(
scanMode
).
assertEqual
(
1
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_NONE
!=
scanMode
);
...
...
@@ -230,7 +205,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
* @tc.name testClassicGetBtConnectionState
* @tc.desc Test ClassicGetBtConnectionState api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -238,7 +212,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get connection state start
'
);
await
tryToEnableBt
();
var
connState
=
bluetooth
.
getBtConnectionState
();
let
connState
=
bluetooth
.
getBtConnectionState
();
console
.
info
(
'
[bluetooth_js] get bt connection state result
'
+
JSON
.
stringify
(
connState
));
expect
(
connState
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
...
...
@@ -251,7 +225,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -269,7 +242,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStopBluetoothDiscovery
* @tc.desc Test ClassicStopBluetoothDiscovery api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -287,7 +259,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001
* @tc.name testClassicGetPairedDevices
* @tc.desc Test ClassicGetPairedDevices api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -295,7 +266,7 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get paired devices start
'
);
await
tryToEnableBt
();
var
devices
=
bluetooth
.
getPairedDevices
();
let
devices
=
bluetooth
.
getPairedDevices
();
console
.
info
(
'
[bluetooth_js] get paired devices:
'
+
JSON
.
stringify
(
devices
)
+
'
length:
'
+
devices
.
length
);
expect
(
devices
.
length
).
assertEqual
(
0
);
done
();
...
...
@@ -306,7 +277,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen
* @tc.desc Test SppListen api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -332,7 +302,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_ACCEPT_0001
* @tc.name testSppAccept
* @tc.desc Test SppAccept api by callbck.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -355,7 +324,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CLOSE_SERVER_SOCKET_0001
* @tc.name testSppCloseServerSocket
* @tc.desc Test SppCloseServerSocket api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -373,7 +341,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CONNECT_0001
* @tc.name testSppConnect
* @tc.desc Test SppConnect api by callback.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -398,7 +365,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_WRITE_0001
* @tc.name testSppWrite
* @tc.desc Test SppWrite api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -419,7 +385,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_NAME_0001
* @tc.name testGetRemoteDeviceName
* @tc.desc Test GetRemoteDeviceName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -437,7 +402,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_CLASS_0001
* @tc.name testGetRemoteDeviceClass
* @tc.desc Test GetRemoteDeviceClass api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -457,7 +421,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_CANCEL_PAIRED_DEV_0001
* @tc.name testCancelPairedDevice
* @tc.desc Test CancelPairedDevice api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -476,18 +439,17 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
state
=
bluetooth
.
getState
();
let
state
=
bluetooth
.
getState
();
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
)
==
state
);
var
name
=
bluetooth
.
setLocalName
(
''
);
let
name
=
bluetooth
.
setLocalName
(
''
);
expect
(
name
).
assertFalse
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
localName
==
name
);
console
.
info
(
'
[bluetooth_js] getLocalName result1 =
'
+
JSON
.
stringify
(
localName
));
done
();
...
...
@@ -498,15 +460,14 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
localName
=
bluetooth
.
getLocalName
();
var
name
=
bluetooth
.
setLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
let
name
=
bluetooth
.
setLocalName
();
console
.
info
(
'
[bluetooth_js] getName result2 =
'
+
JSON
.
stringify
(
localName
)
+
'
setName result2 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertNull
();
...
...
@@ -517,16 +478,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST
);
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
NUM_TEST
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -535,16 +495,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST1
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
NUM_TEST1
);
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
NUM_TEST1
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -553,16 +512,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
LETTERS_TEST
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
LETTERS_TEST
);
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
LETTERS_TEST
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -572,16 +530,15 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
CHINESES_TEST
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
CHINESES_TEST
);
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
CHINESES_TEST
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -591,17 +548,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
SYMBOL_TEST
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
SYMBOL_TEST
);
console
.
info
(
'
[bluetooth_js] setLocalName result7 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
SYMBOL_TEST
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -610,17 +566,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES
);
console
.
info
(
'
[bluetooth_js] setLocalName result8 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -629,17 +584,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES2
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES2
);
console
.
info
(
'
[bluetooth_js] setLocalName result9 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES2
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -648,17 +602,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES3
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES3
);
console
.
info
(
'
[bluetooth_js] setLocalName result10 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES3
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -667,17 +620,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES4
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES4
);
console
.
info
(
'
[bluetooth_js] setLocalName result11 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES4
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -686,17 +638,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES5
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES5
);
console
.
info
(
'
[bluetooth_js] setLocalName result12 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES5
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -705,17 +656,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES6
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES6
);
console
.
info
(
'
[bluetooth_js] setLocalName result13 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES6
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -725,17 +675,16 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
var
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES7
);
let
name
=
bluetooth
.
setLocalName
(
Btname
.
MIXES7
);
console
.
info
(
'
[bluetooth_js] setLocalName result14 =
'
+
JSON
.
stringify
(
name
));
expect
(
name
).
assertTrue
();
var
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
Btname
.
MIXES7
==
JSON
.
stringify
(
localName
));
done
();
})
...
...
@@ -746,7 +695,6 @@ describe('bluetoothhostTest', function() {
* @tc.number SUB_COMMUNACATION_bluetooth_DISABLE_0001
* @tc.name testdisablebluetooth
* @tc.desc Test disablebluetooth api.
* @tc.author zhangyujie zwx1079266
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
...
...
@@ -757,10 +705,9 @@ describe('bluetoothhostTest', function() {
let
disable
=
bluetooth
.
disableBluetooth
();
console
.
info
(
'
[bluetooth_js] disable:
'
+
JSON
.
stringify
(
disable
));
expect
(
disable
).
assertTrue
();
var
state
=
bluetooth
.
getState
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt state:
'
+
JSON
.
stringify
(
state
));
done
();
})
})
鸿蒙社区
@harmonycommunity
mentioned in commit
8ec6336c
·
3月 24, 2022
mentioned in commit
8ec6336c
mentioned in commit 8ec6336cf39650db24109c8bbbdd908801403241
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录