提交 ca648ff7 编写于 作者: Q quanli 提交者: 权力
上级 d3314664
......@@ -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();
}
}
......@@ -58,7 +58,7 @@ export default function nfcATagSessionTest() {
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_Communication_NFC_nfcAtage_js_0001', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0100', 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_0002
* @tc.number SUB_Communication_NFC_nfcAtage_js_0200
* @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_0002', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0200', 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_0003
* @tc.number SUB_Communication_NFC_nfcAtage_js_0300
* @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_0003', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0300', 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_0004
* @tc.number SUB_Communication_NFC_nfcAtage_js_0400
* @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_0004', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0400', 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_0005
* @tc.number SUB_Communication_NFC_nfcAtage_js_0500
* @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_0005', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0500', 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_0006
* @tc.number SUB_Communication_NFC_nfcAtage_js_0600
* @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_0006', 0, function () {
it('SUB_Communication_NFC_nfcAtage_js_0600', 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_0007
* @tc.number SUB_Communication_NFC_nfcAtage_js_0700
* @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_0007', 0, async function (done) {
it('SUB_Communication_NFC_nfcAtage_js_0700', 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_0008
* @tc.number SUB_Communication_NFC_nfcAtage_js_0800
* @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_0008', 0, async function (done) {
it('SUB_Communication_NFC_nfcAtage_js_0800', 0, async function (done) {
let sendDatas = [0x01, 0x02, 0x03, 0x04];
tag.getNfcATag(aTag).sendData(sendDatas, (err, data)=> {
if (err) {
......
......@@ -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*************");
})
}
......
......@@ -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);
})
......
......@@ -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);
})
......
......@@ -198,3 +198,4 @@ export default function actsWifiEventTest() {
console.log("*************[wifi_test] start wifi js unit test end*************");
})
}
......@@ -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 == 5745);
expect(true).assertEqual(5160 < data.frequency < 5865);
});
let removeGroupResult = await wifi.removeGroup();
await sleep(2000);
......
......@@ -14,6 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import wifi from '@ohos.wifi'
function sleep(delay) {
......
......@@ -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() {
})
}
......@@ -76,7 +76,7 @@ export default function actsWifiFunctionsTest() {
/**
* @tc.number SUB_Communication_WiFi_XTS_Sta_0002
* @tc.name testGetScanInfos
* @tc.name testgetScanInfos
* @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 testGetScanInfosSync
* @tc.name testgetScanInfosSync
* @tc.desc Test getScanInfos Sync API functionality.
* @tc.type Function
* @tc.level Level 0
......@@ -325,3 +325,5 @@ export default function actsWifiFunctionsTest() {
})
}
......@@ -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.
先完成此消息的编辑!
想要评论请 注册