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
此差异已折叠。
点击以展开。
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
此差异已折叠。
点击以展开。
鸿蒙社区
@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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录