Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
19e90bdc
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
接近 3 年 前同步成功
通知
10
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看板
You need to sign in or sign up before continuing.
提交
19e90bdc
编写于
3月 17, 2023
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
2c753396
变更
46
展开全部
隐藏空白更改
内联
并排
Showing
46 changed file
with
1176 addition
and
689 deletion
+1176
-689
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
.../bluetooth_manager/src/main/js/test/BleScanResult.test.js
+27
-27
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+27
-27
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+1
-1
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+237
-125
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
...luetooth_standard/src/main/js/test/BRSetLocalName.test.js
+3
-2
communication/nfc_Controller/BUILD.gn
communication/nfc_Controller/BUILD.gn
+2
-2
communication/nfc_Controller/src/main/js/MainAbility/app.js
communication/nfc_Controller/src/main/js/MainAbility/app.js
+1
-1
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.css
..._Controller/src/main/js/MainAbility/pages/index/index.css
+1
-1
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.hml
..._Controller/src/main/js/MainAbility/pages/index/index.hml
+1
-1
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.js
...c_Controller/src/main/js/MainAbility/pages/index/index.js
+1
-1
communication/nfc_Controller/src/main/js/TestAbility/app.js
communication/nfc_Controller/src/main/js/TestAbility/app.js
+1
-1
communication/nfc_Controller/src/main/js/TestAbility/pages/index/index.js
...c_Controller/src/main/js/TestAbility/pages/index/index.js
+1
-1
communication/nfc_Controller/src/main/js/TestRunner/OpenHarmonyTestRunner.js
...ontroller/src/main/js/TestRunner/OpenHarmonyTestRunner.js
+2
-2
communication/nfc_Controller/src/main/js/test/List.test.js
communication/nfc_Controller/src/main/js/test/List.test.js
+1
-1
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
...cation/nfc_Controller/src/main/js/test/nfc.ATagSession.js
+101
-72
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
...ation/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
+44
-39
communication/nfc_Controller/src/main/js/test/nfc.Controller.js
...ication/nfc_Controller/src/main/js/test/nfc.Controller.js
+15
-15
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
...nication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
+31
-30
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
...n/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
+107
-98
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
...fc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
+31
-29
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
+122
-104
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
+54
-48
communication/nfc_ErrorCode/BUILD.gn
communication/nfc_ErrorCode/BUILD.gn
+1
-1
communication/nfc_ErrorCode/src/main/js/MainAbility/app.js
communication/nfc_ErrorCode/src/main/js/MainAbility/app.js
+1
-1
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.css
...c_ErrorCode/src/main/js/MainAbility/pages/index/index.css
+1
-1
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.hml
...c_ErrorCode/src/main/js/MainAbility/pages/index/index.hml
+1
-1
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.js
...fc_ErrorCode/src/main/js/MainAbility/pages/index/index.js
+1
-1
communication/nfc_ErrorCode/src/main/js/TestAbility/app.js
communication/nfc_ErrorCode/src/main/js/TestAbility/app.js
+1
-1
communication/nfc_ErrorCode/src/main/js/TestAbility/pages/index/index.js
...fc_ErrorCode/src/main/js/TestAbility/pages/index/index.js
+1
-1
communication/nfc_ErrorCode/src/main/js/TestRunner/OpenHarmonyTestRunner.js
...ErrorCode/src/main/js/TestRunner/OpenHarmonyTestRunner.js
+2
-2
communication/nfc_ErrorCode/src/main/js/test/List.test.js
communication/nfc_ErrorCode/src/main/js/test/List.test.js
+1
-1
communication/nfc_ErrorCode/src/main/js/test/error.IsoDepTag.js
...ication/nfc_ErrorCode/src/main/js/test/error.IsoDepTag.js
+9
-5
communication/nfc_ErrorCode/src/main/js/test/error.MifareClassicTag.js
.../nfc_ErrorCode/src/main/js/test/error.MifareClassicTag.js
+1
-1
communication/nfc_ErrorCode/src/main/js/test/error.MifareUltralightTag.js
...c_ErrorCode/src/main/js/test/error.MifareUltralightTag.js
+3
-3
communication/nfc_ErrorCode/src/main/js/test/error.NDEFTag.js
...unication/nfc_ErrorCode/src/main/js/test/error.NDEFTag.js
+2
-2
communication/nfc_ErrorCode/src/main/js/test/error.TagABFV.js
...unication/nfc_ErrorCode/src/main/js/test/error.TagABFV.js
+1
-1
communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js
...ion/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js
+34
-3
communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js
.../wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js
+40
-10
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
+35
-5
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
...ication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
+39
-9
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
...fi_standard/src/main/js/test/WifiCandidateNetWork.test.js
+32
-2
communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js
...dard/src/main/js/test/WifiManagerCandidateNetWork.test.js
+40
-10
communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js
...standard/src/main/js/test/WifiManagerStationEvent.test.js
+30
-0
communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js
...dard/src/main/js/test/WifiManagerStationFunctions.test.js
+30
-0
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+29
-0
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
...fi_standard/src/main/js/test/WifiStationFunctions.test.js
+30
-0
未找到文件。
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
浏览文件 @
19e90bdc
...
...
@@ -77,7 +77,7 @@ describe('bluetoothBLETest6', function() {
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result1
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
null
);
...
...
@@ -106,8 +106,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result2
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result2
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
deviceId
:
"
00:11:22:33:44:55
"
}]);
...
...
@@ -136,8 +136,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result3
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result3
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
name
:
"
blue_test
"
}]);
...
...
@@ -166,8 +166,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result4
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result4
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
}]);
...
...
@@ -196,8 +196,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result5
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result5
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -234,8 +234,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result6
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result6
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
let
ScanOptions
=
{
interval
:
100
,
...
...
@@ -270,8 +270,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result7
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result7
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -312,8 +312,8 @@ describe('bluetoothBLETest6', function() {
console
.
info
(
'
[bluetooth_js] bt turn off1:
'
+
JSON
.
stringify
(
state
));
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
=
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
=
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -352,8 +352,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result9
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result9
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -391,8 +391,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result10
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result10
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -429,8 +429,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result11
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result11
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -468,8 +468,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -506,8 +506,8 @@ describe('bluetoothBLETest6', function() {
try
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result13
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result13
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -709,8 +709,8 @@ describe('bluetoothBLETest6', function() {
async
function
onReceiveEvent
(
ScanResult
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
ScanResult
)
+
ScanResult
.
deviceId
+
ScanResult
.
rssi
+
ScanResult
.
data
);
ex
cep
t
(
true
).
assertTrue
(
ScanResult
.
length
>
0
);
+
ScanResult
.
deviceId
+
ScanResult
.
rssi
+
ScanResult
.
data
);
ex
pec
t
(
true
).
assertTrue
(
ScanResult
.
length
>
0
);
await
sleep
(
1000
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
ScanResult
[
0
].
deviceId
);
let
ret
=
gattClient
.
connect
();
...
...
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
19e90bdc
...
...
@@ -76,7 +76,7 @@ describe('bluetoothhostTest', function() {
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result1
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
null
);
...
...
@@ -98,8 +98,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0200
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result2
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result2
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
deviceId
:
"
00:11:22:33:44:55
"
}]);
...
...
@@ -122,8 +122,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0300
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result3
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result3
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
name
:
"
blue_test
"
}]);
...
...
@@ -146,8 +146,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0400
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result4
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result4
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
}]);
...
...
@@ -170,8 +170,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0500
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result5
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result5
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -201,8 +201,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0600
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result6
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result6
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
let
ScanOptions
=
{
interval
:
100
,
...
...
@@ -230,8 +230,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0700
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result7
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result7
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -264,8 +264,8 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] bt turn off1:
'
+
JSON
.
stringify
(
state
));
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
=
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result8
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
=
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -295,8 +295,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0900
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result9
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result9
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -326,8 +326,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1000
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result10
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result10
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -357,8 +357,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1100
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result11
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result11
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -388,8 +388,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1200
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
data
));
ex
cep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
data
));
ex
pec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -419,8 +419,8 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_1300
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result13
'
+
JSON
.
stringify
(
data
));
excep
t
(
true
).
assertTrue
(
data
.
length
>
0
);
console
.
info
(
'
[bluetooth_js] BLEscan device result13
'
+
JSON
.
stringify
(
data
));
expec
t
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
...
...
@@ -584,8 +584,8 @@ describe('bluetoothhostTest', function() {
async
function
onReceiveEvent
(
ScanResult
)
{
console
.
info
(
'
[bluetooth_js] BLEscan device result12
'
+
JSON
.
stringify
(
ScanResult
)
+
ScanResult
.
deviceId
+
ScanResult
.
rssi
+
ScanResult
.
data
);
ex
cep
t
(
true
).
assertTrue
(
ScanResult
.
length
>
0
);
+
ScanResult
.
deviceId
+
ScanResult
.
rssi
+
ScanResult
.
data
);
ex
pec
t
(
true
).
assertTrue
(
ScanResult
.
length
>
0
);
await
sleep
(
1000
);
let
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
ScanResult
[
0
].
deviceId
);
let
ret
=
gattClient
.
connect
();
...
...
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
19e90bdc
...
...
@@ -223,7 +223,7 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0600
'
,
0
,
async
function
(
done
)
{
let
ret
=
bluetooth
.
getPairedDevices
();
console
.
info
(
'
[bluetooth_js] getPairedDevices ret2:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
.
length
).
assertEqual
(
0
);
expect
(
true
).
assertEqual
(
ret
.
length
>=
0
);
done
();
})
...
...
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
浏览文件 @
19e90bdc
此差异已折叠。
点击以展开。
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
浏览文件 @
19e90bdc
...
...
@@ -24,6 +24,7 @@ let Btname = {
+
'
01234567890123456789012345678912
'
,
LETTERS_TEST
:
'
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
'
,
CHINESES_TEST
:
'
测试蓝牙名称是否正常测试蓝牙名称是否试蓝牙
'
,
CHINESES_TEST2
:
'
测试蓝牙名称正常
'
,
SYMBOL_TEST
:
'
*^_^* 、。·ˉˇ¨〃々—~‖·‘’“”「『』〖❂【±×
'
+
'
÷∶∧∨∑∏∪∩∈∷√⊥‖∠⌒⊙∫∮≡≌≈∽∝≠♂♀°℃$¤¢£‰§№☆★○●◎◇□■△※→←↑↓〓
'
,
MIXES
:
'
测试蓝牙名称是否正试蓝牙
\'
名称是否[666]aaw
'
,
...
...
@@ -113,12 +114,12 @@ describe('bluetoothhostTest1', function() {
* @tc.level Level 3
*/
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
2
);
expect
(
result
).
assertTrue
();
await
sleep
(
1000
);
let
getNewName
=
bluetooth
.
getLocalName
();
console
.
info
(
'
[bluetooth_js] LocalName_0200 NewName =
'
+
JSON
.
stringify
(
getNewName
));
expect
(
true
).
assertEqual
(
Btname
.
CHINESES_TEST
==
getNewName
);
expect
(
true
).
assertEqual
(
Btname
.
CHINESES_TEST
2
==
getNewName
);
done
();
})
...
...
communication/nfc_Controller/BUILD.gn
浏览文件 @
19e90bdc
# Copyright (C) 202
2
Huawei Device Co., Ltd.
# Copyright (C) 202
3
Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
...
...
@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
...
...
communication/nfc_Controller/src/main/js/MainAbility/app.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.css
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.hml
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/MainAbility/pages/index/index.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/TestAbility/app.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/TestAbility/pages/index/index.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/TestRunner/OpenHarmonyTestRunner.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -35,7 +35,7 @@ function translateParamsToString(parameters) {
console
.
info
(
'
OpenHarmonyTestRunner OnPrepare
'
)
},
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
console
.
info
(
'
OpenHarmonyTestRunner onRun run
'
)
var
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
var
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
...
...
communication/nfc_Controller/src/main/js/test/List.test.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -39,7 +39,7 @@ let getAtag = null ;
export
default
function
nfcATagSessionTest
()
{
describe
(
'
nfcATagSessionTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
try
{
getAtag
=
tag
.
getNfcATag
(
aTag
)
console
.
info
(
'
Nfcget Connected data
'
+
getAtag
)
...
...
@@ -48,13 +48,13 @@ export default function nfcATagSessionTest() {
}
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -70,15 +70,15 @@ export default function nfcATagSessionTest() {
let
NfcConnected
;
try
{
NfcConnected
=
getAtag
.
connectTag
();
console
.
info
(
"
NfcConnected:
"
+
NfcConnected
);
console
.
log
(
"
[NFC_test] tagsession1
NfcConnected:
"
+
NfcConnected
);
expect
(
NfcConnected
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
NfcConnected error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
log
(
'
[NFC_test] tagsession1
NfcConnected error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
console
.
log
(
"
[NFC_test]getAtag1 = null & = undefined:
"
);
expect
(
).
assertFail
();
}
})
...
...
@@ -93,17 +93,17 @@ export default function nfcATagSessionTest() {
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0200
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
try
{
try
{
getAtag
.
reset
();
console
.
log
(
'
[NFC_test] tagsession2 reset1 pass
'
)
expect
(
true
).
assertTrue
();
console
.
info
(
'
reset1 pass
'
)
}
catch
(
error
)
{
console
.
info
(
'
reset1 error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
log
(
'
[NFC_test] tagsession2
reset1 error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
console
.
log
(
"
[NFC_test]getAtag2 = null & = undefined:
"
);
expect
(
).
assertFail
();
}
})
...
...
@@ -121,15 +121,15 @@ export default function nfcATagSessionTest() {
let
isNfcConnected
;
try
{
isNfcConnected
=
getAtag
.
isTagConnected
();
console
.
info
(
"
isNfcConnected:
"
+
isNfcConnected
);
console
.
log
(
"
[NFC_test] tagsession3
isNfcConnected:
"
+
isNfcConnected
);
expect
(
isNfcConnected
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
isNfcConnected error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
log
(
'
[NFC_test] tagsession3
isNfcConnected error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
console
.
log
(
"
[NFC_test]getAtag3 = null & = undefined:
"
);
expect
(
).
assertFail
();
}
})
...
...
@@ -147,16 +147,15 @@ export default function nfcATagSessionTest() {
let
mazSendLen
;
try
{
mazSendLen
=
getAtag
.
getMaxSendLength
();
console
.
info
(
"
getMaxSendLength:
"
+
mazSendLen
);
console
.
info
(
"
[NFC_test] tagsession4
getMaxSendLength:
"
+
mazSendLen
);
expect
(
mazSendLen
>=
0
).
assertTrue
();
console
.
info
(
'
getMaxSendLength pass
'
)
}
catch
(
error
)
{
console
.
info
(
'
getMaxSendLength error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] tagsession4
getMaxSendLength error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -173,16 +172,17 @@ export default function nfcATagSessionTest() {
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
settime
;
try
{
settime
=
getAtag
.
setSendDataTimeout
(
1000
);
console
.
info
(
"
setSendDataTimeout:
"
+
settime
);
expect
(
settime
>=
0
).
assertTrue
();
let
timeoutMs
=
1000
;
settime
=
getAtag
.
setSendDataTimeout
(
timeoutMs
);
console
.
info
(
"
[NFC_test] tagsession5 setSendDataTimeout:
"
+
settime
);
expect
(
settime
).
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
'
setSendDataTimeout error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] tagsession5
setSendDataTimeout error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -200,16 +200,15 @@ export default function nfcATagSessionTest() {
let
gettime
;
try
{
gettime
=
getAtag
.
getSendDataTimeout
();
console
.
info
(
"
getMaxSendLength:
"
+
gettime
+
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
gettime
));
expect
(
gettime
>=
0
).
assertTrue
();
console
.
info
(
'
getMaxSendLength pass
'
)
console
.
info
(
"
[NFC_test] tagsession6 getMaxSendLength:
"
+
gettime
);
expect
(
gettime
).
assertInstanceOf
(
'
Number
'
)
}
catch
(
error
)
{
console
.
info
(
'
getMaxSendLength error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] tagsession6
getMaxSendLength error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag6 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -226,17 +225,18 @@ export default function nfcATagSessionTest() {
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
await
getAtag
.
sendData
(
sendDatas
).
then
((
data
)
=>
{
console
.
log
(
"
nfcAtage sendData1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] tagsession7 nfcAtage sendData1 data:
"
+
data
);
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
nfcAtage sendData1 err:
"
+
err
);
expect
(
true
).
assertFalse
();
console
.
info
(
"
[NFC_test] tagsession7 nfcAtage sendData1 err:
"
+
err
);
expect
().
assertFail
();
done
();
});
sleep
(
3500
);
}
else
{
console
.
info
(
"
[NFC_test]getAtag7 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -254,19 +254,20 @@ export default function nfcATagSessionTest() {
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
getAtag
.
sendData
(
sendDatas
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
nfcAtage sendData2 data err:
"
+
err
);
expect
(
true
).
assertFalse
();
console
.
info
(
"
[NFC_test] tagsession8 nfcAtage sendData2 data err:
"
+
err
);
expect
().
assertFail
();
done
();
}
else
{
sleep
(
2500
);
console
.
log
(
"
nfcAtage sendData2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] tagsession8 nfcAtage sendData2 data:
"
+
data
);
data
done
();
}
});
sleep
(
500
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]getAtag8 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -275,18 +276,18 @@ export default function nfcATagSessionTest() {
* @tc.name testreset
* @tc.desc Test reset api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0900
'
,
0
,
function
()
{
try
{
tag
.
getNfcA
(
aTag
).
resetConnection
();
console
.
info
(
'
[NFC_test] tagsession9 resetConnection pass
'
)
expect
(
true
).
assertTrue
();
console
.
info
(
'
reset1 pass
'
)
}
catch
(
error
)
{
console
.
info
(
'
reset1
error
'
+
error
)
expect
(
true
).
assertTrue
();
console
.
info
(
'
[NFC_test] tagsession9 resetConnection
error
'
+
error
)
expect
(
3100201
).
assertEqual
(
error
.
code
)
}
})
...
...
@@ -302,12 +303,12 @@ export default function nfcATagSessionTest() {
it
(
'
SUB_Communication_NFC_nfcAtage_js_1000
'
,
0
,
function
()
{
let
settime
;
try
{
settime
=
tag
.
getNfcATag
(
aTag
).
getTimeout
(
1000
);
console
.
info
(
"
setSendDataTimeout:
"
+
settime
);
expect
(
settime
>=
0
).
assertTrue
();
settime
=
tag
.
getNfcATag
(
aTag
).
getTimeout
();
console
.
info
(
"
[NFC_test] tagsession10 getSendDataTimeout:
"
+
settime
);
expect
(
settime
).
assertInstanceOf
(
'
Number
'
)
}
catch
(
error
)
{
console
.
info
(
'
s
etSendDataTimeout error
'
+
error
)
expect
(
true
).
assertTrue
();
console
.
info
(
'
[NFC_test] tagsession10 g
etSendDataTimeout error
'
+
error
)
expect
(
3100201
).
assertEqual
(
error
.
code
)
}
})
...
...
@@ -323,12 +324,13 @@ export default function nfcATagSessionTest() {
it
(
'
SUB_Communication_NFC_nfcAtage_js_1100
'
,
0
,
async
function
(
done
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
await
tag
.
getNfcATag
(
aTag
).
transmit
(
sendDatas
).
then
((
data
)
=>
{
console
.
log
(
"
nfcAtage sendData1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] tagsession11 nfcAtage sendData1 data:
"
+
data
);
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
nfcAtage sendData1 err:
"
+
err
);
expect
(
true
).
assertTrue
();
console
.
info
(
"
[NFC_test] tagsession11 nfcAtage sendData1 err:
"
+
err
);
expect
().
assertFail
();
done
();
});
sleep
(
3500
);
})
...
...
@@ -346,16 +348,17 @@ export default function nfcATagSessionTest() {
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
tag
.
getNfcATag
(
aTag
).
transmit
(
sendDatas
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
nfcAtage sendData2 data err:
"
+
err
);
expect
(
true
).
assertFalse
();
console
.
info
(
"
[NFC_test] tagsession12 nfcAtage sendData2 data err:
"
+
err
);
expect
().
assertFail
();
done
();
}
else
{
sleep
(
2500
);
console
.
log
(
"
nfcAtage sendData2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] tagsession12 nfcAtage sendData2 data:
"
+
data
);
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}
});
sleep
(
500
);
done
();
})
/**
...
...
@@ -371,12 +374,38 @@ export default function nfcATagSessionTest() {
let
mazSendLen
;
try
{
mazSendLen
=
tag
.
getNfcATag
(
aTag
).
getMaxTransmitSize
();
console
.
info
(
"
getMaxTransmitSize:
"
+
mazSendLen
);
expect
(
mazSendLen
>=
0
).
assertTrue
();
console
.
info
(
'
getMaxTransmitSize pass
'
)
console
.
info
(
"
[NFC_test] tagsession13 getMaxTransmitSize:
"
+
mazSendLen
);
expect
(
mazSendLen
).
assertInstanceOf
(
'
Number
'
)
}
catch
(
error
)
{
console
.
info
(
'
getMaxTransmitSize error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] tagsession13 getMaxTransmitSize error
'
+
error
)
expect
().
assertFail
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0500
* @tc.name testsetSendDataTimeout
* @tc.desc Test setSendDataTimeout api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_1400
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
settime
;
try
{
let
timeoutMs
=
1000
;
settime
=
getAtag
.
setTimeout
(
timeoutMs
);
console
.
info
(
"
[NFC_test] tagsession14 setTimeout:
"
+
settime
);
expect
(
settime
).
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
'
[NFC_test] tagsession14 setTimeout error
'
+
error
)
expect
(
3100201
).
assertEqual
(
error
.
code
)
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag14 = null & = undefined:
"
);
expect
().
assertFail
();
}
})
...
...
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -32,16 +32,16 @@ let NfcRfType = {
export
default
function
ConnectedTagTest
()
{
describe
(
'
ConnectedTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -60,8 +60,8 @@ export default function ConnectedTagTest() {
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
inittag
=
connectedTag
.
init
();
console
.
info
(
"
[NFC_test] ConnectedTag1 readMultiplePages1 err:
"
+
inittag
);
expect
(
inittag
).
assertTrue
();
console
.
info
(
"
ConnectedTag readMultiplePages1 err:
"
+
inittag
);
}
})
...
...
@@ -82,12 +82,12 @@ export default function ConnectedTagTest() {
done
();
}
else
{
await
connectedTag
.
readNdefTag
().
then
(
result
=>
{
console
.
info
(
"
ConnectedTag readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
console
.
info
(
"
[NFC_test] ConnectedTag2 readMultiplePages1 result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
ConnectedTag
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] ConnectedTag2
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
);
done
();
});
sleep
(
3000
);
...
...
@@ -112,11 +112,11 @@ export default function ConnectedTagTest() {
}
else
{
connectedTag
.
readNdefTag
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test] ConnectedTag3 isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
console
.
info
(
"
[NFC_test] ConnectedTag3 isExtendedApduSupported result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
(
);
}
});
}
...
...
@@ -140,12 +140,12 @@ export default function ConnectedTagTest() {
done
();
}
else
{
await
connectedTag
.
writeNdefTag
().
then
(
result
=>
{
console
.
info
(
"
ConnectedTag readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
console
.
info
(
"
[NFC_test] ConnectedTag4 readMultiplePages1 result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
ConnectedTag
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] ConnectedTag4
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
true
);
done
();
});
sleep
(
3000
);
...
...
@@ -166,18 +166,20 @@ export default function ConnectedTagTest() {
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
()
}
else
{
connectedTag
.
writeNdefTag
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test] ConnectedTag5 isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
done
(
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
console
.
info
(
"
[NFC_test] ConnectedTag5 isExtendedApduSupported result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}
});
}
done
();
})
/**
...
...
@@ -196,11 +198,11 @@ export default function ConnectedTagTest() {
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
recvNfcRfNotifyFunc
=
result
=>
{
console
.
info
(
"
nfc state receive state ->
"
+
result
);
console
.
info
(
"
[NFC_test] ConnectedTag6
nfc state receive state ->
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
}
connectedTag
.
on
(
'
notify
'
,
recvNfcRfNotifyFunc
)
connectedTag
.
off
(
'
notify
'
,
recvNfcRfNotifyFunc
)
connectedTag
.
on
(
'
[NFC_test] ConnectedTag6
notify
'
,
recvNfcRfNotifyFunc
)
connectedTag
.
off
(
'
[NFC_test] ConnectedTag6
notify
'
,
recvNfcRfNotifyFunc
)
}
})
...
...
@@ -220,8 +222,8 @@ export default function ConnectedTagTest() {
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
uninittag
=
connectedTag
.
uninit
();
console
.
info
(
"
[NFC_test] ConnectedTag7 readMultiplePages1 err:
"
+
uninittag
);
expect
(
uninittag
).
assertTrue
();
console
.
info
(
"
ConnectedTag readMultiplePages1 err:
"
+
uninittag
);
}
})
...
...
@@ -242,8 +244,8 @@ export default function ConnectedTagTest() {
}
else
{
let
inittag
=
connectedTag
.
initialize
();
console
.
info
(
"
[NFC_test] ConnectedTag8 readMultiplePages1 err:
"
+
inittag
);
expect
(
inittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
inittag
);
}
})
...
...
@@ -264,8 +266,8 @@ export default function ConnectedTagTest() {
}
else
{
let
uninittag
=
connectedTag
.
uninitialize
();
console
.
info
(
"
[NFC_test] ConnectedTag9 readMultiplePages1 err:
"
+
uninittag
);
expect
(
uninittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
uninittag
);
}
})
...
...
@@ -287,12 +289,12 @@ export default function ConnectedTagTest() {
}
else
{
await
connectedTag
.
read
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
console
.
info
(
"
[NFC_test] ConnectedTag10 readMultiplePages1 result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] ConnectedTag10
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
);
done
();
});
sleep
(
3000
);
...
...
@@ -318,15 +320,16 @@ export default function ConnectedTagTest() {
else
{
connectedTag
.
read
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test] ConnectedTag11 isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
done
(
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
console
.
info
(
"
[NFC_test] ConnectedTag11 isExtendedApduSupported result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}
});
}
done
();
})
/**
...
...
@@ -347,12 +350,12 @@ export default function ConnectedTagTest() {
}
else
{
await
connectedTag
.
write
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
)
);
console
.
info
(
"
[NFC_test] ConnectedTag12 readMultiplePages1 result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] ConnectedTag12
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
);
done
();
});
sleep
(
3000
);
...
...
@@ -373,19 +376,21 @@ export default function ConnectedTagTest() {
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
connectedTag
.
write
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test] ConnectedTag13 isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
done
(
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
console
.
info
(
"
[NFC_test] ConnectedTag13 isExtendedApduSupported result:
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
done
();
}
});
}
done
();
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
...
...
communication/nfc_Controller/src/main/js/test/nfc.Controller.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -35,16 +35,16 @@ let NfcState={
export
default
function
nfcControllerTest
()
{
describe
(
'
nfcControllerTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -58,7 +58,7 @@ export default function nfcControllerTest() {
it
(
'
SUB_COMMUNICATION_NFC_Cont_0100
'
,
0
,
function
()
{
let
NFC_STATE_NOTIFY
=
"
nfcStateChange
"
;
let
recvNfcStateNotifyFunc
=
result
=>
{
console
.
info
(
"
nfc state receive state ->
"
+
result
);
console
.
info
(
"
[NFC_test] controller1
nfc state receive state ->
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
}
controller
.
on
(
NFC_STATE_NOTIFY
,
recvNfcStateNotifyFunc
);
...
...
@@ -75,10 +75,10 @@ export default function nfcControllerTest() {
*/
it
(
'
SUB_COMMUNICATION_NFC_Cont_0200
'
,
0
,
function
()
{
let
nfcisAvailable
=
controller
.
isNfcAvailable
();
console
.
info
(
'
[NFC_test] controller2 Nfc Available ->
'
+
JSON
.
stringify
(
nfcisAvailable
));
expect
(
nfcisAvailable
).
assertTrue
();
console
.
info
(
'
[nfc_js] Nfc Available ->
'
+
JSON
.
stringify
(
nfcisAvailable
));
})
/**
* @tc.number SUB_COMMUNICATION_NFC_Cont_0300
* @tc.name Test isNfcOpenapi
...
...
@@ -86,11 +86,11 @@ export default function nfcControllerTest() {
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_NFC_Cont_0300
'
,
0
,
function
()
{
let
nfcswitchis
=
controller
.
isNfcOpen
();
console
.
info
(
'
[NFC_test] controller3 Nfc isopen state is ->
'
+
JSON
.
stringify
(
nfcswitchis
));
expect
(
nfcswitchis
).
assertTrue
();
console
.
info
(
'
[nfc_js] Nfc isopen state is ->
'
+
JSON
.
stringify
(
nfcswitchis
));
})
/**
...
...
@@ -100,14 +100,14 @@ export default function nfcControllerTest() {
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNICATION_NFC_Cont_0400
'
,
0
,
function
()
{
let
nfcisAvailable1
=
controller
.
isNfcAvailable
();
console
.
info
(
'
[NFC_test] controller4 NfcAvailable 1 ->
'
+
JSON
.
stringify
(
nfcisAvailable1
));
expect
(
nfcisAvailable1
).
assertTrue
();
console
.
info
(
'
[nfc_js] NfcAvailable 1 ->
'
+
JSON
.
stringify
(
nfcisAvailable1
));
let
nfcenable1
=
controller
.
isNfcOpen
();
console
.
info
(
'
[NFC_test] controller4 Nfc isopen 1 state is ->
'
+
JSON
.
stringify
(
nfcenable1
));
expect
(
nfcenable1
).
assertTrue
();
console
.
info
(
'
[nfc_js] Nfc isopen 1 state is ->
'
+
JSON
.
stringify
(
nfcenable1
));
})
/**
...
...
@@ -120,11 +120,11 @@ export default function nfcControllerTest() {
*/
it
(
'
SUB_COMMUNICATION_NFC_Cont_0500
'
,
0
,
function
()
{
let
checkopennfc
=
controller
.
getNfcState
();
console
.
info
(
"
[NFC_test] controller5 checkopen the state of nfc->
"
+
JSON
.
stringify
(
checkopennfc
));
expect
(
checkopennfc
).
assertEqual
(
NfcState
.
STATE_ON
);
console
.
log
(
"
[nfc_test] checkopen the state of nfc->
"
+
JSON
.
stringify
(
checkopennfc
));
})
console
.
log
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
...
...
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -75,7 +75,7 @@ let IsoDepTag ;
export
default
function
nfcIsoDepTagTest
()
{
describe
(
'
nfcIsoDepTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
try
{
IsoDepTag
=
tag
.
getIsoDep
(
isoDepTaginfo
);
}
catch
(
error
)
{
...
...
@@ -83,13 +83,13 @@ export default function nfcIsoDepTagTest() {
}
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -104,10 +104,10 @@ export default function nfcIsoDepTagTest() {
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
let
ResponseFlags
=
IsoDepTag
.
getHistoricalBytes
();
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[
nfc_js]
test ResponseFlags data>:
'
+
ResponseFlags
);
console
.
info
(
'
[
NFC_test] Isodep1
test ResponseFlags data>:
'
+
ResponseFlags
);
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -123,10 +123,10 @@ export default function nfcIsoDepTagTest() {
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
let
HiLayerResponse
=
IsoDepTag
.
getHiLayerResponse
();
expect
(
HiLayerResponse
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[
nfc_js]
test ResponseFlags data2>:
'
+
HiLayerResponse
);
console
.
info
(
'
[
NFC_test] Isodep2
test ResponseFlags data2>:
'
+
HiLayerResponse
);
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -141,17 +141,17 @@ export default function nfcIsoDepTagTest() {
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0300
'
,
0
,
async
function
(
done
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
await
IsoDepTag
.
isExtendedApduSupported
().
then
((
data
)
=>
{
expect
(
false
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
data
);
console
.
info
(
"
[NFC_test] Isodep3 isExtendedApduSupported data:
"
+
data
);
expect
(
true
).
assertEqual
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
isoDep
isExtendedApduSupported err:
"
+
err
);
expect
(
true
).
assertFalse
();
console
.
info
(
"
[NFC_test] Isodep3
isExtendedApduSupported err:
"
+
err
);
expect
(
).
assertFail
();
done
();
});
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -167,17 +167,18 @@ export default function nfcIsoDepTagTest() {
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
IsoDepTag
.
isExtendedApduSupported
((
err
,
data
)
=>
{
if
(
err
)
{
expect
(
true
).
assertFalse
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
console
.
info
(
"
[NFC_test] Isodep4 isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
done
();
}
else
{
expect
(
false
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
data
);
console
.
info
(
"
[NFC_test] Isodep4 isExtendedApduSupported data:
"
+
data
);
expect
(
true
).
assertEqual
(
data
);
done
();
}
});
done
();
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -194,15 +195,15 @@ export default function nfcIsoDepTagTest() {
let
cardEmulationnfc
;
try
{
cardEmulationnfc
=
cardEmulation
.
isSupported
(
FeatureType
.
ESE
);
console
.
info
(
'
cardEmulationnfc
type ->
'
+
cardEmulationnfc
)
console
.
info
(
'
[NFC_test] cardEmulationnfc5
type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc
error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] cardEmulationnfc5
error
'
+
error
)
expect
(
).
assertFail
();
}
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -218,11 +219,11 @@ export default function nfcIsoDepTagTest() {
let
cardEmulationnfc
;
try
{
cardEmulationnfc
=
cardEmulation
.
hasHceCapability
();
console
.
info
(
'
cardEmulationnfc
hasHceCapability type ->
'
+
cardEmulationnfc
)
console
.
info
(
'
[NFC_test] cardEmulationnfc6
hasHceCapability type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc
error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] cardEmulationnfc6
error
'
+
error
)
expect
(
).
assertFail
();
}
})
...
...
@@ -242,11 +243,11 @@ export default function nfcIsoDepTagTest() {
};
try
{
cardEmulationnfc
=
cardEmulation
.
isDefaultService
(
elementName
,
CardType
.
PAYMENT
);
console
.
info
(
'
cardEmulationnfc
isDefaultService type ->
'
+
cardEmulationnfc
)
console
.
info
(
'
[NFC_test] cardEmulationnfc7
isDefaultService type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc
error
'
+
error
)
expect
(
true
).
assertFalse
();
console
.
info
(
'
[NFC_test] cardEmulationnfc7
error
'
+
error
)
expect
(
).
assertFail
();
}
})
...
...
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
浏览文件 @
19e90bdc
此差异已折叠。
点击以展开。
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -39,7 +39,7 @@ let mifareUltralightTaginfo = {
};
let
MifareUltralightType
=
{
TYPE_UNKOWN
:
0
x04
,
TYPE_UNKOWN
:
0
,
TYPE_ULTRALIGHT
:
1
,
TYPE_ULTRALIGHT_C
:
2
,
}
...
...
@@ -49,7 +49,7 @@ let MifareUltralightTag = null;
export
default
function
nfcMifareUltralightTag
()
{
describe
(
'
nfcMifareUltralightTag
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
})
beforeEach
(
function
()
{
try
{
...
...
@@ -58,13 +58,13 @@ export default function nfcMifareUltralightTag() {
}
catch
(
error
)
{
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -80,18 +80,18 @@ export default function nfcMifareUltralightTag() {
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
pageIndex
=
1
;
await
MifareUltralightTag
.
readMultiplePages
(
pageIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] mifareUltralight1
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] mifareUltralight1
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
);
done
();
});
sleep
(
3000
);
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -109,18 +109,19 @@ export default function nfcMifareUltralightTag() {
let
pageIndex
=
1
;
MifareUltralightTag
.
readMultiplePages
(
pageIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareUltralight readMultiplePages2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
console
.
info
(
"
[NFC_test] mifareUltralight2 readMultiplePages2 err:
"
+
err
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
"
mifareUltralight readMultiplePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
console
.
info
(
"
[NFC_test] mifareUltralight2 readMultiplePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}
});
sleep
(
3000
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -138,18 +139,18 @@ export default function nfcMifareUltralightTag() {
let
pageIndex
=
1
;
let
rawData
=
[
0x01
,
0x02
];
await
MifareUltralightTag
.
writeSinglePage
(
pageIndex
,
rawData
).
then
((
data
)
=>
{
console
.
log
(
"
mifareUltralight
writeSinglePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[NFC_test] mifareUltralight3
writeSinglePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
mifareUltralight
writeSinglePages1 err:
"
+
err
);
expect
(
true
).
assert
Equal
(
true
);
console
.
info
(
"
[NFC_test] mifareUltralight3
writeSinglePages1 err:
"
+
err
);
expect
(
true
).
assert
True
(
);
done
();
});
sleep
(
3000
);
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -168,18 +169,19 @@ export default function nfcMifareUltralightTag() {
let
rawData
=
[
0x01
,
0x02
];
MifareUltralightTag
.
writeSinglePage
(
pageIndex
,
rawData
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
mifareUltralight writeSinglePages2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
console
.
info
(
"
[NFC_test] mifareUltralight4 writeSinglePages2 err:
"
+
err
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
log
(
"
mifareUltralight
writeSinglePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[NFC_test] mifareUltralight4
writeSinglePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
done
();
}
});
sleep
(
3000
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -195,11 +197,11 @@ export default function nfcMifareUltralightTag() {
it
(
'
SUB_Communication_NFC_mifareUltralight_0500
'
,
0
,
function
()
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
getType
=
MifareUltralightTag
.
getType
();
console
.
info
(
"
mifareUltralight
getType:
"
+
getType
);
expect
(
getType
>=
-
1
).
assertTrue
(
);
console
.
info
(
"
[NFC_test] mifareUltralight5
getType:
"
+
getType
);
expect
(
getType
).
assertEqual
(
MifareUltralightType
.
TYPE_UNKOWN
);
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
浏览文件 @
19e90bdc
此差异已折叠。
点击以展开。
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -89,27 +89,33 @@ let vTag = {
"
tagRfDiscId
"
:
1
,
};
let
Want
=
{
"
uid
"
:
'
01020304
'
,
"
technology
"
:
[
1
],
"
tagRfDiscId
"
:
1
,
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
var
Want
=
{
uid
:
[
0x5B
,
0x7F
,
0xCF
,
0xA9
],
technology
:
[
1
,
8
],
tagRfDiscId
:
1
,
extrasData
:
[
{
Sak
:
0x08
,
Atqa
:
'
0400
'
},
{
MifareUltralightC
:
true
},
{
NdefMsg
:
'
030DD207036162632F646566676869
'
,
NdefForumType
:
1
,
NdefTagLength
:
253
,
NdefTagMode
:
1
}
]
}
export
default
function
nfcTagABFVTest
()
{
describe
(
'
nfcTagABFVTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeAll called
'
)
console
.
info
(
'
r
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]
beforeEach called
'
)
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]
afterEach called
'
)
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]
afterAll called
'
)
console
.
info
(
'
afterAll called
'
)
})
/**
...
...
@@ -128,12 +134,12 @@ export default function nfcTagABFVTest() {
console
.
info
(
'
Nfcget tagABFV error
'
+
error
)
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
console
.
info
(
'
[NFC_test] aTag1 is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
expect
(
NfcATag
!=
null
).
assertTrue
();
expect
(
NfcATag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcATag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -153,12 +159,12 @@ export default function nfcTagABFVTest() {
console
.
info
(
'
Nfcget tagABFV error
'
+
error
)
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
console
.
info
(
'
[NFC_test] bTag2 is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
expect
(
NfcBTag
!=
null
).
assertTrue
();
expect
(
NfcBTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
bTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -178,12 +184,12 @@ export default function nfcTagABFVTest() {
console
.
info
(
'
Nfcget tagABFV error
'
+
error
)
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
console
.
info
(
'
[NFC_test] fTag3 is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
expect
(
NfcFTag
!=
null
).
assertTrue
();
expect
(
NfcFTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
fTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -203,12 +209,12 @@ export default function nfcTagABFVTest() {
console
.
info
(
'
Nfcget tagABFV error
'
+
error
)
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
console
.
info
(
'
[NFC_test] vTag4 is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
expect
(
NfcVTag
!=
null
).
assertTrue
();
expect
(
NfcVTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
vTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -229,11 +235,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
let
sak
=
NfcATag
.
getSak
();
console
.
info
(
'
[NFC_test] tag5 test sak data>:
'
+
sak
);
expect
(
sak
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test sak data>:
'
+
sak
);
}
else
{
console
.
info
(
"
[NFC_test]NfcATag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -254,11 +260,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
let
Atqa
=
NfcATag
.
getAtqa
();
console
.
info
(
'
[NFC_test] tag6 test Atqa data>:
'
+
Atqa
);
expect
(
Atqa
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Atqa data>:
'
+
Atqa
);
}
else
{
console
.
info
(
"
[NFC_test]NfcATag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -279,11 +285,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
let
AppData
=
NfcBTag
.
getRespAppData
();
console
.
info
(
'
[NFC_test] tag7 test AppData data>:
'
+
AppData
);
expect
(
AppData
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test AppData data>:
'
+
AppData
);
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -304,11 +310,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
let
Protocol
=
NfcBTag
.
getRespProtocol
();
console
.
info
(
'
[NFC_test] tag8 test Protocol data>:
'
+
Protocol
);
expect
(
Protocol
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Protocol data>:
'
+
Protocol
);
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -329,11 +335,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
let
SystemCode
=
NfcFTag
.
getSystemCode
();
console
.
info
(
'
[NFC_test] tag9 test SystemCode data>:
'
+
SystemCode
);
expect
(
SystemCode
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test SystemCode data>:
'
+
SystemCode
);
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -354,11 +360,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
let
Pmm
=
NfcFTag
.
getPmm
();
console
.
info
(
'
[NFC_test] tag10 test Pmm data>:
'
+
Pmm
);
expect
(
Pmm
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Pmm data>:
'
+
Pmm
);
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -379,11 +385,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
let
ResponseFlags
=
NfcVTag
.
getResponseFlags
();
console
.
info
(
'
[NFC_test] tag11 test ResponseFlags3 data>:
'
+
ResponseFlags
);
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test ResponseFlags3 data>:
'
+
ResponseFlags
);
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -404,11 +410,11 @@ export default function nfcTagABFVTest() {
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
let
DsfId
=
NfcVTag
.
getDsfId
();
console
.
info
(
'
[NFC_test] tag12 test DsfId data>:
'
+
DsfId
);
expect
(
DsfId
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test DsfId data>:
'
+
DsfId
);
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
expect
(
).
assertFail
();
}
})
...
...
@@ -421,16 +427,16 @@ export default function nfcTagABFVTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfctage_js_1300
'
,
0
,
function
()
{
let
TagInfo
;
let
getTagtest
;
try
{
TagInfo
=
tag
.
getTagInfo
(
Want
);
console
.
info
(
'
Nfcget tagABFV gettaginfo is:
'
+
TagInfo
)
expect
(
TagInfo
instanceof
Object
).
assertTrue
();
getTagtest
=
tag
.
getTagInfo
(
Want
);
console
.
info
(
'
[NFC_test] tag13 Nfcget tagABFV gettaginfo is:
'
+
getTagtest
)
expect
(
getTagtest
instanceof
Object
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
'
Nfcget taginfo error
'
+
error
)
console
.
info
(
'
[NFC_test] tag13
Nfcget taginfo error
'
+
error
)
expect
(
true
).
assertTrue
();
}
console
.
info
(
'
[
nfc_js] test TagInfo data>:
'
+
TagInfo
);
console
.
info
(
'
[
NFC_test] tag13 test TagInfo data>:
'
+
getTagtest
);
})
/**
...
...
@@ -448,9 +454,9 @@ export default function nfcTagABFVTest() {
}
catch
(
error
)
{
console
.
info
(
'
nfc gertaga error
'
+
error
)
}
console
.
info
(
'
[NFC_test] aTag14 is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
expect
(
NfcATag
!=
null
).
assertTrue
();
expect
(
NfcATag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
})
/**
...
...
@@ -466,11 +472,11 @@ export default function nfcTagABFVTest() {
try
{
NfcBTag
=
tag
.
getNfcB
(
bTag
);
}
catch
(
error
)
{
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0200
error
'
+
error
)
console
.
info
(
'
nfc getNfcB
error
'
+
error
)
}
console
.
info
(
'
[NFC_test] bTag15 is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
expect
(
NfcBTag
!=
null
).
assertTrue
();
expect
(
NfcBTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
bTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
})
/**
...
...
@@ -486,11 +492,11 @@ export default function nfcTagABFVTest() {
try
{
NfcFTag
=
tag
.
getNfcF
(
fTag
);
}
catch
(
error
)
{
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0300
error
'
+
error
)
console
.
info
(
'
nfc getNfcF
error
'
+
error
)
}
console
.
info
(
'
[NFC_test] fTag16 is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
expect
(
NfcFTag
!=
null
).
assertTrue
();
expect
(
NfcFTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
fTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
})
/**
...
...
@@ -506,11 +512,11 @@ export default function nfcTagABFVTest() {
try
{
NfcVTag
=
tag
.
getNfcV
(
vTag
);
}
catch
(
error
)
{
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0400
error
'
+
error
)
console
.
info
(
'
nfc getNfcV
error
'
+
error
)
}
console
.
info
(
'
[NFC_test] vTag17 is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
expect
(
NfcVTag
!=
null
).
assertTrue
();
expect
(
NfcVTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
vTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
...
...
communication/nfc_ErrorCode/BUILD.gn
浏览文件 @
19e90bdc
# Copyright (C) 202
2
Huawei Device Co., Ltd.
# Copyright (C) 202
3
Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/MainAbility/app.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.css
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.hml
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/MainAbility/pages/index/index.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/TestAbility/app.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/TestAbility/pages/index/index.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/TestRunner/OpenHarmonyTestRunner.js
浏览文件 @
19e90bdc
/*
* Copyright (c) 202
2
Huawei Device Co., Ltd.
* Copyright (c) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -35,7 +35,7 @@ function translateParamsToString(parameters) {
console
.
info
(
'
OpenHarmonyTestRunner OnPrepare
'
)
},
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
console
.
info
(
'
OpenHarmonyTestRunner onRun run
'
)
var
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
var
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
...
...
communication/nfc_ErrorCode/src/main/js/test/List.test.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/test/error.IsoDepTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -23,7 +23,7 @@ function sleep(delay) { // delay x ms
continue
;
}
}
let
NdefRecord
=
{
NFC_A
:
1
,
NFC_B
:
2
,
...
...
@@ -63,7 +63,10 @@ let isoDepTaginfo = {
],
"
tagRfDiscId
"
:
1
,
};
let
IsoDepTag
;
let
parametertest
=
1
;
export
default
function
nfcIsoDepErrorTest
()
{
describe
(
'
nfcIsoDepErrorTest
'
,
function
()
{
beforeAll
(
function
()
{
...
...
@@ -93,10 +96,11 @@ export default function nfcIsoDepErrorTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0100
'
,
0
,
async
function
(
done
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
(
async
()
=>
{
try
{
let
result
=
await
IsoDepTag
.
isExtendedApduSupported
(
'
test
'
);
let
result
=
await
IsoDepTag
.
isExtendedApduSupported
(
"
test
"
);
console
.
info
(
"
[NFC_test]isoDep1 isExtendedApduSupported data:
"
+
result
);
expect
(
result
).
assertInstanceOf
(
'
Array
'
)
expect
().
assertFail
()
...
...
@@ -124,7 +128,7 @@ export default function nfcIsoDepErrorTest() {
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0200
'
,
0
,
async
function
(
done
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
try
{
IsoDepTag
.
isExtendedApduSupported
(
'
test
'
)((
err
,
data
)
=>
{
IsoDepTag
.
isExtendedApduSupported
(
"
test
"
)((
err
,
data
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
console
.
info
(
"
[NFC_test]isoDep2 isExtendedApduSupported errcode:
"
+
err
);
...
...
communication/nfc_ErrorCode/src/main/js/test/error.MifareClassicTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/nfc_ErrorCode/src/main/js/test/error.MifareUltralightTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -176,10 +176,10 @@ export default function UltralightTagErrorTest() {
try
{
MifareUltralightTag
.
writeSinglePage
(
'
test
'
,
rawData
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
[NFC_test]mifareUltralight4 writeSinglePage errcode:
"
+
err
);
console
.
info
(
"
[NFC_test]mifareUltralight4 writeSinglePage errcode:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
log
(
"
[NFC_test]mifareUltralight4 writeSinglePage data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[NFC_test]mifareUltralight4 writeSinglePage data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
}
});
...
...
communication/nfc_ErrorCode/src/main/js/test/error.NDEFTag.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -461,7 +461,7 @@ export default function nfcNDEFErrorTest() {
try
{
NdefFormatable
.
format
(
'
test
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
[NFC_test]ndef12 format errcode:
"
+
err
);
console
.
info
(
"
[NFC_test]ndef12 format errcode:
"
+
err
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
"
[NFC_test]ndef12 format formatReadOnly2
"
);
...
...
communication/nfc_ErrorCode/src/main/js/test/error.TagABFV.js
浏览文件 @
19e90bdc
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
communication/wifi_p2p/src/main/js/test/WifiManagerP2PEvent.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifiMg
from
'
@ohos.wifiManager
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -27,6 +51,12 @@ function checkWifiPowerOn(){
export
default
function
actsWifiManagerEventTest
()
{
describe
(
'
actsWifiManagerEventTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
console
.
info
(
"
[wifi_test]beforeEach start
"
);
checkWifiPowerOn
();
...
...
@@ -74,10 +104,12 @@ export default function actsWifiManagerEventTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
groupName
:
"
DIRECT-
AAAZZZ456
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_AUTO
,
};
let
connectResult
=
wifiMg
.
p2pConnect
(
wifiP2PConfig
);
let
p2pCancelResult
=
wifiMg
.
p2pCancelConnect
();
await
sleep
(
2000
);
await
wifiMg
.
getP2pLinkedInfo
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
...
...
@@ -87,7 +119,6 @@ export default function actsWifiManagerEventTest() {
});
await
sleep
(
2000
);
wifiMg
.
off
(
p2pConnectionState
,
p2pConnectionChangeCallback
);
let
removeP2pGroupResult
=
wifiMg
.
removeP2pGroup
();
done
();
})
...
...
@@ -146,7 +177,7 @@ export default function actsWifiManagerEventTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
2
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
groupName
:
"
DIRECT-
AAAZZZ123
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_AUTO
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
WifiP2PConfig
);
...
...
communication/wifi_p2p/src/main/js/test/WifiManagerP2PFunction.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifiMg
from
'
@ohos.wifiManager
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -27,6 +51,12 @@ function checkWifiPowerOn(){
export
default
function
actsWifiManagerFunctionTest
()
{
describe
(
'
actsWifiManagerFunctionTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
console
.
info
(
"
[wifi_test]beforeEach start
"
);
checkWifiPowerOn
();
...
...
@@ -47,7 +77,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
groupName
:
"
DIRECT-
AAAZZZ123
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifiMg
.
isWifiActive
());
...
...
@@ -116,7 +146,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
1234567
"
,
groupName
:
"
test_pass
"
,
groupName
:
"
DIRECT-
test_pass
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -161,7 +191,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
123@%abcD
"
,
groupName
:
"
test_pass1
"
,
groupName
:
"
DIRECT-
test_pass1
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -203,7 +233,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc345678901234567890123456789012345678901234567890123456789012
"
,
groupName
:
"
test_pass2
"
,
groupName
:
"
DIRECT-
test_pass2
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -245,7 +275,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc3456789012345678901234567890123456789012345678901234567890123
"
,
groupName
:
"
test_pass3
"
,
groupName
:
"
DIRECT-
test_pass3
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -290,7 +320,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band1
"
,
groupName
:
"
DIRECT-
test_band1
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -333,7 +363,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band2
"
,
groupName
:
"
DIRECT-
test_band2
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_5GHZ
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -375,7 +405,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band3
"
,
groupName
:
"
DIRECT-
test_band3
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_AUTO
,
};
let
createP2pGroupResult
=
wifiMg
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -499,7 +529,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
"
,
groupName
:
"
testpassword
"
,
groupName
:
"
DIRECT-
testpassword
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createP2pGroupResult
=
wifi
.
createP2pGroup
(
wifiP2PConfig
);
...
...
@@ -537,7 +567,7 @@ export default function actsWifiManagerFunctionTest() {
deviceAddress
:
"
11:22:33:44:55:66
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
groupName
:
"
DIRECT-
AAAZZZ456
"
,
goBand
:
wifiMg
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
p2pConnectResult
=
wifiMg
.
p2pConnect
(
wifiP2PConfig
);
...
...
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -27,6 +51,12 @@ function checkWifiPowerOn(){
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
console
.
info
(
"
[wifi_test]beforeEach start
"
);
checkWifiPowerOn
();
...
...
@@ -70,11 +100,14 @@ export default function actsWifiEventTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
groupName
:
"
DIRECT-
AAAZZZ456
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_AUTO
};
let
connectResult
=
wifi
.
p2pConnect
(
wifiP2PConfig
);
console
.
info
(
"
[wifi_test]test p2pConnect result.
"
+
connectResult
);
let
p2pCancelResult
=
wifi
.
p2pCancelConnect
();
await
sleep
(
2000
);
console
.
info
(
"
[wifi_test]test p2pCancelConnect result.
"
+
p2pCancelResult
);
await
wifi
.
getP2pLinkedInfo
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
...
...
@@ -84,9 +117,6 @@ export default function actsWifiEventTest() {
});
await
sleep
(
2000
);
wifi
.
off
(
p2pConnectionState
,
p2pConnectionChangeCallback
);
let
removeGroupResult
=
wifi
.
removeGroup
();
console
.
info
(
"
[wifi_test]test start removeGroup:
"
+
removeGroupResult
);
expect
(
removeGroupResult
).
assertTrue
();
done
();
})
...
...
@@ -147,7 +177,7 @@ export default function actsWifiEventTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
2
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
groupName
:
"
DIRECT-
AAAZZZ123
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_AUTO
,
};
let
createGroupResult
=
wifi
.
createGroup
(
WifiP2PConfig
);
...
...
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -27,6 +51,12 @@ function checkWifiPowerOn(){
export
default
function
actsWifiFunctionTest
()
{
describe
(
'
actsWifiFunctionTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
console
.
info
(
"
[wifi_test]beforeEach start
"
);
checkWifiPowerOn
();
...
...
@@ -47,7 +77,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ123
"
,
groupName
:
"
DIRECT-
AAAZZZ123
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
console
.
log
(
"
[wifi_test]check the state of wifi:
"
+
wifi
.
isWifiActive
());
...
...
@@ -119,7 +149,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
1234567
"
,
groupName
:
"
test_pass
"
,
groupName
:
"
DIRECT-
test_pass
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -167,7 +197,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
123@%abcD
"
,
groupName
:
"
test_pass1
"
,
groupName
:
"
DIRECT-
test_pass1
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -212,7 +242,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc345678901234567890123456789012345678901234567890123456789012
"
,
groupName
:
"
test_pass2
"
,
groupName
:
"
DIRECT-
test_pass2
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -257,7 +287,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
abc3456789012345678901234567890123456789012345678901234567890123
"
,
groupName
:
"
test_pass3
"
,
groupName
:
"
DIRECT-
test_pass3
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -305,7 +335,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band1
"
,
groupName
:
"
DIRECT-
test_band1
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -351,7 +381,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band2
"
,
groupName
:
"
DIRECT-
test_band2
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_5GHZ
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -396,7 +426,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
00:00:00:00:00:00
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
test_band3
"
,
groupName
:
"
DIRECT-
test_band3
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_AUTO
,
};
let
createGroupResult
=
wifi
.
createGroup
(
wifiP2PConfig
);
...
...
@@ -438,7 +468,7 @@ export default function actsWifiFunctionTest() {
deviceAddress
:
"
11:22:33:44:55:66
"
,
netId
:
-
1
,
passphrase
:
"
12345678
"
,
groupName
:
"
AAAZZZ456
"
,
groupName
:
"
DIRECT-
AAAZZZ456
"
,
goBand
:
wifi
.
GroupOwnerBand
.
GO_BAND_2GHZ
,
};
let
p2pConnectResult
=
wifi
.
p2pConnect
(
wifiP2PConfig
);
...
...
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -39,6 +63,12 @@ let wifiSecurityType = {
export
default
function
actsWifiCandidateNetWorkTest
()
{
describe
(
'
actsWifiCandidateNetWorkTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -55,7 +85,7 @@ export default function actsWifiCandidateNetWorkTest() {
it
(
'
Communication_WiFi_XTS_UntrustedConfig_0001
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_PSK
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -87,7 +117,7 @@ export default function actsWifiCandidateNetWorkTest() {
it
(
'
Communication_WiFi_XTS_UntrustedConfig_0002
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TYPE_PSK1
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
communication/wifi_standard/src/main/js/test/WifiManagerCandidateNetWork.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifiMg
from
'
@ohos.wifiManager
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -40,6 +64,12 @@ let wifiSecurityType = {
export
default
function
actsWifiManagerCandidateNetWorkTest
()
{
describe
(
'
actsWifiManagerCandidateNetWorkTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
@@ -56,7 +86,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0001
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_OPEN
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
""
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_OPEN
,
...
...
@@ -73,7 +103,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
console
.
info
(
"
[wifi_test]wifi get OPEN CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig
));
let
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TEST_WEP
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
ABCDEF1234
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_WEP
,
...
...
@@ -100,7 +130,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0002
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_PSK
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -147,7 +177,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0003
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_SAE
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_SAE
,
...
...
@@ -190,7 +220,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
console
.
info
(
"
[wifi_test] get canshu result :
"
);
let
wifiDeviceConfig
=
{
"
ssid
"
:
SSID
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -207,7 +237,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
}
let
wifiDeviceConfig1
=
{
"
ssid
"
:
"
TYPE_17
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -247,7 +277,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0005
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
TEST_connect
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -279,7 +309,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
let
configs1
=
wifiMg
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test] wifi get CandidateConfigs result :
"
+
JSON
.
stringify
(
configs1
));
console
.
info
(
"
[wifi_test] getconfig.length result :
"
+
JSON
.
stringify
(
configs1
.
length
));
expect
(
true
).
assertEqual
(
configs1
.
length
==
0
);
expect
(
true
).
assertEqual
(
configs1
.
length
!=
null
);
resolve
();
});
});
...
...
@@ -298,7 +328,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
it
(
'
SUB_Communication_WiFi_XTS_CandidateNetWork_0006
'
,
0
,
async
function
(
done
)
{
let
wifiDeviceConfig
=
{
"
ssid
"
:
"
HONOR 3000
"
,
"
bssid
"
:
""
,
"
bssid
"
:
"
22:9b:e6:48:1f:5c
"
,
"
preSharedKey
"
:
"
12345678
"
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
wifiMg
.
WifiSecurityType
.
WIFI_SEC_TYPE_PSK
,
...
...
@@ -332,7 +362,7 @@ export default function actsWifiManagerCandidateNetWorkTest() {
let
getconfig1
=
wifiMg
.
getCandidateConfigs
();
console
.
info
(
"
[wifi_test]wifi get CandidateConfigs result :
"
+
JSON
.
stringify
(
getconfig1
));
console
.
info
(
"
[wifi_test]wifi getconfig.length result :
"
+
JSON
.
stringify
(
getconfig1
.
length
));
expect
(
true
).
assertEqual
(
getconfig1
.
length
==
0
);
expect
(
true
).
assertEqual
(
getconfig1
.
length
!=
null
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
[wifi_test]remove CandidateConfig promise failed ->
'
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
...
...
communication/wifi_standard/src/main/js/test/WifiManagerStationEvent.test.js
浏览文件 @
19e90bdc
...
...
@@ -18,6 +18,30 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
wifiMg
from
'
@ohos.wifiManager
'
import
wifiManagerExt
from
'
@ohos.wifiManagerExt
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -32,6 +56,12 @@ function resolveIP(ip) {
export
default
function
actsWifiManagerEventTest
()
{
describe
(
'
actsWifiManagerEventTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
communication/wifi_standard/src/main/js/test/WifiManagerStationFunctions.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifiMg
from
'
@ohos.wifiManager
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -40,6 +64,12 @@ let wifiChannelWidth = {
export
default
function
actsWifiManagerFunctionsTest
()
{
describe
(
'
actsWifiManagerFunctionsTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
浏览文件 @
19e90bdc
...
...
@@ -18,7 +18,30 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
wifi
from
'
@ohos.wifi
'
import
wifiext
from
'
@ohos.wifiext
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -39,6 +62,12 @@ let PowerModel = {
export
default
function
actsWifiEventTest
()
{
describe
(
'
actsWifiEventTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
浏览文件 @
19e90bdc
...
...
@@ -16,6 +16,30 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.wifi.wifidevice
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -30,6 +54,12 @@ function resolveIP(ip) {
export
default
function
actsWifiFunctionsTest
()
{
describe
(
'
actsWifiFunctionsTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
function
()
{
checkWifiPowerOn
();
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录