From f2d3a090d3dcc62126da91dd2950ea7ef5056127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Fri, 1 Jul 2022 15:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E6=94=B9bundle.d.ts=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?api-mock=E8=A7=84=E8=8C=83,=E5=88=A0=E9=99=A4=E5=B7=B2=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8E=A5=E5=8F=A3api-mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../napi/bundle/applicationInfo.js | 70 ++++++++++---- .../extend/systemplugin/napi/ohos_bundle.js | 94 ++++++------------- .../napi/ohos_bundle_innerBundleManager.js | 4 +- 3 files changed, 83 insertions(+), 85 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index 05b117fd..52ad36e7 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -14,22 +14,59 @@ */ export const ApplicationInfoMock = { - packageName: "[PC preview] unknown packageName", - className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 1, - iconId: 2, - sourceDir: "[PC preview] unknown sourceDir", - flags: 3, - customizeData: { - key: "[PC preview] unknown key", - value: { - CustomizeData: { - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - } + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + systemApp: "[PC preview] unknown systemApp", + enabled: "[PC preview] unknown enabled", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + supportedModes: "[PC preview] unknown supportedModes", + moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], + permissions: ["[PC preview] unknown permissions"], + moduleInfos: [ + { + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", } - } + ], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + labelResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + descriptionResource: { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + id: "[PC preview] unknown id" + }, + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", } export const WantMock = { @@ -41,7 +78,8 @@ export const WantMock = { flag: "[PC Preview] unknow flag", action: "[PC Preview] unknow action", parameters: "[PC Preview] unknow parameters", - entities: "[PC Preview] unknow entities" + entities: "[PC Preview] unknow entities", + moduleName: "[PC Preview] unknow moduleName" } export const ShortcutInfoMock = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index 8a515d27..dede023e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,13 +14,9 @@ */ import { paramMock } from "../utils" -import {resolve} from 'path/posix' import {BundleInfoMock, BundlePackInfo, DispatchInfoMock} from './bundle/bundleInfo' import {ApplicationInfoMock} from './bundle/applicationInfo' -import {AbilityInfoMock} from './bundle/abilityInfo' import {WantMock} from './bundle/applicationInfo' -import {ShortcutInfoMock} from './bundle/applicationInfo' -import {ModuleUsageRecordMock} from './bundle/applicationInfo' export function mockBundle() { const extensionAbilityType = { @@ -94,7 +90,7 @@ export function mockBundle() { const bundle = { getBundleInfo: function(...args) { console.warn("bundle.getBundleInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, BundleInfoMock); @@ -106,7 +102,7 @@ export function mockBundle() { }, getBundleInstaller: function(...args) { console.warn("bundle.getBundleInstaller interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -118,7 +114,7 @@ export function mockBundle() { }, getApplicationInfo: function(...args) { console.warn("bundle.getApplicationInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfoMock); @@ -128,21 +124,9 @@ export function mockBundle() { }) } }, - checkPermission: function(...args) { - console.warn("bundle.checkPermission 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 (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramNumberMock); - }) - } - }, queryAbilityByWant: function(...args) { console.warn("bundle.queryAbilityByWant interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); @@ -154,7 +138,7 @@ export function mockBundle() { }, getAllApplicationInfo: function(...args){ console.warn("bundle.getAllApplicationInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); @@ -166,7 +150,7 @@ export function mockBundle() { }, getAllBundleInfo: function(...args) { console.warn("bundle.getAllBundleInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfoMock)); @@ -178,7 +162,7 @@ export function mockBundle() { }, getBundleArchiveInfo: function(...args) { console.warn("bundle.getBundleArchiveInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfoMock)); @@ -190,7 +174,7 @@ export function mockBundle() { }, getLaunchWantForBundle: function(...args) { console.warn("bundle.getBundleArchiveInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Array(WantMock)); @@ -200,33 +184,9 @@ export function mockBundle() { }) } }, - getAllShortcutInfo: function(...args) { - console.warn("bundle.getAllShortcutInfo 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 (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfoMock)); - } else { - return new Promise((resolve) => { - resolve(Array(ShortcutInfoMock)); - }) - } - }, - getModuleUsageRecords: function(...args) { - console.warn("bundle.getAllShortcutInfo 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 (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, Array(ModuleUsageRecordMock)); - } else { - return new Promise((resolve) => { - resolve(Array(ModuleUsageRecordMock)); - }) - } - }, cleanBundleCacheFiles: function(...args) { console.warn("bundle.cleanBundleCacheFiles interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -238,7 +198,7 @@ export function mockBundle() { }, setApplicationEnabled: function(...args) { console.warn("bundle.setApplicationEnabled interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -250,7 +210,7 @@ export function mockBundle() { }, setAbilityEnabled: function(...args) { console.warn("bundle.setAbilityEnabled interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -262,10 +222,10 @@ export function mockBundle() { }, setModuleUpgradeFlag: function (...args) { console.warn("bundle.setModuleUpgradeFlag interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) + args[len - 1].call(this, paramMock.businessErrorMock) } else { return new Promise((resolve) => { resolve() @@ -274,10 +234,10 @@ export function mockBundle() { }, isModuleRemovable: function (...args) { console.warn("bundle.isModuleRemovable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) } else { return new Promise((resolve) => { resolve(paramMock.paramBooleanMock) @@ -286,10 +246,10 @@ export function mockBundle() { }, getProfileByAbility: function (...args) { console.warn("bundle.getProfileByAbility interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) } else { return new Promise((resolve) => { resolve(new Array(paramMock.paramStringMock)) @@ -298,10 +258,10 @@ export function mockBundle() { }, getProfileByExtensionAbility: function (...args) { console.warn("bundle.getProfileByExtensionAbility interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(paramMock.paramStringMock)) } else { return new Promise((resolve) => { resolve(new Array(paramMock.paramStringMock)) @@ -310,10 +270,10 @@ export function mockBundle() { }, queryExtensionAbilityInfos: function (...args) { console.warn("bundle.queryExtensionAbilityInfos interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfoMock)) + args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfoMock)) } else { return new Promise((resolve) => { resolve(Array(ExtensionAbilityInfoMock)) @@ -322,7 +282,7 @@ export function mockBundle() { }, getBundlePackInfo: function(...args) { console.warn("bundle.getBundlePackInfo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, BundlePackInfo); @@ -334,7 +294,7 @@ export function mockBundle() { }, getDispatcherVersion: function(...args) { console.warn("bundle.getDispatcherVersion interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfoMock); @@ -346,10 +306,10 @@ export function mockBundle() { }, setDisposedStatus: function (...args) { console.warn("bundle.setDisposedStatus interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) + args[len - 1].call(this, paramMock.businessErrorMock) } else { return new Promise((resolve) => { resolve() @@ -358,10 +318,10 @@ export function mockBundle() { }, getDisposedStatus: function (...args) { console.warn("bundle.getDisposedStatus interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve) => { resolve(paramMock.paramNumberMock) diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 72fe60d6..eb0d6dc3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -import {resolve} from 'path/posix' -import {BundleInfoMock} from './bundle/bundleInfo' +import { resolve } from 'path/posix' +import { BundleInfoMock } from './bundle/bundleInfo' import {ApplicationInfoMock} from './bundle/applicationInfo' import {AbilityInfoMock} from './bundle/abilityInfo' import {WantMock} from './bundle/applicationInfo'