Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
45164681
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看板
提交
45164681
编写于
5月 24, 2022
作者:
B
bayanxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
整理和补充Bluetooth模块测试用例
Signed-off-by:
N
bayanxing
<
bayanxing@kaihongdigi.com
>
上级
3aa77e49
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
115 addition
and
6 deletion
+115
-6
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
...uetooth_ble/src/main/js/default/test/BluetoothBle.test.js
+115
-6
未找到文件。
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
浏览文件 @
45164681
...
@@ -316,6 +316,30 @@ describe('bluetoothhostTest', function() {
...
@@ -316,6 +316,30 @@ describe('bluetoothhostTest', function() {
done
();
done
();
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE get device name callback start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
00:00:00:00:00:00
"
);
gattClient
.
getDeviceName
((
err
,
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name
'
+
JSON
.
stringify
(
data
))
expect
(
data
).
assertNull
();
done
();
})
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.name testGetServices
* @tc.name testGetServices
...
@@ -381,7 +405,7 @@ describe('bluetoothhostTest', function() {
...
@@ -381,7 +405,7 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readCharacteristicValue start
'
);
console
.
info
(
'
[bluetooth_js] readCharacteristicValue
promise
start
'
);
await
tryToEnableBt
();
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
promise
=
new
Promise
((
resolve
)
=>
{
let
descriptors
=
[];
let
descriptors
=
[];
...
@@ -402,12 +426,12 @@ describe('bluetoothhostTest', function() {
...
@@ -402,12 +426,12 @@ describe('bluetoothhostTest', function() {
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
}
else
{
console
.
info
(
'
[bluetooth_js] readCharacValue data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] readCharacValue
promise
data:
'
+
JSON
.
stringify
(
data
));
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
done
();
done
();
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readCharacteristicValue has error:
${
err
}
`
);
console
.
error
(
`bluetooth readCharacteristicValue
promise
has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
done
();
done
();
});
});
...
@@ -417,6 +441,53 @@ describe('bluetoothhostTest', function() {
...
@@ -417,6 +441,53 @@ describe('bluetoothhostTest', function() {
done
();
done
();
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0002
* @tc.name testReadCharacteristicValue
* @tc.desc Test ReadCharacteristicValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readCharacteristicValue callback start
'
);
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
descriptors
=
[];
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
};
descriptors
[
0
]
=
descriptor
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
let
cccValue
=
new
Uint8Array
(
arrayBufferCCC
);
cccValue
[
0
]
=
32
;
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
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`bluetooth readCharacteristicValue callback has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
done
();
return
;
}
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js] readCharacValue callback data:
'
+
JSON
.
stringify
(
data
));
expect
(
null
).
assertFail
();
}
done
();
})
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
* @tc.name testReadDescriptorValue
* @tc.name testReadDescriptorValue
...
@@ -426,7 +497,7 @@ describe('bluetoothhostTest', function() {
...
@@ -426,7 +497,7 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readDescriptorValue start
'
);
console
.
info
(
'
[bluetooth_js] readDescriptorValue
promise
start
'
);
await
tryToEnableBt
();
await
tryToEnableBt
();
let
promise
=
new
Promise
((
resolve
)
=>
{
let
promise
=
new
Promise
((
resolve
)
=>
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
...
@@ -439,12 +510,12 @@ describe('bluetoothhostTest', function() {
...
@@ -439,12 +510,12 @@ describe('bluetoothhostTest', function() {
if
(
object
!=
null
)
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
}
else
{
console
.
info
(
'
[bluetooth_js] BLEDescriptor data:
'
+
JSON
.
stringify
(
object
));
console
.
info
(
'
[bluetooth_js] BLEDescriptor
promise
data:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
done
();
done
();
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readDescriptorValue has error:
${
err
}
`
);
console
.
error
(
`bluetooth readDescriptorValue
promise
has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
expect
(
true
).
assertEqual
(
true
);
done
();
done
();
});
});
...
@@ -454,6 +525,44 @@ describe('bluetoothhostTest', function() {
...
@@ -454,6 +525,44 @@ describe('bluetoothhostTest', function() {
done
();
done
();
})
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0002
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] readDescriptorValue callback 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
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`bluetooth readDescriptorValue callback has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
done
();
return
;
}
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js] BLEDescriptor callback data:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
}
done
();
})
resolve
()
})
await
promise
.
then
(
done
)
done
();
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录