Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
07445e52
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看板
提交
07445e52
编写于
10月 30, 2022
作者:
Q
quanli
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
0b8d0c24
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
463 addition
and
0 deletion
+463
-0
communication/nfc_Controller/src/main/js/test/List.test.js
communication/nfc_Controller/src/main/js/test/List.test.js
+2
-0
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
...ation/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
+239
-0
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
...n/wifi_standard/src/main/js/test/WifiStationEvent.test.js
+222
-0
未找到文件。
communication/nfc_Controller/src/main/js/test/List.test.js
浏览文件 @
07445e52
...
...
@@ -20,6 +20,7 @@ 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
ConnectedTagTest
from
'
./nfc.ConnectedTag.js
'
import
parameter
from
'
@ohos.systemparameter
'
;
let
info
=
parameter
.
getSync
(
"
const.SystemCapability.Communication.NFC.Core
"
,
"
false
"
);
export
default
function
testsuite
()
{
...
...
@@ -32,6 +33,7 @@ if (info != "false")
nfcMifareUltralightTag
();
nfcTagABFVTest
();
nfcNDEFTagTest
();
ConnectedTagTest
();
}
}
communication/nfc_Controller/src/main/js/test/nfc.ConnectedTag.js
0 → 100644
浏览文件 @
07445e52
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
connectedTag
from
'
@ohos.connectedTag
'
;
import
parameter
from
'
@ohos.systemparameter
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
function
sleep
(
delay
)
{
// delay x ms
let
start
=
(
new
Date
()).
getTime
();
while
((
new
Date
()).
getTime
()
-
start
<
delay
)
{
continue
;
}
}
let
NfcRfType
=
{
NFC_RF_LEAVE
:
0
,
NFC_RF_ENTER
:
1
,
}
export
default
function
ConnectedTagTest
()
{
describe
(
'
ConnectedTagTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
[NFC_test]beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
[NFC_test]beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
[NFC_test]afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
[NFC_test]afterAll called
'
)
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0100
* @tc.name Test init 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_0100
'
,
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
inittag
=
connectedTag
.
init
();
expect
(
inittag
).
assertTrue
();
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
inittag
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0200
* @tc.name Test init 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_0200
'
,
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
.
readNdefTag
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
result
!=
null
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0300
* @tc.name Test init 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_0300
'
,
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
.
readNdefTag
((
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_0400
* @tc.name Test writeNdefTag 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_0400
'
,
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
.
writeNdefTag
().
then
(
result
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 data:
"
+
data
+
"
json1:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
result
!=
null
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
"
mifareUltralight readMultiplePages1 err:
"
+
err
);
expect
(
true
).
assertEqual
(
true
);
done
();
});
sleep
(
3000
);
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0500
* @tc.name Test writeNdefTag 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_0500
'
,
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
.
writeNdefTag
((
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_0600
* @tc.name Test on_off connectedTag
* @tc.desc Registers and cancels the NFC field strength status event.
* @tc.size since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_Communication_NFC_nfcConnectedTag_js_0600
'
,
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
recvNfcRfNotifyFunc
=
result
=>
{
console
.
info
(
"
nfc state receive state ->
"
+
result
);
expect
(
result
!=
null
).
assertTrue
();
}
connectedTag
.
on
(
'
notify
'
,
recvNfcRfNotifyFunc
)
connectedTag
.
off
(
'
notify
'
,
recvNfcRfNotifyFunc
)
}
})
/**
* @tc.number SUB_Communication_NFC_nfcConnectedTag_js_0700
* @tc.name Test uninit connectedTag
* @tc.desc Unloads active label chip resources.
* @tc.size since 8
* @tc.type Function
* @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
(
"
mifareUltralight readMultiplePages1 err:
"
+
uninittag
);
}
})
console
.
info
(
"
*************[nfc_test] start nfc js unit test end*************
"
);
})
}
communication/wifi_standard/src/main/js/test/WifiStationEvent.test.js
浏览文件 @
07445e52
...
...
@@ -17,6 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import
wifi
from
'
@ohos.wifi
'
import
wifiext
from
'
@ohos.wifiext
'
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
...
...
@@ -37,6 +38,12 @@ let wifiSecurityType = {
WIFI_SEC_TYPE_SAE
:
4
,
}
let
PowerModel
=
{
SLEEPING
:
0
,
GENERAL
:
1
,
THROUGH_WALL
:
2
,
}
let
connState
=
{
SCANNING
:
0
,
CONNECTING
:
1
,
...
...
@@ -163,8 +170,223 @@ export default function actsWifiEventTest() {
wifi
.
off
(
hotspotState
,
hotspotStateChangeCallback
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0001
* @tc.name testenableHotspot
* @tc.desc Test enableHotspot api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps01 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
console
.
info
(
"
[wifi_test] enableHotspot:
"
+
wifiext
.
enableHotspot
())
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps01 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps01 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0002
* @tc.name testdisableHotspot
* @tc.desc Test disableHotspot api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps02 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
console
.
info
(
"
[wifi_test] disableHotspot:
"
+
wifiext
.
disableHotspot
())
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps02 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps02 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0003
* @tc.name testgetSupportedPowerModel
* @tc.desc Test getSupportedPowerModel api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps03 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
await
wifiext
.
getSupportedPowerModel
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test]getSupportedPowerModel promise result ->
"
+
JSON
.
stringify
(
data
));
});
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps03 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps03 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0004
* @tc.name testgetSupportedPowerModel
* @tc.desc Test getSupportedPowerModel api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0004
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps04 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps04 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
function
getSupportedPowerModelResult
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifiext
.
getSupportedPowerModel
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]failed to getSupportedPowerModel:
"
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertTrue
();
}
console
.
info
(
"
[wifi_test]getSupportedPowerModel callback:
"
+
JSON
.
stringify
(
result
));
resolve
();
});
});
}
await
getSupportedPowerModelResult
();
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps04 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps04 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0005
* @tc.name testgetPowerModel
* @tc.desc Test getPowerModel api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps05 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
await
wifiext
.
getPowerModel
()
.
then
(
data
=>
{
console
.
info
(
"
[wifi_test]getPowerModel promise result ->
"
+
JSON
.
stringify
(
data
));
});
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps05 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps05 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0006
* @tc.name testgetPowerModel
* @tc.desc Test getPowerModel api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0006
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps04 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps04 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
function
getPowerModelResult
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wifiext
.
getPowerModel
(
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
"
[wifi_test]failed to getPowerModel:
"
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertTrue
();
}
console
.
info
(
"
[wifi_test]getPowerModel callback:
"
+
JSON
.
stringify
(
result
));
resolve
();
});
});
}
await
getPowerModelResult
();
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps06 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps06 end
'
);
done
();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0007
* @tc.name testsetPowerModel
* @tc.desc Test setPowerModel api.
* @tc.type Function
*/
it
(
'
SUB_Communication_WiFi_SysCaps_Test_0007
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSysCaps01 start
'
);
let
ret
=
false
;
try
{
var
isAccessToken
=
canIUse
(
"
SystemCapability.Communication.WiFi.AP.Extension
"
);
console
.
info
(
"
testSysCaps01 test.syscap.param.001 :
"
+
isAccessToken
);
if
(
isAccessToken
)
{
ret
=
true
;
}
console
.
info
(
"
[wifi_test] setPowerModel:
"
+
wifiext
.
setPowerModel
(
PowerModel
))
expect
(
isAccessToken
).
assertFalse
();
done
();
}
catch
(
e
)
{
expect
(
ret
).
assertFalse
();
console
.
info
(
"
testSysCaps07 canIUse isAccessToken error:
"
+
e
);
}
console
.
info
(
'
testSysCaps07 end
'
);
done
();
})
console
.
log
(
"
*************[wifi_test] start wifi js unit test end*************
"
);
})
}
鸿蒙社区
@harmonycommunity
mentioned in commit
08751865
·
11月 03, 2022
mentioned in commit
08751865
mentioned in commit 087518658d862f4cedadd8f57970a2b93b0bc1b5
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录