Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
81d9f187
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看板
提交
81d9f187
编写于
11月 29, 2022
作者:
Q
quanli
提交者:
权力
1月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
6f2d3255
from
https://gitee.com/quanli125/xts_acts/pulls/7205
quanli1@huawei.com Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
32e66d66
变更
20
展开全部
显示空白变更内容
内联
并排
Showing
20 changed file
with
1605 addition
and
980 deletion
+1605
-980
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
...tion/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
+10
-9
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+63
-48
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+19
-30
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+4
-9
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
.../bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
+19
-39
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
...n/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
+12
-25
communication/bluetooth_standard/signature/openharmony_sx.p7b
...unication/bluetooth_standard/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
...n/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
+25
-12
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+20
-27
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
...ication/bluetooth_standard/src/main/js/test/BRSpp.test.js
+2
-4
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
...tion/bluetooth_standard/src/main/js/test/BRSwitch.test.js
+11
-20
communication/nfc_Controller/src/main/js/test/List.test.js
communication/nfc_Controller/src/main/js/test/List.test.js
+2
-3
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
...cation/nfc_Controller/src/main/js/test/nfc.ATagSession.js
+215
-49
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
...ation/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
+176
-20
communication/nfc_Controller/src/main/js/test/nfc.Controller.js
...ication/nfc_Controller/src/main/js/test/nfc.Controller.js
+11
-4
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
...nication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
+110
-31
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
...n/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
+338
-218
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
...fc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
+79
-55
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
+285
-314
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
+204
-63
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
浏览文件 @
81d9f187
...
...
@@ -89,7 +89,7 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
150
,
txPower
:
6
0
,
txPower
:
-
1
0
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -145,7 +145,7 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
20
,
txPower
:
6
0
,
txPower
:
-
1
0
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -200,8 +200,8 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1
63
85
,
txPower
:
6
0
,
interval
:
1
04
85
,
txPower
:
-
1
0
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -256,8 +256,8 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
2
]
=
7
;
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1
64
00
,
txPower
:
6
0
,
interval
:
1
05
00
,
txPower
:
-
1
0
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -313,7 +313,7 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
19
,
txPower
:
6
0
,
txPower
:
-
1
0
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -705,7 +705,7 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
70
,
txPower
:
-
7
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -761,7 +761,7 @@ describe('bluetoothBLETest2', function() {
serviceValueBuffer
[
3
]
=
8
;
let
setting
=
{
interval
:
1000
,
txPower
:
70
,
txPower
:
-
7
,
connectable
:
true
,
}
let
advData
=
{
...
...
@@ -976,3 +976,4 @@ describe('bluetoothBLETest2', function() {
})
}
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
浏览文件 @
81d9f187
...
...
@@ -376,11 +376,13 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
'
,
0
,
async
function
(
done
)
{
try
{
let
descriptors
=
[];
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
...
...
@@ -391,19 +393,22 @@ describe('bluetoothBLETest', function() {
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferCCC
,
descriptors
:
descriptors
};
await
gattClient
.
readCharacteristicValue
(
characteristic
).
then
((
data
)
=>
{
if
(
object
!=
null
)
{
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js] readCharacValue promise data:
'
+
JSON
.
stringify
(
data
));
expect
(
null
).
assertFail
();
}
expect
(
true
).
assertEqual
(
data
.
length
>=
0
);
done
();
}).
catch
(
err
=>
{
console
.
error
(
`bluetooth readCharacteValue
promise has error:
${
err
}
`
);
console
.
error
(
`bluetooth readCharacteValue01
promise has error:
${
err
}
`
);
expect
(
true
).
assertEqual
(
true
);
done
();
})
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]readDescrValue01 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
undefined
);
done
()
}
})
/**
...
...
@@ -429,6 +434,7 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
...
...
@@ -465,7 +471,6 @@ describe('bluetoothBLETest', function() {
console
.
info
(
'
[bluetooth_js] sendResponse ret :
'
+
ret
);
expect
(
ret
).
assertEqual
(
false
);
}
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
await
gattServer
.
on
(
"
characteristicRead
"
,
ReadCharacteristicReq
);
await
gattServer
.
off
(
"
characteristicRead
"
);
...
...
@@ -482,27 +487,28 @@ describe('bluetoothBLETest', function() {
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100
'
,
0
,
async
function
(
done
)
{
try
{
let
arrayBuffer
=
new
ArrayBuffer
(
8
);
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
await
gattClient
.
readDescriptorValue
(
descriptor
).
then
((
object
)
=>
{
if
(
object
!=
null
)
{
console
.
error
(
'
readDescriptorValue promise object:
'
+
JSON
.
stringify
(
object
));
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
'
[bluetooth_js]readDescripValue null:
'
+
JSON
.
stringify
(
object
));
expect
(
null
).
assertFail
();
}
expect
(
true
).
assertEqual
(
object
!=
null
);
done
();
}).
catch
(
err
=>
{
console
.
error
(
'
[bluetooth_js]readDescrValue promise err:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
[bluetooth_js]readDescrValue promise err:
'
+
JSON
.
stringify
(
err
))
expect
(
true
).
assertEqual
(
true
);
done
();
})
}
catch
(
error
)
{
console
.
error
(
'
[bluetooth_js]readDescrValue01 error code:
'
+
JSON
.
stringify
(
error
.
code
));
expect
(
error
.
code
).
assertEqual
(
undefined
);
done
()
}
})
/**
...
...
@@ -528,6 +534,7 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
gattClient
.
readDescriptorValue
(
descriptor
,
readDesc
);
done
()
...
...
@@ -584,6 +591,7 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
descriptors
[
0
]
=
descriptor
;
let
arrayBufferCCC
=
new
ArrayBuffer
(
8
);
...
...
@@ -659,6 +667,7 @@ describe('bluetoothBLETest', function() {
let
desValue
=
new
Uint8Array
(
arrayBuffer
);
desValue
[
0
]
=
11
;
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
ret
=
gattClient
.
writeDescriptorValue
(
descriptor
);
console
.
info
(
'
[bluetooth_js] bluetooth writeDescriptorValue ret :
'
+
ret
);
...
...
@@ -737,9 +746,11 @@ describe('bluetoothBLETest', function() {
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotify
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBufferNotify
};
descriptors
[
0
]
=
descriptor
;
...
...
@@ -773,9 +784,11 @@ describe('bluetoothBLETest', function() {
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotify
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00002902-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBufferNotify
};
descriptors
[
0
]
=
descriptor
;
...
...
@@ -831,6 +844,7 @@ describe('bluetoothBLETest', function() {
let
descNotifyValue
=
new
Uint8Array
(
arrayBufferNotify
);
descNotifyValue
[
0
]
=
1
let
descriptor
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
descriptorUuid
:
'
00001830-0000-1000-8000-00805F9B34FB
'
,
descriptorValue
:
arrayBuffer
};
let
descriptorNotify
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
...
...
@@ -870,3 +884,4 @@ describe('bluetoothBLETest', function() {
}
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
81d9f187
...
...
@@ -15,18 +15,6 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ScanDuty
=
{
SCAN_MODE_LOW_POWER
:
0
,
SCAN_MODE_BALANCED
:
1
,
SCAN_MODE_LOW_LATENCY
:
2
,
};
let
MatchMode
=
{
MATCH_MODE_AGGRESSIVE
:
1
,
MATCH_MODE_STICKY
:
2
,
};
export
default
function
bluetoothhostTest
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
...
...
@@ -190,8 +178,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
100
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -218,8 +206,8 @@ describe('bluetoothhostTest', function() {
}
let
ScanOptions
=
{
interval
:
100
,
dutyMode
:
ScanDuty
.
SCAN_MODE_BALANCED
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{}],
ScanOptions
);
...
...
@@ -250,8 +238,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
100
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -284,8 +272,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
100
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -315,8 +303,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
0
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -346,8 +334,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
500
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -377,8 +365,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
500
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
);
await
sleep
(
1000
);
...
...
@@ -408,8 +396,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
500
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
MatchMode
.
MATCH_MODE_STICKY
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_STICKY
,
}
);
await
sleep
(
1000
);
...
...
@@ -613,8 +601,8 @@ describe('bluetoothhostTest', function() {
[{}],
{
interval
:
500
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
MatchMode
.
MATCH_MODE_STICKY
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_STICKY
,
}
);
console
.
info
(
'
[bluetooth_js] BLE scan offC
'
);
...
...
@@ -627,3 +615,4 @@ describe('bluetoothhostTest', function() {
})
}
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
81d9f187
...
...
@@ -283,21 +283,15 @@ describe('bluetoothhostTest2', function() {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0900
'
,
0
,
async
function
(
done
)
{
let
BondState
=
{
BOND_STATE_INVALID
:
0
,
BOND_STATE_BONDING
:
1
,
BOND_STATE_BONDED
:
2
};
function
BondStateParam
(
data
)
{
console
.
info
(
"
[bluetooth_js] bondStateChange on:
"
+
JSON
.
stringify
(
data
)
+
'
bondStateChange deviceId:
'
+
data
.
deviceId
+
'
bondStateChange state:
'
+
data
.
state
);
}
bluetooth
.
BLE
.
on
(
'
bondStateChange
'
,
BondStateParam
);
let
result
=
bluetooth
.
pairDevice
(
"
11:22:55:66:33:44
"
);
expect
(
BondState
.
BOND_STATE_INVALID
==
0
).
assertTrue
();
expect
(
BondState
.
BOND_STATE_BONDING
==
1
).
assertTrue
();
expect
(
BondState
.
BOND_STATE_BONDED
==
2
).
assertTrue
();
expect
(
bluetooth
.
BondState
.
BOND_STATE_INVALID
==
0
).
assertTrue
();
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDING
==
1
).
assertTrue
();
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDED
==
2
).
assertTrue
();
bluetooth
.
BLE
.
off
(
'
bondStateChange
'
,
BondStateParam
);
done
()
})
...
...
@@ -308,3 +302,4 @@ describe('bluetoothhostTest2', function() {
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
浏览文件 @
81d9f187
...
...
@@ -17,27 +17,6 @@ import bluetooth from '@ohos.bluetooth';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ProfileId
=
{
PROFILE_A2DP_SOURCE
:
1
,
PROFILE_HANDS_FREE_AUDIO_GATEWAY
:
4
,
PROFILE_HID_HOST
:
6
,
PROFILE_PAN_NETWORK
:
7
}
let
PlayingState
=
{
STATE_NOT_PLAYING
:
0x0000
,
STATE_PLAYING
:
0x0001
,
}
let
ProfileConnectionState
=
{
STATE_CONNECTING
:
1
,
STATE_CONNECTED
:
2
,
STATE_DISCONNECTED
:
0
,
STATE_DISCONNECTING
:
3
}
export
default
function
bluetoothhostTest_host_1
()
{
describe
(
'
bluetoothhostTest_host_1
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -97,10 +76,10 @@ describe('bluetoothhostTest_host_1', function () {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0100
'
,
0
,
async
function
(
done
)
{
let
connState
=
bluetooth
.
getBtConnectionState
();
console
.
info
(
'
[bluetooth_js] get bt connection state result
'
+
JSON
.
stringify
(
connState
));
expect
(
connState
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
expect
(
connState
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
done
();
})
...
...
@@ -119,7 +98,7 @@ describe('bluetoothhostTest_host_1', function () {
'
deviceId:
'
+
data
.
deviceId
+
'
state:
'
+
data
.
state
);
expect
(
true
).
assertEqual
(
data
!=
null
);
}
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
a2dpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
a2dpSrc
.
connect
(
'
11:22:33:44:55:77
'
);
...
...
@@ -145,7 +124,7 @@ describe('bluetoothhostTest_host_1', function () {
'
deviceId:
'
+
data
.
deviceId
+
'
state:
'
+
data
.
state
);
expect
(
true
).
assertEqual
(
data
!=
null
);
}
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
a2dpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
await
sleep
(
6000
);
...
...
@@ -166,7 +145,7 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0400
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
let
conn
=
a2dpSrc
.
disconnect
(
'
test
'
);
console
.
info
(
'
[bluetooth_js]a2dp disconnect1 result:
'
+
JSON
.
stringify
(
conn
));
...
...
@@ -184,9 +163,9 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0500
'
,
0
,
async
function
(
done
)
{
let
a2dpSrcConn
=
bluetooth
.
getProfileConnState
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrcConn
=
bluetooth
.
getProfileConnState
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]get a2dp result:
'
+
JSON
.
stringify
(
a2dpSrcConn
));
expect
(
a2dpSrcConn
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
a2dpSrcConn
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -200,7 +179,7 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0600
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
Inst
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
conn
=
a2dpSrc
.
connect
(
'
test
'
);
console
.
info
(
'
[bluetooth_js]a2dp invaild connect:
'
+
JSON
.
stringify
(
conn
));
expect
(
conn
).
assertFalse
();
...
...
@@ -217,10 +196,10 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0700
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
let
ret
=
a2dpSrc
.
getDeviceState
(
'
11:22:33:44:55:66
'
);
expect
(
ret
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
ret
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -234,10 +213,10 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0800
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
let
ret
=
a2dpSrc
.
getDeviceState
(
'
test
'
);
expect
(
ret
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
ret
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -251,12 +230,12 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0900
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
let
state
=
a2dpSrc
.
getPlayingState
(
'
11:22:33:44:55:66
'
);
console
.
info
(
'
[bluetooth_js]a2dp getPlayingState result:
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
PlayingState
.
STATE_NOT_PLAYING
);
expect
(
true
).
assertEqual
(
state
!=
PlayingState
.
STATE_PLAYING
);
expect
(
state
).
assertEqual
(
bluetooth
.
PlayingState
.
STATE_NOT_PLAYING
);
expect
(
true
).
assertEqual
(
state
!=
bluetooth
.
PlayingState
.
STATE_PLAYING
);
done
();
})
...
...
@@ -270,7 +249,7 @@ describe('bluetoothhostTest_host_1', function () {
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_1000
'
,
0
,
async
function
(
done
)
{
let
a2dpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]a2dp get profile result:
'
+
JSON
.
stringify
(
a2dpSrc
));
let
retArray
=
a2dpSrc
.
getConnectionDevices
();
expect
(
true
).
assertEqual
(
retArray
.
length
>=
0
);
...
...
@@ -282,3 +261,4 @@ describe('bluetoothhostTest_host_1', function () {
}
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
浏览文件 @
81d9f187
...
...
@@ -16,20 +16,6 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ProfileId
=
{
PROFILE_A2DP_SOURCE
:
1
,
PROFILE_HANDS_FREE_AUDIO_GATEWAY
:
4
,
PROFILE_HID_HOST
:
6
,
PROFILE_PAN_NETWORK
:
7
}
let
ProfileConnectionState
=
{
STATE_CONNECTING
:
1
,
STATE_CONNECTED
:
2
,
STATE_DISCONNECTED
:
0
,
STATE_DISCONNECTING
:
3
,
};
export
default
function
bluetoothhostTest_host_3
()
{
describe
(
'
bluetoothhostTest_host_3
'
,
function
()
{
...
...
@@ -89,9 +75,9 @@ describe('bluetoothhostTest_host_3', function () {
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1100
'
,
0
,
async
function
(
done
)
{
let
hfpSrcConn
=
bluetooth
.
getProfileConnState
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
bluetooth
.
getProfileConnState
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
console
.
info
(
'
[bluetooth_js]get hfp result:
'
+
JSON
.
stringify
(
hfpSrcConn
));
expect
(
hfpSrcConn
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
hfpSrcConn
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -105,10 +91,10 @@ describe('bluetoothhostTest_host_3', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1200
'
,
0
,
async
function
(
done
)
{
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
ret
=
hfpSrc
.
getDeviceState
(
'
11:22:33:44:55:66
'
);
console
.
info
(
'
[bluetooth_js]hfp getDeviceState:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
ret
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -122,10 +108,10 @@ describe('bluetoothhostTest_host_3', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1300
'
,
0
,
async
function
(
done
)
{
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
ret
=
hfpSrc
.
getDeviceState
(
'
bluetooth1
'
);
console
.
info
(
'
[bluetooth_js]hfp get valid mac DeviceState:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
ret
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
done
();
})
...
...
@@ -144,7 +130,7 @@ describe('bluetoothhostTest_host_3', function () {
'
deviceId:
'
+
data
.
deviceId
+
'
state:
'
+
data
.
state
);
expect
(
true
).
assertEqual
(
data
!=
null
);
}
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
hfpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
hfpSrc
.
connect
(
'
11:22:33:44:55:66
'
);
await
sleep
(
6000
);
...
...
@@ -167,7 +153,7 @@ describe('bluetoothhostTest_host_3', function () {
'
deviceId:
'
+
data
.
deviceId
+
'
state:
'
+
data
.
state
);
expect
(
true
).
assertEqual
(
data
!=
null
);
}
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
hfpSrc
.
on
(
'
connectionStateChange
'
,
StateChangeParam
);
await
sleep
(
10000
);
let
conn
=
hfpSrc
.
disconnect
(
'
11:22:33:44:55:66
'
);
...
...
@@ -187,7 +173,7 @@ describe('bluetoothhostTest_host_3', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1600
'
,
0
,
async
function
(
done
)
{
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
conn1
=
hfpSrc
.
connect
(
'
test
'
);
console
.
info
(
'
[bluetooth_js]hfp vaild MAC disconnect :
'
+
JSON
.
stringify
(
conn1
));
expect
(
conn1
).
assertFalse
();
...
...
@@ -204,7 +190,7 @@ describe('bluetoothhostTest_host_3', function () {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1700
'
,
0
,
async
function
(
done
)
{
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
console
.
info
(
'
[bluetooth_js]hfp get profile result:
'
+
JSON
.
stringify
(
hfpSrc
));
let
conn
=
hfpSrc
.
disconnect
(
'
test
'
);
console
.
info
(
'
[bluetooth_js]hfp disconnect1 result:
'
+
JSON
.
stringify
(
conn
));
...
...
@@ -222,7 +208,7 @@ describe('bluetoothhostTest_host_3', function () {
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1800
'
,
0
,
async
function
(
done
)
{
let
hfpSrc
=
bluetooth
.
getProfile
(
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
retArray
=
hfpSrc
.
getConnectionDevices
();
console
.
info
(
'
[bluetooth_js]hfp getConnectionDevices:
'
+
JSON
.
stringify
(
retArray
));
expect
(
true
).
assertEqual
(
retArray
.
length
>=
0
);
...
...
@@ -234,3 +220,4 @@ describe('bluetoothhostTest_host_3', function () {
}
communication/bluetooth_standard/signature/openharmony_sx.p7b
浏览文件 @
81d9f187
无法预览此类型文件
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
浏览文件 @
81d9f187
...
...
@@ -14,17 +14,26 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
}
const
PERMISSION_USER_SET
=
1
;
const
PERMISSION_USER_NAME1
=
"
ohos.permission.LOCATION
"
;
const
PERMISSION_USER_NAME2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
let
tokenID
=
undefined
;
async
function
grantPerm
()
{
console
.
info
(
"
====grant Permission start====
"
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
100
);
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
"
accessTokenId
"
+
appInfo
.
accessTokenId
+
"
bundleName:
"
+
appInfo
.
bundleName
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
result
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
PERMISSION_USER_NAME1
,
PERMISSION_USER_SET
);
console
.
info
(
"
tokenId
"
+
tokenID
+
"
result:
"
+
result
);
let
result1
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
PERMISSION_USER_NAME2
,
PERMISSION_USER_SET
);
console
.
info
(
"
tokenId
"
+
tokenID
+
"
result1:
"
+
result1
);
console
.
info
(
"
====grant Permission end====
"
);
}
export
default
function
bluetoothhostTest3
()
{
describe
(
'
bluetoothhostTest3
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -57,8 +66,11 @@ describe('bluetoothhostTest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
grantPerm
();
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
@@ -109,11 +121,11 @@ describe('bluetoothhostTest3', function() {
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0300
'
,
0
,
async
function
(
done
)
{
let
result1
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE
,
10
);
let
result1
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE
,
10
);
expect
(
result1
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE
);
let
result
=
bluetooth
.
startBluetoothDiscovery
();
await
sleep
(
2000
);
console
.
info
(
'
[bluetooth_js] startDiscovery1
'
+
result
);
...
...
@@ -126,3 +138,4 @@ describe('bluetoothhostTest3', function() {
})
}
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
浏览文件 @
81d9f187
...
...
@@ -15,15 +15,7 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
}
export
default
function
bluetoothhostTest2
()
{
describe
(
'
bluetoothhostTest2
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -82,11 +74,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0100
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_NONE
,
0
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_NONE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_NONE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_NONE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -107,11 +99,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0200
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
0
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -132,11 +124,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0300
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
40000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -157,11 +149,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0400
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
40000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -181,11 +173,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0500
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
0
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -206,11 +198,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0600
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
0
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -231,11 +223,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0700
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
20000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
20000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -256,11 +248,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0800
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
0
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -281,11 +273,11 @@ describe('bluetoothhostTest2', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0900
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
30000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
30000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
...
...
@@ -317,3 +309,4 @@ describe('bluetoothhostTest2', function() {
})
}
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
浏览文件 @
81d9f187
...
...
@@ -71,11 +71,8 @@ describe('bluetoothhostTest4', function() {
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0100
'
,
0
,
async
function
(
done
)
{
let
SppType
=
{
SPP_RFCOMM
:
0
}
let
SppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
secure
:
true
,
type
:
SppType
.
SPP_RFCOMM
};
secure
:
true
,
type
:
bluetooth
.
SppType
.
SPP_RFCOMM
};
let
serverNumber
=
-
1
;
function
serverSocket
(
code
,
number
)
{
if
(
code
)
{
...
...
@@ -392,3 +389,4 @@ describe('bluetoothhostTest4', function() {
}
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
浏览文件 @
81d9f187
...
...
@@ -16,16 +16,6 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
BluetoothState
=
{
STATE_OFF
:
0
,
STATE_TURNING_ON
:
1
,
STATE_ON
:
2
,
STATE_TURNING_OFF
:
3
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_TURNING_OFF
:
6
,
}
export
default
function
bluetoothhostTest
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -88,7 +78,7 @@ describe('bluetoothhostTest', function() {
await
bluetooth
.
on
(
'
stateChange
'
,
onReceiveEvent
);
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] get bluetooth state001
'
+
JSON
.
stringify
(
state
));
if
(
state
!=
BluetoothState
.
STATE_ON
)
if
(
state
!=
bluetooth
.
BluetoothState
.
STATE_ON
)
{
let
enable
=
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
...
...
@@ -96,7 +86,7 @@ describe('bluetoothhostTest', function() {
expect
(
enable
).
assertTrue
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] enable state001
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_ON
);
expect
(
state1
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
}
let
disable
=
bluetooth
.
disableBluetooth
();
await
sleep
(
3000
);
...
...
@@ -104,7 +94,7 @@ describe('bluetoothhostTest', function() {
expect
(
disable
).
assertTrue
();
let
state2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] disable state001
'
+
JSON
.
stringify
(
state2
));
expect
(
state2
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
expect
(
state2
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_OFF
);
await
bluetooth
.
off
(
'
stateChange
'
,
onReceiveEvent
);
done
()
})
...
...
@@ -121,15 +111,15 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0300
'
,
0
,
async
function
(
done
)
{
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt open state1 =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
BluetoothState
.
STATE_ON
);
if
(
state
==
BluetoothState
.
STATE_ON
)
{
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
if
(
state
==
bluetooth
.
BluetoothState
.
STATE_ON
)
{
let
enable1
=
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
console
.
info
(
'
[bluetooth_js]enable1 :
'
+
JSON
.
stringify
(
enable1
));
expect
(
enable1
).
assertFalse
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt open state2=
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_ON
);
expect
(
state1
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
}
else
{
console
.
info
(
'
[bluetooth_js]bluetooth open fail
'
);
}
...
...
@@ -152,17 +142,18 @@ describe('bluetoothhostTest', function() {
expect
(
result1
).
assertTrue
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState1 off =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
if
(
state
==
BluetoothState
.
STATE_OFF
)
{
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_OFF
);
if
(
state
==
bluetooth
.
BluetoothState
.
STATE_OFF
)
{
let
result2
=
bluetooth
.
disableBluetooth
();
console
.
info
(
'
[bluetooth_js]disable result1
'
+
JSON
.
stringify
(
result2
));
expect
(
result2
).
assertFalse
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState4 off =
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
expect
(
state1
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_OFF
);
}
done
();
})
})
}
communication/nfc_Controller/src/main/js/test/List.test.js
浏览文件 @
81d9f187
...
...
@@ -28,12 +28,11 @@ if (info != "false")
{
nfcATagSessionTest
();
nfcControllerTest
();
ConnectedTagTest
();
nfcIsoDepTagTest
();
nfcMifareClassicTag
();
nfcMifareUltralightTag
();
nfcTagABFVTest
();
nfcNDEFTagTest
();
ConnectedTag
Test
();
nfcTagABFV
Test
();
}
}
communication/nfc_Controller/src/main/js/test/nfc.ATagSession.js
浏览文件 @
81d9f187
...
...
@@ -34,11 +34,18 @@ let aTag = {
],
"
tagRfDiscId
"
:
1
,
};
let
getAtag
=
null
;
export
default
function
nfcATagSessionTest
()
{
describe
(
'
nfcATagSessionTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
try
{
getAtag
=
tag
.
getNfcATag
(
aTag
)
console
.
info
(
'
Nfcget Connected data
'
+
getAtag
)
}
catch
(
error
)
{
console
.
info
(
'
Nfcget Connected error
'
+
error
)
}
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]beforeEach called
'
)
...
...
@@ -59,13 +66,19 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0100
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
NfcConnected
;
try
{
NfcConnected
=
tag
.
getNfcATag
(
aTag
)
.
connectTag
();
console
.
info
(
"
NfcConnected:
"
+
NfcConnected
);
try
{
NfcConnected
=
getAtag
.
connectTag
();
console
.
info
(
"
NfcConnected:
"
+
NfcConnected
);
expect
(
NfcConnected
).
assertFalse
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
NfcConnected error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -79,12 +92,18 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0200
'
,
0
,
function
()
{
try
{
tag
.
getNfcATag
(
aTag
).
reset
();
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
try
{
getAtag
.
reset
();
expect
(
true
).
assertTrue
();
console
.
info
(
'
reset1 pass
'
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
reset1 error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -98,13 +117,19 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0300
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
isNfcConnected
;
try
{
isNfcConnected
=
tag
.
getNfcATag
(
aTag
)
.
isTagConnected
();
try
{
isNfcConnected
=
getAtag
.
isTagConnected
();
console
.
info
(
"
isNfcConnected:
"
+
isNfcConnected
);
expect
(
isNfcConnected
).
assertFalse
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
isNfcConnected error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -118,14 +143,20 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0400
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
mazSendLen
;
try
{
mazSendLen
=
tag
.
getNfcATag
(
aTag
)
.
getMaxSendLength
();
console
.
info
(
"
getMaxSendLength:
"
+
mazSendLen
);
expect
(
true
).
assertTrue
(
mazSendLen
>=
0
);
try
{
mazSendLen
=
getAtag
.
getMaxSendLength
();
console
.
info
(
"
getMaxSendLength:
"
+
mazSendLen
);
expect
(
mazSendLen
>=
0
).
assertTrue
(
);
console
.
info
(
'
getMaxSendLength pass
'
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
getMaxSendLength error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -139,13 +170,19 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0500
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
settime
;
try
{
settime
=
tag
.
getNfcATag
(
aTag
)
.
setSendDataTimeout
(
1000
);
console
.
info
(
"
setSendDataTimeout:
"
+
settime
);
expect
(
true
).
assertTrue
(
settime
>=
0
);
}
catch
(
error
)
{
try
{
settime
=
getAtag
.
setSendDataTimeout
(
1000
);
console
.
info
(
"
setSendDataTimeout:
"
+
settime
);
expect
(
settime
>=
0
).
assertTrue
(
);
}
catch
(
error
)
{
console
.
info
(
'
setSendDataTimeout error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -159,14 +196,20 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0600
'
,
0
,
function
()
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
gettime
;
try
{
gettime
=
tag
.
getNfcATag
(
aTag
)
.
getSendDataTimeout
();
console
.
info
(
"
getMaxSendLength:
"
+
gettime
+
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
gettime
));
expect
(
true
).
assertTrue
(
gettime
>=
0
);
try
{
gettime
=
getAtag
.
getSendDataTimeout
();
console
.
info
(
"
getMaxSendLength:
"
+
gettime
+
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
gettime
));
expect
(
gettime
>=
0
).
assertTrue
(
);
console
.
info
(
'
getMaxSendLength pass
'
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
getMaxSendLength error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]getAtag6 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -180,15 +223,21 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0700
'
,
0
,
async
function
(
done
)
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
await
tag
.
getNfcATag
(
aTag
)
.
sendData
(
sendDatas
).
then
((
data
)
=>
{
await
getAtag
.
sendData
(
sendDatas
).
then
((
data
)
=>
{
console
.
log
(
"
nfcAtage sendData1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
nfcAtage sendData1 err:
"
+
err
);
expect
(
true
).
assertFalse
();
});
sleep
(
3500
);
}
else
{
console
.
info
(
"
[NFC_test]getAtag7 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -201,21 +250,138 @@ export default function nfcATagSessionTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0800
'
,
0
,
async
function
(
done
)
{
if
(
getAtag
!=
null
&&
getAtag
!=
undefined
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
tag
.
getNfcATag
(
aTag
)
.
sendData
(
sendDatas
,
(
err
,
data
)
=>
{
getAtag
.
sendData
(
sendDatas
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
nfcAtage sendData2 data err:
"
+
err
);
expect
(
true
).
assertFalse
();
}
else
{
sleep
(
2500
);
console
.
log
(
"
nfcAtage sendData2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
}
});
sleep
(
500
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]getAtag8 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0900
* @tc.name testreset
* @tc.desc Test reset api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_0900
'
,
0
,
function
()
{
try
{
tag
.
getNfcA
(
aTag
).
resetConnection
();
expect
(
true
).
assertTrue
();
console
.
info
(
'
reset1 pass
'
)
}
catch
(
error
)
{
console
.
info
(
'
reset1 error
'
+
error
)
expect
(
true
).
assertTrue
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_1000
* @tc.name testsetSendDataTimeout
* @tc.desc Test setSendDataTimeout api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_1000
'
,
0
,
function
()
{
let
settime
;
try
{
settime
=
tag
.
getNfcATag
(
aTag
).
getTimeout
(
1000
);
console
.
info
(
"
setSendDataTimeout:
"
+
settime
);
expect
(
settime
>=
0
).
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
'
setSendDataTimeout error
'
+
error
)
expect
(
true
).
assertTrue
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_1100
* @tc.name testsendData
* @tc.desc Test sendData api by peomise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_1100
'
,
0
,
async
function
(
done
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
await
tag
.
getNfcATag
(
aTag
).
transmit
(
sendDatas
).
then
((
data
)
=>
{
console
.
log
(
"
nfcAtage sendData1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
nfcAtage sendData1 err:
"
+
err
);
expect
(
true
).
assertTrue
();
});
sleep
(
3500
);
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_1200
* @tc.name testsendData
* @tc.desc Test sendData api by callback.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_1200
'
,
0
,
async
function
(
done
)
{
let
sendDatas
=
[
0x01
,
0x02
,
0x03
,
0x04
];
tag
.
getNfcATag
(
aTag
).
transmit
(
sendDatas
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
"
nfcAtage sendData2 data err:
"
+
err
);
expect
(
true
).
assertFalse
();
}
else
{
sleep
(
2500
);
console
.
log
(
"
nfcAtage sendData2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
data
>=
0
).
assertTrue
();
}
});
sleep
(
500
);
done
();
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_1300
* @tc.name testgetMaxSendLength
* @tc.desc Test getMaxSendLength api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcAtage_js_1300
'
,
0
,
function
()
{
let
mazSendLen
;
try
{
mazSendLen
=
tag
.
getNfcATag
(
aTag
).
getMaxTransmitSize
();
console
.
info
(
"
getMaxTransmitSize:
"
+
mazSendLen
);
expect
(
mazSendLen
>=
0
).
assertTrue
();
console
.
info
(
'
getMaxTransmitSize pass
'
)
}
catch
(
error
)
{
console
.
info
(
'
getMaxTransmitSize error
'
+
error
)
expect
(
true
).
assertFalse
();
}
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
浏览文件 @
81d9f187
...
...
@@ -58,11 +58,10 @@ export default function ConnectedTagTest() {
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
}
else
{
let
inittag
=
connectedTag
.
init
();
expect
(
inittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
inittag
);
console
.
info
(
"
ConnectedTag
readMultiplePages1 err:
"
+
inittag
);
}
})
...
...
@@ -81,14 +80,13 @@ export default function ConnectedTagTest() {
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
}
else
{
await
connectedTag
.
readNdefTag
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
result
!=
null
);
console
.
info
(
"
ConnectedTag
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
result
!=
null
).
assertTrue
(
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
err
);
console
.
info
(
"
ConnectedTag
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
...
...
@@ -111,8 +109,7 @@ export default function ConnectedTagTest() {
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
}
else
{
connectedTag
.
readNdefTag
((
err
,
result
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
...
...
@@ -141,14 +138,13 @@ export default function ConnectedTagTest() {
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
}
else
{
await
connectedTag
.
writeNdefTag
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
result
!=
null
);
console
.
info
(
"
ConnectedTag
readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
result
!=
null
).
assertTrue
(
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight
readMultiplePages1 err:
"
+
err
);
console
.
info
(
"
ConnectedTag
readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
...
...
@@ -170,8 +166,7 @@ export default function ConnectedTagTest() {
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
}
else
{
connectedTag
.
writeNdefTag
((
err
,
result
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
...
...
@@ -199,8 +194,7 @@ export default function ConnectedTagTest() {
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
}
else
{
let
recvNfcRfNotifyFunc
=
result
=>
{
console
.
info
(
"
nfc state receive state ->
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
...
...
@@ -219,6 +213,27 @@ export default function ConnectedTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_0700
'
,
0
,
function
()
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
uninittag
=
connectedTag
.
uninit
();
expect
(
uninittag
).
assertTrue
();
console
.
info
(
"
ConnectedTag readMultiplePages1 err:
"
+
uninittag
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0800
* @tc.name Test initialize connectedTag
* @tc.desc Initializes the active label chip.
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_0800
'
,
0
,
function
()
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
...
...
@@ -226,14 +241,155 @@ export default function ConnectedTagTest() {
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
uninittag
=
connectedTag
.
uninit
();
let
inittag
=
connectedTag
.
initialize
();
expect
(
inittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
inittag
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0900
* @tc.name Test uninitialize connectedTag
* @tc.desc uninitialize active label chip resources.
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_0900
'
,
0
,
function
()
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
let
uninittag
=
connectedTag
.
uninitialize
();
expect
(
uninittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
uninittag
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_1000
* @tc.name Test read connectedTag
* @tc.desc Reads the content of the active tag.
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_1000
'
,
0
,
async
function
(
done
)
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
await
connectedTag
.
read
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_1100
* @tc.name Test read connectedTag
* @tc.desc Reads the content of the active tag.
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_1100
'
,
0
,
async
function
(
done
)
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
connectedTag
.
read
((
err
,
result
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
}
});
}
done
();
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_1200
* @tc.name Test write connectedTag
* @tc.desc Write Content to Active Tags
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_1200
'
,
0
,
async
function
(
done
)
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
done
();
}
else
{
await
connectedTag
.
write
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
result
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_1200
* @tc.name Test write connectedTag
* @tc.desc Write Content to Active Tags
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_1200
'
,
0
,
async
function
(
done
)
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.ConnectedTag
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
!
isAccessToken
)
{
console
.
info
(
"
The device does not support active label chips.
"
)
expect
(
isAccessToken
).
assertFalse
()
}
else
{
connectedTag
.
write
((
err
,
result
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
}
else
{
expect
(
result
!=
null
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
result
);
}
});
}
done
();
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
communication/nfc_Controller/src/main/js/test/nfc.Controller.js
浏览文件 @
81d9f187
...
...
@@ -34,11 +34,17 @@ let NfcState={
export
default
function
nfcControllerTest
()
{
describe
(
'
nfcControllerTest
'
,
function
()
{
before
Each
(
function
()
{
console
.
info
(
"
[NFC_test]beforeEach start
"
);
before
All
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
})
afterEach
(
async
function
()
{
console
.
info
(
"
[NFC_test]afterEach start
"
);
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]afterAll called
'
)
})
/**
...
...
@@ -124,3 +130,4 @@ export default function nfcControllerTest() {
communication/nfc_Controller/src/main/js/test/nfc.IsoDepTag.js
浏览文件 @
81d9f187
...
...
@@ -16,6 +16,7 @@
import
tag
from
'
@ohos.nfc.tag
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
cardEmulation
from
'
@ohos.nfc.cardEmulation
'
;
function
sleep
(
delay
)
{
// delay x ms
let
start
=
(
new
Date
()).
getTime
();
...
...
@@ -63,14 +64,21 @@ let isoDepTaginfo = {
],
"
tagRfDiscId
"
:
1
,
};
let
CardType
=
{
PAYMENT
:
"
payment
"
,
OTHER
:
"
other
"
,
};
let
IsoDepTag
;
export
default
function
nfcIsoDepTagTest
()
{
describe
(
'
nfcIsoDepTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
try
{
try
{
IsoDepTag
=
tag
.
getIsoDep
(
isoDepTaginfo
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
getIsoDep is ->
'
+
error
)
}
})
...
...
@@ -93,9 +101,14 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0100
'
,
0
,
function
()
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
let
ResponseFlags
=
IsoDepTag
.
getHistoricalBytes
();
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
ResponseFlags
);
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -107,9 +120,14 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0200
'
,
0
,
function
()
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
let
HiLayerResponse
=
IsoDepTag
.
getHiLayerResponse
();
expect
(
HiLayerResponse
).
assertInstanceOf
(
'
Array
'
)
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
HiLayerResponse
);
console
.
info
(
'
[nfc_js] test ResponseFlags data2>:
'
+
HiLayerResponse
);
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -121,15 +139,20 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0300
'
,
0
,
async
function
(
done
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
await
IsoDepTag
.
isExtendedApduSupported
().
then
((
data
)
=>
{
expect
(
false
).
assertEqual
(
data
);
console
.
info
(
"
isoDep isExtendedApduSupported data:
"
+
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
expect
().
assertFail
();
expect
(
true
).
assertFalse
();
done
();
});
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -141,9 +164,10 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcIsoDep_js_0400
'
,
0
,
async
function
(
done
)
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
IsoDepTag
.
isExtendedApduSupported
((
err
,
data
)
=>
{
if
(
err
)
{
expect
().
assertFail
();
expect
(
true
).
assertFalse
();
console
.
info
(
"
isoDep isExtendedApduSupported err:
"
+
err
);
}
else
{
expect
(
false
).
assertEqual
(
data
);
...
...
@@ -151,6 +175,10 @@ export default function nfcIsoDepTagTest() {
}
});
done
();
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -162,13 +190,63 @@ export default function nfcIsoDepTagTest() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfccardEmulationnfc_js_0500
'
,
0
,
function
()
{
if
(
IsoDepTag
!=
null
&&
IsoDepTag
!=
undefined
)
{
let
cardEmulationnfc
;
try
{
try
{
cardEmulationnfc
=
cardEmulation
.
isSupported
(
FeatureType
.
ESE
);
console
.
info
(
'
cardEmulationnfc type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc error
'
+
error
)
expect
(
true
).
assertFalse
();
}
}
else
{
console
.
info
(
"
[NFC_test]IsoDepTag5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfccardEmulationnfc_js_0600
* @tc.name Test cardEmulationnfc
* @tc.desc hasHceCapability 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_0600
'
,
0
,
function
()
{
let
cardEmulationnfc
;
try
{
cardEmulationnfc
=
cardEmulation
.
hasHceCapability
();
console
.
info
(
'
cardEmulationnfc hasHceCapability type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc error
'
+
error
)
expect
(
true
).
assertFalse
();
}
})
/**
* @tc.number SUB_Communication_NFC_nfccardEmulationnfc_js_0700
* @tc.name Test cardEmulationnfc
* @tc.desc Whether to support a certain type of card isDefaultService.
* @tc.size since 9
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfccardEmulationnfc_js_0700
'
,
0
,
function
()
{
let
cardEmulationnfc
;
let
elementName
=
{
"
bundleName
"
:
"
com.test.cardemulation
"
,
"
abilityName
"
:
"
com.test.cardemulation.MainAbility
"
,
};
try
{
cardEmulationnfc
=
cardEmulation
.
isDefaultService
(
elementName
,
CardType
.
PAYMENT
);
console
.
info
(
'
cardEmulationnfc isDefaultService type ->
'
+
cardEmulationnfc
)
expect
(
cardEmulationnfc
).
assertFalse
();
}
catch
(
error
)
{
console
.
info
(
'
cardEmulationnfc error
'
+
error
)
expect
(
true
).
assertFalse
();
}
})
...
...
@@ -176,3 +254,4 @@ export default function nfcIsoDepTagTest() {
})
}
communication/nfc_Controller/src/main/js/test/nfc.MifareClassicTag.js
浏览文件 @
81d9f187
此差异已折叠。
点击以展开。
communication/nfc_Controller/src/main/js/test/nfc.MifareUltralightTag.js
浏览文件 @
81d9f187
...
...
@@ -52,10 +52,10 @@ export default function nfcMifareUltralightTag() {
console
.
info
(
'
[NFC_test]beforeAll called
'
)
})
beforeEach
(
function
()
{
try
{
try
{
MifareUltralightTag
=
tag
.
getMifareUltralight
(
mifareUltralightTaginfo
);
console
.
info
(
'
mifareUltralight is
'
+
mifareUltralight
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
'
mifareUltralight error
'
+
error
)
}
console
.
info
(
'
[NFC_test]beforeEach called
'
)
...
...
@@ -77,12 +77,11 @@ export default function nfcMifareUltralightTag() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0100
'
,
0
,
async
function
(
done
)
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
pageIndex
=
1
;
await
MifareUltralightTag
.
readMultiplePages
(
pageIndex
).
then
((
data
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
err
);
...
...
@@ -90,6 +89,10 @@ export default function nfcMifareUltralightTag() {
done
();
});
sleep
(
3000
);
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -102,6 +105,7 @@ export default function nfcMifareUltralightTag() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0200
'
,
0
,
async
function
(
done
)
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
pageIndex
=
1
;
MifareUltralightTag
.
readMultiplePages
(
pageIndex
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -109,11 +113,15 @@ export default function nfcMifareUltralightTag() {
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
info
(
"
mifareUltralight readMultiplePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
}
});
sleep
(
3000
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -126,11 +134,12 @@ export default function nfcMifareUltralightTag() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0300
'
,
0
,
async
function
(
done
)
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
pageIndex
=
1
;
let
rawData
=
[
0x01
,
0x02
];
await
MifareUltralightTag
.
writeSinglePage
(
pageIndex
,
rawData
).
then
((
data
)
=>
{
console
.
log
(
"
mifareUltralight writeSinglePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
mifareUltralight writeSinglePages1 err:
"
+
err
);
...
...
@@ -138,6 +147,10 @@ export default function nfcMifareUltralightTag() {
done
();
});
sleep
(
3000
);
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -150,6 +163,7 @@ export default function nfcMifareUltralightTag() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0400
'
,
0
,
async
function
(
done
)
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
pageIndex
=
1
;
let
rawData
=
[
0x01
,
0x02
];
MifareUltralightTag
.
writeSinglePage
(
pageIndex
,
rawData
,
(
err
,
data
)
=>
{
...
...
@@ -158,11 +172,15 @@ export default function nfcMifareUltralightTag() {
expect
(
true
).
assertEqual
(
true
);
}
else
{
console
.
log
(
"
mifareUltralight writeSinglePages2 data:
"
+
data
+
"
json2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
>=
0
);
expect
(
data
>=
0
).
assertTrue
(
);
}
});
sleep
(
3000
);
done
();
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight4 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -175,9 +193,14 @@ export default function nfcMifareUltralightTag() {
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_mifareUltralight_0500
'
,
0
,
function
()
{
if
(
MifareUltralightTag
!=
null
&&
MifareUltralightTag
!=
undefined
)
{
let
getType
=
MifareUltralightTag
.
getType
();
console
.
info
(
"
mifareUltralight getType:
"
+
getType
);
expect
(
true
).
assertTrue
(
getType
>=
-
1
);
expect
(
getType
>=
-
1
).
assertTrue
();
}
else
{
console
.
info
(
"
[NFC_test]mifareUltralight5 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
...
...
@@ -185,3 +208,4 @@ export default function nfcMifareUltralightTag() {
}
communication/nfc_Controller/src/main/js/test/nfc.NDEFTag.js
浏览文件 @
81d9f187
此差异已折叠。
点击以展开。
communication/nfc_Controller/src/main/js/test/nfc.TagABFV.js
浏览文件 @
81d9f187
...
...
@@ -122,14 +122,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0100
'
,
0
,
function
()
{
let
NfcATag
;
try
{
try
{
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0100
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
expect
(
NfcATag
!=
null
).
assertTrue
();
expect
(
NfcATag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcATag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -142,14 +147,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0200
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0200
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
expect
(
NfcBTag
!=
null
).
assertTrue
();
expect
(
NfcBTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
bTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcBTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -162,14 +172,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0300
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0300
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
expect
(
NfcFTag
!=
null
).
assertTrue
();
expect
(
NfcFTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
fTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcFTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -182,14 +197,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0400
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0400
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
expect
(
NfcVTag
!=
null
).
assertTrue
();
expect
(
NfcVTag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
vTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcVTag
));
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag1 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -202,14 +222,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0500
'
,
0
,
function
()
{
let
NfcATag
;
try
{
try
{
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0500
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
let
sak
=
NfcATag
.
getSak
();
expect
(
sak
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test sak data>:
'
+
sak
);
}
else
{
console
.
info
(
"
[NFC_test]NfcATag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -222,14 +247,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0600
'
,
0
,
function
()
{
let
NfcATag
;
try
{
try
{
NfcATag
=
tag
.
getNfcATag
(
aTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0600
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcATag
!=
null
&&
NfcATag
!=
undefined
)
{
let
Atqa
=
NfcATag
.
getAtqa
();
expect
(
Atqa
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Atqa data>:
'
+
Atqa
);
}
else
{
console
.
info
(
"
[NFC_test]NfcATag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -242,14 +272,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0700
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0700
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
let
AppData
=
NfcBTag
.
getRespAppData
();
expect
(
AppData
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test AppData data>:
'
+
AppData
);
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -262,14 +297,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0800
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
try
{
NfcBTag
=
tag
.
getNfcBTag
(
bTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0800
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcBTag
!=
null
&&
NfcBTag
!=
undefined
)
{
let
Protocol
=
NfcBTag
.
getRespProtocol
();
expect
(
Protocol
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Protocol data>:
'
+
Protocol
);
}
else
{
console
.
info
(
"
[NFC_test]NfcBTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -282,14 +322,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_0900
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_0900
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
let
SystemCode
=
NfcFTag
.
getSystemCode
();
expect
(
SystemCode
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test SystemCode data>:
'
+
SystemCode
);
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -302,14 +347,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_1000
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
try
{
NfcFTag
=
tag
.
getNfcFTag
(
fTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1000
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcFTag
!=
null
&&
NfcFTag
!=
undefined
)
{
let
Pmm
=
NfcFTag
.
getPmm
();
expect
(
Pmm
).
assertInstanceOf
(
'
Array
'
);
console
.
info
(
'
[nfc_js] test Pmm data>:
'
+
Pmm
);
}
else
{
console
.
info
(
"
[NFC_test]NfcFTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -322,14 +372,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_1100
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1100
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
let
ResponseFlags
=
NfcVTag
.
getResponseFlags
();
expect
(
ResponseFlags
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test ResponseFlags data>:
'
+
ResponseFlags
);
console
.
info
(
'
[nfc_js] test ResponseFlags3 data>:
'
+
ResponseFlags
);
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag2 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -342,14 +397,19 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_1200
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
try
{
NfcVTag
=
tag
.
getNfcVTag
(
vTag
);
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1200
error
'
+
error
)
console
.
info
(
'
Nfcget tagABFV
error
'
+
error
)
}
if
(
NfcVTag
!=
null
&&
NfcVTag
!=
undefined
)
{
let
DsfId
=
NfcVTag
.
getDsfId
();
expect
(
DsfId
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
'
[nfc_js] test DsfId data>:
'
+
DsfId
);
}
else
{
console
.
info
(
"
[NFC_test]NfcVTag3 = null & = undefined:
"
);
expect
(
true
).
assertFalse
();
}
})
/**
...
...
@@ -362,18 +422,99 @@ export default function nfcTagABFVTest() {
*/
it
(
'
SUB_Communication_NFC_nfctage_js_1300
'
,
0
,
function
()
{
let
TagInfo
;
try
{
try
{
TagInfo
=
tag
.
getTagInfo
(
Want
);
console
.
info
(
'
SUB_Communication_NFC_nfctage_js1111111
'
+
TagInfo
)
console
.
info
(
'
Nfcget tagABFV gettaginfo is:
'
+
TagInfo
)
expect
(
TagInfo
instanceof
Object
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
'
SUB_Communication_NFC_nfctage_js_1300
error
'
+
error
)
console
.
info
(
'
Nfcget taginfo
error
'
+
error
)
expect
(
true
).
assertTrue
();
}
console
.
info
(
'
[nfc_js] test TagInfo data>:
'
+
TagInfo
);
})
/**
* @tc.number SUB_Communication_NFC_nfctage_js_1400
* @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_nfctage_js_1400
'
,
0
,
function
()
{
let
NfcATag
;
try
{
NfcATag
=
tag
.
getNfcA
(
aTag
);
}
catch
(
error
)
{
console
.
info
(
'
nfc gertaga error
'
+
error
)
}
expect
(
NfcATag
!=
null
).
assertTrue
();
expect
(
NfcATag
instanceof
Object
).
assertTrue
();
console
.
info
(
'
aTag is--<-!!!->
'
+
JSON
.
stringify
(
NfcATag
));
})
/**
* @tc.number SUB_Communication_NFC_nfctage_js_1500
* @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_nfctage_js_1500
'
,
0
,
function
()
{
let
NfcBTag
;
try
{
NfcBTag
=
tag
.
getNfcB
(
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_nfctage_js_1600
* @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_nfctage_js_1600
'
,
0
,
function
()
{
let
NfcFTag
;
try
{
NfcFTag
=
tag
.
getNfcF
(
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_nfctage_js_1700
* @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_nfctage_js_1700
'
,
0
,
function
()
{
let
NfcVTag
;
try
{
NfcVTag
=
tag
.
getNfcV
(
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
));
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录