Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d4a9e27f
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看板
提交
d4a9e27f
编写于
2月 23, 2022
作者:
Q
q00313334
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
q00313334
<
quanli1@huawei.com
>
上级
92ffde9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
53 deletion
+94
-53
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
...uetooth_ble/src/main/js/default/test/BluetoothBle.test.js
+70
-33
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
...bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
+22
-17
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
...tooth_standard/src/main/js/default/test/Bluetooth.test.js
+2
-3
未找到文件。
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
浏览文件 @
d4a9e27f
...
@@ -100,10 +100,10 @@ describe('bluetoothhostTest', function() {
...
@@ -100,10 +100,10 @@ describe('bluetoothhostTest', function() {
default
:
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
await
sleep
(
2
000
);
await
sleep
(
3
000
);
var
state
=
bluetooth
.
getState
();
var
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
bluetooth enable done
'
);
expect
(
state
).
assertEqual
(
2
);
done
();
done
();
})
})
...
@@ -148,20 +148,60 @@ describe('bluetoothhostTest', function() {
...
@@ -148,20 +148,60 @@ describe('bluetoothhostTest', function() {
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_ST
OP_BLESCAN
_0001
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_ST
ART_ADVERTISING
_0001
* @tc.name test
ClassicStopBLEScan
* @tc.name test
StartAdvertising
* @tc.desc Test
ClassicStopBLEScan
api.
* @tc.desc Test
StartAdvertising
api.
* @tc.author quanli 00313334
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
bluetooth_ble_stop_scan
'
,
0
,
function
()
{
it
(
'
bluetooth_ble_start_advertising
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE stop scan start
'
);
console
.
info
(
'
BLE advertising start
'
);
var
result
=
bluetooth
.
BLE
.
stopBLEScan
();
var
manufactureValueBuffer
=
new
Uint8Array
(
4
);
console
.
info
(
"
[bluetooth_js] onStopBLEScan ->
"
+
JSON
.
stringify
(
result
));
manufactureValueBuffer
[
0
]
=
1
;
expect
(
result
).
assertNull
();
manufactureValueBuffer
[
1
]
=
2
;
console
.
info
(
'
[bluetooth_js] BLE stop scan end
'
);
manufactureValueBuffer
[
2
]
=
3
;
manufactureValueBuffer
[
3
]
=
4
;
var
serviceValueBuffer
=
new
Uint8Array
(
4
);
serviceValueBuffer
[
0
]
=
4
;
serviceValueBuffer
[
1
]
=
6
;
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
console
.
info
(
'
manufactureValueBuffer =
'
+
JSON
.
stringify
(
manufactureValueBuffer
))
console
.
info
(
'
serviceValueBuffer =
'
+
JSON
.
stringify
(
serviceValueBuffer
))
let
promise
=
new
Promise
((
resolve
)
=>
{
var
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
gattServer
.
startAdvertising
({
interval
:
150
,
txPower
:
60
,
connectable
:
true
,
},{
serviceUuids
:[
"
12
"
],
manufactureData
:[{
manufactureId
:
4567
,
manufactureValue
:
manufactureValueBuffer
.
buffer
}],
serviceData
:[{
serviceUuid
:
"
1234
"
,
serviceValue
:
serviceValueBuffer
.
buffer
}],
},{
serviceUuids
:[
"
12
"
],
manufactureData
:[{
manufactureId
:
1789
,
manufactureValue
:
manufactureValueBuffer
.
buffer
}],
serviceData
:[{
serviceUuid
:
"
1794
"
,
serviceValue
:
serviceValueBuffer
.
buffer
}],
});
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
})
/**
/**
...
@@ -180,6 +220,25 @@ describe('bluetoothhostTest', function() {
...
@@ -180,6 +220,25 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE stop advertising end
'
);
console
.
info
(
'
[bluetooth_js] BLE stop advertising end
'
);
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_gatt_connect
'
,
0
,
function
()
{
console
.
info
(
'
[bluetooth_js] gatt connect start
'
);
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gatt connect ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
console
.
info
(
'
[bluetooth_js] gatt connect end
'
);
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEVICE_NAME_PROMISE_0001
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEVICE_NAME_PROMISE_0001
* @tc.name testGetDeviceName
* @tc.name testGetDeviceName
...
@@ -251,24 +310,6 @@ describe('bluetoothhostTest', function() {
...
@@ -251,24 +310,6 @@ describe('bluetoothhostTest', function() {
});
});
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.author quanli 00313334
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
bluetooth_gatt_connect
'
,
0
,
function
()
{
console
.
info
(
'
[bluetooth_js] gatt connect start
'
);
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
let
ret
=
gattClient
.
connect
();
console
.
info
(
'
[bluetooth_js] gatt connect ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
true
);
console
.
info
(
'
[bluetooth_js] gatt connect end
'
);
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_CALLBACK_0001
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_GETSERVICES_CALLBACK_0001
...
@@ -667,7 +708,6 @@ describe('bluetoothhostTest', function() {
...
@@ -667,7 +708,6 @@ describe('bluetoothhostTest', function() {
}
}
})
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
* @tc.name testDisConnect
...
@@ -685,7 +725,6 @@ describe('bluetoothhostTest', function() {
...
@@ -685,7 +725,6 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] gatt disconnect end
'
);
console
.
info
(
'
[bluetooth_js] gatt disconnect end
'
);
})
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CLIENT_CLOSE_0001
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose
* @tc.name testGattClientClose
...
@@ -713,6 +752,4 @@ describe('bluetoothhostTest', function() {
...
@@ -713,6 +752,4 @@ describe('bluetoothhostTest', function() {
}
}
})
})
})
})
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
浏览文件 @
d4a9e27f
...
@@ -86,9 +86,10 @@ describe('bluetoothhostTest', function() {
...
@@ -86,9 +86,10 @@ describe('bluetoothhostTest', function() {
default
:
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
await
sleep
(
2
000
);
await
sleep
(
3
000
);
var
state
=
bluetooth
.
getState
();
var
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
2
);
await
bluetooth
.
off
(
'
stateChange
'
,
result
=>
{
await
bluetooth
.
off
(
'
stateChange
'
,
result
=>
{
console
.
info
(
"
stateChange off:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
stateChange off:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
expect
(
true
).
assertEqual
(
result
==
null
);
...
@@ -138,24 +139,30 @@ describe('bluetoothhostTest', function() {
...
@@ -138,24 +139,30 @@ describe('bluetoothhostTest', function() {
* @tc.type Function
* @tc.type Function
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
bluetooth_ble_start_scan_without_param
'
,
0
,
async
function
(
done
)
{
it
(
'
bluetooth_ble_start_scan_without_param
_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan start without scan options start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan start without scan options start
'
);
var
state
=
bluetooth
.
getState
();
var
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState On1 =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
[bluetooth_js] getState On1 =
'
+
JSON
.
stringify
(
state
));
await
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
let
promise
=
new
Promise
((
resolve
)
=>
{
function
onReceiveEvent
(
data
)
{
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
console
.
info
(
'
[bluetooth_js] BLE scan device find result3 =
'
+
JSON
.
stringify
(
data
))
function
onReceiveEvent
(
data
)
{
expect
(
data
.
length
).
assertLarger
(
0
);
console
.
info
(
'
[bluetooth_js] BLE scan device find result3 =
'
+
JSON
.
stringify
(
data
));
done
();
expect
(
data
.
length
).
assertLarger
(
0
);
}
done
();
bluetooth
.
BLE
.
startBLEScan
([{}]);
}
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
bluetooth
.
BLE
.
startBLEScan
([{}]);
console
.
info
(
"
[bluetooth_js] BLE scan device find off2:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
expect
(
true
).
assertEqual
(
result
==
null
);
console
.
info
(
"
[bluetooth_js] BLE scan device find off2:
"
+
JSON
.
stringify
(
result
));
done
();
expect
(
true
).
assertEqual
(
result
==
null
);
});
done
();
console
.
info
(
'
[bluetooth_js] BLE scan start end
'
);
});
var
result
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[bluetooth_js] BLE scan start end
'
);
resolve
()
})
await
promise
.
then
(
done
)
done
();
done
();
})
})
...
@@ -435,7 +442,6 @@ describe('bluetoothhostTest', function() {
...
@@ -435,7 +442,6 @@ describe('bluetoothhostTest', function() {
console
.
info
(
"
[bluetooth_js] desWriOn jsondata:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] desWriOn jsondata:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] desWriOn data:
"
+
data
);
console
.
info
(
"
[bluetooth_js] desWriOn data:
"
+
data
);
expect
(
true
).
assertEqual
(
data
!=
null
);
expect
(
true
).
assertEqual
(
data
!=
null
);
console
.
info
(
'
[bluetooth_js] desWrite callback data ->
'
);
console
.
info
(
'
[bluetooth_js] desWrite callback data ->
'
);
console
.
info
(
'
[bluetooth_js] desWriOn deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] desWriOn deviceId:
'
+
data
.
deviceId
);
console
.
info
(
'
[bluetooth_js] desWriOn transId:
'
+
data
.
transId
);
console
.
info
(
'
[bluetooth_js] desWriOn transId:
'
+
data
.
transId
);
...
@@ -635,4 +641,3 @@ describe('bluetoothhostTest', function() {
...
@@ -635,4 +641,3 @@ describe('bluetoothhostTest', function() {
})
})
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
浏览文件 @
d4a9e27f
...
@@ -93,9 +93,10 @@ describe('bluetoothhostTest', function() {
...
@@ -93,9 +93,10 @@ describe('bluetoothhostTest', function() {
default
:
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
await
sleep
(
2
000
);
await
sleep
(
3
000
);
var
state
=
bluetooth
.
getState
();
var
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
[bluetooth_js] getState On =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
2
);
console
.
info
(
'
[bluetooth_js]state on:
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
));
console
.
info
(
'
[bluetooth_js]state on:
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
));
console
.
info
(
'
[bluetooth_js]off :
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_OFF
));
console
.
info
(
'
[bluetooth_js]off :
'
+
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_OFF
));
console
.
info
(
'
[bluetooth_js] turning on :
'
console
.
info
(
'
[bluetooth_js] turning on :
'
...
@@ -869,7 +870,6 @@ describe('bluetoothhostTest', function() {
...
@@ -869,7 +870,6 @@ describe('bluetoothhostTest', function() {
* @tc.type Function
* @tc.type Function
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
bluetooth_classic_disable_bluetooth
'
,
0
,
function
()
{
it
(
'
bluetooth_classic_disable_bluetooth
'
,
0
,
function
()
{
console
.
info
(
'
[bluetooth_js] disable test start
'
);
console
.
info
(
'
[bluetooth_js] disable test start
'
);
let
disable
=
bluetooth
.
disableBluetooth
();
let
disable
=
bluetooth
.
disableBluetooth
();
...
@@ -881,4 +881,3 @@ describe('bluetoothhostTest', function() {
...
@@ -881,4 +881,3 @@ describe('bluetoothhostTest', function() {
})
})
})
})
鸿蒙社区
@harmonycommunity
mentioned in commit
2f9fa783
·
3月 15, 2022
mentioned in commit
2f9fa783
mentioned in commit 2f9fa7835fa9abbda328c0019b4239e43de65af2
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录