From 3a253381ec6bbbd3e1c16a222cc94f7279a075f2 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 21 Jul 2022 16:29:03 +0800 Subject: [PATCH 1/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 124 +++++++++++++++++- 1 file changed, 118 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 70eb0116..09605e12 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -15,23 +15,135 @@ import { paramMock } from "../utils" -export const constraintSourceType = { +export const ConstraintSourceType = { CONSTRAINT_NOT_EXIST: 0, CONSTRAINT_TYPE_BASE: 1, CONSTRAINT_TYPE_DEVICE_OWNER: 2, CONSTRAINT_TYPE_PROFILE_OWNER: 3 }; +export const OsAccountTypeMock = { + ADMIN: 0, + NORMAL: 1, + GUEST: 2 +}; +export const FingerprintTips = { + FINGERPRINT_TIP_GOOD: 0, + FINGERPRINT_TIP_IMAGER_DIRTY: 1, + FINGERPRINT_TIP_INSUFFICIENT: 2, + FINGERPRINT_TIP_PARTIAL: 3, + FINGERPRINT_TIP_TOO_FAST: 4, + FINGERPRINT_TIP_TOO_SLOW: 5 +}; +export const FaceTipsCode = { + 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 +}; +export const EesultCode = { + SUCCESS: 0, + FAIL: 1, + GENERAL_ERROR: 2, + CANCELED: 3, + TIMEOUT: 4, + TYPE_NOT_SUPPORT: 5, + TRUST_LEVEL_NOT_SUPPORT: 6, + BUSY: 7, + INVALID_PARAMETERS: 8, + LOCKED: 9, + NOT_ENROLLED: 10 +}; +export const module = { + FACE_AUTH: 1 +}; +export const authTrustLevel = { + ATL1: 10000, + ATL2: 20000, + ATL3: 30000, + ATL4: 40000 +}; +export const authSubType = { + PIN_SIX: 10000, + PIN_NUMBER: 10001, + PIN_MIXED: 10002, + FACE_2D: 20000, + FACE_3D: 20001 +}; +export const getPropertyType = { + AUTH_SUB_TYPE: 1, + REMAIN_TIMES: 2, + FREEZING_TIME: 3 +}; +export const setPropertyType = { + INIT_ALGORITHM: 1 +}; +export const authType = { + PIN: 1, + FACE: 2 +}; export function mockOsAccount() { const osAccountInfoMock = { - localId: "[PC Preview] unknown id", - localName: "[PC Preview] unknown name", + localId: "[PC Preview] unknown localId", + localName: "[PC Preview] unknown localName", type: "[PC Preview] unknown type", constraints: "[PC Preview] unknown constraints", + isVerified: "[PC Preview] unknown isVerified", + photo: "[PC Preview] unknown photo", + createTime: "[PC Preview] unknown createTime", + lastLoginTime: "[PC Preview] unknown lastLoginTime", + serialNumber: "[PC Preview] unknown serialNumber", + isActived: "[PC Preview] unknown isActived", + domainInfo: "[PC Preview] unknown domainInfo", distributedInfo: "[PC Preview] unknown distributedInfo" }; + const domainAccountInfoMock = { + domain: "[PC Preview] unknown domain", + accountName: "[PC Preview] unknown accountName" + }; const constraintSourceTypeInfoMock = { - localId: "[PC Preview] unknown id", - type: constraintSourceType, + localId: "[PC Preview] unknown localId", + type: "[PC Preview] unknown type" + }; + const getPropertyRequest = { + authType: "[PC Preview] unknown authType", + keys: "[PC Preview] unknown keys" + }; + const setPropertyRequest = { + authType: "[PC Preview] unknown authType", + key: "[PC Preview] unknown key", + setInfo: "[PC Preview] unknown setInfo" + }; + const executorProperty = { + result: "[PC Preview] unknown result", + authSubType: "[PC Preview] unknown authSubType", + remainTimes: "[PC Preview] unknown remainTimes", + freezingTime: "[PC Preview] unknown freezingTime" + }; + const authResult = { + token: "[PC Preview] unknown token", + remainTimes: "[PC Preview] unknown remainTimes", + ferezingTime: "[PC Preview] unknown freezingTime" + }; + const credentialInfo = { + credType: "[PC Preview] unknown credType", + credSubType: "[PC Preview] unknown credSubType", + token: "[PC Preview] unknown token" + }; + const requestResult = { + credentialId: "[PC Preview] unknown credentialId" + }; + const enrolledCredInfo = { + credentialId: "[PC Preview] unknown credentialId", + authType: "[PC Preview] unknown authType", + authSubType: "[PC Preview] unknown authSubType", + templateId: "[PC Preview] unknown templateId" }; const osAccountTypeMock = "[PC Preview] unknown type"; const accountManagerMock = { @@ -440,4 +552,4 @@ export function mockOsAccount() { constraintSourceType, } return osAccount -} \ No newline at end of file +} From 3b001581c7c19ed500185d61a405f6b353f40f73 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 11:11:49 +0800 Subject: [PATCH 2/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 09605e12..cdb31e26 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -21,7 +21,7 @@ export const ConstraintSourceType = { CONSTRAINT_TYPE_DEVICE_OWNER: 2, CONSTRAINT_TYPE_PROFILE_OWNER: 3 }; -export const OsAccountTypeMock = { +export const OsAccountType = { ADMIN: 0, NORMAL: 1, GUEST: 2 @@ -47,7 +47,7 @@ export const FaceTipsCode = { FACE_AUTH_TIP_POOR_GAZE: 10, FACE_AUTH_TIP_NOT_DETECTED: 11 }; -export const EesultCode = { +export const ResultCode = { SUCCESS: 0, FAIL: 1, GENERAL_ERROR: 2, @@ -60,36 +60,36 @@ export const EesultCode = { LOCKED: 9, NOT_ENROLLED: 10 }; -export const module = { +export const Module = { FACE_AUTH: 1 }; -export const authTrustLevel = { +export const AuthTrustLevel = { ATL1: 10000, ATL2: 20000, ATL3: 30000, ATL4: 40000 }; -export const authSubType = { +export const AuthSubType = { PIN_SIX: 10000, PIN_NUMBER: 10001, PIN_MIXED: 10002, FACE_2D: 20000, FACE_3D: 20001 }; -export const getPropertyType = { +export const GetPropertyType = { AUTH_SUB_TYPE: 1, REMAIN_TIMES: 2, FREEZING_TIME: 3 }; -export const setPropertyType = { +export const SetPropertyType = { INIT_ALGORITHM: 1 }; -export const authType = { +export const AuthType = { PIN: 1, FACE: 2 }; export function mockOsAccount() { - const osAccountInfoMock = { + const OsAccountInfoMock = { localId: "[PC Preview] unknown localId", localName: "[PC Preview] unknown localName", type: "[PC Preview] unknown type", @@ -103,50 +103,50 @@ export function mockOsAccount() { domainInfo: "[PC Preview] unknown domainInfo", distributedInfo: "[PC Preview] unknown distributedInfo" }; - const domainAccountInfoMock = { + const DomainAccountInfoMock = { domain: "[PC Preview] unknown domain", accountName: "[PC Preview] unknown accountName" }; - const constraintSourceTypeInfoMock = { + const ConstraintSourceTypeInfoMock = { localId: "[PC Preview] unknown localId", type: "[PC Preview] unknown type" }; - const getPropertyRequest = { + const GetPropertyRequest = { authType: "[PC Preview] unknown authType", keys: "[PC Preview] unknown keys" }; - const setPropertyRequest = { + const SetPropertyRequest = { authType: "[PC Preview] unknown authType", key: "[PC Preview] unknown key", setInfo: "[PC Preview] unknown setInfo" }; - const executorProperty = { + const ExecutorProperty = { result: "[PC Preview] unknown result", authSubType: "[PC Preview] unknown authSubType", remainTimes: "[PC Preview] unknown remainTimes", freezingTime: "[PC Preview] unknown freezingTime" }; - const authResult = { + const AuthResult = { token: "[PC Preview] unknown token", remainTimes: "[PC Preview] unknown remainTimes", ferezingTime: "[PC Preview] unknown freezingTime" }; - const credentialInfo = { + const CredentialInfo = { credType: "[PC Preview] unknown credType", credSubType: "[PC Preview] unknown credSubType", token: "[PC Preview] unknown token" }; - const requestResult = { + const RequestResult = { credentialId: "[PC Preview] unknown credentialId" }; - const enrolledCredInfo = { + const EnrolledCredInfo = { credentialId: "[PC Preview] unknown credentialId", authType: "[PC Preview] unknown authType", authSubType: "[PC Preview] unknown authSubType", templateId: "[PC Preview] unknown templateId" }; - const osAccountTypeMock = "[PC Preview] unknown type"; - const accountManagerMock = { + const OsAccountTypeMock = "[PC Preview] unknown type"; + const AccountManagerMock = { activateOsAccount: function (...args) { console.warn("AccountManager.activateOsAccount interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") From 18d700363cfe6da85c16be60593562638f7986a9 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 11:21:00 +0800 Subject: [PATCH 3/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index cdb31e26..de28a68f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -15,79 +15,6 @@ import { paramMock } from "../utils" -export const ConstraintSourceType = { - CONSTRAINT_NOT_EXIST: 0, - CONSTRAINT_TYPE_BASE: 1, - CONSTRAINT_TYPE_DEVICE_OWNER: 2, - CONSTRAINT_TYPE_PROFILE_OWNER: 3 -}; -export const OsAccountType = { - ADMIN: 0, - NORMAL: 1, - GUEST: 2 -}; -export const FingerprintTips = { - FINGERPRINT_TIP_GOOD: 0, - FINGERPRINT_TIP_IMAGER_DIRTY: 1, - FINGERPRINT_TIP_INSUFFICIENT: 2, - FINGERPRINT_TIP_PARTIAL: 3, - FINGERPRINT_TIP_TOO_FAST: 4, - FINGERPRINT_TIP_TOO_SLOW: 5 -}; -export const FaceTipsCode = { - 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 -}; -export const ResultCode = { - SUCCESS: 0, - FAIL: 1, - GENERAL_ERROR: 2, - CANCELED: 3, - TIMEOUT: 4, - TYPE_NOT_SUPPORT: 5, - TRUST_LEVEL_NOT_SUPPORT: 6, - BUSY: 7, - INVALID_PARAMETERS: 8, - LOCKED: 9, - NOT_ENROLLED: 10 -}; -export const Module = { - FACE_AUTH: 1 -}; -export const AuthTrustLevel = { - ATL1: 10000, - ATL2: 20000, - ATL3: 30000, - ATL4: 40000 -}; -export const AuthSubType = { - PIN_SIX: 10000, - PIN_NUMBER: 10001, - PIN_MIXED: 10002, - FACE_2D: 20000, - FACE_3D: 20001 -}; -export const GetPropertyType = { - AUTH_SUB_TYPE: 1, - REMAIN_TIMES: 2, - FREEZING_TIME: 3 -}; -export const SetPropertyType = { - INIT_ALGORITHM: 1 -}; -export const AuthType = { - PIN: 1, - FACE: 2 -}; export function mockOsAccount() { const OsAccountInfoMock = { localId: "[PC Preview] unknown localId", @@ -538,6 +465,79 @@ export function mockOsAccount() { } }, }; + const ConstraintSourceType = { + CONSTRAINT_NOT_EXIST: 0, + CONSTRAINT_TYPE_BASE: 1, + CONSTRAINT_TYPE_DEVICE_OWNER: 2, + CONSTRAINT_TYPE_PROFILE_OWNER: 3 + }; + const OsAccountType = { + ADMIN: 0, + NORMAL: 1, + GUEST: 2 + }; + const FingerprintTips = { + FINGERPRINT_TIP_GOOD: 0, + FINGERPRINT_TIP_IMAGER_DIRTY: 1, + FINGERPRINT_TIP_INSUFFICIENT: 2, + FINGERPRINT_TIP_PARTIAL: 3, + FINGERPRINT_TIP_TOO_FAST: 4, + FINGERPRINT_TIP_TOO_SLOW: 5 + }; + const FaceTipsCode = { + 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 + }; + const ResultCode = { + SUCCESS: 0, + FAIL: 1, + GENERAL_ERROR: 2, + CANCELED: 3, + TIMEOUT: 4, + TYPE_NOT_SUPPORT: 5, + TRUST_LEVEL_NOT_SUPPORT: 6, + BUSY: 7, + INVALID_PARAMETERS: 8, + LOCKED: 9, + NOT_ENROLLED: 10 + }; + const Module = { + FACE_AUTH: 1 + }; + const AuthTrustLevel = { + ATL1: 10000, + ATL2: 20000, + ATL3: 30000, + ATL4: 40000 + }; + const AuthSubType = { + PIN_SIX: 10000, + PIN_NUMBER: 10001, + PIN_MIXED: 10002, + FACE_2D: 20000, + FACE_3D: 20001 + }; + const GetPropertyType = { + AUTH_SUB_TYPE: 1, + REMAIN_TIMES: 2, + FREEZING_TIME: 3 + }; + const SetPropertyType = { + INIT_ALGORITHM: 1 + }; + const AuthType = { + PIN: 1, + FACE: 2 + }; const osAccount = { getAccountManager: function (...args) { console.warn("osAccount.getAccountManager interface mocked in the Previewer. " + From 36972df05b56c65e39e8fbfdc2938221daf14d13 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 21:14:06 +0800 Subject: [PATCH 4/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 271 +++++++++++++++--- 1 file changed, 225 insertions(+), 46 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index de28a68f..a38a48aa 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -81,7 +81,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -93,7 +93,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -105,7 +105,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -117,7 +117,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -129,7 +129,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -141,7 +141,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -153,7 +153,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -165,7 +165,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -177,7 +177,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -189,7 +189,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -201,7 +201,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -213,7 +213,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -225,7 +225,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -237,7 +237,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -249,7 +249,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -258,12 +258,12 @@ export function mockOsAccount() { console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var osAccountInfoArrayMock = new Array(); - osAccountInfoArrayMock.push(osAccountInfoMock); + osAccountInfoArrayMock.push(OsAccountInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(osAccountInfoArrayMock); }) } @@ -272,12 +272,12 @@ export function mockOsAccount() { console.warn("AccountManager.queryActivatedOsAccountIds interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var osAccountIdsArrayMock = new Array(); - osAccountIdsArrayMock.push(osAccountInfoMock); + osAccountIdsArrayMock.push(OsAccountInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(osAccountIdsArrayMock); }) } @@ -287,10 +287,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -299,10 +299,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -311,10 +311,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -323,10 +323,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -335,10 +335,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountTypeMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountTypeMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountTypeMock); }) } }, @@ -349,7 +349,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -361,7 +361,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -373,7 +373,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -385,7 +385,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -397,7 +397,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -409,7 +409,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -421,7 +421,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -433,7 +433,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -445,7 +445,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -454,17 +454,196 @@ export function mockOsAccount() { console.warn("AccountManager.queryOsAccountConstraintSourceTypes interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var constraintSourceTypeInfoArrayMock = new Array(); - constraintSourceTypeInfoArrayMock.push(constraintSourceTypeInfoMock); + constraintSourceTypeInfoArrayMock.push(ConstraintSourceTypeInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(constraintSourceTypeInfoArrayMock); }) } }, }; + const UserAuthClass = class UserAuth { + constructor() { + console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.getVersion = function (..._args) { + console.warn("UserAuth.getVersion interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getAvailableStatus = function (..._args) { + console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getProperty = function (...args) { + console.warn("UserAuth.getProperty interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); + } else { + return new Promise((resolve, _reject) => { + resolve(ExecutorProperty); + }) + } + }; + this.setProperty = function (...args) { + console.warn("UserAuth.setProperty interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, _reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }; + this.auth = function (...args) { + console.warn("UserAuth.auth interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } + }; + this.anthUser = function (...args) { + console.warn("UserAuth.authUser interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } + }; + this.cancelAuth = function (..._args) { + console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + }; + }; + const PINAuthClass = class PINAuth { + constructor() { + console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.registerInputer = function (...args) { + console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.unregisterInputer = function (..._args) { + console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }; + }; + }; + const UserIdentityManagerClass = class UserIdentityManager { + constructor() { + console.warn("osAccount.getAccountManager constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.openSession = function (...args) { + console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, _reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }; + this.addCredential = function (...args) { + console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.updateCredential = function (...args) { + console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.closeSession = function (..._args) { + console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }; + this.cancel = function (..._args) { + console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.delUser = function (..._args) { + console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.delCred = function (..._args) { + console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.getAuthInfo = function (..._args) { + console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new Array(EnrolledCredInfo)); + } else { + return new Promise((resolve, reject) => { + resolve(new Array(EnrolledCredInfo)) + }) + } + }; + }; + } + const IInputData = { + onSetData: function (..._args) { + console.warn("IInputData.onSetData interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IInputer = { + onSetData: function (..._args) { + console.warn("IInputer.onSetData interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IUserAuthCallback = { + onResult: function (..._args) { + console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + onAcquireInfo: function (..._args) { + console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IIdmCallback = { + onResult: function (..._args) { + console.warn("IIdmCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + onAcquireInfo: function (..._args) { + console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; const ConstraintSourceType = { CONSTRAINT_NOT_EXIST: 0, CONSTRAINT_TYPE_BASE: 1, @@ -549,7 +728,7 @@ export function mockOsAccount() { NORMAL: "[PC Preview] unknown NORMAL", GUEST: "[PC Preview] unknown GUEST" }, - constraintSourceType, + ConstraintSourceType, } return osAccount } From 0b2fab459515936e32a5f01ce7ceea40a4bf22a5 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 21:21:06 +0800 Subject: [PATCH 5/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index a38a48aa..5a3f4148 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -81,7 +81,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -93,7 +93,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -105,7 +105,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -117,7 +117,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -129,7 +129,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -141,7 +141,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -153,7 +153,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -165,7 +165,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -177,7 +177,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -189,7 +189,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -201,7 +201,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -213,7 +213,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -225,7 +225,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -237,7 +237,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -249,7 +249,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -263,7 +263,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(osAccountInfoArrayMock); }) } @@ -277,7 +277,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(osAccountIdsArrayMock); }) } @@ -289,7 +289,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -301,7 +301,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -313,7 +313,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -325,7 +325,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -337,7 +337,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountTypeMock); }) } @@ -349,7 +349,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -361,7 +361,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -373,7 +373,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -385,7 +385,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -397,7 +397,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -409,7 +409,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -421,7 +421,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -433,7 +433,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -445,7 +445,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -459,7 +459,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(constraintSourceTypeInfoArrayMock); }) } @@ -486,7 +486,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(ExecutorProperty); }) } @@ -498,7 +498,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -552,7 +552,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); }) } From 54ad76d08f743ffd9a21ceeec69783e14889d4ec Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 23:30:26 +0800 Subject: [PATCH 6/9] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 5a3f4148..d3ddfaae 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -49,7 +49,7 @@ export function mockOsAccount() { }; const ExecutorProperty = { result: "[PC Preview] unknown result", - authSubType: "[PC Preview] unknown authSubType", + authSubType: AuthSubType, remainTimes: "[PC Preview] unknown remainTimes", freezingTime: "[PC Preview] unknown freezingTime" }; @@ -468,20 +468,20 @@ export function mockOsAccount() { const UserAuthClass = class UserAuth { constructor() { console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - this.getVersion = function (..._args) { + "How this interface works on the Previewer may be different from that on a real device.") + this.getVersion = function (...args) { console.warn("UserAuth.getVersion interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; - this.getAvailableStatus = function (..._args) { + this.getAvailableStatus = function (...args) { console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; this.getProperty = function (...args) { console.warn("UserAuth.getProperty interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); @@ -493,7 +493,7 @@ export function mockOsAccount() { }; this.setProperty = function (...args) { console.warn("UserAuth.setProperty interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); @@ -505,7 +505,7 @@ export function mockOsAccount() { }; this.auth = function (...args) { console.warn("UserAuth.auth interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); @@ -513,16 +513,16 @@ export function mockOsAccount() { }; this.anthUser = function (...args) { console.warn("UserAuth.authUser interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } }; - this.cancelAuth = function (..._args) { + this.cancelAuth = function (...args) { console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; }; }; @@ -530,15 +530,15 @@ export function mockOsAccount() { constructor() { console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - this.registerInputer = function (...args) { - console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + this.registerInputer = function (...args) { + console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; - }; - this.unregisterInputer = function (..._args) { - console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + }; + this.unregisterInputer = function (...args) { + console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - }; + }; }; }; const UserIdentityManagerClass = class UserIdentityManager { @@ -573,75 +573,75 @@ export function mockOsAccount() { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.closeSession = function (..._args) { + this.closeSession = function (...args) { console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }; - this.cancel = function (..._args) { + this.cancel = function (...args) { console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; - this.delUser = function (..._args) { + this.delUser = function (...args) { console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.delCred = function (..._args) { + this.delCred = function (...args) { console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.getAuthInfo = function (..._args) { + this.getAuthInfo = function (...args) { console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, new Array(EnrolledCredInfo)); } else { return new Promise((resolve, reject) => { - resolve(new Array(EnrolledCredInfo)) + resolve(new Array(EnrolledCredInfo)) }) } }; }; } const IInputData = { - onSetData: function (..._args) { + onSetData: function (...args) { console.warn("IInputData.onSetData interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IInputer = { - onSetData: function (..._args) { + onSetData: function (...args) { console.warn("IInputer.onSetData interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IUserAuthCallback = { - onResult: function (..._args) { + onResult: function (...args) { console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, - onAcquireInfo: function (..._args) { + onAcquireInfo: function (...args) { console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IIdmCallback = { - onResult: function (..._args) { + onResult: function (...args) { console.warn("IIdmCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, - onAcquireInfo: function (..._args) { + onAcquireInfo: function (...args) { console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const ConstraintSourceType = { From 6df7c7da7591d4fca13722ebf0231148536aaf06 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 10:05:55 +0800 Subject: [PATCH 7/9] osAccount API Mock Signed-off-by: chen --- .../systemplugin/napi/ohos_account_osAccount.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index d3ddfaae..ed394b24 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -721,14 +721,27 @@ export function mockOsAccount() { getAccountManager: function (...args) { console.warn("osAccount.getAccountManager interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - return accountManagerMock; + return AccountManagerMock; }, OsAccountType: { ADMIN: "[PC Preview] unknown ADMIN", NORMAL: "[PC Preview] unknown NORMAL", GUEST: "[PC Preview] unknown GUEST" }, + UserAuth: UserAuthClass, + PINAuth: PINAuthClass, + UserIdentityManager: UserIdentityManagerClass, ConstraintSourceType, + OsAccountType, + FingerprintTips, + FaceTipsCode, + ResultCode, + Module, + AuthTrustLevel, + AuthSubType, + GetPropertyType, + SetPropertyType, + AuthType, } return osAccount } From b315804f4f816e54d3ea2c94099756f6de87efe6 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 10:11:03 +0800 Subject: [PATCH 8/9] osAccount API Mock Signed-off-by: chen --- .../main/extend/systemplugin/napi/ohos_account_osAccount.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index ed394b24..67579cac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -723,11 +723,6 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") return AccountManagerMock; }, - OsAccountType: { - ADMIN: "[PC Preview] unknown ADMIN", - NORMAL: "[PC Preview] unknown NORMAL", - GUEST: "[PC Preview] unknown GUEST" - }, UserAuth: UserAuthClass, PINAuth: PINAuthClass, UserIdentityManager: UserIdentityManagerClass, From db05de68a441062cf42bdcf25c8aaed3c2bbb176 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 20:08:28 +0800 Subject: [PATCH 9/9] osAccount API Mock Signed-off-by: chen --- .../systemplugin/napi/ohos_account_osAccount.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 67579cac..95d6ec67 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -475,7 +475,7 @@ export function mockOsAccount() { return paramMock.paramNumberMock; }; this.getAvailableStatus = function (...args) { - console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + + console.warn("UserAuth.getAvailableStatus interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; @@ -512,7 +512,7 @@ export function mockOsAccount() { } }; this.anthUser = function (...args) { - console.warn("UserAuth.authUser interface mocked in the Previewer. " + + console.warn("UserAuth.anthUser interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -531,19 +531,19 @@ export function mockOsAccount() { console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") this.registerInputer = function (...args) { - console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + console.warn("PINAuth.registerInputer interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }; this.unregisterInputer = function (...args) { - console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + console.warn("PINAuth.unregisterInputer interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }; }; }; const UserIdentityManagerClass = class UserIdentityManager { constructor() { - console.warn("osAccount.getAccountManager constructor interface mocked in the Previewer. " + + console.warn("osAccount.getAccountManager.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") this.openSession = function (...args) { console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " + @@ -566,7 +566,7 @@ export function mockOsAccount() { } }; this.updateCredential = function (...args) { - console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + console.warn("AUserIdentityManager.updateCredential interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -578,7 +578,7 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") }; this.cancel = function (...args) { - console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + + console.warn("AUserIdentityManager.cancel interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; @@ -630,7 +630,7 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") }, onAcquireInfo: function (...args) { - console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + console.warn("IUserAuthCallback.onAcquireInfo interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }, };