Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1c308076
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1c308076
编写于
1月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1703 人脸合作项目第一期测试代码上库
Merge pull request !1703 from 胡吉翔/useriam_js_220125
上级
a9bfaaf8
19e72de0
变更
38
隐藏空白更改
内联
并排
Showing
38 changed file
with
2236 addition
and
0 deletion
+2236
-0
useriam/BUILD.gn
useriam/BUILD.gn
+24
-0
useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn
...iam/face_auth/js_api_test/function_test/userauth/BUILD.gn
+31
-0
useriam/face_auth/js_api_test/function_test/userauth/Test.json
...am/face_auth/js_api_test/function_test/userauth/Test.json
+38
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json
...pi_test/function_test/userauth/entry/src/main/config.json
+84
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/app.js
...t/function_test/userauth/entry/src/main/js/default/app.js
+22
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/en-US.json
...n_test/userauth/entry/src/main/js/default/i18n/en-US.json
+6
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/zh-CN.json
...n_test/userauth/entry/src/main/js/default/i18n/zh-CN.json
+6
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.css
.../userauth/entry/src/main/js/default/pages/index/index.css
+60
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.hml
.../userauth/entry/src/main/js/default/pages/index/index.hml
+19
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.js
...t/userauth/entry/src/main/js/default/pages/index/index.js
+72
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json
...auth/entry/src/main/js/resources/base/element/string.json
+12
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/media/icon.png
.../userauth/entry/src/main/js/resources/base/media/icon.png
+0
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js
...function_test/userauth/entry/src/main/js/test/ListTest.js
+20
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/cancel.js
...t/function_test/userauth/entry/src/main/js/test/cancel.js
+141
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/checkAvailability.js
...test/userauth/entry/src/main/js/test/checkAvailability.js
+162
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js
.../function_test/userauth/entry/src/main/js/test/execute.js
+528
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/off.js
...test/function_test/userauth/entry/src/main/js/test/off.js
+80
-0
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/on.js
..._test/function_test/userauth/entry/src/main/js/test/on.js
+252
-0
useriam/face_auth/js_api_test/function_test/userauth/signature/openharmony_sx.p7b
..._test/function_test/userauth/signature/openharmony_sx.p7b
+0
-0
useriam/face_auth/js_api_test/performance_test/performance/BUILD.gn
...ce_auth/js_api_test/performance_test/performance/BUILD.gn
+31
-0
useriam/face_auth/js_api_test/performance_test/performance/Test.json
...e_auth/js_api_test/performance_test/performance/Test.json
+38
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/config.json
...t/performance_test/performance/entry/src/main/config.json
+66
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/app.js
...ormance_test/performance/entry/src/main/js/default/app.js
+22
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/i18n/en-US.json
...est/performance/entry/src/main/js/default/i18n/en-US.json
+6
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/i18n/zh-CN.json
...est/performance/entry/src/main/js/default/i18n/zh-CN.json
+6
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.css
...rformance/entry/src/main/js/default/pages/index/index.css
+60
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.hml
...rformance/entry/src/main/js/default/pages/index/index.hml
+19
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.js
...erformance/entry/src/main/js/default/pages/index/index.js
+42
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/resources/base/element/string.json
...ance/entry/src/main/js/resources/base/element/string.json
+12
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/resources/base/media/icon.png
...rformance/entry/src/main/js/resources/base/media/icon.png
+0
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/ListTest.js
...mance_test/performance/entry/src/main/js/test/ListTest.js
+20
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/cancel.js
...ormance_test/performance/entry/src/main/js/test/cancel.js
+60
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/checkAvailability.js
...t/performance/entry/src/main/js/test/checkAvailability.js
+50
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/execute.js
...rmance_test/performance/entry/src/main/js/test/execute.js
+91
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/getAuthenticator.js
...st/performance/entry/src/main/js/test/getAuthenticator.js
+54
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/off.js
...erformance_test/performance/entry/src/main/js/test/off.js
+51
-0
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/on.js
...performance_test/performance/entry/src/main/js/test/on.js
+51
-0
useriam/face_auth/js_api_test/performance_test/performance/signature/openharmony_sx.p7b
...performance_test/performance/signature/openharmony_sx.p7b
+0
-0
未找到文件。
useriam/BUILD.gn
0 → 100644
浏览文件 @
1c308076
# Copyright (C) 2021 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("//build/ohos_var.gni")
import("//test/xts/tools/build/suite.gni")
group("useriam") {
testonly = true
if (is_standard_system) {
deps = [
"face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
"face_auth/js_api_test/performance_test/performance:ActsUserauthPerformanceTest",
]
}
}
useriam/face_auth/js_api_test/function_test/userauth/BUILD.gn
0 → 100644
浏览文件 @
1c308076
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsUserauthTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUserauthTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
useriam/face_auth/js_api_test/function_test/userauth/Test.json
0 → 100644
浏览文件 @
1c308076
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"600000"
,
"package"
:
"com.example.myapplication101"
,
"shell-timeout"
:
"600000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsUserauthTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"remount"
,
"mkdir /data/test"
]
},
{
"type"
:
"PushKit"
,
"push"
:
[
"UserauthTest.hap->/data/test/ActsUserauthTest.hap"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 644 /data/test/*.hap"
,
"chmod 777 -R data"
]
}
]
}
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/config.json
0 → 100644
浏览文件 @
1c308076
{
"app"
:
{
"bundleName"
:
"com.example.myapplication101"
,
"vendor"
:
"example"
,
"version"
:
{
"code"
:
12
,
"name"
:
"1.0.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
,
"releaseType"
:
"Beta1"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"com.example.myapplication101"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"com.example.myapplication101.MainAbility"
,
"deviceType"
:
[
"phone"
,
"tablet"
,
"tv"
,
"wearable"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"name"
:
"com.example.myapplication101.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"launchType"
:
"standard"
,
"visible"
:
true
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
true
}
}
],
"reqPermissions"
:
[
{
"reason"
:
"reason_manage_face"
,
"usedScene"
:
{
"ability"
:
[
"com.myface.Ability"
,
"com.myface.AbilityBackground"
],
"when"
:
"always"
},
"name"
:
"ohos.permission.MANAGE_FACE"
},
{
"reason"
:
"reason_access_biometric"
,
"usedScene"
:
{
"ability"
:
[
"com.mybiometric.Ability"
,
"com.mybiometric.AbilityBackground"
],
"when"
:
"always"
},
"name"
:
"ohos.permission.ACCESS_BIOMETRIC"
}
]
}
}
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/app.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
AceApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
AceApplication onDestroy
'
);
}
};
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
1c308076
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
}
}
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
1c308076
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
}
}
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
40px
;
color
:
#000000
;
opacity
:
0.9
;
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
@media
screen
and
(
device-type
:
wearable
)
{
.title
{
font-size
:
28px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
tv
)
{
.container
{
background-image
:
url("/common/images/Wallpaper.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
}
.title
{
font-size
:
100px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
import
fileio
from
'
@ohos.fileio
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow start
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
this
.
timeout
=
35000
;
configService
.
setConfig
(
this
)
require
(
'
../../../test/ListTest
'
)
core
.
execute
()
console
.
info
(
'
onShow end
'
)
},
onReady
()
{
},
fileSave
(
caseNum
,
codeNum
,
...
code
)
{
console
.
log
(
caseNum
+
'
fileSave start
'
);
var
path
=
"
/data/config.dat
"
let
fd
=
fileio
.
openSync
(
path
,
0o102
,
0o666
);
var
message
=
caseNum
+
"
\r\n
"
+
codeNum
+
"
\r\n
"
;
for
(
var
i
=
0
;
i
<
code
.
length
;
i
++
){
message
=
message
+
code
[
i
]
+
"
\r\n
"
;
}
fileio
.
writeSync
(
fd
,
message
);
fileio
.
closeSync
(
fd
);
console
.
log
(
caseNum
+
'
fileSave end
'
);
},
fileSaveB
(
caseNum
,
code
)
{
console
.
log
(
caseNum
+
'
fileSave start
'
);
var
path
=
"
/data/config.dat
"
let
fd
=
fileio
.
openSync
(
path
,
0o102
,
0o666
);
var
message
=
code
;
fileio
.
writeSync
(
fd
,
message
);
fileio
.
closeSync
(
fd
);
console
.
log
(
caseNum
+
'
fileSave end
'
);
},
saveNull
()
{
console
.
log
(
'
JSAPI null file faceid.dat start
'
);
var
path
=
"
/data/faceId.dat
"
let
fd
=
fileio
.
openSync
(
path
,
0o102
,
0o666
);
var
message
=
""
;
fileio
.
writeSync
(
fd
,
message
);
fileio
.
closeSync
(
fd
);
console
.
log
(
'
JSAPI null file faceid.dat end
'
);
},
}
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/element/string.json
0 → 100644
浏览文件 @
1c308076
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Empty Ability"
}
]
}
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/resources/base/media/icon.png
0 → 100644
浏览文件 @
1c308076
6.6 KB
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/ListTest.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
require
(
'
./execute.js
'
)
require
(
'
./cancel.js
'
)
require
(
'
./checkAvailability.js
'
)
require
(
'
./on.js
'
)
require
(
'
./off.js
'
)
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/cancel.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
index
=
require
(
'
../default/pages/index/index.js
'
);
/**
* test case
*/
describe
(
'
userAuthTest
'
,
function
()
{
beforeEach
(
function
(
done
)
{
let
waitTime
=
1000
;
setTimeout
(
function
()
{
done
();
},
waitTime
);
})
afterEach
(
function
()
{
})
/**
* @tc.name execute_authentication_callback_cancel
* @tc.number JSAPI_Function_Cancel_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Cancel_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
flag
=
false
;
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0100 execute:
"
+
data
);
if
(
data
==
0
){
flag
=
true
;
}
setTimeout
(
function
()
{
done
();
},
1
);
if
(
flag
&&
data
!=
0
){
expect
(
data
).
assertEqual
(
2
);
}
});
let
result
=
auth
.
cancel
();
console
.
log
(
"
JSAPI_Function_Cancel_0100 auth.cancel:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_Cancel_0100 end
"
);
})
/**
* @tc.name execute_authentication_promise_cancel
* @tc.number JSAPI_Function_Cancel_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Cancel_0200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0200 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
flag
=
false
;
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0200 auth.execute:
"
+
data
);
if
(
data
==
0
){
flag
=
true
;
}
setTimeout
(
function
()
{
done
();
},
1
);
if
(
flag
&&
data
!=
0
){
expect
(
data
).
assertEqual
(
2
);
}
});
let
result
=
auth
.
cancel
();
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_Cancel_0200 auth.cancel:
"
+
result
);
console
.
log
(
"
JSAPI_Function_Cancel_0200 end
"
);
})
/**
* @tc.name no userAuth cancel
* @tc.number JSAPI_Function_Cancel_0300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Cancel_0300
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_Cancel_0300 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
cancel
();
console
.
log
(
"
JSAPI_Function_Cancel_0300 cancel result:
"
+
Number
(
result
));
expect
(
result
).
assertEqual
(
1
);
console
.
log
(
"
JSAPI_Function_Cancel_0300 end
"
);
})
/**
* @tc.name repeat cancel
* @tc.number JSAPI_Function_Cancel_0400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Cancel_0400
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0400 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
flag
=
false
;
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Cancel_0400 auth.execute:
"
+
data
);
if
(
data
==
0
){
flag
=
true
;
}
setTimeout
(
function
()
{
done
();
},
1
);
if
(
flag
&&
data
!=
0
){
expect
(
data
).
assertEqual
(
2
);
}
// CANCELED(2)
let
result2
=
auth
.
cancel
();
console
.
log
(
"
JSAPI_Function_Cancel_0400 2 cancel result2:
"
+
result2
);
expect
(
result2
).
assertEqual
(
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
let
result1
=
auth
.
cancel
();
console
.
log
(
"
JSAPI_Function_Cancel_0400 1 cancel result1:
"
+
result1
);
console
.
log
(
"
JSAPI_Function_Cancel_0400 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/checkAvailability.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
index
=
require
(
'
../default/pages/index/index.js
'
);
/**
* test case
*/
describe
(
'
userAuthTest
'
,
function
()
{
beforeEach
(
function
(
done
)
{
let
waitTime
=
1000
;
setTimeout
(
function
()
{
done
();
},
waitTime
);
})
afterEach
(
function
()
{
})
/**
* @tc.name checkAvailability type=FACE_ONLY
* @tc.number JSAPI_Function_CheckAvailability_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0100
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S2
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0100 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0100 end
"
);
})
/**
* @tc.name checkAvailability type=ALL
* @tc.number JSAPI_Function_CheckAvailability_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0200
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0200 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
ALL
"
,
"
S2
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0200 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0200 end
"
);
})
/**
* @tc.name checkAvailability type=null
* @tc.number JSAPI_Function_CheckAvailability_0300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0300
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0300 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
""
,
"
S2
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0300 result:
"
+
result
);
// AUTH_TYPE_NOT_SUPPORT
expect
(
result
).
assertEqual
(
1
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0300 end
"
);
})
/**
* @tc.name checkAvailability level=S1
* @tc.number JSAPI_Function_CheckAvailability_0400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0400
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0400 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S1
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0400 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0400 end
"
);
})
/**
* @tc.name checkAvailability level=S2
* @tc.number JSAPI_Function_CheckAvailability_0500
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0500
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0500 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S2
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0500 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0500 end
"
);
})
/**
* @tc.name checkAvailability level=S3
* @tc.number JSAPI_Function_CheckAvailability_0600
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0600
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0600 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S3
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0600 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0600 end
"
);
})
/**
* @tc.name checkAvailability level=S4
* @tc.number JSAPI_Function_CheckAvailability_0700
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0700
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0700 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S4
"
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0700 result:
"
+
result
);
expect
(
result
).
assertEqual
(
0
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0700 end
"
);
})
/**
* @tc.name checkAvailability level=null
* @tc.number JSAPI_Function_CheckAvailability_0800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_CheckAvailability_0800
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Function_CheckAvailability_0800 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
result
=
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
""
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0800 result:
"
+
result
);
// SECURE_LEVEL_NOT_SUPPORT
expect
(
result
).
assertEqual
(
2
);
console
.
log
(
"
JSAPI_Function_CheckAvailability_0800 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
index
=
require
(
'
../default/pages/index/index.js
'
);
var
waitFlag
=
false
;
/**
* test case
*/
describe
(
'
userAuthTest
'
,
function
()
{
beforeEach
(
function
(
done
)
{
let
waitTime
=
1000
;
if
(
waitFlag
)
{
waitTime
=
30000
;
}
setTimeout
(
function
()
{
done
();
},
waitTime
);
})
afterEach
(
function
()
{
})
/**
* @tc.name execute_authentication_callback_failed
* @tc.number JSAPI_Function_Execute_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0100 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0100
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0100 auth.execute:
"
+
data
);
// COMPARE_FAILURE(1)
expect
(
data
).
assertEqual
(
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0100 end
"
);
})
/**
* @tc.name execute_authentication_callback_timeout
* @tc.number JSAPI_Function_Execute_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0200 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0200
'
,
'
1
'
,
'
18 6 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0200 auth.execute:
"
+
data
);
// TIMEOUT (3)
expect
(
data
).
assertEqual
(
3
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0200 end
"
);
})
/**
* @tc.name execute_authentication_callback_camera_fail
* @tc.number JSAPI_Function_Execute_0300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0300
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0300 start
"
);
index
.
default
.
fileSaveB
(
'
JSAPI_Function_Execute_0300
'
,
'
903
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0300 auth.execute:
"
+
data
);
// CAMERA_FAIL(4)
expect
(
data
).
assertEqual
(
4
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0300 end
"
);
})
/**
* @tc.name execute_authentication_callback_busy
* @tc.number JSAPI_Function_Execute_0400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0400
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0400 start
"
);
waitFlag
=
true
;
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0400 auth.execute1:
"
+
data
);
})
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0400 auth.execute2:
"
+
data
);
// BUSY(5)
expect
(
data
).
assertEqual
(
5
);
setTimeout
(
function
()
{
done
();
},
3000
);
})
console
.
log
(
"
JSAPI_Function_Execute_0400 end
"
);
})
/**
* @tc.name execute_authentication_callback_LOCKED
* @tc.number JSAPI_Function_Execute_0500
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0500
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
// exe 1~5
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
();
}).
then
(
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute1:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute2:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute3:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute4:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute5:
"
+
data
);
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0500 auth.execute6:
"
+
data
);
// LOCKED(7)
expect
(
data
).
assertEqual
(
7
);
setTimeout
(
function
()
{
console
.
log
(
"
JSAPI_Function_Execute_0500 end wait 30m
"
);
done
();
},
1
);
})
})
})
})
})
})
);
console
.
log
(
"
JSAPI_Function_Execute_0500 end
"
);
})
/**
* @tc.name execute_authentication_callback_NOT_ENROLLED
* @tc.number JSAPI_Function_Execute_0600
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0600
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0600 start
"
);
waitFlag
=
false
;
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0800
'
,
'
1
'
,
'
18 9 0 0 0 0 0 0 0 0 0
'
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0600 auth.execute:
"
+
data
);
// NOT_ENROLLED(8)
expect
(
data
).
assertEqual
(
8
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0600 end
"
);
})
/**
* @tc.name execute_authentication_callback_GENERAL_ERROR
* @tc.number JSAPI_Function_Execute_0700
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0700
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0700 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0700
'
,
'
1
'
,
'
18 4 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0700 auth.execute:
"
+
data
);
// GENERAL_ERROR(100)
expect
(
data
).
assertEqual
(
100
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0700 end
"
);
})
/**
* @tc.name execute_authentication_promise_COMPARE_FAILURE
* @tc.number JSAPI_Function_Execute_0800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0800
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0800 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0800
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0800 auth.execute:
"
+
data
);
// COMPARE_FAILURE(1)
expect
(
data
).
assertEqual
(
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0800 end
"
);
})
/**
* @tc.name execute_authentication_promise_TIMEOUT
* @tc.number JSAPI_Function_Execute_0900
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_0900
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_0900 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0800
'
,
'
1
'
,
'
18 6 0 0 0 0 0 0 0 0 0
'
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_0900 auth.execute:
"
+
data
);
// TIMEOUT (3)
expect
(
data
).
assertEqual
(
3
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_0900 end
"
);
})
/**
* @tc.name execute_authentication_promise_CAMERA_FAIL
* @tc.number JSAPI_Function_Execute_1000
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1000
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1000 start
"
);
index
.
default
.
fileSaveB
(
'
JSAPI_Function_Execute_1000
'
,
'
903
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1000 auth.execute:
"
+
data
);
// CAMERA_FAIL(4)
expect
(
data
).
assertEqual
(
4
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1000 end
"
);
})
/**
* @tc.name execute_authentication_promise_BUSY
* @tc.number JSAPI_Function_Execute_1100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1100 start
"
);
waitFlag
=
true
;
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1100 auth.execute1:
"
+
data
);
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1100 auth.execute2:
"
+
data
);
// BUSY(5)
expect
(
data
).
assertEqual
(
5
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1100 end
"
);
})
/**
* @tc.name execute_authentication_promise_LOCKED
* @tc.number JSAPI_Function_Execute_1200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
// exe 1~5
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
();
}).
then
(
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute1:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute2:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute3:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute4:
"
+
data
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0500
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
)
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute5:
"
+
data
);
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1200 auth.execute6:
"
+
data
);
// LOCKED(7)
expect
(
data
).
assertEqual
(
7
);
setTimeout
(
function
()
{
done
();
},
1
);
});
})
})
})
})
})
);
console
.
log
(
"
JSAPI_Function_Execute_1200 end
"
);
})
/**
* @tc.name execute_authentication_promise_NOT_ENROLLED
* @tc.number JSAPI_Function_Execute_1300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1300
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1300 start
"
);
waitFlag
=
false
;
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_0800
'
,
'
1
'
,
'
18 9 0 0 0 0 0 0 0 0 0
'
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1300 auth.execute:
"
+
data
);
// NOT_ENROLLED(8)
expect
(
data
).
assertEqual
(
8
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1300 end
"
);
})
/**
* @tc.name execute_authentication_promise_GENERAL_ERROR
* @tc.number JSAPI_Function_Execute_1400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1400
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1400 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_Execute_1400
'
,
'
1
'
,
'
18 4 0 0 0 0 0 0 0 0 0
'
)
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1400 auth.execute:
"
+
data
);
// GENERAL_ERROR(100)
expect
(
data
).
assertEqual
(
100
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1400 end
"
);
})
/**
* @tc.name execute_authentication_callback_FACE_ONLY_SUCCESS
* @tc.number JSAPI_Function_Execute_1600
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1600
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1600 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S1
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1600 auth.execute:
"
+
data
);
// SUCCESS(0)
expect
(
data
).
assertEqual
(
0
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1600 end
"
);
})
/**
* @tc.name execute_authentication_callback_ALL_NO_SUPPORT
* @tc.number JSAPI_Function_Execute_1700
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1700
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1700 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
ALL
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1700 auth.execute:
"
+
data
);
// NO_SUPPORT(-1)
expect
(
data
).
assertEqual
(
-
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1700 end
"
);
})
/**
* @tc.name execute_authentication_callback_Type_is_null
* @tc.number JSAPI_Function_Execute_1800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1800
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1800 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
""
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1800 auth.execute:
"
+
data
);
// INVALID_PARAMETERS(6)
expect
(
data
).
assertEqual
(
6
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1800 end
"
);
})
/**
* @tc.name execute_authentication_promise_FACE_ONLY_SUCCESS
* @tc.number JSAPI_Function_Execute_1900
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_1900
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_1900 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_1900 auth.execute:
"
+
data
);
// SUCCESS(0)
expect
(
data
).
assertEqual
(
0
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_1900 end
"
);
})
/**
* @tc.name execute_authentication_promise_ALL_NO_SUPPORT
* @tc.number JSAPI_Function_Execute_2000
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_2000
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_2000 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
"
ALL
"
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_2000 auth.execute:
"
+
data
);
// NO_SUPPORT(-1)
expect
(
data
).
assertEqual
(
-
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_2000 end
"
);
})
/**
* @tc.name execute_authentication_promise_Type_is_null
* @tc.number JSAPI_Function_Execute_2100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Execute_2100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Execute_2100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
execute
(
""
,
"
S2
"
).
then
(
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Execute_2100 auth.execute:
"
+
data
);
// INVALID_PARAMETERS(6)
expect
(
data
).
assertEqual
(
6
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Execute_2100 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/off.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
index
=
require
(
'
../default/pages/index/index.js
'
);
/**
* test case
*/
describe
(
'
userAuthTest
'
,
function
()
{
beforeEach
(
function
(
done
)
{
let
waitTime
=
1000
;
setTimeout
(
function
()
{
done
();
},
waitTime
);
})
afterEach
(
function
()
{
})
/**
* @tc.name off FAILED
* @tc.number JSAPI_Function_Off_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Off_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Off_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
off
(
"
tip8
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Off_0100 off:
"
+
data
);
// errorCode=FAILED
expect
(
data
).
assertEqual
(
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Off_0100 end
"
);
})
/**
* @tc.name off FAILED
* @tc.number JSAPI_Function_Off_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_Off_0200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_Off_0200 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
auth
.
on
(
"
tip1
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Off_0200 tip1 on CallBack
"
);
});
auth
.
on
(
"
tip2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Off_0200 tip2 on CallBack
"
);
});
auth
.
off
(
"
tip1
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_Off_0200 off:
"
+
data
);
// errorCode=SUCCESS
expect
(
data
).
assertEqual
(
0
);
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_Off_0200 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/on.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
var
index
=
require
(
'
../default/pages/index/index.js
'
);
var
waitFlag
=
false
;
/**
* test case
*/
describe
(
'
userAuthTest
'
,
function
()
{
beforeEach
(
function
(
done
)
{
let
waitTime
=
1000
;
if
(
waitFlag
)
{
waitTime
=
30000
;
}
setTimeout
(
function
()
{
done
();
},
waitTime
);
})
afterEach
(
function
()
{
})
/**
* @tc.name on getTips 0100
* @tc.number JSAPI_Function_On_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_On_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_On_0100 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_On_0100
'
,
'
12
'
,
'
8200 0 0 0 0 0 0 0 0 0 0
'
,
'
13 0 0 0 0 0 0 0 0 0 0
'
,
'
4 0 0 0 0 0 0 0 0 0 0
'
,
'
3 0 0 0 0 0 0 0 0 0 0
'
,
'
6 0 0 0 0 0 0 0 0 0 0
'
,
'
8 0 0 0 0 0 0 0 0 0 0
'
,
'
7 0 0 0 0 0 0 0 0 0 0
'
,
'
5 0 0 0 0 0 0 0 0 0 0
'
,
'
4105 0 0 0 0 0 0 0 0 0 0
'
,
'
9 0 0 0 0 0 0 0 0 0 0
'
,
'
2 0 0 0 0 0 0 0 0 0 0
'
,
'
17 0 0 0 0 0 0 0 0 0 0
'
);
const
auth
=
userAuth
.
getAuthenticator
();
let
tipCodeIndex
=
1
;
auth
.
on
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0100 on.index:
"
+
tipCodeIndex
);
console
.
log
(
"
JSAPI_Function_On_0100 on.errorCode:
"
+
data
.
errorCode
);
console
.
log
(
"
JSAPI_Function_On_0100 on.tipEvent:
"
+
data
.
tipEvent
);
console
.
log
(
"
JSAPI_Function_On_0100 on.tipCode:
"
+
data
.
tipCode
);
if
(
tipCodeIndex
<
12
){
// errorCode = Success
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// ACQUIRE = 3
expect
(
data
.
tipEvent
).
assertEqual
(
3
);
// FACE_AUTH_TIP_TOO_BRIGHT = 1,
// FACE_AUTH_TIP_TOO_DARK = 2,
// FACE_AUTH_TIP_TOO_CLOSE = 3,
// FACE_AUTH_TIP_TOO_FAR = 4,
// FACE_AUTH_TIP_TOO_HIGH = 5,
// FACE_AUTH_TIP_TOO_LOW = 6,
// FACE_AUTH_TIP_TOO_RIGHT = 7,
// FACE_AUTH_TIP_TOO_LEFT = 8,
// FACE_AUTH_TIP_TOO_MUCH_MOTION = 9,
// FACE_AUTH_TIP_POOR_GAZE = 10,
// FACE_AUTH_TIP_NOT_DETECTED = 11,
expect
(
data
.
tipCode
).
assertEqual
(
tipCodeIndex
);
tipCodeIndex
=
tipCodeIndex
+
1
;
}
else
{
// errorCode = Success
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// result = 1
expect
(
data
.
tipEvent
).
assertEqual
(
1
);
expect
(
data
.
tipCode
).
assertEqual
(
0
);
}
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0100 auth.execute:
"
+
data
);
auth
.
off
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0100 off:
"
+
data
);
});
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_On_0100 end
"
);
})
/**
* @tc.name on getTips 0200
* @tc.number JSAPI_Function_On_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_On_0200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_On_0200 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
waitFlag
=
true
;
auth
.
on
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0200 on.errorCode:
"
+
data
.
errorCode
);
console
.
log
(
"
JSAPI_Function_On_0200 on.tipEvent:
"
+
data
.
tipEvent
);
if
(
data
.
tipEvent
==
1
){
// errorCode= SUCCESS
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// RESULT = 1
expect
(
data
.
tipEvent
).
assertEqual
(
1
);
}
setTimeout
(
function
()
{
done
();
},
1
);
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0200 auth.execute:
"
+
data
);
expect
(
data
).
assertEqual
(
0
);
auth
.
off
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0200 off:
"
+
data
);
});
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_On_0200 end
"
);
})
/**
* @tc.name on getTips 0300
* @tc.number JSAPI_Function_On_0300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_On_0300
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_On_0300 start
"
);
index
.
default
.
fileSave
(
'
JSAPI_Function_On_0300
'
,
'
1
'
,
'
18 0 0 0 0 0 0 0 0 0 0
'
);
const
auth
=
userAuth
.
getAuthenticator
();
waitFlag
=
false
;
auth
.
on
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0300 on.errorCode:
"
+
data
.
errorCode
);
console
.
log
(
"
JSAPI_Function_On_0300 on.tipEvent:
"
+
data
.
tipEvent
);
// errorCode= Success
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// RESULT = 1
expect
(
data
.
tipEvent
).
assertEqual
(
1
);
setTimeout
(
function
()
{
done
();
},
1
);
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0300 auth.execute:
"
+
data
);
expect
(
data
).
assertEqual
(
1
);
auth
.
off
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0300 off:
"
+
data
);
});
setTimeout
(
function
()
{
done
();
},
1
);
});
console
.
log
(
"
JSAPI_Function_On_0300 end
"
);
})
/**
* @tc.name on getTips 0400
* @tc.number JSAPI_Function_On_0400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_On_0400
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_On_0400 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
waitFlag
=
true
;
auth
.
on
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0400 on.errorCode:
"
+
data
.
errorCode
);
console
.
log
(
"
JSAPI_Function_On_0400 on.tipEvent:
"
+
data
.
tipEvent
);
if
(
data
.
tipCode
==
5
){
expect
(
data
.
tipCode
).
assertEqual
(
5
);
// errorCode= SUCCESS
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// RESULT = 1
expect
(
data
.
tipEvent
).
assertEqual
(
1
);
}
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0400 auth.execute:
"
+
data
);
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0400 auth.execute:
"
+
data
);
auth
.
off
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0400 off:
"
+
data
);
});
setTimeout
(
function
()
{
done
();
},
3000
);
});
console
.
log
(
"
JSAPI_Function_On_0400 end
"
);
})
/**
* @tc.name on getTips 0500
* @tc.number JSAPI_Function_On_0500
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Function_On_0500
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Function_On_0500 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
waitFlag
=
false
;
auth
.
on
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0500 on.errorCode:
"
+
data
.
errorCode
);
console
.
log
(
"
JSAPI_Function_On_0500 on.tipEvent:
"
+
data
.
tipEvent
);
// errorCode= SUCCESS
expect
(
data
.
errorCode
).
assertEqual
(
0
);
// CANCEL = 2
expect
(
data
.
tipEvent
).
assertEqual
(
2
);
setTimeout
(
function
()
{
done
();
},
1
);
});
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0500 auth.execute:
"
+
data
);
auth
.
off
(
"
tip
"
,
function
(
data
)
{
console
.
log
(
"
JSAPI_Function_On_0500 off:
"
+
data
);
});
setTimeout
(
function
()
{
done
();
},
1
);
});
let
result
=
auth
.
cancel
();
console
.
log
(
"
JSAPI_Function_On_0500 auth.cancel:
"
+
result
);
console
.
log
(
"
JSAPI_Function_On_0500 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/function_test/userauth/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
1c308076
文件已添加
useriam/face_auth/js_api_test/performance_test/performance/BUILD.gn
0 → 100644
浏览文件 @
1c308076
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsUserauthPerformanceTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUserauthPerformanceTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
useriam/face_auth/js_api_test/performance_test/performance/Test.json
0 → 100644
浏览文件 @
1c308076
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"19000000"
,
"package"
:
"com.example.myapplication102"
,
"shell-timeout"
:
"19000000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsUserauthPerformanceTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"remount"
,
"mkdir /data/test"
]
},
{
"type"
:
"PushKit"
,
"push"
:
[
"PerformanceTest.hap->/data/test/ActsUserauthPerformanceTest.hap"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 644 /data/test/*.hap"
,
"chmod 777 -R data"
]
}
]
}
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/config.json
0 → 100644
浏览文件 @
1c308076
{
"app"
:
{
"bundleName"
:
"com.example.myapplication102"
,
"vendor"
:
"example"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
,
"releaseType"
:
"Beta1"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"com.example.myapplication102"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"com.example.myapplication102.MainAbility"
,
"deviceType"
:
[
"phone"
,
"tablet"
,
"tv"
,
"wearable"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"name"
:
"com.example.myapplication102.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"launchType"
:
"standard"
,
"visible"
:
true
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
true
}
}
]
}
}
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/app.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
AceApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
AceApplication onDestroy
'
);
}
};
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
1c308076
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
}
}
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
1c308076
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
}
}
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
40px
;
color
:
#000000
;
opacity
:
0.9
;
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
@media
screen
and
(
device-type
:
wearable
)
{
.title
{
font-size
:
28px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
tv
)
{
.container
{
background-image
:
url("/common/images/Wallpaper.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
}
.title
{
font-size
:
100px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
import
fileio
from
'
@ohos.fileio
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow start
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
this
.
timeout
=
6100000
;
configService
.
setConfig
(
this
)
require
(
'
../../../test/ListTest
'
)
core
.
execute
()
console
.
info
(
'
onShow end
'
)
},
onReady
()
{
},
}
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/resources/base/element/string.json
0 → 100644
浏览文件 @
1c308076
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Empty Ability"
}
]
}
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/resources/base/media/icon.png
0 → 100644
浏览文件 @
1c308076
6.6 KB
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/ListTest.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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.
*/
require
(
'
./getAuthenticator.js
'
)
require
(
'
./execute.js
'
)
require
(
'
./cancel.js
'
)
require
(
'
./checkAvailability.js
'
)
require
(
'
./on.js
'
)
require
(
'
./off.js
'
)
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/cancel.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name cancel performance
* @tc.number JSAPI_Performance_Cancel_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_Cancel_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Performance_Cancel_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
let
count
=
0
;
function
callback
(){
if
(
count
<=
1000
){
console
.
log
(
"
JSAPI_Performance_Cancel_0100 count
"
+
++
count
);
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
callback
)
let
startDate
=
new
Date
();
auth
.
cancel
()
let
endDate
=
new
Date
();
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
else
{
console
.
log
(
"
JSAPI_Performance_Cancel_0100 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_Cancel_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_Cancel_0100 end
"
);
setTimeout
(
function
()
{
done
();
},
1
);
}
}
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
callback
)
auth
.
cancel
()
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/checkAvailability.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name checkAvailability performance
* @tc.number JSAPI_Performance_CheckAvailability_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_CheckAvailability_0100
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Performance_CheckAvailability_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
for
(
let
i
=
0
;
i
<
1000
;
i
++
){
console
.
log
(
"
JSAPI_Performance_CheckAvailability_0100 count
"
+
i
);
let
startDate
=
new
Date
();
auth
.
checkAvailability
(
"
FACE_ONLY
"
,
"
S2
"
)
let
endDate
=
new
Date
();
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
console
.
log
(
"
JSAPI_Performance_CheckAvailability_0100 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_CheckAvailability_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_CheckAvailability_0100 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/execute.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name execute_authentication_callback_performance
* @tc.number JSAPI_Performance_Execute_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_Execute_0100
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Performance_Execute_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
let
count
=
0
;
function
callback
(
data
){
if
(
count
<=
1000
){
console
.
log
(
"
JSAPI_Performance_Execute_0100 count
"
+
++
count
);
let
startDate
=
new
Date
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
callback
)
let
endDate
=
new
Date
();
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
else
{
console
.
log
(
"
JSAPI_Performance_Execute_0100 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_Execute_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_Execute_0100 end
"
);
setTimeout
(
function
()
{
done
();
},
1
);
}
}
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
callback
)
})
/**
* @tc.name execute_authentication_promise_performance
* @tc.number JSAPI_Performance_Execute_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_Execute_0200
'
,
0
,
function
(
done
)
{
console
.
log
(
"
JSAPI_Performance_Execute_0200 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
let
count
=
0
;
function
promise
(
data
){
console
.
log
(
"
JSAPI_Performance_Execute_0200 count
"
+
++
count
);
if
(
count
<=
1000
){
console
.
log
(
"
JSAPI_Performance_Execute_0100 count
"
+
++
count
);
let
startDate
=
new
Date
();
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
).
then
(
promise
)
let
endDate
=
new
Date
();
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
else
{
console
.
log
(
"
JSAPI_Performance_Execute_0200 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_Execute_0200 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_Execute_0200 end
"
);
setTimeout
(
function
()
{
done
();
},
1
);
}
}
auth
.
execute
(
"
FACE_ONLY
"
,
"
S2
"
,
promise
)
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/getAuthenticator.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name getAuthenticator performance
* @tc.number JSAPI_Performance_GetAuthenticator_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_GetAuthenticator_0100
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Performance_GetAuthenticator_0100 start
"
);
let
allTime
=
0
;
for
(
let
i
=
0
;
i
<
1000
;
i
++
)
{
let
result
=
false
;
let
startDate
=
new
Date
();
const
auth
=
userAuth
.
getAuthenticator
();
if
(
auth
!==
null
)
{
result
=
true
;
}
expect
(
result
).
assertTrue
();
let
endDate
=
new
Date
();
let
diff
=
endDate
.
getTime
()
-
startDate
.
getTime
();
allTime
=
allTime
+
diff
;
}
console
.
log
(
"
JSAPI_Performance_GetAuthenticator_0100 performance all time
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_GetAuthenticator_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_GetAuthenticator_0100 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/off.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name off performance
* @tc.number JSAPI_Performance_Off_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_Off_0100
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Performance_Off_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
for
(
let
i
=
0
;
i
<
1000
;
i
++
){
console
.
log
(
"
JSAPI_Performance_Off_0100 count
"
+
i
);
auth
.
on
(
"
tip
"
+
i
,
function
(
data
)
{})
let
startDate
=
new
Date
();
auth
.
off
(
"
tip
"
+
i
,
function
(
data
)
{})
let
endDate
=
new
Date
();
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
console
.
log
(
"
JSAPI_Performance_Off_0100 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_Off_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_Off_0100 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/entry/src/main/js/test/on.js
0 → 100644
浏览文件 @
1c308076
/*
* Copyright (c) 2021 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
userAuth
from
'
@ohos.userIAM.userAuth
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
/**
* performance case
*/
describe
(
'
userAuthPerformanceTest
'
,
function
()
{
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
/**
* @tc.name on performance
* @tc.number JSAPI_Performance_On_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it
(
'
JSAPI_Performance_On_0100
'
,
0
,
function
()
{
console
.
log
(
"
JSAPI_Performance_On_0100 start
"
);
const
auth
=
userAuth
.
getAuthenticator
();
let
allTime
=
0
;
for
(
let
i
=
0
;
i
<
1000
;
i
++
){
console
.
log
(
"
JSAPI_Performance_On_0100 count
"
+
i
);
let
startDate
=
new
Date
();
auth
.
on
(
"
tip
"
+
i
,
function
(
data
)
{})
let
endDate
=
new
Date
();
auth
.
off
(
"
tip
"
+
i
,
function
(
data
)
{})
allTime
+=
(
endDate
.
getTime
()
-
startDate
.
getTime
());
}
console
.
log
(
"
JSAPI_Performance_On_0100 performance allTime:
"
+
allTime
);
console
.
log
(
"
JSAPI_Performance_On_0100 performance avg
"
+
(
allTime
/
1000
));
expect
((
allTime
/
1000
)
<
2
).
assertTrue
();
console
.
log
(
"
JSAPI_Performance_On_0100 end
"
);
})
})
\ No newline at end of file
useriam/face_auth/js_api_test/performance_test/performance/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
1c308076
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录