From 6467a0af7d9111f926e716602849eddcc8d516b4 Mon Sep 17 00:00:00 2001 From: zhangalong Date: Mon, 24 Jan 2022 12:11:36 +0800 Subject: [PATCH] codes for os account mock Signed-off-by:zhang_along Signed-off-by: zhangalong --- .../extend/systemplugin/ohos/osAccount.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/runtime/main/extend/systemplugin/ohos/osAccount.js b/runtime/main/extend/systemplugin/ohos/osAccount.js index 592ce66f..368e5340 100644 --- a/runtime/main/extend/systemplugin/ohos/osAccount.js +++ b/runtime/main/extend/systemplugin/ohos/osAccount.js @@ -169,6 +169,18 @@ export function mockOsAccount() { }) } }, + getOsAccountLocalIdFromDomain: function (...args) { + console.warn("AccountManager.getOsAccountLocalIdFromDomain 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); + }) + } + }, queryMaxOsAccountNumber: function (...args) { console.warn("AccountManager.queryMaxOsAccountNumber interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") @@ -219,6 +231,18 @@ export function mockOsAccount() { }) } }, + createOsAccountForDomain: function (...args) { + console.warn("AccountManager.createOsAccountForDomain 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, osAccountInfoMock); + } else { + return new Promise((resolve, reject) => { + resolve(osAccountInfoMock); + }) + } + }, queryCurrentOsAccount: function (...args) { console.warn("AccountManager.queryCurrentOsAccount interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") @@ -291,6 +315,30 @@ export function mockOsAccount() { }) } }, + getOsAccountLocalIdBySerialNumber: function (...args) { + console.warn("AccountManager.getOsAccountLocalIdBySerialNumber 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getSerialNumberByOsAccountLocalId: function (...args) { + console.warn("AccountManager.getSerialNumberByOsAccountLocalId 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, on: function (...args) { console.warn("AccountManager.on interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.")