mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 12:35:31 -04:00
!417 Add FaceAuth/UserAuth API Mock
Merge pull request !417 from 黄志敏/master
This commit is contained in:
@@ -91,6 +91,7 @@ import { mockSecurityLabel } from './ohos_securitylabel'
|
||||
import { mockWorkScheduler } from './ohos_workScheduler'
|
||||
import { mockWorkSchedulerExtensionAbility } from './ohos_WorkSchedulerExtensionAbility'
|
||||
import { mockUserAuth } from './ohos_userIAM_userAuth'
|
||||
import { mockFaceAuth } from './ohos_userIAM_faceAuth'
|
||||
import { mockArrayList } from './ohos_util_Arraylist'
|
||||
import { mockDeque } from './ohos_util_Deque'
|
||||
import { mockHashMap } from './ohos_util_HashMap'
|
||||
@@ -432,6 +433,8 @@ export function mockRequireNapiFun() {
|
||||
return mockWorkSchedulerExtensionAbility();
|
||||
case "userIAM.userAuth":
|
||||
return mockUserAuth();
|
||||
case "userIAM.faceAuth":
|
||||
return mockFaceAuth();
|
||||
case "util.ArrayList":
|
||||
return mockArrayList();
|
||||
case "util.Deque":
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 { paramMock } from "../utils"
|
||||
|
||||
export function mockFaceAuth() {
|
||||
|
||||
const ResultCode = {
|
||||
SUCCESS : 0,
|
||||
FAIL : 1
|
||||
}
|
||||
const FaceAuthManagerClass = class FaceAuthManager {
|
||||
constructor() {
|
||||
console.warn("faceAuth.constructor interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
|
||||
this.setSurfaceId = function (...args) {
|
||||
console.warn("faceAuth.setSurfaceId interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return ResultCode.SUCCESS;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const faceAuth = {
|
||||
ResultCode,
|
||||
FaceAuthManager : FaceAuthManagerClass
|
||||
}
|
||||
return faceAuth;
|
||||
}
|
||||
@@ -32,7 +32,13 @@ export function mockUserAuth() {
|
||||
onAcquireInfo: function (...args) {
|
||||
console.warn("uerAuth.onAcquireInfo interface mocked in the Previewer. How this interface works" +
|
||||
" on the Previewer may be different from that on a real device.")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const AuthResult = {
|
||||
token : paramMock.paramArrayMock,
|
||||
remainTimes : "[PC Preview] unknown remainTimes",
|
||||
freezingTime : "[PC Preview] unknown freezingTime",
|
||||
}
|
||||
|
||||
const AuthenticatorClass = class Authenticator {
|
||||
@@ -84,11 +90,12 @@ export function mockUserAuth() {
|
||||
console.warn("uerAuth.cancelAuth interface mocked in the Previewer." +
|
||||
" How this interface works on the Previewer may be different from that on a real device.")
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const result = {
|
||||
const userAuth = {
|
||||
AuthenticationResult: {
|
||||
NO_SUPPORT : -1,
|
||||
SUCCESS : 0,
|
||||
@@ -151,14 +158,12 @@ export function mockUserAuth() {
|
||||
ATL3 : 30000,
|
||||
ATL4 : 40000
|
||||
},
|
||||
|
||||
getAuthenticator: function (...args) {
|
||||
getAuthenticator : function (...args) {
|
||||
console.warn("uerAuth.getAuthenticator interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
return new AuthenticatorClass;
|
||||
},
|
||||
|
||||
UserAuth : UserAuthClass
|
||||
}
|
||||
return result
|
||||
return userAuth;
|
||||
}
|
||||
Reference in New Issue
Block a user