Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ca648ff7
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ca648ff7
编写于
10月 30, 2022
作者:
Q
quanli
提交者:
权力
11月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
0d7698e9
from
https://gitee.com/quanli125/xts_acts/pulls/6323
quanli1@huawei.com Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
d3314664
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
1175 addition
and
581 deletion
+1175
-581
communication/nfc_Controller/src/main/js/test/List.test.js
communication/nfc_Controller/src/main/js/test/List.test.js
+2
-0
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
...cation/nfc_Controller/src/main/js/test/nfc.ATagSession.js
+15
-15
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
...nication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
+31
-6
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
...n/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
+44
-50
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
...fc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
+22
-86
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
+800
-0
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
+247
-418
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
+1
-0
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
...ication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
+4
-3
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
...fi_standard/src/main/js/test/WifiCandidateNetWork.test.js
+1
-0
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+2
-0
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
...fi_standard/src/main/js/test/WifiStationFunctions.test.js
+4
-2
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+2
-1
未找到文件。
communication/nfc_Controller/src/main/js/test/List.test.js
浏览文件 @
ca648ff7
...
...
@@ -19,6 +19,7 @@ import nfcIsoDepTagTest from './nfc.IsoDepTag.js'
import
nfcMifareClassicTag
from
'
./nfc.MifareClassicTag.js
'
import
nfcMifareUltralightTag
from
'
./nfc.MifareUltralightTag.js
'
import
nfcTagABFVTest
from
'
./nfc.TagABFV.js
'
import
nfcNDEFTagTest
from
'
./nfc.NDEFTag.js
'
import
parameter
from
'
@ohos.systemparameter
'
;
let
info
=
parameter
.
getSync
(
"
const.SystemCapability.Communication.NFC.Core
"
,
"
false
"
);
export
default
function
testsuite
()
{
...
...
@@ -30,6 +31,7 @@ if (info != "false")
nfcMifareClassicTag
();
nfcMifareUltralightTag
();
nfcTagABFVTest
();
nfcNDEFTagTest
();
}
}
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
浏览文件 @
ca648ff7
...
...
@@ -58,7 +58,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
001
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
100
'
,
0
,
function
()
{
let
NfcConnected
;
try
{
NfcConnected
=
tag
.
getNfcATag
(
aTag
).
connectTag
();
...
...
@@ -70,7 +70,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
002
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
200
* @tc.name testreset
* @tc.desc Test reset api.
* @tc.size MEDIUM
...
...
@@ -78,7 +78,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
002
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
200
'
,
0
,
function
()
{
try
{
tag
.
getNfcATag
(
aTag
).
reset
();
expect
(
true
).
assertTrue
();
...
...
@@ -89,7 +89,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
003
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
300
* @tc.name testisTagConnected
* @tc.desc Test isTagConnected api by callback.
* @tc.size MEDIUM
...
...
@@ -97,7 +97,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
003
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
300
'
,
0
,
function
()
{
let
isNfcConnected
;
try
{
isNfcConnected
=
tag
.
getNfcATag
(
aTag
).
isTagConnected
();
...
...
@@ -109,7 +109,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
004
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
400
* @tc.name testgetMaxSendLength
* @tc.desc Test getMaxSendLength api.
* @tc.size MEDIUM
...
...
@@ -117,7 +117,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
004
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
400
'
,
0
,
function
()
{
let
mazSendLen
;
try
{
mazSendLen
=
tag
.
getNfcATag
(
aTag
).
getMaxSendLength
();
...
...
@@ -130,7 +130,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
005
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
500
* @tc.name testsetSendDataTimeout
* @tc.desc Test setSendDataTimeout api.
* @tc.size MEDIUM
...
...
@@ -138,7 +138,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
005
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
500
'
,
0
,
function
()
{
let
settime
;
try
{
settime
=
tag
.
getNfcATag
(
aTag
).
setSendDataTimeout
(
1000
);
...
...
@@ -150,7 +150,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
006
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
600
* @tc.name testgetSendDataTimeout
* @tc.desc Test getSendDataTimeout api.
* @tc.size MEDIUM
...
...
@@ -158,7 +158,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
006
'
,
0
,
function
()
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
600
'
,
0
,
function
()
{
let
gettime
;
try
{
gettime
=
tag
.
getNfcATag
(
aTag
).
getSendDataTimeout
();
...
...
@@ -171,7 +171,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
007
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
700
* @tc.name testsendData
* @tc.desc Test sendData api by peomise.
* @tc.size MEDIUM
...
...
@@ -179,7 +179,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
007
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
700
'
,
0
,
async
function
(
done
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
await
tag
.
getNfcATag
(
aTag
).
sendData
(
sendDatas
).
then
((
data
)
=>
{
console
.
log
(
"
nfcAtage sendData1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
...
...
@@ -192,7 +192,7 @@ export default function nfcATagSessionTest() {
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
008
* @tc.number SUB_Communication_NFC_nfcAtage_js_0
800
* @tc.name testsendData
* @tc.desc Test sendData api by callback.
* @tc.size MEDIUM
...
...
@@ -200,7 +200,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
008
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_NFC_nfcAtage_js_0
800
'
,
0
,
async
function
(
done
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
tag
.
getNfcATag
(
aTag
).
sendData
(
sendDatas
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
浏览文件 @
ca648ff7
...
...
@@ -44,6 +44,12 @@ let NfcForumType = {
MIFARE_CLASSIC
:
101
,
};
let
FeatureType
=
{
HCE
:
0
,
UICC
:
0
,
ESE
:
0
,
}
let
isoDepTaginfo
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
3
],
...
...
@@ -57,13 +63,13 @@ let isoDepTaginfo = {
],
"
tagRfDiscId
"
:
1
,
};
let
isoDep
;
let
IsoDepTag
;
export
default
function
nfcIsoDepTagTest
()
{
describe
(
'
nfcIsoDepTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
try
{
isoDep
=
tag
.
getIsoDep
(
isoDepTaginfo
);
IsoDepTag
=
tag
.
getIsoDep
(
isoDepTaginfo
);
}
catch
(
error
){
console
.
info
(
'
getIsoDep is ->
'
+
error
)
}
...
...
@@ -87,7 +93,7 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0100
'
,
0
,
function
()
{
let
ResponseFlags
=
isoDep
.
getHistoricalBytes
();
let
ResponseFlags
=
IsoDepTag
.
getHistoricalBytes
();
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
ResponseFlags
);
})
...
...
@@ -101,7 +107,7 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0200
'
,
0
,
function
()
{
let
HiLayerResponse
=
isoDep
.
getHiLayerResponse
();
let
HiLayerResponse
=
IsoDepTag
.
getHiLayerResponse
();
expect
(
HiLayerResponse
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
HiLayerResponse
);
})
...
...
@@ -115,7 +121,7 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0300
'
,
0
,
async
function
(
done
)
{
await
isoDep
.
isExtendedApduSupported
().
then
((
data
)
=>
{
await
IsoDepTag
.
isExtendedApduSupported
().
then
((
data
)
=>
{
expect
(
false
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
data
);
done
();
...
...
@@ -135,7 +141,7 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0400
'
,
0
,
async
function
(
done
)
{
isoDep
.
isExtendedApduSupported
((
err
,
data
)
=>
{
IsoDepTag
.
isExtendedApduSupported
((
err
,
data
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
...
...
@@ -147,6 +153,25 @@ export default function nfcIsoDepTagTest() {
done
();
})
/**
* @tc.number SUB_Communication_NFC_nfccardEmulationnfc_js_0500
* @tc.name Test cardEmulationnfc
* @tc.desc Whether to support a certain type of card emulation.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfccardEmulationnfc_js_0500
'
,
0
,
function
()
{
let
cardEmulationnfc
;
try
{
cardEmulationnfc
=
cardEmulation
.
isSupported
(
FeatureType
.
ESE
);
console
.
info
(
'
cardEmulationnfc type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
){
console
.
info
(
'
cardEmulationnfc error
'
+
error
)
}
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
...
...
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
浏览文件 @
ca648ff7
...
...
@@ -51,13 +51,13 @@ let mifareclassicTaginfo = {
],
"
tagRfDiscId
"
:
1
,
};
let
mifareClassic
=
null
;
let
MifareClassicTag
=
null
;
export
default
function
nfcMifareClassicTag
()
{
describe
(
'
nfcMifareClassicTag
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
try
{
mifareClassic
=
tag
.
getMifareClassic
(
mifareclassicTaginfo
);
MifareClassicTag
=
tag
.
getMifareClassic
(
mifareclassicTaginfo
);
}
catch
(
error
){
console
.
info
(
'
beforeAll mifareClassic error
'
+
error
)
}
...
...
@@ -79,14 +79,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testauthenticateSector
* @tc.desc Test authenticateSector api by callback.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0100
'
,
0
,
async
function
(
done
)
{
let
sectorIndex
=
1
;
let
key
=
[
0x04
,
0x05
];
await
mifareClassic
.
authenticateSector
(
sectorIndex
,
key
,
true
).
then
((
data
)
=>
{
await
MifareClassicTag
.
authenticateSector
(
sectorIndex
,
key
,
true
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic authenticateSector1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
done
();
...
...
@@ -104,14 +104,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testauthenticateSector
* @tc.desc Test authenticateSector api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0200
'
,
0
,
async
function
(
done
)
{
let
sectorIndex
=
1
;
let
key
=
[
0x04
,
0x05
];
mifareClassic
.
authenticateSector
(
sectorIndex
,
key
,
true
,
(
err
,
data
)
=>
{
MifareClassicTag
.
authenticateSector
(
sectorIndex
,
key
,
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic authenticateSector2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -130,19 +130,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testreadSingleBlock
* @tc.desc Test readSingleBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0300
'
,
0
,
async
function
(
done
)
{
let
mifareClassic
;
try
{
mifareClassic
=
tag
.
getMifareClassic
(
mifareclassicTaginfo
);
}
catch
(
error
){
console
.
info
(
'
beforeAll mifareClassic error
'
+
error
)
}
let
blockIndex
=
1
;
await
mifareClassic
.
readSingleBlock
(
blockIndex
).
then
((
data
)
=>
{
await
MifareClassicTag
.
readSingleBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic readSingleBlock1 data:
"
+
data
+
"
json3:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
...
...
@@ -160,13 +154,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testreadSingleBlock
* @tc.desc Test readSingleBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0400
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
readSingleBlock
(
blockIndex
,
(
err
,
data
)
=>
{
MifareClassicTag
.
readSingleBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic readSingleBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -184,14 +178,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testwriteSingleBlock
* @tc.desc Test writeSingleBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0500
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
rawData
=
[
0x0a
,
0x14
];
await
mifareClassic
.
writeSingleBlock
(
blockIndex
,
rawData
).
then
((
data
)
=>
{
await
MifareClassicTag
.
writeSingleBlock
(
blockIndex
,
rawData
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic writeSingleBlock1 data:
"
+
data
+
"
json5:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
done
();
...
...
@@ -209,14 +203,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testwriteSingleBlock
* @tc.desc Test writeSingleBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0600
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
rawData
=
[
0x0a
,
0x14
];
mifareClassic
.
writeSingleBlock
(
blockIndex
,
rawData
,
(
err
,
data
)
=>
{
MifareClassicTag
.
writeSingleBlock
(
blockIndex
,
rawData
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic writeSingleBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -235,14 +229,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testincrementBlock
* @tc.desc Test incrementBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0700
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
await
mifareClassic
.
incrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
await
MifareClassicTag
.
incrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic incrementBlock1 data:
"
+
data
+
"
json7:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
...
...
@@ -260,14 +254,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testincrementBlock
* @tc.desc Test incrementBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0800
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
mifareClassic
.
incrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
MifareClassicTag
.
incrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic incrementBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -286,14 +280,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testdecrementBlock
* @tc.desc Test decrementBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0900
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
await
mifareClassic
.
decrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
await
MifareClassicTag
.
decrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic decrementBlock1 data:
"
+
data
+
"
json9:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
...
...
@@ -311,14 +305,14 @@ export default function nfcMifareClassicTag() {
* @tc.name testdecrementBlock
* @tc.desc Test decrementBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1000
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
mifareClassic
.
decrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
MifareClassicTag
.
decrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic decrementBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -337,13 +331,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testtransferToBlock
* @tc.desc Test transferToBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1100
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
await
mifareClassic
.
transferToBlock
(
blockIndex
).
then
((
data
)
=>
{
await
MifareClassicTag
.
transferToBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic transferToBlock1 data:
"
+
data
+
"
json9:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
...
...
@@ -361,13 +355,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testtransferToBlock
* @tc.desc Test transferToBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1200
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
transferToBlock
(
blockIndex
,
(
err
,
data
)
=>
{
MifareClassicTag
.
transferToBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic transferToBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -386,13 +380,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testrestoreFromBlock
* @tc.desc Test restoreFromBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1300
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
await
mifareClassic
.
restoreFromBlock
(
blockIndex
).
then
((
data
)
=>
{
await
MifareClassicTag
.
restoreFromBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic restoreFromBlock1 data:
"
+
data
+
"
json11:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
...
...
@@ -410,13 +404,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testrestoreFromBlock
* @tc.desc Test restoreFromBlock api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1400
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
restoreFromBlock
(
blockIndex
,
(
err
,
data
)
=>
{
MifareClassicTag
.
restoreFromBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic restoreFromBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -435,12 +429,12 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetSectorCount
* @tc.desc Test getSectorCount api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1500
'
,
0
,
function
()
{
let
sectorCount
=
mifareClassic
.
getSectorCount
();
let
sectorCount
=
MifareClassicTag
.
getSectorCount
();
console
.
info
(
"
mifareClassic sectorCount:
"
+
sectorCount
);
expect
(
sectorCount
).
assertInstanceOf
(
'
Number
'
)
})
...
...
@@ -451,12 +445,12 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetBlockCountInSector
* @tc.desc Test getBlockCountInSector api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1600
'
,
0
,
function
()
{
let
blockCountInSector
=
mifareClassic
.
getBlockCountInSector
();
let
blockCountInSector
=
MifareClassicTag
.
getBlockCountInSector
();
console
.
info
(
"
mifareClassic blockCountInSector:
"
+
blockCountInSector
);
expect
(
blockCountInSector
).
assertInstanceOf
(
'
Number
'
)
})
...
...
@@ -467,12 +461,12 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetType
* @tc.desc Test getType api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1700
'
,
0
,
function
()
{
let
getType
=
mifareClassic
.
getType
();
let
getType
=
MifareClassicTag
.
getType
();
console
.
info
(
"
mifareClassic getType:
"
+
getType
);
expect
(
true
).
assertTrue
(
getType
>=
-
1
);
})
...
...
@@ -483,12 +477,12 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetTagSize
* @tc.desc Test getTagSize api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1800
'
,
0
,
function
()
{
let
tagSize
=
mifareClassic
.
getTagSize
();
let
tagSize
=
MifareClassicTag
.
getTagSize
();
console
.
info
(
"
mifareClassic tagSize:
"
+
tagSize
);
expect
(
tagSize
).
assertInstanceOf
(
'
Number
'
)
})
...
...
@@ -499,12 +493,12 @@ export default function nfcMifareClassicTag() {
* @tc.name testisEmulatedTag
* @tc.desc Test isEmulatedTag api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1900
'
,
0
,
function
()
{
let
isEmulatedTag
=
mifareClassic
.
isEmulatedTag
();
let
isEmulatedTag
=
MifareClassicTag
.
isEmulatedTag
();
console
.
info
(
"
mifareClassic isEmulatedTag:
"
+
isEmulatedTag
);
expect
(
false
).
assertEqual
(
isEmulatedTag
);
})
...
...
@@ -515,13 +509,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetBlockIndex
* @tc.desc Test getBlockIndex api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_2000
'
,
0
,
function
()
{
let
sectorIndex
=
1
;
let
blockIndex
=
mifareClassic
.
getBlockIndex
(
sectorIndex
);
let
blockIndex
=
MifareClassicTag
.
getBlockIndex
(
sectorIndex
);
console
.
info
(
"
mifareClassic blockIndex:
"
+
blockIndex
);
expect
(
true
).
assertTrue
(
blockIndex
>=
0
);
})
...
...
@@ -532,13 +526,13 @@ export default function nfcMifareClassicTag() {
* @tc.name testgetSectorIndex
* @tc.desc Test getSectorIndex api.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_2100
'
,
0
,
function
()
{
let
blockIndex
=
1
;
let
sectorIndex
=
mifareClassic
.
getSectorIndex
(
blockIndex
);
let
sectorIndex
=
MifareClassicTag
.
getSectorIndex
(
blockIndex
);
console
.
info
(
"
mifareClassic sectorIndex:
"
+
sectorIndex
);
expect
(
true
).
assertTrue
(
sectorIndex
>=
0
);
})
...
...
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
浏览文件 @
ca648ff7
...
...
@@ -38,12 +38,26 @@ let mifareUltralightTaginfo = {
"
tagRfDiscId
"
:
1
,
};
let
MifareUltralightType
=
{
TYPE_UNKOWN
:
0x04
,
TYPE_ULTRALIGHT
:
1
,
TYPE_ULTRALIGHT_C
:
2
,
}
let
MifareUltralightTag
=
null
;
export
default
function
nfcMifareUltralightTag
()
{
describe
(
'
nfcMifareUltralightTag
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
})
beforeEach
(
function
()
{
try
{
MifareUltralightTag
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
console
.
info
(
'
mifareUltralight is
'
+
mifareUltralight
)
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
console
.
info
(
'
[NFC_test]beforeEach called
'
)
})
afterEach
(
function
()
{
...
...
@@ -58,20 +72,15 @@ export default function nfcMifareUltralightTag() {
* @tc.name testreadMultiplePages
* @tc.desc Test readMultiplePages api by promise.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0100
'
,
0
,
async
function
(
done
)
{
let
mifareUltralight
;
try
{
mifareUltralight
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
console
.
info
(
'
mifareUltralight is
'
+
mifareUltralight
)
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
let
pageIndex
=
1
;
await
mifareUltralight
.
readMultiplePages
(
pageIndex
).
then
((
data
)
=>
{
await
MifareUltralightTag
.
readMultiplePages
(
pageIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
done
();
...
...
@@ -88,19 +97,13 @@ export default function nfcMifareUltralightTag() {
* @tc.name testreadMultiplePages
* @tc.desc Test readMultiplePages api by callback.
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0200
'
,
0
,
async
function
(
done
)
{
let
mifareUltralight
;
try
{
mifareUltralight
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
let
pageIndex
=
1
;
mifareUltralight
.
readMultiplePages
(
pageIndex
,
(
err
,
data
)
=>
{
MifareUltralightTag
.
readMultiplePages
(
pageIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareUltralight readMultiplePages2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
...
...
@@ -115,82 +118,15 @@ export default function nfcMifareUltralightTag() {
/**
* @tc.number SUB_Communication_NFC_mifareUltralight_0300
* @tc.name testwriteSinglePages
* @tc.desc Test writeSinglePages api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0300
'
,
0
,
async
function
(
done
)
{
let
mifareUltralight
;
try
{
mifareUltralight
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
let
pageIndex
=
1
;
let
datatype
=
[
0x01
,
0x02
];
await
mifareUltralight
.
writeSinglePage
(
pageIndex
,
datatype
).
then
((
data
)
=>
{
console
.
info
(
"
mifareUltralight writeSinglePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight writeSinglePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_mifareUltralight_0400
* @tc.name testwriteSinglePages
* @tc.desc Test writeSinglePages api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0400
'
,
0
,
async
function
(
done
)
{
let
mifareUltralight
;
try
{
mifareUltralight
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
let
pageIndex
=
1
;
let
datatype
=
[
0x01
,
0x02
];
mifareUltralight
.
writeSinglePage
(
pageIndex
,
datatype
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareUltralight writeSinglePages2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareUltralight writeSinglePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
}
});
sleep
(
3000
);
done
();
})
/**
* @tc.number SUB_Communication_NFC_mifareUltralight_0500
* @tc.name testgetType
* @tc.desc Gets the type of Mifare Ultralight label
* @tc.size MEDIUM
* @ since
7
* @ since
9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0500
'
,
0
,
function
()
{
let
mifareUltralight
;
try
{
mifareUltralight
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
}
catch
(
error
){
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
let
getType
=
mifareUltralight
.
getType
();
let
getType
=
MifareUltralightTag
.
getType
();
console
.
info
(
"
mifareUltralight getType:
"
+
getType
);
expect
(
true
).
assertTrue
(
getType
>=
-
1
);
})
...
...
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
0 → 100644
浏览文件 @
ca648ff7
/*
* Copyright (C) 2022 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* 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.
*/
import
tag
from
'
@ohos.nfc.tag
'
;
import
cardEmulation
from
'
@ohos.nfc.cardEmulation
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
function
sleep
(
delay
)
{
// delay x ms
let
start
=
(
new
Date
()).
getTime
();
while
((
new
Date
()).
getTime
()
-
start
<
delay
)
{
continue
;
}
}
let
NdefRecord
=
{
NFC_A
:
1
,
NFC_B
:
2
,
ISO_DEP
:
3
,
NFC_F
:
4
,
NFC_V
:
5
,
NDEF
:
6
,
MIFARE_CLASSIC
:
8
,
MIFARE_ULTRALIGHT
:
9
,
NDEF_FORMATABLE
:
10
,
};
let
NfcForumType
=
{
NFC_FORUM_TYPE_1
:
1
,
NFC_FORUM_TYPE_2
:
2
,
NFC_FORUM_TYPE_3
:
3
,
NFC_FORUM_TYPE_4
:
4
,
MIFARE_CLASSIC
:
101
,
};
let
TnfType
=
{
TNF_EMPTY
:
0x0
,
TNF_WELL_KNOWN
:
0x01
,
TNF_MEDIA
:
0x02
,
TNF_ABSOLUTE_URI
:
0x03
,
TNF_EXT_APP
:
0x04
,
TNF_UNKNOWN
:
0x05
,
TNF_UNCHANGED
:
0x06
,
};
let
NDEFRecordRTD
=
{
RTD_TEXT
:
0x54
,
RTD_URI
:
0x55
,
}
let
NDEFTaginfo
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
6
],
"
extrasData
"
:
[
{
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
},
{
"
NdefMsg
"
:
"
D4010354787473
"
,
"
NdefForumType
"
:
1
,
"
NdefTagLength
"
:
255
,
"
NdefTagMode
"
:
1
,
},
],
"
tagRfDiscId
"
:
1
,
};
let
FeatureType
=
{
HCE
:
0
,
UICC
:
0
,
ESE
:
0
,
};
let
NdefFormatableTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
10
],
"
extrasData
"
:
[
{
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
},
{
},
],
"
tagRfDiscId
"
:
1
,
};
export
default
function
nfcNDEFTagTest
()
{
describe
(
'
nfcNDEFTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]afterAll called
'
)
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0100
* @tc.name Test createNdefMessage NDEF
* @tc.desc Creates an ndef message using the original bytes.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0100
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
console
.
info
(
"
[NFC_test]NdefTag001 ->:
"
+
JSON
.
stringify
(
NdefTag
));
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0100 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefMessage
;
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object1
"
);
try
{
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
expect
(
ndefMessage
!=
null
).
assertTrue
();
expect
(
ndefMessage
instanceof
Object
).
assertTrue
();
console
.
info
(
"
[NFC_test]ndef ndefMessage1:
"
+
ndefMessage
);
}
catch
(
error
){
console
.
info
(
"
[NFC_test]ndef ndefMessage1 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof1 ->:
"
+
typeof
(
NdefTag
));
}
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0200
* @tc.name Test getNdefRecords NDEF
* @tc.desc Obtains all records of ndef messages.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0200
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0200 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object2
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result:
"
);
if
(
ndefMessage
!=
null
&&
ndefMessage
!=
undefined
)
{
console
.
info
(
"
[NFC_test]ndef 1111111111:
"
);
let
ndefRecords
=
ndefMessage
.
getNdefRecords
();
console
.
info
(
"
[NFC_test]ndef ndefRecords number:
"
+
JSON
.
stringify
(
ndefRecords
));
expect
(
ndefRecords
).
assertInstanceOf
(
'
Array
'
)
}
else
{
console
.
info
(
"
[NFC_test]ndef 1222222222:
"
+
error
);
}
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage2 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof2 ->:
"
+
typeof
(
NdefTag
)
);
}
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0300
* @tc.name Test createNdefMessage NDEF
* @tc.desc Creates an ndef message using the original bytes.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0300
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_03001 error
'
+
error
)
}
let
ndefRecords
=
[
{
tnf
:
0x01
,
rtdType
:
[
0x54
],
id
:
[
0x01
,
0x02
],
payload
:
[
0x00
,
0xa4
,
0x04
]},
{
tnf
:
0x02
,
rtdType
:
[
0x55
],
id
:
[
0x03
,
0x04
],
payload
:
[
0x00
,
0xa4
,
0x04
]},
];
let
ndefMessage
;
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
ndefRecords is object3
"
);
try
{
ndefMessage
=
NdefTag
.
createNdefMessage
(
ndefRecords
);
if
(
ndefMessage
!=
null
&&
ndefMessage
!=
undefined
)
{
console
.
info
(
"
[NFC_test]ndef ndefMessage1113:
"
+
ndefMessage
);
expect
(
ndefMessage
!=
null
).
assertTrue
();
expect
(
ndefMessage
instanceof
Object
).
assertTrue
();
}
else
{
console
.
info
(
"
[NFC_test]ndef ndefMessage111:
"
+
error
);
}
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_03002 error
'
+
error
)
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof3 ->:
"
+
typeof
(
NdefTag
)
);
}
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0400
* @tc.name Test getNdefTagType NDEF
* @tc.desc Obtains the type of the Ndef tag.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0400
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0400 error
'
+
error
)
}
let
ndefTagType
=
NdefTag
.
getNdefTagType
();
expect
(
NfcForumType
.
NFC_FORUM_TYPE_1
).
assertEqual
(
ndefTagType
);
console
.
info
(
"
[NFC_test]ndef ndefTagType:
"
+
ndefTagType
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0500
* @tc.name Test getNdefMessage NDEF
* @tc.desc Obtains the message read from the NDEF tag when the tag is discovered.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0500
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_05001 error
'
+
error
)
}
try
{
let
getMessage
=
NdefTag
.
getNdefMessage
();
expect
(
ndefMessage
!=
null
).
assertTrue
();
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_05004
'
+
getMessage
)
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_05001 error
'
+
error
)
}
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0600
* @tc.name Test isNdefWritable NDEF
* @tc.desc Check whether the NDEF label is writable,promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0600
'
,
0
,
async
function
(
done
)
{
let
NdefTag
;
let
NDEFTaginfo
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
6
],
"
extrasData
"
:
[
{
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
},
{
"
NdefMsg
"
:
"
D4010354787473
"
,
"
NdefForumType
"
:
1
,
"
NdefTagLength
"
:
255
,
"
NdefTagMode
"
:
2
,
},
],
"
tagRfDiscId
"
:
1
,
};
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0600 error
'
+
error
)
}
let
data
=
NdefTag
.
isNdefWritable
();
console
.
info
(
"
[NFC_test]ndef isNdefWritable data:
"
+
data
);
expect
(
data
).
assertTrue
();
done
();
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0700
* @tc.name Test readNdef NDEF
* @tc.desc Read the ndef message on the tag,promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0700
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0800 error
'
+
error
)
}
await
NdefTag
.
readNdef
().
then
((
data
)
=>
{
console
.
info
(
"
[NFC_test]ndef readNdef1 data:
"
+
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
ndef readNdef1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0800
* @tc.name Test readNdef NDEF
* @tc.desc Read the ndef message on the tag,callback
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0800
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0800 error
'
+
error
)
}
NdefTag
.
readNdef
((
err
,
data
)
=>
{
if
(
err
)
{
expect
(
true
).
assertEqual
(
true
);
console
.
info
(
"
[NFC_test]ndef readNdef2 err:
"
+
err
);
}
else
{
expect
(
data
!=
true
).
assertTrue
();
console
.
info
(
"
[NFC_test]ndef readNdef2 data:
"
+
data
);
}
});
done
();
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_0900
* @tc.name Test writeNdef NDEF
* @tc.desc Write ndef messages to this tag.promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_0900
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0900 error
'
+
error
)
}
let
ndefMessage
=
NdefTag
.
createNdefMessage
([
0x01
,
0x02
]);
await
NdefTag
.
writeNdef
(
ndefMessage
).
then
((
data
)
=>
{
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
console
.
info
(
"
[NFC_test]ndef writeNdef1 data:
"
+
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
[NFC_test]ndef writeNdef1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1000
* @tc.name Test writeNdef NDEF
* @tc.desc Write ndef messages to this tag.callback
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1000
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1000 error
'
+
error
)
}
let
ndefMessage
=
NdefTag
.
createNdefMessage
([
0x01
,
0x02
]);
NdefTag
.
writeNdef
(
ndefMessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
[NFC_test]ndef writeNdef2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
console
.
info
(
"
[NFC_test]ndef writeNdef2 data:
"
+
data
);
}
});
done
();
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1100
* @tc.name Test canSetReadOnly NDEF
* @tc.desc Check whether the NDEF tag can be set to read-only.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1100
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
console
.
info
(
"
[NFC_test]get NdefTag:
"
+
NdefTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1100 error
'
+
error
)
}
let
canSetReadOnly
=
NdefTag
.
canSetReadOnly
();
console
.
info
(
"
[NFC_test]ndef canSetReadOnly:
"
+
canSetReadOnly
);
expect
(
canSetReadOnly
).
assertTrue
();
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1200
* @tc.name Test setReadOnly NDEF
* @tc.desc Set the Ndef label to read-only.Promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1200
'
,
0
,
async
function
(
done
)
{
let
NdefTag
;
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1200 error
'
+
error
)
}
await
NdefTag
.
setReadOnly
().
then
((
data
)
=>
{
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
console
.
info
(
"
[NFC_test]ndef setReadOnly1 data:
"
+
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
[NFC_test]ndef setReadOnly1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1300
* @tc.name Test setReadOnly NDEF
* @tc.desc Set the Ndef label to read-only.callback
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1300
'
,
0
,
async
function
(
done
)
{
let
NdefTag
;
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1300 error
'
+
error
)
}
NdefTag
.
setReadOnly
((
err
,
data
)
=>
{
if
(
err
)
{
expect
(
true
).
assertEqual
(
true
);
console
.
info
(
"
[NFC_test]ndef setReadOnly2 err:
"
+
err
);
}
else
{
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
console
.
info
(
"
[NFC_test]ndef setReadOnly2 data:
"
+
data
);
}
});
done
();
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1400
* @tc.name Test getNdefTagTypeString NDEF
* @tc.desc Converts the Nfc forum type to the byte array defined in the Nfc forum.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1400
'
,
0
,
function
()
{
let
NdefTag
;
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1400 error
'
+
error
)
}
let
ndefTypeString
=
NdefTag
.
getNdefTagTypeString
(
NfcForumType
.
NFC_FORUM_TYPE_1
);
console
.
info
(
"
[NFC_test]ndef ndefTypeString:
"
+
JSON
.
stringify
(
ndefTypeString
));
expect
(
ndefTypeString
.
length
>=
0
).
assertTrue
();
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1500
* @tc.name Test createNdefMessage NDEF
* @tc.desc Formats the tag as an NDEF tag and writes the NDEF message to the NDEF tag.Promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1500
'
,
0
,
async
function
()
{
let
NdefTag
;
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1600 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
await
NdefFormatable
.
format
(
ndefmessage
).
then
(()
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable format1
"
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable format1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
});
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1600
* @tc.name Test createNdefMessage NDEF
* @tc.desc Formats the tag as an NDEF tag and writes the NDEF message to the NDEF tag.callback
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1600
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1700 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
NdefFormatable
.
format
(
ndefmessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
ndefFormatable format err:
"
+
err
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
"
[NFC_test]ndefFormatable formatReadOnly2
"
);
}
});
done
();
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1700
* @tc.name Test formatReadOnly NDEF
* @tc.desc Format as NDEF and set the NDEF message write label to read-only.Promise
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1700
'
,
0
,
async
function
()
{
let
NdefTag
;
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1800 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
await
NdefFormatable
.
formatReadOnly
(
ndefmessage
).
then
(()
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable formatReadOnly1
"
+
data
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
[NFC_test]ndefFormatable formatReadOnly1 err:
"
+
err
);
expect
(
true
).
assertTrue
();
});
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1800
* @tc.name Test formatReadOnly NDEF
* @tc.desc Format as NDEF and set the NDEF message write label to read-only.callback
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1800
'
,
0
,
async
function
(
done
)
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_1900 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
let
ndefmessage
=
NdefTag
.
createNdefMessage
(
rawData
);
let
NdefFormatable
=
tag
.
getNdefFormatable
(
NdefFormatableTag
);
NdefFormatable
.
formatReadOnly
(
ndefmessage
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
ndefFormatable format err:
"
+
err
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
"
[NFC_test]ndefFormatable formatReadOnly2
"
);
}
});
done
();
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_1900
* @tc.name Test makeUriRecord NDEF
* @tc.desc Obtains all records of ndef makeUriRecord.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_1900
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_0300 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeUriRecord is object3
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeRecords
=
ndefMessage
.
makeUriRecord
(
"
D4010354787473
"
);
console
.
info
(
"
[NFC_test]makeUriRecord result:
"
+
JSON
.
stringify
(
makeRecords
));
expect
(
JSON
.
stringify
(
makeRecords
)
!=
null
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof2 ->:
"
+
typeof
(
NdefTag
)
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_2000
* @tc.name Test createNdefMessage NDEF
* @tc.desc Obtains all records of createNdefMessage NDEF
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_2000
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_2000 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeTextRecord is object4
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result1:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeTRecords
=
ndefMessage
.
makeTextRecord
(
"
test112HW
"
,
"
test
"
);
console
.
info
(
"
[NFC_test]makeTextRecord result1:
"
+
JSON
.
stringify
(
makeTRecords
));
expect
(
JSON
.
stringify
(
makeTRecords
)
!=
null
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage1 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof1 ->:
"
+
typeof
(
NdefTag
)
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_2100
* @tc.name Test makeMimeRecord NDEF
* @tc.desc Obtains all records of ndef makeMimeRecord.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_2100
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_2100 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeMimeRecord is object5
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result2:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeMRecords
=
ndefMessage
.
makeMimeRecord
(
"
BYTE
"
,
"
0112
"
);
console
.
info
(
"
[NFC_test]makeMimeRecord result2:
"
+
JSON
.
stringify
(
makeMRecords
));
expect
(
JSON
.
stringify
(
makeMRecords
)
!=
null
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage2 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof2 ->:
"
+
typeof
(
NdefTag
)
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_2200
* @tc.name Test makeExternalRecord NDEF
* @tc.desc Obtains all records of ndef makeExternalRecord.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_2200
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_2200 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
makeExternalRecord is object6
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result3:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeERecords
=
ndefMessage
.
makeExternalRecord
(
"
NFC
"
,
"
NFCtest
"
,[
0x01
,
0x02
]);
console
.
info
(
"
[NFC_test]makeExternalRecord result13:
"
+
JSON
.
stringify
(
makeERecords
));
expect
(
makeERecords
instanceof
Object
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage3 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof3 ->:
"
+
typeof
(
NdefTag
)
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcNDEF_js_2300
* @tc.name Test messageToBytes NDEF
* @tc.desc Obtains all records of ndef messageToBytes.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcNDEF_js_2300
'
,
0
,
function
()
{
let
NdefTag
try
{
NdefTag
=
tag
.
getNdef
(
NDEFTaginfo
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfcNDEF_js_2300 error
'
+
error
)
}
let
rawData
=
[
0xD1
,
0x01
,
0x03
,
0x54
,
0x4E
,
0x46
,
0x43
];
if
(
NdefTag
!=
undefined
){
console
.
info
(
"
messageToBytes is object7
"
);
try
{
let
ndefMessage
=
NdefTag
.
createNdefMessage
(
rawData
);
console
.
info
(
"
[NFC_test]ndefMessage result4:
"
+
JSON
.
stringify
(
ndefMessage
));
let
makeERecords
=
ndefMessage
.
messageToBytes
(
ndefMessage
);
console
.
info
(
"
[NFC_test]messageToBytes result4:
"
+
JSON
.
stringify
(
makeERecords
));
expect
(
makeERecords
).
assertInstanceOf
(
'
Array
'
)
}
catch
(
error
){
console
.
info
(
"
ndef ndefMessage4 error:
"
+
error
);
}
}
else
{
console
.
info
(
"
[NFC_test]ndef typeof4 ->:
"
+
typeof
(
NdefTag
)
);
}
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
浏览文件 @
ca648ff7
...
...
@@ -24,43 +24,82 @@ function sleep(delay) { // delay x ms
}
}
let
MifareClassicType
=
{
TYPE_UNKNOWN
:
-
1
,
TYPE_CLASSIC
:
0
,
TYPE_PLUS
:
1
,
TYPE_PRO
:
2
,
}
let
NdefRecord
=
{
NFC_A
:
1
,
NFC_B
:
2
,
ISO_DEP
:
3
,
NFC_F
:
4
,
NFC_V
:
5
,
NDEF
:
6
,
MIFARE_CLASSIC
:
8
,
MIFARE_ULTRALIGHT
:
9
,
NDEF_FORMATABLE
:
10
,
};
let
MifareTagSize
=
{
MC_SIZE_MINI
:
320
,
MC_SIZE_1K
:
1024
,
MC_SIZE_2K
:
2048
,
MC_SIZE_4K
:
4096
,
}
let
NfcForumType
=
{
NFC_FORUM_TYPE_1
:
1
,
NFC_FORUM_TYPE_2
:
2
,
NFC_FORUM_TYPE_3
:
3
,
NFC_FORUM_TYPE_4
:
4
,
MIFARE_CLASSIC
:
101
,
};
let
mifareclassicTaginfo
=
{
let
aTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
1
,
8
],
"
technology
"
:
[
1
],
"
extrasData
"
:
[
{
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
},
],
"
tagRfDiscId
"
:
1
,
};
let
bTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
2
],
"
extrasData
"
:
[
{
},
"
AppData
"
:
"
A0C0
"
,
"
ProtocolInfo
"
:
"
131F
"
,
}
],
"
tagRfDiscId
"
:
1
,
};
let
fTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
4
],
"
extrasData
"
:
[
{
"
SystemCode
"
:
"
A0C0
"
,
"
Pmm
"
:
"
131F
"
,
}
],
"
tagRfDiscId
"
:
1
,
};
let
mifareClassic
=
null
;
export
default
function
nfcMifareClassicTag
()
{
describe
(
'
nfcMifareClassicTag
'
,
function
()
{
let
vTag
=
{
"
uid
"
:
[
0x01
,
0x02
,
0x03
,
0x04
],
"
technology
"
:
[
5
],
"
extrasData
"
:
[
{
"
ResponseFlags
"
:
0x09
,
"
DsfId
"
:
0x13
,
}
],
"
tagRfDiscId
"
:
1
,
};
let
Want
=
{
"
uid
"
:
'
01020304
'
,
"
technology
"
:
[
1
],
"
tagRfDiscId
"
:
1
,
"
Sak
"
:
0x08
,
"
Atqa
"
:
"
B000
"
,
}
export
default
function
nfcTagABFVTest
()
{
describe
(
'
nfcTagABFVTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
try
{
mifareClassic
=
tag
.
getMifareClassic
(
mifareclassicTaginfo
);
}
catch
(
error
){
console
.
info
(
'
beforeAll mifareClassic error
'
+
error
)
}
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]beforeEach called
'
)
...
...
@@ -71,478 +110,268 @@ export default function nfcMifareClassicTag() {
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]afterAll called
'
)
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0100
* @tc.name testauthenticateSector
* @tc.desc Test authenticateSector api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0100
* @tc.name Test getNfcATag
* @tc.desc This interface is used to obtain the NFC A tag object.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0100
'
,
0
,
async
function
(
done
)
{
let
sectorIndex
=
1
;
let
key
=
[
0x04
,
0x05
];
await
mifareClassic
.
authenticateSector
(
sectorIndex
,
key
,
true
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic authenticateSector1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic authenticateSector1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0200
* @tc.name testauthenticateSector
* @tc.desc Test authenticateSector api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0200
'
,
0
,
async
function
(
done
)
{
let
sectorIndex
=
1
;
let
key
=
[
0x04
,
0x05
];
mifareClassic
.
authenticateSector
(
sectorIndex
,
key
,
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic authenticateSector2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic authenticateSector2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
}
});
sleep
(
3000
);
done
();
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0300
* @tc.name testreadSingleBlock
* @tc.desc Test readSingleBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0300
'
,
0
,
async
function
(
done
)
{
let
mifareClassic
;
it
(
'
SUB_Communication_NFC_nfctage_js_0100
'
,
0
,
function
()
{
let
NfcATag
;
try
{
mifareClassic
=
tag
.
getMifareClassic
(
mifareclassicTaginfo
);
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
beforeAll mifareClassic
error
'
+
error
)
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0100
error
'
+
error
)
}
let
blockIndex
=
1
;
await
mifareClassic
.
readSingleBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic readSingleBlock1 data:
"
+
data
+
"
json3:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic readSingleBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0400
* @tc.name testreadSingleBlock
* @tc.desc Test readSingleBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0400
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
readSingleBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic readSingleBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic readSingleBlock2 data:
"
+
data
+
"
json4:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Array
'
)
}
});
done
();
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0500
* @tc.name testwriteSingleBlock
* @tc.desc Test writeSingleBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0500
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
rawData
=
[
0x0a
,
0x14
];
await
mifareClassic
.
writeSingleBlock
(
blockIndex
,
rawData
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic writeSingleBlock1 data:
"
+
data
+
"
json5:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic writeSingleBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0600
* @tc.name testwriteSingleBlock
* @tc.desc Test writeSingleBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0600
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
rawData
=
[
0x0a
,
0x14
];
mifareClassic
.
writeSingleBlock
(
blockIndex
,
rawData
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic writeSingleBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic writeSingleBlock2 data:
"
+
data
+
"
json6:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
}
});
sleep
(
3000
);
done
();
})
expect
(
NfcATag
!=
null
).
assertTrue
();
expect
(
NfcATag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0700
* @tc.name testincrementBlock
* @tc.desc Test incrementBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0200
* @tc.name Test getNfcBTag
* @tc.desc This interface is used to obtain the NFC B tag object.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0700
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
await
mifareClassic
.
incrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic incrementBlock1 data:
"
+
data
+
"
json7:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic incrementBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0800
* @tc.name testincrementBlock
* @tc.desc Test incrementBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0800
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
mifareClassic
.
incrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic incrementBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic incrementBlock2 data:
"
+
data
+
"
json8:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
}
});
sleep
(
3000
);
done
();
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_0900
* @tc.name testdecrementBlock
* @tc.desc Test decrementBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_0900
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
await
mifareClassic
.
decrementBlock
(
blockIndex
,
value
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic decrementBlock1 data:
"
+
data
+
"
json9:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic decrementBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
it
(
'
SUB_Communication_NFC_nfctage_js_0200
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0200 error
'
+
error
)
}
expect
(
NfcBTag
!=
null
).
assertTrue
();
expect
(
NfcBTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
bTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1000
* @tc.name testdecrementBlock
* @tc.desc Test decrementBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0300
* @tc.name Test getNfcFTag
* @tc.desc This interface is used to obtain the NFC F tag object.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1000
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
let
value
=
0x20
;
mifareClassic
.
decrementBlock
(
blockIndex
,
value
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic decrementBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic decrementBlock2 data:
"
+
data
+
"
json10:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
}
});
sleep
(
3000
);
done
();
})
it
(
'
SUB_Communication_NFC_nfctage_js_0300
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0300 error
'
+
error
)
}
expect
(
NfcFTag
!=
null
).
assertTrue
();
expect
(
NfcFTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
fTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1100
* @tc.name testtransferToBlock
* @tc.desc Test transferToBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0400
* @tc.name Test getNfcVTag
* @tc.desc This interface is used to obtain the NFC V tag object.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1100
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
await
mifareClassic
.
transferToBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic transferToBlock1 data:
"
+
data
+
"
json9:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic transferToBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
})
it
(
'
SUB_Communication_NFC_nfctage_js_0400
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0400 error
'
+
error
)
}
expect
(
NfcVTag
!=
null
).
assertTrue
();
expect
(
NfcVTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
vTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1200
* @tc.name testtransferToBlock
* @tc.desc Test transferToBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0500
* @tc.name Test getsak_taga
* @tc.desc Obtains the SAK value of the NFC-A tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1200
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
transferToBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic transferToBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic transferToBlock2 data:
"
+
data
+
"
json10:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
}
});
sleep
(
3000
);
done
();
it
(
'
SUB_Communication_NFC_nfctage_js_0500
'
,
0
,
function
()
{
let
NfcATag
;
try
{
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0500 error
'
+
error
)
}
let
sak
=
NfcATag
.
getSak
();
expect
(
sak
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test sak data>:
'
+
sak
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1300
* @tc.name testrestoreFromBlock
* @tc.desc Test restoreFromBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0600
* @tc.name Test getAtqa_taga
* @tc.desc Obtains the Atqa value of the NFC-A tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1300
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
await
mifareClassic
.
restoreFromBlock
(
blockIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareClassic restoreFromBlock1 data:
"
+
data
+
"
json11:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareClassic restoreFromBlock1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
it
(
'
SUB_Communication_NFC_nfctage_js_0600
'
,
0
,
function
()
{
let
NfcATag
;
try
{
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0600 error
'
+
error
)
}
let
Atqa
=
NfcATag
.
getAtqa
();
expect
(
Atqa
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Atqa data>:
'
+
Atqa
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1400
* @tc.name testrestoreFromBlock
* @tc.desc Test restoreFromBlock api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0700
* @tc.name Test getAppData_tagB
* @tc.desc Obtains the AppData value of the NFC-B tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1400
'
,
0
,
async
function
(
done
)
{
let
blockIndex
=
1
;
mifareClassic
.
restoreFromBlock
(
blockIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
"
mifareClassic restoreFromBlock2 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareClassic restoreFromBlock2 data:
"
+
data
+
"
json12:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertInstanceOf
(
'
Number
'
)
}
});
sleep
(
3000
);
done
();
it
(
'
SUB_Communication_NFC_nfctage_js_0700
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0700 error
'
+
error
)
}
let
AppData
=
NfcBTag
.
getRespAppData
();
expect
(
AppData
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test AppData data>:
'
+
AppData
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1500
* @tc.name testgetSectorCount
* @tc.desc Test getSectorCount api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0800
* @tc.name Test getRespProtocol_tagB
* @tc.desc Obtains the Protocol value of the NFC-B tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1500
'
,
0
,
function
()
{
let
sectorCount
=
mifareClassic
.
getSectorCount
();
console
.
info
(
"
mifareClassic sectorCount:
"
+
sectorCount
);
expect
(
sectorCount
).
assertInstanceOf
(
'
Number
'
)
it
(
'
SUB_Communication_NFC_nfctage_js_0800
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0800 error
'
+
error
)
}
let
Protocol
=
NfcBTag
.
getRespProtocol
();
expect
(
Protocol
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Protocol data>:
'
+
Protocol
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1600
* @tc.name testgetBlockCountInSector
* @tc.desc Test getBlockCountInSector api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_0900
* @tc.name Test getSystemCode_tagF
* @tc.desc Obtains the SystemCode value of the NFC-F tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1600
'
,
0
,
function
()
{
let
blockCountInSector
=
mifareClassic
.
getBlockCountInSector
();
console
.
info
(
"
mifareClassic blockCountInSector:
"
+
blockCountInSector
);
expect
(
blockCountInSector
).
assertInstanceOf
(
'
Number
'
)
it
(
'
SUB_Communication_NFC_nfctage_js_0900
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0900 error
'
+
error
)
}
let
SystemCode
=
NfcFTag
.
getSystemCode
();
expect
(
SystemCode
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test SystemCode data>:
'
+
SystemCode
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1700
* @tc.name testgetType
* @tc.desc Test getType api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_1000
* @tc.name Test getPmm_tagF
* @tc.desc Obtains the getPmm value of the NFC-F tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1700
'
,
0
,
function
()
{
let
getType
=
mifareClassic
.
getType
();
console
.
info
(
"
mifareClassic getType:
"
+
getType
);
expect
(
true
).
assertTrue
(
getType
>=
-
1
);
it
(
'
SUB_Communication_NFC_nfctage_js_1000
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1000 error
'
+
error
)
}
let
Pmm
=
NfcFTag
.
getPmm
();
expect
(
Pmm
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Pmm data>:
'
+
Pmm
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1800
* @tc.name testgetTagSize
* @tc.desc Test getTagSize api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_1100
* @tc.name Test getResponseFlags_tagV
* @tc.desc Obtains the ResponseFlags value of the NFC-V tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1800
'
,
0
,
function
()
{
let
tagSize
=
mifareClassic
.
getTagSize
();
console
.
info
(
"
mifareClassic tagSize:
"
+
tagSize
);
expect
(
tagSize
).
assertInstanceOf
(
'
Number
'
)
it
(
'
SUB_Communication_NFC_nfctage_js_1100
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1100 error
'
+
error
)
}
let
ResponseFlags
=
NfcVTag
.
getResponseFlags
();
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
ResponseFlags
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_1900
* @tc.name testisEmulatedTag
* @tc.desc Test isEmulatedTag api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_1200
* @tc.name Test getDsfId_tagV
* @tc.desc Obtains the DsfId value of the NFC-V tag.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_1900
'
,
0
,
function
()
{
let
isEmulatedTag
=
mifareClassic
.
isEmulatedTag
();
console
.
info
(
"
mifareClassic isEmulatedTag:
"
+
isEmulatedTag
);
expect
(
false
).
assertEqual
(
isEmulatedTag
);
it
(
'
SUB_Communication_NFC_nfctage_js_1200
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1200 error
'
+
error
)
}
let
DsfId
=
NfcVTag
.
getDsfId
();
expect
(
DsfId
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test DsfId data>:
'
+
DsfId
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_2000
* @tc.name testgetBlockIndex
* @tc.desc Test getBlockIndex api.
* @tc.size MEDIUM
* @ since 7
* @tc.number SUB_Communication_NFC_nfctage_js_1300
* @tc.name Test getTagInfo
* @tc.desc Obtains the DsfId value of the taginfo.
* @tc.size since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_2000
'
,
0
,
function
()
{
let
sectorIndex
=
1
;
let
blockIndex
=
mifareClassic
.
getBlockIndex
(
sectorIndex
);
console
.
info
(
"
mifareClassic blockIndex:
"
+
blockIndex
);
expect
(
true
).
assertTrue
(
blockIndex
>=
0
);
it
(
'
SUB_Communication_NFC_nfctage_js_1300
'
,
0
,
function
()
{
let
TagInfo
;
try
{
TagInfo
=
tag
.
getTagInfo
(
Want
);
console
.
info
(
'
SUB_Communication_NFC_nfctage_js1111111
'
+
TagInfo
)
expect
(
TagInfo
instanceof
Object
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1300 error
'
+
error
)
expect
(
true
).
assertTrue
();
}
console
.
info
(
'
[nfc_js] test TagInfo data>:
'
+
TagInfo
);
})
/**
* @tc.number SUB_Communication_NFC_mifareClassic_js_2100
* @tc.name testgetSectorIndex
* @tc.desc Test getSectorIndex api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareClassic_js_2100
'
,
0
,
function
()
{
let
blockIndex
=
1
;
let
sectorIndex
=
mifareClassic
.
getSectorIndex
(
blockIndex
);
console
.
info
(
"
mifareClassic sectorIndex:
"
+
sectorIndex
);
expect
(
true
).
assertTrue
(
sectorIndex
>=
0
);
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
...
...
communication/wifi_p2p/src/main/js/test/WifiP2PEvent.test.js
浏览文件 @
ca648ff7
...
...
@@ -198,3 +198,4 @@ export default function actsWifiEventTest() {
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
communication/wifi_p2p/src/main/js/test/WifiP2PFunction.test.js
浏览文件 @
ca648ff7
...
...
@@ -85,6 +85,8 @@ export default function actsWifiFunctionTest() {
"
passphrase:
"
+
result
.
passphrase
+
"
interface:
"
+
result
.
interface
+
"
groupName:
"
+
result
.
groupName
+
"
frequency:
"
+
result
.
frequency
+
"
goIpAddress:
"
+
result
.
goIpAddress
);
console
.
info
(
"
[wifi_test] clientDevices:
"
+
JSON
.
stringify
(
result
.
clientDevices
));
console
.
info
(
"
[wifi_test] ownerInfo:
"
+
JSON
.
stringify
(
result
.
WifiP2pDevice
));
resolve
();
});
});
...
...
@@ -124,7 +126,6 @@ export default function actsWifiFunctionTest() {
expect
(
createGroupResult
).
assertTrue
();
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
let
resultLength
=
Object
.
keys
(
data
).
length
;
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
networkId
==
-
999
);
});
...
...
@@ -274,7 +275,7 @@ export default function actsWifiFunctionTest() {
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test]getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
frequency
==
2412
);
expect
(
true
).
assertEqual
(
2412
<
data
.
frequency
<
2484
);
});
let
removeGroupResult
=
wifi
.
removeGroup
();
await
sleep
(
2000
);
...
...
@@ -312,7 +313,7 @@ export default function actsWifiFunctionTest() {
await
wifi
.
getCurrentGroup
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test] getCurrentGroup promise result :
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
frequency
==
574
5
);
expect
(
true
).
assertEqual
(
5160
<
data
.
frequency
<
586
5
);
});
let
removeGroupResult
=
await
wifi
.
removeGroup
();
await
sleep
(
2000
);
...
...
communication/wifi_standard/src/main/js/test/WifiCandidateNetWork.test.js
浏览文件 @
ca648ff7
...
...
@@ -14,6 +14,7 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
...
...
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
浏览文件 @
ca648ff7
...
...
@@ -17,6 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
wifi
from
'
@ohos.wifi
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
...
...
@@ -166,3 +167,4 @@ export default function actsWifiEventTest() {
})
}
communication/wifi_standard/src/main/js/test/WifiStationFunctions.test.js
浏览文件 @
ca648ff7
...
...
@@ -76,7 +76,7 @@ export default function actsWifiFunctionsTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name test
G
etScanInfos
* @tc.name test
g
etScanInfos
* @tc.desc Test getScanInfos promise and callback API functionality.
* @tc.type Function
* @tc.level Level 0
...
...
@@ -308,7 +308,7 @@ export default function actsWifiFunctionsTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0034
* @tc.name test
G
etScanInfosSync
* @tc.name test
g
etScanInfosSync
* @tc.desc Test getScanInfos Sync API functionality.
* @tc.type Function
* @tc.level Level 0
...
...
@@ -325,3 +325,5 @@ export default function actsWifiFunctionsTest() {
})
}
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
ca648ff7
...
...
@@ -188,7 +188,8 @@ describe('geolocationTest_geo1', function () {
+
JSON
.
stringify
(
data
)[
0
].
placeName
+
JSON
.
stringify
(
data
)[
0
].
postalCode
+
JSON
.
stringify
(
data
)[
0
].
premises
+
JSON
.
stringify
(
data
)[
0
].
roadName
+
JSON
.
stringify
(
data
)[
0
].
subAdministrativeArea
+
JSON
.
stringify
(
data
)[
0
].
subLocality
+
JSON
.
stringify
(
data
)[
0
].
subRoadName
);
+
JSON
.
stringify
(
data
)[
0
].
subLocality
+
JSON
.
stringify
(
data
)[
0
].
subRoadName
+
JSON
.
stringify
(
data
)[
0
].
isFromMock
);
done
();
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise then error.
"
+
JSON
.
stringify
(
error
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录