diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/accessibility.js deleted file mode 100644 index cb2bbe10..00000000 --- a/runtime/main/extend/systemplugin/accessibility.js +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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 { paramMock } from './utils'; - -export function mockAccessibility() { - const AbilityTypeMock = { - audible: 'audible', - generic: 'generic', - haptic: 'haptic', - spoken: 'spoken', - visual: 'visual' - }; - - const CapabilityMock = { - retrieve: 'retrieve', - touchGuide: 'touchGuide', - keyEventObserver: 'keyEventObserver', - zoom: 'zoom', - gesture: 'gesture' - }; - - const EventTypeMock = '[PC Preview] unknow EventType'; - - const AccessibilityAbilityInfoMock = { - id: '[PC Preview] unknow id', - name: '[PC Preview] unknow name', - bundleName: '[PC Preview] unknow bundleName', - abilityTypes: [AbilityTypeMock], - capabilities: [CapabilityMock], - description: '[PC Preview] unknow description', - eventTypes: [EventTypeMock] - }; - - const CaptionsFontEdgeTypeMock = '[PC Preview] unknow CaptionsFontEdgeType'; - - const CaptionsFontFamilyMock = '[PC Preview] unknow CaptionsFontFamily'; - - const CaptionStyleMock = { - fontFamily: [CaptionsFontFamilyMock], - fontScale: '[PC Preview] unknow fontScale', - fontColor: '[PC Preview] unknow fontColor', - fontEdgeType: [CaptionsFontEdgeTypeMock], - backgroundColor: '[PC Preview] unknow backgroundColor', - windowColor: '[PC Preview] unknow windowColor' - }; - - const CaptionsManagerMock = { - enabled: '[PC Preview] unknow enabled', - style: [CaptionStyleMock] - }; - - const WindowUpdateTypeMock = '[PC Preview] unknow WindowUpdateType'; - - const ActionMock = '[PC Preview] unknow Action'; - - const TextMoveUnitMock = '[PC Preview] unknow TextMoveUnit'; - const EventInfoClass = class EventInfo { - constructor(jsonObject) { - console.warn('accessibility.EventInfoClass.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.type = EventTypeMock; - this.windowUpdateType = WindowUpdateTypeMock; - this.bundleName = '[PC Preview] unknow bundleName'; - this.componentType = '[PC Preview] unknow componentType'; - this.pageId = '[PC Preview] unknow pageId'; - this.description = '[PC Preview] unknow description'; - this.triggerAction = ActionMock; - this.textMoveUnit = TextMoveUnitMock; - this.contents = '[PC Preview] unknow contents'; - this.lastContent = '[PC Preview] unknow lastContent'; - this.beginIndex = '[PC Preview] unknow beginIndex'; - this.currentIndex = '[PC Preview] unknow currentIndex'; - this.endIndex = '[PC Preview] unknow endIndex'; - this.itemCount = '[PC Preview] unknow itemCount'; - } - }; - const StateEventMock = { - eventType: '[PC Preview] unknow eventType', - state: '[PC Preview] unknow state', - description: '[PC Preview] unknow description' - }; - - global.systemplugin.accessibility = { - EventInfo: EventInfoClass, - isOpenAccessibility: function (...args) { - console.warn('accessibility.isOpenAccessibility 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.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - isOpenTouchGuide: function (...args) { - console.warn('accessibility.isOpenTouchGuide 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.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - on: function (...args) { - console.warn('accessibility.on 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; - args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock); - }, - off: function (...args) { - console.warn('accessibility.off 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, StateEventMock); - } - }, - getAbilityLists: function (...args) { - console.warn('accessibility.getAbilityLists 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, [AccessibilityAbilityInfoMock]); - } else { - return new Promise((resolve, reject) => { - resolve([AccessibilityAbilityInfoMock]); - }); - } - }, - sendEvent: function (...args) { - console.warn('accessibility.sendEvent 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }); - } - }, - getCaptionsManager: function (...args) { - console.warn('accessibility.getCaptionsManager 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, [CaptionsManagerMock]); - } else { - return new Promise((resolve, reject) => { - resolve([CaptionsManagerMock]); - }); - } - } - }; -} diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index 08455ecf..cb5e503d 100644 --- a/runtime/main/extend/systemplugin/index.js +++ b/runtime/main/extend/systemplugin/index.js @@ -43,7 +43,6 @@ import { mockSystemPackage } from './systemPackage' import { mockUserauth } from './userIAM' import { mockVibrator } from './vibrator' import { mockRequireNapiFun } from './napi' -import { mockAccessibility } from './accessibility' import { mockAI } from './ai' import { mockUserIAMUserAuth } from './ohos/userIAMuserAuth.js' import { mockBundleManager } from './ohos/bundleManager' @@ -74,7 +73,6 @@ export function mockSystemPlugin() { mockAbilityFeatureAbility() mockAbilityContinuationRegisterManager() mockRequireNapiFun() - mockAccessibility() mockAbilityParticleAbility() mockAbilityFormManager() mockAbilityAbilityAgent() diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js new file mode 100755 index 00000000..c89704b7 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js @@ -0,0 +1,289 @@ +/* + * 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" + +const DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count" +} +const ResultSet = { + columnNames: [paramMock.paramStringMock], + columnCount: "[PC Preview] unknow columnCount", + rowCount: "[PC Preview] unknow rowCount", + rowIndex: "[PC Preview] unknow rowIndex", + isAtFirstRow: "[PC Preview] unknow isAtFirstRow", + isAtLastRow: "[PC Preview] unknow isAtLastRow", + isEnded: "[PC Preview] unknow isEnded", + isStarted: "[PC Preview] unknow isStarted", + isClose: "[PC Preview] unknow isClose", + getColumnIndex: function (...args) { + console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getColumnName: function (...args) { + console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + goTo: function (...args) { + console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToRow: function (...args) { + console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToLastRow: function (...args) { + console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToFirstRow: function (...args) { + console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToNextRow: function (...args) { + console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToPreviousRow: function (...args) { + console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getBlob: function (...args) { + console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }, + getString: function (...args) { + console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getLong: function (...args) { + console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDouble: function (...args) { + console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isColumnNull: function (...args) { + console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + close: function () { + console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } +} + +export const PacMap = {key:{}} +export const DataAbilityHelper = { + openFile: function (...args) { + console.warn("dataAbilityHelper.openFile 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); + }) + } + }, + on: function (...args) { + console.warn("dataAbilityHelper.on 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) + } + }, + off: function (...args) { + console.warn("dataAbilityHelper.off 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) + } + }, + call: function (...args) { + console.warn("dataAbilityHelper.call 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, PacMap) + } else { + return new Promise((resolve) => { + resolve(PacMap); + }) + } + }, + getType: function (...args) { + console.warn("dataAbilityHelper.getType 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.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getFileTypes: function (...args) { + console.warn("dataAbilityHelper.getFileTypes 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.paramStringMock]) + } else { + return new Promise((resolve) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + normalizeUri: function (...args) { + console.warn("dataAbilityHelper.normalizeUri 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.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + denormalizeUri: function (...args) { + console.warn("dataAbilityHelper.denormalizeUri 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.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + notifyChange: function (...args) { + console.warn("dataAbilityHelper.notifyChange 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) + } else { + return new Promise((resolve) => { + resolve(); + }) + } + }, + insert: function (...args) { + console.warn("dataAbilityHelper.insert 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); + }) + } + }, + batchInsert: function (...args) { + console.warn("dataAbilityHelper.batchInsert 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); + }) + } + }, + delete: function (...args) { + console.warn("dataAbilityHelper.delete 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); + }) + } + }, + update: function (...args) { + console.warn("dataAbilityHelper.update 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); + }) + } + }, + query: function (...args) { + console.warn("dataAbilityHelper.query 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, ResultSet) + } else { + return new Promise((resolve) => { + resolve(ResultSet); + }) + } + }, + call: function (...args) { + console.warn("dataAbilityHelper.call 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, PacMap) + } else { + return new Promise((resolve) => { + resolve(PacMap); + }) + } + }, + executeBatch: function (...args) { + console.warn("dataAbilityHelper.executeBatch 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, [DataAbilityResult]) + } else { + return new Promise((resolve) => { + resolve([DataAbilityResult]); + }) + } + } +} diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js new file mode 100755 index 00000000..7337d35a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js @@ -0,0 +1,33 @@ +/* + * 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" +import { mockDataAbility } from "../ohos_data_dataAbility" + +export const DataAbilityOperation = { + uri: "[PC Preview] unknow uri", + type: { + TYPE_INSERT: 1, + TYPE_UPDATE: 2, + TYPE_DELETE: 3, + TYPE_ASSERT: 4 + }, + valuesBucket: {key:{}}, + valueBackReferences: {key:{}}, + predicates: mockDataAbility().DataAbilityPredicates, + predicatesBackReferences: new Map([[paramMock.paramNumberMock, paramMock.paramNumberMock]]), + interrupted: "[PC Preview] unknow interrupted", + expectedCount: "[PC Preview] unknow expectedCount" +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js old mode 100644 new mode 100755 similarity index 68% rename from runtime/main/extend/systemplugin/napi/volume/volumeInfo.js rename to runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js index 529b1fe8..b2905210 --- a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js @@ -1,23 +1,19 @@ -/* - * 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. - */ - -export const VolumeMock = { - id: '[PC preview] unknow id', - uuid: '[PC preview] unknow uuid', - description: '[PC preview] unknow description', - removeAble: '[PC preview] unknow removeAble', - path: '[PC preview] unknow path', - state: '[PC preview] unknow state', -}; \ No newline at end of file +/* + * 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. + */ + +export const DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js index 1b7a9305..c25d3f00 100644 --- a/runtime/main/extend/systemplugin/napi/application/AbilityContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AbilityContext.js @@ -14,245 +14,21 @@ */ import { paramMock } from "../../utils" -import { MessageParcelClass } from "../ohos_rpc" -import { ContextClass } from "../ohos_application_ServiceExtAbility" +import { ContextClass } from "./Context" import { Configuration } from "../ohos_application_Configuration" import { Caller } from "../ohos_application_Ability" +import { AbilityInfo } from "../bundle/abilityInfo" +import { HapModuleInfo } from "../bundle/hapModuleInfo" +import { AbilityResult } from "../ability/abilityResult" +import { PermissionRequestResultClass } from "./PermissionRequestResult" -const ModuleInfoMock = { - moduleName: '[PC preview] unknow moduleName', - moduleSourceDir: '[PC preview] unknow moduleSourceDir', -} -export const AbilityInfoMock = { - bundleName: '[PC preview] unknow bundleName', - name: '[PC preview] unknow name', - label: '[PC preview] unknow label', - description: '[PC preview] unknow description', - icon: '[PC preview] unknow icon', - labelId: '[PC preview] unknow labelId', - descriptionId: '[PC preview] unknow descriptionId', - iconId: '[PC preview] unknow iconId', - moduleName: '[PC preview] unknow moduleName', - process: '[PC preview] unknow process', - targetAbility: '[PC preview] unknow targetAbility', - backgroundModes: '[PC preview] unknow backgroundModes', - isVisible: '[PC preview] unknow isVisible', - abilityTypeMock: '[PC preview] unknow abilityTypeMock', - AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock', - DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock', - launchModeMock: '[PC preview] unknow launchModeMock', - formEnabled: '[PC preview] unknow formEnabled', - permissions: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - deviceCapabilities: [paramMock.paramStringMock], - readPermission: '[PC preview] unknow readPermission', - writePermission: '[PC preview] unknow writePermission', - applicationInfo: applicationInfoMock, - formEntity: '[PC preview] unknow formEntity', - minFormHeight: '[PC preview] unknow minFormHeight', - defaultFormHeight: '[PC preview] unknow defaultFormHeight', - minFormWidth: '[PC preview] unknow minFormWidth', - defaultFormWidth: '[PC preview] unknow defaultFormWidth', - uri: '[PC preview] unknow uri', - customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) -} -const applicationInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - systemApp: '[PC preview] unknow systemApp', - enabled: '[PC preview] unknow enabled', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - icon: '[PC preview] unknow icon', - iconId: '[PC preview] unknow iconId', - process: '[PC preview] unknow process', - supportedModes: '[PC preview] unknow supportedModes', - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfo: [ModuleInfoMock], - entryDir: '[PC preview] unknow entryDir', - codepath: '[PC preview] unknow codepath', - removable: '[PC preview] unknow removable', - customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) -} -const HapModuleInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - icon: '[PC preview] unknow icon', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - iconId: '[PC preview] unknow iconId', - backgroundImg: '[PC preview] unknow backgroundImg', - supportedModes: '[PC preview] unknow supportedModes', - reqCapabilities: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - abilityInfo: AbilityInfoMock, - moduleName: '[PC preview] unknow moduleName', - mainAbilityName: '[PC preview] unknow mainAbilityName', - installationFree: '[PC preview] unknow installationFree', -} -const screenDensityMock = { - SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI', - SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI', - SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI', - SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI', - SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI', - SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI' -} -const deviceTypeMock = { - DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE', - DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET', - DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR', - DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC', - DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV', - DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE' -} -const DeviceCapabilityClass = class DeviceCapability { - constructor() { - console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.screenDensity = screenDensityMock; - this.deviceType = deviceTypeMock; - } -} -const configurationClass = class configuration { - constructor() { - console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.directionMock = '[PC preview] unknow directionMock'; - this.locale = '[PC preview] unknow locale'; - } -} -const resourceManagerMock = { - getString: function (...args) { - console.warn("ResourceManager.getString 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.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getStringArray: function (...args) { - console.warn("ResourceManager.getStringArray 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.paramStringMock]); - } else { - return new Promise((resolve, reject) => { - resolve([paramMock.paramStringMock]); - }) - } - }, - getMedia: function (...args) { - console.warn("ResourceManager.getMedia 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 Uint8Array()); - } else { - return new Promise((resolve, reject) => { - resolve(new Uint8Array()); - }) - } - }, - getMediaBase64: function (...args) { - console.warn("ResourceManager.getMediaBase64 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.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getDeviceCapability: function (...args) { - console.warn("ResourceManager.getDeviceCapability 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 DeviceCapabilityClass()); - } else { - return new Promise((resolve, reject) => { - resolve(new DeviceCapabilityClass()); - }) - } - }, - getConfiguration: function (...args) { - console.warn("ResourceManager.getConfiguration 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 configurationClass()); - } else { - return new Promise((resolve, reject) => { - resolve(new configurationClass()); - }) - } - }, - getPluralString: function (...args) { - console.warn("ResourceManager.getPluralString 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.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getRawFile: function (...args) { - console.warn("ResourceManager.getRawFile 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 Uint8Array()); - } else { - return new Promise((resolve, reject) => { - resolve(new Uint8Array()); - }) - } - }, -} -export const abilityStageContextClass = class abilityStageContext extends ContextClass { - constructor() { - super(); - console.warn('Context.abilityStageContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.currentHapModuleInfo = HapModuleInfoMock; - } -} -export const ExtensionContextClass = class ExtensionContext extends ContextClass { - constructor() { - super(); - console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.currentHapModuleInfo = HapModuleInfoMock; - } -}; -export const AbilityResultMock = { - resultCode: "[PC Preview] unknow resultCode", -} -const PermissionRequestResultMock = { - permissions: [paramMock.paramStringMock], - authResults: [paramMock.paramNumberMock] -} export const AbilityContextClass = class AbilityContext extends ContextClass { constructor() { super(); console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); - this.abilityInfo = AbilityInfoMock; - this.currentHapModuleInfo = HapModuleInfoMock; + this.abilityInfo = AbilityInfo; + this.currentHapModuleInfo = HapModuleInfo; this.config = Configuration; this.startAbility = function (...args) { console.warn("Ability.AbilityContext.startAbility interface mocked in the Previewer." + @@ -290,10 +66,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { " 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, AbilityResultMock); + args[len - 1].call(this, paramMock.businessErrorMock, AbilityResult); } else { return new Promise((resolve, reject) => { - resolve(AbilityResultMock); + resolve(AbilityResult); }) } }; @@ -302,10 +78,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { " 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, AbilityResultMock); + args[len - 1].call(this, paramMock.businessErrorMock, AbilityResult); } else { return new Promise((resolve, reject) => { - resolve(AbilityResultMock); + resolve(AbilityResult); }) } }; @@ -432,10 +208,10 @@ export const AbilityContextClass = class AbilityContext extends ContextClass { " 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, PermissionRequestResultMock); + args[len - 1].call(this, paramMock.businessErrorMock, new PermissionRequestResultClass()); } else { return new Promise((resolve, reject) => { - resolve(PermissionRequestResultMock); + resolve( new PermissionRequestResultClass()); }) } }; diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js new file mode 100755 index 00000000..1462d1a5 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js @@ -0,0 +1,39 @@ +/* + * 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. + */ + +const ElementName = { + deviceId: '[PC preview] unknow deviceId', + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + uri: '[PC preview] unknow uri', + shortName: '[PC preview] unknow shortName', + moduleName: '[PC preview] unknow moduleName' +} +const AbilityState = { + INITIAL: 0, + FOREGROUND: 9, + BACKGROUND: 10, + FOREGROUNDING: 11, + BACKGROUNDING: 12 +} + +export const AbilityRunningInfo = { + ability: ElementName, + pid: '[PC preview] unknow pid', + uid: '[PC preview] unknow uid', + processName: '[PC preview] unknow processName', + startTime: '[PC preview] unknow startTime', + abilityState: AbilityState +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js new file mode 100755 index 00000000..8199d32c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js @@ -0,0 +1,28 @@ +/* + * 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 { ContextClass } from "./Context" +import { HapModuleInfo } from "../bundle/hapModuleInfo" +import { Configuration } from "../ohos_application_Configuration" + +export const AbilityStageContextClass = class AbilityStageContext extends ContextClass { + constructor() { + super(); + console.warn("AbilityStageContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.currentHapModuleInfo = HapModuleInfo; + this.config = Configuration; + } +}; diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js b/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js new file mode 100755 index 00000000..02192c55 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js @@ -0,0 +1,28 @@ +/* + * 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. + */ + +export const AbilityStateDataClass = class AbilityStateData { + constructor() { + console.warn("AbilityStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.moduleName = "[PC Preview] unknow moduleName", + this.bundleName = "[PC Preview] unknow bundleName", + this.abilityName = "[PC Preview] unknow abilityName", + this.pid = "[PC Preview] unknow pid", + this.uid = "[PC Preview] unknow uid", + this.state = "[PC Preview] unknow state", + this.abilityType = "[PC Preview] unknow abilityType" + } +}; diff --git a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js new file mode 100644 index 00000000..eee99234 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js @@ -0,0 +1,199 @@ +/* + * 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' +import { ExtensionContextClass } from './ExtensionContext' + +const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; + +const ElementAttributeValuesMock = '[PC Preview] unknown element attribute value'; + +const Rect = { + left: '[PC Preview] unknown element left', + top: '[PC Preview] unknown element top', + width: '[PC Preview] unknown element width', + height: '[PC Preview] unknown element height' +}; + +const AccessibilityElement = { + attributeNames: function (...args) { + console.warn('AccessibilityElement.attributeNames 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, [ElementAttributeNameMock]); + } else { + return new Promise((resolve, reject) => { + resolve([ElementAttributeNameMock]); + }); + } + }, + attributeValue: function (...args) { + console.warn('AccessibilityElement.attributeValue interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + let value = null; + switch (args[0]) { + case 'contents': + value = [ElementAttributeValuesMock]; + break; + case 'rect': + case 'screenRect': + value = Rect; + break; + case 'parent': + case 'rootElement': + value = AccessibilityElement; + break; + case 'children': + value = [AccessibilityElement]; + break; + default: + value = ElementAttributeValuesMock; + break; + } + + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, value); + } else { + return new Promise((resolve, reject) => { + resolve(value); + }); + } + }, + actionNames: function (...args) { + console.warn('AccessibilityElement.actionNames 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, [param.paramStringMock]); + } else { + return new Promise((resolve, reject) => { + resolve([param.paramStringMock]); + }); + } + }, + performAction: function (...args) { + console.warn('AccessibilityElement.performAction 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + findElement: function (...args) { + console.warn('AccessibilityElement.findElement interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + const result = (args[0] === 'content') ? [AccessibilityElement] : AccessibilityElement; + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, result); + } else { + return new Promise((resolve, reject) => { + resolve(result); + }); + } + }, +}; + +export class AccessibilityExtensionContext extends ExtensionContextClass { + constructor(...args) { + super(); + console.warn('AccessibilityExtensionContext.constructor interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + + this.setEventTypeFilter = function (...args) { + console.warn('AccessibilityExtensionContext.setEventTypeFilter 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }; + + this.setTargetBundleName = function (...args) { + console.warn('AccessibilityExtensionContext.setTargetBundleName 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }; + + this.getFocusElement = function (...args) { + console.warn('AccessibilityExtensionContext.getFocusElement 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, AccessibilityElement); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElement); + }); + } + }; + + this.getWindowRootElement = function (...args) { + console.warn('AccessibilityExtensionContext.getWindowRootElement 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, AccessibilityElement); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElement); + }); + } + }; + + this.getWindows = function (...args) { + console.warn('AccessibilityExtensionContext.getWindows 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, [AccessibilityElement]); + } else { + return new Promise((resolve, reject) => { + resolve([AccessibilityElement]); + }); + } + }; + + this.injectGesture = function (...args) { + console.warn('AccessibilityExtensionContext.injectGesture 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/AppStateData.js b/runtime/main/extend/systemplugin/napi/application/AppStateData.js new file mode 100755 index 00000000..48465100 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AppStateData.js @@ -0,0 +1,24 @@ +/* + * 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. + */ + +export const AppStateDataClass = class AppStateData { + constructor() { + console.warn("AppStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.bundleName = "[PC Preview] unknow bundleName"; + this.uid = "[PC Preview] unknow uid"; + this.state = "[PC Preview] unknow state"; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js b/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js new file mode 100755 index 00000000..92290c92 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js @@ -0,0 +1,59 @@ +/* + * 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" +import { ContextClass } from "./Context" + +export const ApplicationContextClass = class ApplicationContext extends ContextClass { + constructor() { + super(); + console.warn('ApplicationContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.registerAbilityLifecycleCallback = function (...args) { + console.warn("ApplicationContext.registerAbilityLifecycleCallback 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.unregisterAbilityLifecycleCallback = function (...args) { + console.warn("ApplicationContext.unregisterAbilityLifecycleCallback 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(); + }) + } + }; + this.registerEnvironmentCallback = function (...args) { + console.warn("ApplicationContext.registerEnvironmentCallback 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.unregisterEnvironmentCallback = function (...args) { + console.warn("ApplicationContext.unregisterEnvironmentCallback 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(); + }) + } + }; + } + } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js b/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js new file mode 100755 index 00000000..b8327543 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +export const ApplicationStateObserverClass = class ApplicationStateObserver { + constructor() { + console.warn('ApplicationStateObserver.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.onForegroundApplicationChanged = function (...args) { + console.warn("ApplicationStateObserver.onForegroundApplicationChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onAbilityStateChanged = function (...args) { + console.warn("ApplicationStateObserver.onAbilityStateChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onProcessCreated = function (...args) { + console.warn("ApplicationStateObserver.onProcessCreated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onProcessDied = function (...args) { + console.warn("ApplicationStateObserver.onProcessDied interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + } + } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/BaseContext.js b/runtime/main/extend/systemplugin/napi/application/BaseContext.js index 7d8b0e82..f3847be4 100644 --- a/runtime/main/extend/systemplugin/napi/application/BaseContext.js +++ b/runtime/main/extend/systemplugin/napi/application/BaseContext.js @@ -12,7 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -export const BaseContext = { - stageMode: "[PC Preview] unknow stageMode", -} \ No newline at end of file +export const BaseContextClass = class BaseContext { + constructor() { + console.warn("BaseContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.stageMode = "[PC Preview] unknow stageMode"; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/Context.js b/runtime/main/extend/systemplugin/napi/application/Context.js index bc9339ef..ac512d42 100644 --- a/runtime/main/extend/systemplugin/napi/application/Context.js +++ b/runtime/main/extend/systemplugin/napi/application/Context.js @@ -13,7 +13,8 @@ * limitations under the License. */ import { ApplicationInfo } from "../bundle/applicationInfo" -import { BaseContext } from "./BaseContext" +import { BaseContextClass as BaseContext } from "./BaseContext" + const ResourceManager = { getString: function(...args) { console.warn("ResourceManager.getString interface mocked in the Previewer. " + @@ -280,10 +281,12 @@ export const ContextClass = class Context extends BaseContext { this.tempDir = "[PC Preview] unknow tempDir"; this.filesDir = "[PC Preview] unknow filesDir"; this.databaseDir = "[PC Preview] unknow databaseDir"; + this.preferencesDir = "[PC Preview] unknow preferencesDir"; this.storageDir = "[PC Preview] unknow storageDir"; this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir"; this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir"; this.eventHub = new EventHubClass(); + this.area = AreaMode; this.createBundleContext = function (...args) { console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js b/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js new file mode 100755 index 00000000..6cfe5d31 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js @@ -0,0 +1,25 @@ +/* + * 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. + */ + +export const ErrorObserverClass = class ErrorObserver { + constructor() { + console.warn("ErrorObserver.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.onUnhandledException = function (...args) { + console.warn("ErrorObserver.onUnhandledException interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/EventHub.js b/runtime/main/extend/systemplugin/napi/application/EventHub.js new file mode 100755 index 00000000..d2f68c19 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/EventHub.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +export const EventHubClass = class EventHub { + constructor() { + console.warn("EventHub.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.on = function (...args) { + console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.off = function (...args) { + console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.emit = function (...args) { + console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js new file mode 100755 index 00000000..b2f4e883 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js @@ -0,0 +1,30 @@ +/* + * 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 { HapModuleInfo } from "../bundle/hapModuleInfo"; +import { Configuration } from "../ohos_application_Configuration" +import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo" +import { ContextClass } from "./Context" + +export const ExtensionContextClass = class ExtensionContext extends ContextClass { + constructor() { + super(); + console.warn("ExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.currentHapModuleInfo = HapModuleInfo; + this.config = Configuration; + this.extensionAbilityInfo = ExtensionAbilityInfo; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js new file mode 100755 index 00000000..16406d9a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js @@ -0,0 +1,50 @@ +/* + * 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" + +const ElementName = { + deviceId: '[PC preview] unknow deviceId', + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + uri: '[PC preview] unknow uri', + shortName: '[PC preview] unknow shortName', + moduleName: '[PC preview] unknow moduleName' +} +const ExtensionAbilityType = { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20 +} + +export const ExtensionRunningInfo = { + extension: ElementName, + pid: '[PC preview] unknow pid', + uid: '[PC preview] unknow uid', + processName: '[PC preview] unknow processName', + startTime: '[PC preview] unknow startTime', + clientPackage: [paramMock.paramStringMock], + abilityState: ExtensionAbilityType +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js index 7dc55b19..5bf26661 100644 --- a/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/FormExtensionContext.js @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ExtensionContextClass } from "./abilityContext" -export const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass { +import { ExtensionContextClass } from "./ExtensionContext" +export const FormExtensionContextClass = class FormExtensionContext extends ExtensionContextClass { constructor() { super(); - console.warn('formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + + console.warn('FormExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); this.startAbility = function (...args) { - console.warn("formExtensionContext.startAbility interface mocked in the Previewer." + + console.warn("FormExtensionContext.startAbility 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') { diff --git a/runtime/main/extend/systemplugin/napi/application/MissionInfo.js b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js new file mode 100755 index 00000000..b157bda2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js @@ -0,0 +1,27 @@ +/* + * 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 { WantClass } from "../ohos_application_Want" + +export const MissionInfo = { + missionId: '[PC preview] unknow missionId', + runningState: '[PC preview] unknow runningState', + lockedState: '[PC preview] unknow lockedState', + timestamp: '[PC preview] unknow timestamp', + want: new WantClass(), + label: '[PC preview] unknow label', + iconPath: '[PC preview] unknow iconPath', + continuable: '[PC preview] unknow continuable' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/MissionListener.js b/runtime/main/extend/systemplugin/napi/application/MissionListener.js new file mode 100755 index 00000000..ae014e52 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionListener.js @@ -0,0 +1,37 @@ +/* + * 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. + */ + +export const MissionListener = { + onMissionCreated: function(...args) { + console.warn("MissionListener.onMissionCreated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionDestroyed: function(...args) { + console.warn("MissionListener.onMissionDestroyed interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionSnapshotChanged: function(...args) { + console.warn("MissionListener.onMissionSnapshotChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionMovedToFront: function(...args) { + console.warn("MissionListener.onMissionMovedToFront interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionIconUpdated: function(...args) { + console.warn("MissionListener.onMissionIconUpdated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js b/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js new file mode 100755 index 00000000..a71f4797 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js @@ -0,0 +1,30 @@ +/* + * 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 { PixelMapMock } from "../../multimedia" + +const ElementName = { + deviceId: '[PC preview] unknown deviceId', + bundleName: '[PC preview] unknown bundleName', + abilityName: '[PC preview] unknown abilityName', + uri: '[PC preview] unknown uri', + shortName: '[PC preview] unknown shortName', + moduleName: '[PC preview] unknown moduleName' +} + +export const MissionSnapshot = { + abality: ElementName, + snapshot: PixelMapMock +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js b/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js new file mode 100755 index 00000000..4b7b387c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js @@ -0,0 +1,25 @@ +/* + * 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 const PermissionRequestResultClass = class PermissionRequestResult { + constructor() { + console.warn("PermissionRequestResult.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.permissions = [paramMock.paramStringMock] + this.authResults = [paramMock.paramNumberMock] + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ProcessData.js b/runtime/main/extend/systemplugin/napi/application/ProcessData.js new file mode 100755 index 00000000..f27582f0 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ProcessData.js @@ -0,0 +1,24 @@ +/* + * 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. + */ + +export const ProcessDataClass = class ProcessData { + constructor() { + console.warn("ProcessData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.bundleName = "[PC Preview] unknow bundleName" + this.pid = "[PC Preview] unknow pid" + this.uid = "[PC Preview] unknow uid" + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js new file mode 100755 index 00000000..761fd862 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js @@ -0,0 +1,23 @@ +/* + * 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 const ProcessRunningInfo = { + pid: "[PC Preview] unknow pid", + uid: "[PC Preview] unknow uid", + processName: "[PC Preview] unknow processName", + bundleNames: [paramMock.paramStringMock] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js new file mode 100755 index 00000000..86d92b59 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js @@ -0,0 +1,131 @@ +/* + * 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" +import { ExtensionContextClass } from "./ExtensionContext" + +export const ServiceExtensionContextClass = class ServiceExtensionContext extends ExtensionContextClass { + constructor() { + super(); + console.warn("ServiceExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.startAbility = function (...args) { + console.warn("ServiceExtensionContext.startAbility 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(); + }) + } + }; + this.startAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.startAbilityWithAccount 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(); + }) + } + }; + this.startServiceExtensionAbility = function (...args) { + console.warn("ServiceExtensionContext.startServiceExtensionAbility 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(); + }) + } + }; + this.startServiceExtensionAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.startServiceExtensionAbilityWithAccount 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(); + }) + } + }; + this.stopServiceExtensionAbility = function (...args) { + console.warn("ServiceExtensionContext.stopServiceExtensionAbility 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(); + }) + } + }; + this.stopServiceExtensionAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.stopServiceExtensionAbilityWithAccount 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(); + }) + } + }; + this.terminateSelf = function (...args) { + console.warn("ServiceExtensionContext.terminateSelf 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(); + }) + } + }; + this.connectAbility = function (...args) { + console.warn("ServiceExtensionContext.connectAbility 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.connectAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.connectAbilityWithAccount 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.disconnectAbility = function (...args) { + console.warn("ServiceExtensionContext.disconnectAbility 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(); + }) + } + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js index fb5d7fa1..b56b2388 100644 --- a/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js +++ b/runtime/main/extend/systemplugin/napi/application/abilityDelegator.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../../utils" import { AbilityClass } from "../ohos_application_Ability" -import { ContextClass } from "../ohos_application_ServiceExtAbility" +import { ContextClass } from "./Context" import { ShellCmdResult } from "./shellCmdResult" export const AbilityDelegator = { diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index 3bcd1e31..3a0bbf33 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -41,6 +41,9 @@ export const AbilityInfo = { appId: '[PC Preview] unknow appId', label: "[PC preview] unknown label", description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", uid: '[PC Preview] unknow uid', installTime: '[PC Preview] unknow installTime', updateTime: '[PC Preview] unknow updateTime', diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index c55193b6..68793e40 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -39,7 +39,7 @@ export const BundleInfo = { installTime: "[PC preview] unknown installTime", updateTime: "[PC preview] unknown updateTime", appInfo: ApplicationInfo, - abilityInfo: [AbilityInfo], + abilityInfos: [AbilityInfo], reqPermissions: [paramMock.paramStringMock], reqPermissionDetails: [ReqPermissionDetail], vendor: "[PC preview] unknown vendor", diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js index 801d5d8e..d0c85129 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -24,6 +24,7 @@ export const HashParam = { export const InstallParam = { userId: "[PC preview] unknown userId", installFlag: "[PC preview] unknown installFlag", + isKeepData: "[PC preview] unknown isKeepData", hashParams: [HashParam], crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", } diff --git a/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js index 36c5110d..318aefb8 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js @@ -14,6 +14,6 @@ */ export const DispatchInfo = { - verison: "[PC preview] unknown verison", + version: "[PC preview] unknown version", dispatchAPI: "[PC preview] unknown dispatchAPI", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js index 7496aef6..8a85e2a5 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -15,6 +15,8 @@ import { paramMock } from "../../utils" import { AbilityInfo } from './abilityInfo'; +import { ExtensionAbilityInfo } from './extensionAbilityInfo'; +import { Metadata } from './metadata'; export const HapModuleInfo = { @@ -33,4 +35,8 @@ export const HapModuleInfo = { moduleName: "[PC preview] unknown moduleName", mainAbilityName: "[PC preview] unknown mainAbilityName", installationFree: "[PC preview] unknown installationFree", + mainElementName: "[PC preview] unknown mainElementName", + extensionAbilityInfo: [ExtensionAbilityInfo], + metadata: [Metadata], + hashValue: "[PC preview] unknown mainElementName", } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 54ca8cc3..830d0533 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -18,8 +18,8 @@ import { ApplicationInfo } from './applicationInfo'; import { ElementName } from './elementName' export const LauncherAbilityInfo = { - applicationInfo: {ApplicationInfo}, - elementName: {ElementName}, + applicationInfo: ApplicationInfo, + elementName: ElementName, labelId: "[PC preview] unknown labelId", iconId: "[PC preview] unknown iconId", userId: "[PC preview] unknown userId", diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js index 8a7bfebf..fd6e7dc8 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -33,7 +33,7 @@ export const ModuleDistroInfo = { export const AbilityFormInfo = { name: "[PC preview] unknown name", type: "[PC preview] unknown type", - updateEnabledtype: "[PC preview] unknown updateEnabled", + updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", supportDimensions: [paramMock.paramNumberMock], diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js index 83ee21a6..8631a7ec 100644 --- a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js @@ -18,5 +18,5 @@ export const CommonEventData = { bundleName: '[PC preview] unknow bundleName', code: '[PC preview] unknow code', data: '[PC preview] unknow data', - parameters: {} -} \ No newline at end of file + parameters: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js index 9174974b..248f625b 100644 --- a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js @@ -21,5 +21,5 @@ export const CommonEventPublishData = { subscriberPermissions: [paramMock.paramStringMock], isOrdered: '[PC preview] unknow isOrdered', isSticky: '[PC preview] unknow isSticky', - parameters: {} -} \ No newline at end of file + parameters: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js index 7d494bf6..f29740cd 100644 --- a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js @@ -23,5 +23,5 @@ export const ContinuationExtraParams = { description: "[PC Preview] unknow description", filter: "[PC Preview] unknow filter", continuationMode: ContinuationMode, - authInfo: {} -} \ No newline at end of file + authInfo: {"key":"unknow any"} +} diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 155e7d1e..dde8e7fc 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -15,23 +15,34 @@ import { mockSystemParameter } from './ohos_systemparameter' import { mockAbility } from './ohos_application_Ability' +import { mockErrorCode } from './ohos_ability_errorCode' import { mockFeatureAbility } from './ohos_ability_featureAbility' import { mockDataUriUtils } from './ohos_ability_dataUriUtils' +import { mockWantConstant } from './ohos_ability_wantConstant' +import { mockAbilityConstant } from './ohos_application_AbilityConstant' import { mockAbilityDelegatorRegistry } from './ohos_application_abilityDelegatorRegistry' import { mockAbilityLifecycleCallback } from './ohos_application_AbilityLifecycleCallback' import { mockFormExtension } from './ohos_application_FormExtension' import { mockStaticSubscriberExtensionAbility } from './ohos_application_StaticSubscriberExtensionAbility' import { mockFormHost } from './ohos_application_formHost' +import { mockFormInfo } from './ohos_application_formInfo' import { mockErrorManager } from './ohos_application_errorManager' import { mockTestRunner } from './ohos_application_testRunner' +import { mockWant } from './ohos_application_Want' import { mockServiceExtensionAbility } from './ohos_application_ServiceExtensionAbility' +import { mockStartOptions } from './ohos_application_StartOptions' import { mockAbilityStage } from './ohos_application_AbilityStage' import { mockFormBindingData } from './ohos_application_formBindingData' +import { mockFormError } from './ohos_application_formError' import { mockAbilityManager } from './ohos_application_abilityManager' +import { mockParticleAbility } from './ohos_ability_particleAbility' import { mockAppManager } from './ohos_application_appManager' +import { mockConfiguration } from './ohos_application_Configuration' +import { mockConfigurationConstant } from './ohos_application_ConfigurationConstant' +import { mockContext } from './ohos_application_context' import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility' +import { mockEnvironmentCallback } from './ohos_application_EnvironmentCallback' import { mockMissionManager } from "./ohos_application_missionManager" -import { mockServiceExtAbility } from "./ohos_application_ServiceExtAbility" import { mockUriPermissionManager } from "./ohos_application_uriPermissionManager" import { mockCommonEvent } from './ohos_commonEvent' import { mockNotification } from './ohos_notification' @@ -54,6 +65,7 @@ import { mockHilog } from './ohos_hilog' import { mockHiSysEvent } from './ohos_hiSysEvent' import { mockHiTraceChain } from './ohos_hiTraceChain' import { mockHidebug } from './ohos_hidebug' +import { mockFaultLogger } from './ohos_faultLogger' import { mockTv } from './tv' import { mockDtv } from './dtv' import { mockDistributedAccount } from './ohos_account_distributedAccount' @@ -71,6 +83,7 @@ import { mockInputDevice } from './ohos_multimodalInput_inputDevice' import { mockVibrator } from './ohos_vibrator' import { mockSensor } from './ohos_sensor' import { mockWifi } from './ohos_wifi' +import { mockWifiExt } from './ohos_wifiext' import { mockUsb } from './ohos_usb' import { mockBundle } from './ohos_bundle' import { mockInnerBundle } from './ohos_bundle_innerBundleManager' @@ -92,6 +105,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' @@ -106,6 +120,7 @@ import { mockStack } from './ohos_util_Stack' import { mockTreeMap } from './ohos_util_TreeMap' import { mockTreeSet } from './ohos_util_TreeSet' import { mockVector } from './ohos_util_Vector' +import { mockMultimediaAVSession } from './ohos_multimedia_av_session' import { mockMultimediaCamera } from './ohos_multimedia_camera' import { mockMultimediaAudio } from './ohos_multimedia_audio' import { mockMultimediaImage } from './ohos_multimedia_image' @@ -172,6 +187,11 @@ import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' import { mockUiAppearance } from './ohos_uiAppearance' import { mockContinationManager } from './ohos_continuation_continuationManager' +import { mockUiTest } from './ohos_uitest' +import { mockWindowAnimationManager } from './ohos_animation_windowAnimationManager' +import { mockAccessibility } from './ohos_accessibility' +import { mockAccessibilityConfig } from './ohos_accessibility_config' +import { mockAccessibilityExtensionAbility } from './ohos_application_AccessibilityExtensionAbility' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -189,7 +209,7 @@ export function mockRequireNapiFun() { return mockZlib(); case "screenshot": return mockScreenshot(); - case "WantAgent": + case "wantAgent": return mockWantAgent(); case "wallpaper": return mockWallpaper(); @@ -273,24 +293,38 @@ export function mockRequireNapiFun() { return mockBatteryinfo(); case "systemParameter": return mockSystemParameter(); + case "ability.errorCode": + return mockErrorCode(); case "ability.dataUriUtils": return mockDataUriUtils(); + case "ability.particleAbility": + return mockParticleAbility(); case "ability.featureAbility": return mockFeatureAbility(); + case "ability.wantConstant": + return mockWantConstant(); case "application.Ability": return mockAbility(); case "application.formHost": return mockFormHost(); + case "application.formInfo": + return mockFormInfo(); case "application.FormExtension": return mockFormExtension(); case "application.ServiceExtensionAbility": return mockServiceExtensionAbility(); + case "application.StartOptions": + return mockStartOptions(); + case "application.StaticSubscriberExtensionAbility": + return mockStaticSubscriberExtensionAbility() case "application.errorManager": return mockErrorManager(); case "application.testRunner": return mockTestRunner(); - case "application.StaticSubscriberExtensionAbility": - return mockStaticSubscriberExtensionAbility(); + case "application.Want": + return mockWant(); + case "application.AbilityConstant": + return mockAbilityConstant(); case "application.abilityDelegatorRegistry": return mockAbilityDelegatorRegistry(); case "application.AbilityLifecycleCallback": @@ -299,16 +333,24 @@ export function mockRequireNapiFun() { return mockAbilityStage(); case "application.formBindingData": return mockFormBindingData(); + case "application.formError": + return mockFormError(); case "application.abilityManager": return mockAbilityManager(); case "application.appManager": return mockAppManager(); + case "application.Configuration": + return mockConfiguration(); + case "application.ConfigurationConstant": + return mockConfigurationConstant(); + case "application.context": + return mockContext(); case "application.DataShareExtensionAbility": return mockDataShareExtensionAbility(); + case "application.EnvironmentCallback": + return mockEnvironmentCallback(); case "application.missionManager": return mockMissionManager(); - case "application.ServiceExtAbility": - return mockServiceExtAbility(); case "application.UriPermissionManager": return mockUriPermissionManager(); case "commonEvent": @@ -353,6 +395,8 @@ export function mockRequireNapiFun() { return mockHidebug(); case "hiTraceChain": return mockHiTraceChain(); + case "faultLogger": + return mockFaultLogger(); case "tv": return mockTv(); case "dtv": @@ -387,6 +431,8 @@ export function mockRequireNapiFun() { return mockSensor(); case "wifi": return mockWifi(); + case "wifiext": + return mockWifiExt(); case "usb": return mockUsb(); case "bundle": @@ -405,13 +451,13 @@ export function mockRequireNapiFun() { return mockConvertXml(); case "statfs": return mockStatfs(); - case "filemanager": + case "fileManager": return mockFileManager(); case "environment": return mockEnvironment(); - case "storagestatistics": + case "storageStatistics": return mockStorageStatistics(); - case "volumemanager": + case "volumeManager": return mockVolumeManager(); case "settings": return mockSettings(); @@ -425,7 +471,7 @@ export function mockRequireNapiFun() { return mockBackgroundTaskManager(); case "bundleState": return mockBundleState(); - case "securitylabel": + case "securityLabel": return mockSecurityLabel(); case "workScheduler": return mockWorkScheduler(); @@ -433,6 +479,8 @@ export function mockRequireNapiFun() { return mockWorkSchedulerExtensionAbility(); case "userIAM.userAuth": return mockUserAuth(); + case "userIAM.faceAuth": + return mockFaceAuth(); case "util.ArrayList": return mockArrayList(); case "util.Deque": @@ -467,6 +515,8 @@ export function mockRequireNapiFun() { return mockMultimediaMedia(); case "multimedia.image": return mockMultimediaImage(); + case "multimedia.avsession": + return mockMultimediaAVSession(); case "multimedia.camera": return mockMultimediaCamera(); case "multimedia.audio": @@ -491,8 +541,18 @@ export function mockRequireNapiFun() { return mockMouseEvent(); case "multimodalInput.touchEvent": return mockTouchEvent(); + case "accessibility": + return mockAccessibility(); + case "accessibility.config": + return mockAccessibilityConfig(); + case "application.AccessibilityExtensionAbility": + return mockAccessibilityExtensionAbility(); case "continuation.continuationManager": return mockContinationManager(); + case "uitest": + return mockUiTest(); + case "animation.windowAnimationManager": + return mockWindowAnimationManager(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js index f78f5a58..0b4fbb30 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js @@ -17,6 +17,6 @@ import { NotificationUserInput } from "./notificationUserInput" export const NotificationActionButton = { title: '[PC preview] unknow title', wantAgent: '[PC preview] unknow wantAgent', - extras: {}, + extras: {"key": "unknown any"}, userInput: NotificationUserInput, -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js index ccb0bb7b..81f0c521 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js @@ -30,7 +30,7 @@ export const NotificationRequest = { tapDismissed: '[PC preview] unknow tapDismissed', autoDeletedTime: '[PC preview] unknow autoDeletedTime', wantAgent: '[PC preview] unknow wantAgent', - extraInfo: {}, + extraInfo: {"key": "unknown any"}, color: '[PC preview] unknow color', colorEnabled: '[PC preview] unknow colorEnabled', isAlertOnce: '[PC preview] unknow isAlertOnce', @@ -64,4 +64,4 @@ export const DistributedOptions = { supportDisplayDevices: [paramMock.paramStringMock], supportOperateDevices: [paramMock.paramStringMock], remindType: '[PC preview] unknow remindType', -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js index d7ca9875..8ed89dff 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js @@ -15,6 +15,6 @@ import { paramMock } from "../../utils" export const NotificationSortingMap = { - sortings: {}, + sortings: {"key": "unknown any"}, sortedHashCode: [paramMock.paramStringMock], -}; \ No newline at end of file +}; diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js index 62d68e12..c235f1ef 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js @@ -14,5 +14,5 @@ */ export const NotificationTemplate = { name: '[PC preview] unknow name', - data: {}, -} \ No newline at end of file + data: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js index 59f0bd7a..21cdc9e2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_errorCode.js @@ -17,4 +17,7 @@ export const ErrorCode = { ABILITY_NOT_FOUND: -2, INVALID_PARAMETER: -1, NO_ERROR: 0, +} +export function mockErrorCode() { + return ErrorCode; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js index ae1aa3cd..5321b14d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_featureAbility.js @@ -15,274 +15,13 @@ import { paramMock } from "../utils" import { WantClass } from "./ohos_application_Want" -import { Context } from "./app/context" +import { Context as _Context } from "./app/context" import { AbilityResult } from "./ability/abilityResult" import { windowMock } from "./ohos_window" +import { DataAbilityHelper } from "./ability/dataAbilityHelper" +import { AppVersionInfo as _AppVersionInfo } from "./app/appVersionInfo" +import { ProcessInfo as _ProcessInfo } from "./app/processInfo" -const DataAbilityResult = { - uri: "[PC Preview] unknow uri", - count: "[PC Preview] unknow count" -} -const DataAbilityResultArray = [ - DataAbilityResult -] -export const PacMapType = { - PacMap: {key:{}} -} -export const ResultSet = { - columnNames: [paramMock.paramStringMock], - columnCount: "[PC Preview] unknow columnCount", - rowCount: "[PC Preview] unknow rowCount", - rowIndex: "[PC Preview] unknow rowIndex", - isAtFirstRow: "[PC Preview] unknow isAtFirstRow", - isAtLastRow: "[PC Preview] unknow isAtLastRow", - isEnded: "[PC Preview] unknow isEnded", - isStarted: "[PC Preview] unknow isStarted", - isClose: "[PC Preview] unknow isClose", - getColumnIndex: function (...args) { - console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getColumnName: function (...args) { - console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - goTo: function (...args) { - console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToRow: function (...args) { - console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToLastRow: function (...args) { - console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToFirstRow: function (...args) { - console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToNextRow: function (...args) { - console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - goToPreviousRow: function (...args) { - console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - getBlob: function (...args) { - console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramArrayMock; - }, - getString: function (...args) { - console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - getLong: function (...args) { - console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getDouble: function (...args) { - console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - isColumnNull: function (...args) { - console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - close: function () { - console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } -} -const DataAbilityHelper = { - openFile: function (...args) { - console.warn("DataAbilityHelper.openFile 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); - }) - } - }, - on: function (...args) { - console.warn("DataAbilityHelper.on 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) - } - }, - off: function (...args) { - console.warn("DataAbilityHelper.off 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) - } - }, - getType: function (...args) { - console.warn("DataAbilityHelper.getType 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.paramStringMock) - } else { - return new Promise((resolve) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getFileTypes: function (...args) { - console.warn("DataAbilityHelper.getFileTypes 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.paramStringMock]) - } else { - return new Promise((resolve) => { - resolve([paramMock.paramStringMock]); - }) - } - }, - normalizeUri: function (...args) { - console.warn("DataAbilityHelper.normalizeUri 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.paramStringMock) - } else { - return new Promise((resolve) => { - resolve(paramMock.paramStringMock); - }) - } - }, - denormalizeUri: function (...args) { - console.warn("DataAbilityHelper.denormalizeUri 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.paramStringMock) - } else { - return new Promise((resolve) => { - resolve(paramMock.paramStringMock); - }) - } - }, - notifyChange: function (...args) { - console.warn("DataAbilityHelper.notifyChange 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) - } else { - return new Promise((resolve) => { - resolve(); - }) - } - }, - insert: function (...args) { - console.warn("DataAbilityHelper.insert 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); - }) - } - }, - batchInsert: function (...args) { - console.warn("DataAbilityHelper.batchInsert 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); - }) - } - }, - delete: function (...args) { - console.warn("DataAbilityHelper.delete 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); - }) - } - }, - update: function (...args) { - console.warn("DataAbilityHelper.update 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); - }) - } - }, - query: function (...args) { - console.warn("DataAbilityHelper.query 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, ResultSet) - } else { - return new Promise((resolve) => { - resolve(ResultSet); - }) - } - }, - call: function (...args) { - console.warn("DataAbilityHelper.call 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, PacMapType) - } else { - return new Promise((resolve) => { - resolve(PacMapType); - }) - } - }, - executeBatch: function (...args) { - console.warn("DataAbilityHelper.executeBatch 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, DataAbilityResultArray) - } else { - return new Promise((resolve) => { - resolve(DataAbilityResultArray); - }) - } - } -} export function mockFeatureAbility() { const featureAbility = { getWant: function (...args) { @@ -312,7 +51,7 @@ export function mockFeatureAbility() { getContext: function () { console.warn("featureAbility.getContext interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return Context; + return _Context; }, startAbilityForResult: function (...args) { console.warn("featureAbility.startAbilityForResult interface mocked in the Previewer." + @@ -396,6 +135,13 @@ export function mockFeatureAbility() { }) } }, + AbilityWindowConfiguration, + AbilityStartSetting, + ErrorCode, + DataAbilityOperationType, + Context: _Context, + AppVersionInfo: _AppVersionInfo, + ProcessInfo: _ProcessInfo } return featureAbility; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js new file mode 100755 index 00000000..f1e4ec1c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js @@ -0,0 +1,96 @@ +/* + * 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" +import { DataAbilityHelper } from "./ability/dataAbilityHelper" + +export function mockParticleAbility() { + const particleAbility = { + startAbility: function (...args) { + console.warn("ability.particleAbility.startAbility 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + terminateSelf: function (...args) { + console.warn("ability.particleAbility.terminateSelf 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + acquireDataAbilityHelper: function (...args) { + console.warn("ability.particleAbility.acquireDataAbilityHelper interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return DataAbilityHelper; + }, + connectAbility: function (...args) { + console.warn("ability.particleAbility.connectAbility interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + disconnectAbility: function (...args) { + console.warn("ability.particleAbility.disconnectAbility 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + startBackgroundRunning: function (...args) { + console.warn("ability.particleAbility.startBackgroundRunning 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + cancelBackgroundRunning: function (...args) { + console.warn("ability.particleAbility.cancelBackgroundRunning 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + ErrorCode : { + INVALID_PARAMETER: -1, + } + } + return particleAbility; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js index 7f469b89..e317a31a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_wantConstant.js @@ -65,4 +65,12 @@ export const Flags = { FLAG_ABILITY_CLEAR_MISSION: 0x00008000, FLAG_ABILITY_NEW_MISSION: 0x10000000, FLAG_ABILITY_MISSION_TOP: 0x20000000 +} +export function mockWantConstant() { + const wantConstant = { + Action, + Entity, + Flags + } + return wantConstant; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_accessibility.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js new file mode 100644 index 00000000..ba20e642 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js @@ -0,0 +1,189 @@ +/* + * 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 + * + * 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 mockAccessibility() { + const AbilityTypeMock = '[PC Preview] unknown AbilityType'; + + const CapabilityMock = '[PC Preview] unknown Capability'; + + const EventTypeMock = '[PC Preview] unknown EventType'; + + const AccessibilityAbilityInfo = { + id: '[PC Preview] unknown id', + name: '[PC Preview] unknown name', + bundleName: '[PC Preview] unknown bundleName', + TargetBundleName: ['[PC Preview] unknown TargetBundleName'], + abilityTypes: [AbilityTypeMock], + capabilities: [CapabilityMock], + description: '[PC Preview] unknown description', + eventTypes: [EventTypeMock] + }; + + const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType'; + + const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily'; + + const CaptionStyle = { + fontFamily: CaptionsFontFamilyMock, + fontScale: '[PC Preview] unknown fontScale', + fontColor: '[PC Preview] unknown fontColor', + fontEdgeType: CaptionsFontEdgeTypeMock, + backgroundColor: '[PC Preview] unknown backgroundColor', + windowColor: '[PC Preview] unknown windowColor' + }; + + const CaptionsManagerMock = { + enabled: '[PC Preview] unknown enabled', + style: CaptionStyle, + on: function (...args) { + console.warn('CaptionsManager.on 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 > 1 && typeof args[len - 1] === 'function') { + if (args[0] === 'enableChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'styleChange') { + args[len - 1].call(this, CaptionStyle); + } + } + }, + off: function (...args) { + console.warn('CaptionsManager.off 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 > 1 && typeof args[len - 1] === 'function') { + if (args[0] === 'enableChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'styleChange') { + args[len - 1].call(this, CaptionStyle); + } + } + }, + }; + + const WindowUpdateTypeMock = '[PC Preview] unknown WindowUpdateType'; + + const ActionMock = '[PC Preview] unknown Action'; + + const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit'; + + const EventInfoClass = class EventInfo { + constructor(...args) { + console.warn('accessibility.EventInfoClass.constructor interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + this.type = EventTypeMock; + this.windowUpdateType = WindowUpdateTypeMock; + this.bundleName = '[PC Preview] unknown bundleName'; + this.componentType = '[PC Preview] unknown componentType'; + this.pageId = '[PC Preview] unknown pageId'; + this.description = '[PC Preview] unknown description'; + this.triggerAction = ActionMock; + this.textMoveUnit = TextMoveUnitMock; + this.contents = ['[PC Preview] unknown content']; + this.lastContent = '[PC Preview] unknown lastContent'; + this.beginIndex = '[PC Preview] unknown beginIndex'; + this.currentIndex = '[PC Preview] unknown currentIndex'; + this.endIndex = '[PC Preview] unknown endIndex'; + this.itemCount = '[PC Preview] unknown itemCount'; + } + }; + + const accessibility = { + EventInfo: EventInfoClass, + isOpenAccessibility: function (...args) { + console.warn('accessibility.isOpenAccessibility 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + isOpenTouchGuide: function (...args) { + console.warn('accessibility.isOpenTouchGuide 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.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + on: function (...args) { + console.warn('accessibility.on 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') { + if (args[0] == 'accessibilityStateChange') { + args[len - 1].call(this, this, paramMock.paramBooleanMock); + } else if (args[0] == 'touchGuideStateChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else { + args[len - 1].call(this, this, paramMock.paramBooleanMock); + } + } + }, + off: function (...args) { + console.warn('accessibility.off 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 > 1 && typeof args[len - 1] === 'function') { + if (args[0] === 'accessibilityStateChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'touchGuideStateChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + } + }, + getAbilityLists: function (...args) { + console.warn('accessibility.getAbilityLists 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, [AccessibilityAbilityInfo]); + } else { + return new Promise((resolve, reject) => { + resolve([AccessibilityAbilityInfo]); + }); + } + }, + sendEvent: function (...args) { + console.warn('accessibility.sendEvent 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }, + getCaptionsManager: function () { + console.warn('accessibility.getCaptionsManager interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return CaptionsManagerMock; + } + }; + + return accessibility; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_accessibility_config.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility_config.js new file mode 100644 index 00000000..b20d2865 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility_config.js @@ -0,0 +1,46 @@ +/* + * 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 mockAccessibilityConfig() { + const config = { + enableAbility: function (...args) { + console.warn('accessibilityConfig config.enableAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }); + } + }, + disableAbility: function (...args) { + console.warn('accessibilityConfig config.disableAbility 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); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + } + }; + return config; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 70eb0116..95d6ec67 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -15,26 +15,65 @@ 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 function mockOsAccount() { - const osAccountInfoMock = { - localId: "[PC Preview] unknown id", - localName: "[PC Preview] unknown name", + const OsAccountInfoMock = { + 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 constraintSourceTypeInfoMock = { - localId: "[PC Preview] unknown id", - type: constraintSourceType, + const DomainAccountInfoMock = { + domain: "[PC Preview] unknown domain", + accountName: "[PC Preview] unknown accountName" }; - const osAccountTypeMock = "[PC Preview] unknown type"; - const accountManagerMock = { + const ConstraintSourceTypeInfoMock = { + 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: 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 = { 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.") @@ -219,7 +258,7 @@ 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); @@ -233,7 +272,7 @@ 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); @@ -248,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); + resolve(OsAccountInfoMock); }) } }, @@ -260,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); + resolve(OsAccountInfoMock); }) } }, @@ -272,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); + resolve(OsAccountInfoMock); }) } }, @@ -284,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); + resolve(OsAccountInfoMock); }) } }, @@ -296,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); + resolve(OsAccountTypeMock); }) } }, @@ -415,7 +454,7 @@ 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); @@ -426,18 +465,278 @@ 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) { + 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.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; + }; + 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.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') { + 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 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 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.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') { + 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.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; + }; + 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.onAcquireInfo 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, + 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. " + "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" - }, - constraintSourceType, + UserAuth: UserAuthClass, + PINAuth: PINAuthClass, + UserIdentityManager: UserIdentityManagerClass, + ConstraintSourceType, + OsAccountType, + FingerprintTips, + FaceTipsCode, + ResultCode, + Module, + AuthTrustLevel, + AuthSubType, + GetPropertyType, + SetPropertyType, + AuthType, } return osAccount -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js b/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js new file mode 100644 index 00000000..9839a613 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js @@ -0,0 +1,79 @@ +/* + * 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 mockWindowAnimationManager() { + const RRect = { + left: '[PC preview] unknow left', + top: '[PC preview] unknow top', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + radius: '[PC preview] unknow radius', + } + const WindowAnimationTarget = { + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + windowBounds: RRect, + } + const WindowAnimationFinishedCallback = { + onAnimationFinish: function (...args) { + console.warn("WindowAnimationFinishedCallback.onAnimationFinish interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + } + const WindowAnimationController = { + onStartAppFromLauncher: function (...args) { + console.warn("WindowAnimationController.onStartAppFromLauncher interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onStartAppFromRecent: function (...args) { + console.warn("WindowAnimationController.onStartAppFromRecent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onStartAppFromOther: function (...args) { + console.warn("WindowAnimationController.onStartAppFromOther interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onAppTransition: function (...args) { + console.warn("WindowAnimationController.onAppTransition interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onMinimizeWindow: function (...args) { + console.warn("WindowAnimationController.onMinimizeWindow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onCloseWindow: function (...args) { + console.warn("WindowAnimationController.onCloseWindow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onScreenUnlock: function (...args) { + console.warn("WindowAnimationController.onScreenUnlock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + } + + const windowAnimationManager = { + WindowAnimationController, + WindowAnimationFinishedCallback, + WindowAnimationTarget, + RRect, + setController: function (...args) { + console.warn("windowAnimationManager.setController interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } + } + return windowAnimationManager +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js index f32f7d60..5a0aedb5 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js @@ -32,4 +32,13 @@ export const OnContinueResult = { AGREE: 0, REJECT: 1, MISMATCH: 2, +} +export function mockAbilityConstant() { + const AbilityConstant = { + LaunchParam, + LaunchReason, + LastExitReason, + OnContinueResult + } + return AbilityConstant; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js index 511379ed..f6e0b1d1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityLifecycleCallback.js @@ -13,8 +13,6 @@ * limitations under the License. */ -import { paramMock } from "../utils" - export function mockAbilityLifecycleCallback() { const AbilityLifecycleCallbackClass = class AbilityLifecycleCallback { constructor() { diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js index 526875db..37d0d8af 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityStage.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { abilityStageContextClass } from "./application/AbilityContext" +import { AbilityStageContextClass } from "./application/AbilityStageContext" import { paramMock } from "../utils" export function mockAbilityStage() { @@ -21,7 +21,7 @@ export function mockAbilityStage() { constructor() { console.warn('application.AbilityStage.constructor interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); - this.context = new abilityStageContextClass(); + this.context = new AbilityStageContextClass(); this.onCreate = function () { console.warn("application.AbilityStage.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js new file mode 100755 index 00000000..fe7eb1f7 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js @@ -0,0 +1,62 @@ +/* + * 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'; +import { AccessibilityExtensionContext } from './application/AccessibilityExtensionContext'; + +const AccessibilityEvent = { + eventType: '[PC Preview] unknown eventType', + target: '[PC Preview] unknown target', + timeStamp: '[PC Preview] unknown timeStamp' +}; + +const GesturePoint = { + positionX: '[PC Preview] unknown positionX', + positionY: '[PC Preview] unknown positionY' + }; + +const GesturePath = { + points: [GesturePoint], + durationTime: '[PC Preview] unknown durationTime' +}; + +export function mockAccessibilityExtensionAbility() { + const AccessibilityExtensionAbilityClass = class AccessibilityExtensionAbility { + constructor() { + console.warn('accessibilityExtensionAbility.constructor interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + this.context = new AccessibilityExtensionContext(); + this.onConnect = function (...args) { + console.warn('accessibilityExtensionAbility.onConnect interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + }; + this.onDisconnect = function (...args) { + console.warn('accessibilityExtensionAbility.onDisconnect interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + }; + this.onAccessibilityEvent = function (...args) { + console.warn('accessibilityExtensionAbility.onAccessibilityEvent interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + }; + this.onKeyEvent = function (...args) { + console.warn('accessibilityExtensionAbility.onKeyEvent interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + return paramMock.paramBooleanMock; + }; + } + }; + + return AccessibilityExtensionAbilityClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js index 487bf868..c368d86a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -19,4 +19,8 @@ export const Configuration = { direction: Direction, screenDensity: ScreenDensity, displayId: '[PC preview] unknow displayId', + hasPointerDevice: '[PC preview] unknow hasPointerDevice', +} +export function mockConfiguration() { + return Configuration; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js index e4f874a9..1c57b1dc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ConfigurationConstant.js @@ -30,4 +30,12 @@ export const ScreenDensity = { SCREEN_DENSITY_XLDPI: 320, SCREEN_DENSITY_XXLDPI: 480, SCREEN_DENSITY_XXXLDPI: 640, +} +export function mockConfigurationConstant() { + const ConfigurationConstant = { + ColorMode, + Direction, + ScreenDensity + } + return ConfigurationConstant; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js index 69cccc55..47766cf0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_DataShareExtensionAbility.js @@ -14,8 +14,7 @@ */ import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/AbilityContext" -import { DataShareResultSetMock } from "./ohos_data_DataShareResultSet" +import { ExtensionContextClass } from "./application/ExtensionContext" export function mockDataShareExtensionAbility() { const DataShareExtensionAbilityClass = class DataShareExtensionAbility { diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_EnvironmentCallback.js b/runtime/main/extend/systemplugin/napi/ohos_application_EnvironmentCallback.js new file mode 100644 index 00000000..0589efdf --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_EnvironmentCallback.js @@ -0,0 +1,29 @@ +/* + * 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. + */ + +export const EnvironmentCallbackClass = class EnvironmentCallback { + constructor() { + console.warn('EnvironmentCallback.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.onConfigurationUpdated = function (...args) { + console.warn("EnvironmentCallback.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +} + +export function mockEnvironmentCallback() { + return new EnvironmentCallbackClass(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js index d1aa94ca..10cc4978 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_FormExtension.js @@ -13,54 +13,20 @@ * limitations under the License. */ -import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/AbilityContext" import { FormState } from "./ohos_application_formInfo" +import { FormExtensionContextClass as FormExtensionContext } from "./application/FormExtensionContext" +import { FormBindingData } from "./ohos_application_formBindingData" export function mockFormExtension() { - const formBindingDataMock = { - data: paramMock.paramObjectMock - } - const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass { - constructor() { - super(); - console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.updateForm = function (...args) { - console.warn("formExtension.formExtensionContext.updateForm 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(); - }) - } - }; - this.startAbility = function (...args) { - console.warn("formExtension.formExtensionContext.startAbility 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(); - }) - } - }; - } - } const formExtensionClass = class formExtension { constructor() { console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); - this.context = new formExtensionContextClass(); + this.context = new FormExtensionContext(); this.onCreate = function (...args) { console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return formBindingDataMock + return FormBindingData }; this.onCastToNormal = function (...args) { console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtAbility.js deleted file mode 100644 index 288f773c..00000000 --- a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtAbility.js +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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" -import { RemoteObjectClass } from "./ohos_application_ServiceExtensionAbility" - -const ApplicationInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - systemApp: '[PC preview] unknow systemApp', - enabled: '[PC preview] unknow enabled', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - icon: '[PC preview] unknow icon', - iconId: '[PC preview] unknow iconId', - process: '[PC preview] unknow process', - supportedModes: '[PC preview] unknow supportedModes', - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - entryDir: '[PC preview] unknow entryDir', - codePath: '[PC preview] unknow codePath', - removable: '[PC preview] unknow removable', - accessTokenId: '[PC preview] unknow accessTokenId', - uid: '[PC preview] unknow uid', - entityType: '[PC preview] unknow entityType' -} -const EventHubClass = class EventHub { - constructor() { - console.warn('EventHub.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.on = function (...args) { - console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.off = function (...args) { - console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.emit = function (...args) { - console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - } -} -const BaseContextClass = class BaseContext { - constructor() { - console.warn('BaseContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.stageMode = "[PC Preview] unknow stageMode"; - } -} -export const ContextClass = class Context extends BaseContextClass { - constructor() { - super(); - console.warn('Context.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.applicationInfo = ApplicationInfoMock; - this.cacheDir = "[PC Preview] unknow cacheDir"; - this.tempDir = "[PC Preview] unknow tempDir"; - this.filesDir = "[PC Preview] unknow filesDir"; - this.databaseDir = "[PC Preview] unknow databaseDir"; - this.storageDir = "[PC Preview] unknow storageDir"; - this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir"; - this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir"; - this.eventHub = new EventHubClass(); - this.createBundleContext = function (...args) { - console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new ContextClass(); - }; - this.createModuleContext = function (...args) { - console.warn("Context.createModuleContext interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new ContextClass(); - }; - this.getApplicationContext = function () { - console.warn("Context.getApplicationContext interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new ContextClass(); - }; - this.switchArea = function (...args) { - console.warn("Context.switchArea interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - } -} -export function mockServiceExtAbility() { - const HapModuleInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - icon: '[PC preview] unknow icon', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - iconId: '[PC preview] unknow iconId', - backgroundImg: '[PC preview] unknow backgroundImg', - supportedModes: '[PC preview] unknow supportedModes', - reqCapabilities: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - moduleName: '[PC preview] unknow moduleName', - mainAbilityName: '[PC preview] unknow mainAbilityName', - installationFree: '[PC preview] unknow installationFree', - mainElementName: '[PC preview] unknow mainElementName', - } - const ExtAbilityContextClass = class ExtAbilityContext extends ContextClass { - constructor() { - super(); - console.warn('ExtAbilityContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.currentHapModuleInfo = HapModuleInfoMock; - } - } - const ServiceExtAbilityContextClass = class ServiceExtAbilityContext extends ExtAbilityContextClass { - constructor() { - super(); - console.warn('ServiceExtAbilityContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.startAbility = function (...args) { - console.warn("ServiceExtAbilityContext.startAbility 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(); - }) - } - }; - this.startAbilityWithAccount = function (...args) { - console.warn("ServiceExtAbilityContext.startAbilityWithAccount 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(); - }) - } - }; - this.terminateSelf = function (...args) { - console.warn("ServiceExtAbilityContext.terminateSelf 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(); - }) - } - }; - this.connectAbility = function (...args) { - console.warn("ServiceExtAbilityContext.connectAbility 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.connectAbilityWithAccount = function (...args) { - console.warn("ServiceExtAbilityContext.connectAbilityWithAccount 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.disconnectAbility = function (...args) { - console.warn("ServiceExtAbilityContext.disconnectAbility 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(); - }) - } - }; - } - } - const ServiceExtAbilityClass = class ServiceExtAbility { - constructor() { - console.warn('application.ServiceExtAbility.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.context = new ServiceExtAbilityContextClass(); - this.onCreate = function (...args) { - console.warn("ServiceExtAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onDestroy = function () { - console.warn("ServiceExtAbility.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onRequest = function (...args) { - console.warn("ServiceExtAbility.onRequest interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onConnect = function (...args) { - console.warn("ServiceExtAbility.onConnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new RemoteObjectClass(); - }; - this.onDisconnect = function (...args) { - console.warn("ServiceExtAbility.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - this.onReconnect = function (...args) { - console.warn("ServiceExtAbility.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - } - } - return new ServiceExtAbilityClass(); -} diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js index 3fc1e183..6ee3b2c8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtensionAbility.js @@ -14,194 +14,15 @@ */ import { paramMock } from "../utils" -import { ExtensionContextClass } from "./application/AbilityContext" +import { ServiceExtensionContextClass } from "./application/ServiceExtensionContext" +import { RemoteObjectClass } from "./ohos_rpc" -export const RemoteObjectClass = class RemoteObject { - constructor() { - console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.queryLocalInterface = function () { - console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteBrokerMock; - }; - this.sendRequest = function (...args) { - console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }; - this.addDeathRecipient = function () { - console.warn("RemoteObject.addDeathRecipient 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.removeDeathRecipient = function () { - console.warn("RemoteObject.removeDeathRecipient 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.getInterfaceDescriptor = function () { - console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }; - this.isObjectDead = function () { - console.warn("RemoteObject.isObjectDead 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.queryLocalInterface = function (...args) { - console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteObjectMock - }; - this.getInterfaceDescriptor = function () { - console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }; - this.onRemoteRequest = function (...args) { - console.warn("RemoteObject.onRemoteRequest 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.sendRequest = function (...args) { - console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }; - this.getCallingPid = function () { - console.warn("RemoteObject.getCallingPid 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.getCallingUid = function () { - console.warn("RemoteObject.getCallingUid 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.attachLocalInterface = function (...args) { - console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; - } -} export function mockServiceExtensionAbility() { - const IRemoteBrokerMock = { - asObject: function () { - console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteObjectMock; - }, - } - const IRemoteObjectMock = { - queryLocalInterface: function () { - console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteBrokerMock; - }, - sendRequest: function (...args) { - console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }, - addDeathRecipient: function () { - console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - removeDeathRecipient: function () { - console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - getInterfaceDescriptor: function () { - console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - isObjectDead: function () { - console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - } - } - const serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass { - constructor() { - super(); - console.warn('ServiceExtensionAbility.serviceExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.startAbility = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.startAbility 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(); - }) - } - }; - this.startAbilityWithAccount = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.startAbilityWithAccount 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(); - }) - } - }; - this.terminateSelf = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.terminateSelf 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(); - }) - } - }; - this.connectAbility = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.connectAbility 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.connectAbilityWithAccount = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.connectAbilityWithAccount 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.disconnectAbility = function (...args) { - console.warn("ServiceExtensionAbility.serviceExtensionContext.disconnectAbility 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(); - }) - } - } - } - } const ServiceExtensionAbilityClass = class ServiceExtensionAbility { constructor() { console.warn('application.ServiceExtensionAbility.constructor interface mocked in the Previewer. How this interface works on' + ' the Previewer may be different from that on a real device.'); - this.context = new serviceExtensionContextClass(); + this.context = new ServiceExtensionContextClass(); this.onCreate = function (...args) { console.warn("application.ServiceExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js index 530bd319..a1e50970 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_StartOptions.js @@ -19,4 +19,7 @@ export const StartOptionsClass = class StartOptions { this.windowMode = "[PC Preview] unknow windowMode"; this.displayId = "[PC Preview] unknow displayId"; } +} +export function mockStartOptions() { + return new StartOptionsClass(); } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js index 1fad9fd2..85c6a5be 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -15,18 +15,20 @@ import { paramMock } from "../utils" export const WantClass = class Want { - constructor() { - console.warn('Want.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.deviceId = "[PC Preview] unknow deviceId"; - this.bundleName = "[PC Preview] unknow bundleName"; - this.abilityName = "[PC Preview] unknow abilityName"; - this.uri = "[PC Preview] unknow uri"; - this.type = "[PC Preview] unknow type"; - this.flag = "[PC Preview] unknow flag"; - this.action = "[PC Preview] unknow action"; - this.parameters = {}; - this.entities = [paramMock.paramStringMock]; - this.moduleName = "[PC Preview] unknow moduleName"; - } -} \ No newline at end of file + constructor() { + this.deviceId = "[PC Preview] unknow deviceId"; + this.bundleName = "[PC Preview] unknow bundleName"; + this.abilityName = "[PC Preview] unknow abilityName"; + this.uri = "[PC Preview] unknow uri"; + this.type = "[PC Preview] unknow type"; + this.flags = "[PC Preview] unknow flags"; + this.action = "[PC Preview] unknow action"; + this.parameters = {}; + this.entities = [paramMock.paramStringMock]; + this.moduleName = "[PC Preview] unknow moduleName"; + } +} +export function mockWant() { + return new WantClass(); +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js index 6b3df79d..613e1cf4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityDelegatorRegistry.js @@ -13,8 +13,10 @@ * limitations under the License. */ -import { AbilityDelegator } from "./application/abilityDelegator" -import { AbilityDelegatorArgs } from "./application/abilityDelegatorArgs" +import { AbilityDelegator as _AbilityDelegator} from "./application/abilityDelegator" +import { AbilityDelegatorArgs as _AbilityDelegatorArgs } from "./application/abilityDelegatorArgs" +import { AbilityMonitor as _AbilityMonitor } from "./application/abilityMonitor" +import { ShellCmdResult as _ShellCmdResult } from "./application/shellCmdResult" export const AbilityLifecycleState = { UNINITIALIZED: '[PC preview] unknow UNINITIALIZED', @@ -29,13 +31,18 @@ export function mockAbilityDelegatorRegistry() { getAbilityDelegator: function () { console.warn('abilityDelegatorRegistry.getAbilityDelegator interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); - return AbilityDelegator; + return _AbilityDelegator; }, getArguments: function () { console.warn('abilityDelegatorRegistry.getArguments interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); - return AbilityDelegatorArgs; + return _AbilityDelegatorArgs; }, + AbilityLifecycleState, + AbilityDelegator: _AbilityDelegator, + AbilityDelegatorArgs: _AbilityDelegatorArgs, + AbilityMonitor: _AbilityMonitor, + ShellCmdResult: _ShellCmdResult } return abilityDelegatorRegistry } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js index c438205c..1513b1f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_abilityManager.js @@ -14,6 +14,9 @@ */ import { paramMock } from "../utils" +import { AbilityRunningInfo as _AbilityRunningInfo } from "./application/AbilityRunningInfo" +import { ExtensionRunningInfo as _ExtensionRunningInfo } from "./application/ExtensionRunningInfo" +import { ElementName } from "./bundle/elementName" export const AbilityState = { INITIAL: 0, @@ -23,39 +26,8 @@ export const AbilityState = { BACKGROUNDING: 12 } export function mockAbilityManager() { - const AbilityRunningInfoMock = { - ability: ElementNameMock, - pid: '[PC preview] unknow pid', - uid: '[PC preview] unknow uid', - processName: '[PC preview] unknow processName', - startTime: '[PC preview] unknow startTime', - AbilityStateMock: '[PC preview] unknow abilityStateMock' - } - const ElementNameMock = { - deviceId: '[PC preview] unknow deviceId', - bundleName: '[PC preview] unknow bundleName', - abilityName: '[PC preview] unknow abilityName', - uri: '[PC preview] unknow uri', - shortName: '[PC preview] unknow shortName' - } - const ExtensionRunningInfoMock = { - extension: ElementNameMock, - pid: '[PC preview] unknow pid', - uid: '[PC preview] unknow uid', - processName: '[PC preview] unknow processName', - startTime: '[PC preview] unknow startTime', - clientPackage: [paramMock.paramStringMock], - ExtensionAbilityTypeMock: '[PC preview] unknow ExtensionAbilityTypeMock', - } - const elementName = { - deviceId: "[PC preview] unknown deviceId", - bundleName: "[PC preview] unknown bundleName", - abilityName: "[PC preview] unknown abilityName", - uri: "[PC preview] unknown uri", - shortName: "[PC preview] unknown shortName", - moduleName: "[PC preview] unknown moduleName", - } const abilityManager = { + AbilityState, updateConfiguration: function (...args) { console.warn('abilityManager.updateConfiguration interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -73,10 +45,10 @@ export function mockAbilityManager() { ' 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, [AbilityRunningInfoMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [_AbilityRunningInfo]); } else { return new Promise((resolve) => { - resolve([AbilityRunningInfoMock]); + resolve([_AbilityRunningInfo]); }); } }, @@ -85,10 +57,10 @@ export function mockAbilityManager() { ' 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, [ExtensionRunningInfoMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [_ExtensionRunningInfo]); } else { return new Promise((resolve) => { - resolve([ExtensionRunningInfoMock]); + resolve([_ExtensionRunningInfo]); }); } }, @@ -97,13 +69,15 @@ export function mockAbilityManager() { ' 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, elementName); + args[len - 1].call(this, paramMock.businessErrorMock, ElementName); } else { return new Promise((resolve) => { - resolve(elementName); + resolve(ElementName); }); } - } + }, + AbilityRunningInfo: _AbilityRunningInfo, + ExtensionRunningInfo: _ExtensionRunningInfo } return abilityManager } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js index 7c3dfdf0..53d18896 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_appManager.js @@ -14,19 +14,13 @@ */ import { paramMock } from "../utils" +import { AppStateDataClass as _AppStateData } from "./application/AppStateData" +import { ProcessRunningInfo } from "./application/ProcessRunningInfo" +import { AppStateDataClass as _AbilityStateData } from "./application/AppStateData" +import { ApplicationStateObserverClass as _ApplicationStateObserver } from "./application/ApplicationStateObserver" +import { ProcessDataClass as _ProcessData } from "./application/ProcessData" export function mockAppManager() { - const AppStateDataMock = { - bundleName: '[PC preview] unknow bundleName', - uid: '[PC preview] unknow uid', - state: '[PC preview] unknow state' - } - const ProcessRunningInfoMock = { - pid: '[PC preview] unknow pid', - uid: '[PC preview] unknow uid', - processName: '[PC preview] unknow processName', - bundleNames: [paramMock.paramStringMock] - } const appManager = { registerApplicationStateObserver: function (...args) { console.warn('appManager.registerApplicationStateObserver interface mocked in the Previewer. How this interface works on the' + @@ -50,10 +44,10 @@ export function mockAppManager() { ' 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, [AppStateDataMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [new _AppStateData()]); } else { return new Promise((resolve) => { - resolve([AppStateDataMock]); + resolve([new _AppStateData()]); }); } }, @@ -86,10 +80,10 @@ export function mockAppManager() { ' 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, [ProcessRunningInfoMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [ProcessRunningInfo]); } else { return new Promise((resolve) => { - resolve([ProcessRunningInfoMock]); + resolve([ProcessRunningInfo]); }); } }, @@ -140,7 +134,12 @@ export function mockAppManager() { resolve(paramMock.paramNumberMock); }); } - } + }, + AbilityStateData: new _AbilityStateData(), + AppStateData: new _AppStateData(), + ApplicationStateObserver: new _ApplicationStateObserver(), + ProcessData: new _ProcessData(), + ProcessRunningInfo } return appManager } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_context.js b/runtime/main/extend/systemplugin/napi/ohos_application_context.js new file mode 100644 index 00000000..58689e8b --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_application_context.js @@ -0,0 +1,43 @@ +/* + * 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 { AbilityContextClass as _AbilityContext } from "./application/AbilityContext" +import { AbilityStageContextClass as _AbilityStageContext } from "./application/AbilityStageContext" +import { ApplicationContextClass as _ApplicationContext } from "./application/ApplicationContext" +import { BaseContextClass as _BaseContext } from "./application/BaseContext" +import { ContextClass as _Context } from "./application/Context" +import { ExtensionContextClass as _ExtensionContext } from "./application/ExtensionContext" +import { FormExtensionContextClass as _FormExtensionContext } from "./application/FormExtensionContext" +import { EventHubClass as _EventHub } from "./application/EventHub" +import { PermissionRequestResultClass as _PermissionRequestResult } from "./application/PermissionRequestResult" + +export const AreaMode = { + EL1: 0, + EL2: 1 +} +export function mockContext() { + const Context = { + AbilityContext: new _AbilityContext(), + AbilityStageContext: new _AbilityStageContext(), + ApplicationContext: new _ApplicationContext(), + BaseContext: new _BaseContext(), + Context: new _Context(), + ExtensionContext: new _ExtensionContext(), + FormExtensionContext: new _FormExtensionContext(), + AreaMode, + EventHub: new _EventHub(), + PermissionRequestResult: new _PermissionRequestResult() + } + return Context; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js old mode 100644 new mode 100755 index ae82557b..b4ecd6ed --- a/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js @@ -13,6 +13,7 @@ * limitations under the License. */ import { paramMock } from "../utils" +import { ErrorObserverClass as _ErrorObserver } from "./application/ErrorObserver" export function mockErrorManager() { const errorManager = { @@ -33,6 +34,7 @@ export function mockErrorManager() { }); } }, + ErrorObserver: new _ErrorObserver() } return errorManager } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js index da8ffa55..0284a3ce 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formBindingData.js @@ -24,6 +24,7 @@ export function mockFormBindingData() { " may be different from that on a real device.") return FormBindingData; }, + FormBindingData } return formBindingData; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formError.js b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js index 431d7166..200dda33 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formError.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formError.js @@ -36,4 +36,10 @@ export const FormError = { ERR_SYSTEM_RESPONSES_FAILED: 30, ERR_FORM_DUPLICATE_ADDED: 31, ERR_IN_RECOVERY: 36 +} +export function mockFormError() { + const formError = { + FormError + } + return formError; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js index 23a551b8..21217b58 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_formInfo.js @@ -63,4 +63,16 @@ export const FormParam = { } export const FormInfoFilter = { moduleName: '[PC preview] unknow moduleName', +} +export function mockFormInfo() { + const formInfo = { + FormInfo, + FormType, + ColorMode, + FormStateInfo, + FormState, + FormParam, + FormInfoFilter + } + return formInfo; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js index ab5d68ad..d6619a5c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js @@ -14,30 +14,11 @@ */ import { paramMock } from "../utils" -import { PixelMapMock } from "../multimedia" +import { MissionInfo as _MissionInfo } from "./application/MissionInfo" +import { MissionSnapshot as _MissionSnapshot } from "./application/MissionSnapshot" +import { MissionListener as _MissionListener } from "./application/MissionListener" export function mockMissionManager() { - const MissionInfoMock = { - missionId: '[PC preview] unknown missionId', - runningState: '[PC preview] unknown runningState', - lockedState: '[PC preview] unknown lockedState', - timestamp: '[PC preview] unknown timestamp', - want: '[PC preview] unknown want', - label: '[PC preview] unknown label', - iconPath: '[PC preview] unknown iconPath', - continuable: '[PC preview] unknown continuable' - } - const ElementNameMock = { - deviceId: '[PC preview] unknown deviceId', - bundleName: '[PC preview] unknown bundleName', - abilityName: '[PC preview] unknown abilityName', - uri: '[PC preview] unknown uri', - shortName: '[PC preview] unknown shortName' - } - const MissionSnapshotMock = { - abality: ElementNameMock, - snapshot: PixelMapMock, - } const missionManager = { registerMissionListener: function (...args) { console.warn("missionManager.registerMissionListener interface mocked in the Previewer. How this interface works on the Previewer" + @@ -61,10 +42,10 @@ export function mockMissionManager() { ' 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, MissionInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, _MissionInfo); } else { return new Promise((resolve) => { - resolve(MissionInfoMock); + resolve(_MissionInfo); }); } }, @@ -73,10 +54,10 @@ export function mockMissionManager() { ' 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, [MissionInfoMock]); + args[len - 1].call(this, paramMock.businessErrorMock, [_MissionInfo]); } else { return new Promise((resolve) => { - resolve([MissionInfoMock]); + resolve([_MissionInfo]); }); } }, @@ -85,10 +66,22 @@ export function mockMissionManager() { ' 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, MissionSnapshotMock); + args[len - 1].call(this, paramMock.businessErrorMock, _MissionSnapshot); } else { return new Promise((resolve) => { - resolve(MissionSnapshotMock); + resolve(_MissionSnapshot); + }); + } + }, + getLowResolutionMissionSnapShot: function (...args) { + console.warn('missionManager.getLowResolutionMissionSnapShot 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, _MissionSnapshot); + } else { + return new Promise((resolve) => { + resolve(_MissionSnapshot); }); } }, @@ -151,7 +144,10 @@ export function mockMissionManager() { resolve(); }); } - } + }, + MissionInfo: _MissionInfo, + MissionListener: _MissionListener, + MissionSnapshot: _MissionSnapshot } return missionManager } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js index 9dbe65dd..9e7abd7c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_commonEvent.js @@ -252,7 +252,8 @@ export function mockCommonEvent() { if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } - } + }, + Support } return commonEvent } diff --git a/runtime/main/extend/systemplugin/napi/ohos_contact.js b/runtime/main/extend/systemplugin/napi/ohos_contact.js index 8b1706bd..ed8ca6d9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_contact.js +++ b/runtime/main/extend/systemplugin/napi/ohos_contact.js @@ -39,6 +39,8 @@ export function mockContact() { this.organization = "[PC Preview] unknow organization"; } } + ContactClass.INVALID_CONTACT_ID = -1; + const ContactAttributesClass = class ContactAttributes { constructor() { console.warn('contact.ContactAttributes.constructor interface mocked in the Previewer. How this interface' + @@ -122,6 +124,7 @@ export function mockContact() { this.middleNamePhonetic = "[PC Preview] unknow middleNamePhonetic"; this.namePrefix = "[PC Preview] unknow namePrefix"; this.nameSuffix = "[PC Preview] unknow nameSuffix"; + this.middleName = "[PC Preview] unknow middleName"; } } const NickNameClass = class NickName { @@ -269,6 +272,22 @@ export function mockContact() { Relation: RelationClass, SipAddress: SipAddressClass, Website: WebsiteClass, + Attribute:{ + ATTR_CONTACT_EVENT: "[PC Preview] unknow ATTR_CONTACT_EVENT", + ATTR_EMAIL: "[PC Preview] unknow ATTR_EMAIL", + ATTR_GROUP_MEMBERSHIP: "[PC Preview] unknow ATTR_GROUP_MEMBERSHIP", + ATTR_IM: "[PC Preview] unknow ATTR_IM", + ATTR_NAME: "[PC Preview] unknow ATTR_NAME", + ATTR_NICKNAME: "[PC Preview] unknow ATTR_NICKNAME", + ATTR_NOTE: "[PC Preview] unknow ATTR_NOTE", + ATTR_ORGANIZATION: "[PC Preview] unknow ATTR_ORGANIZATION", + ATTR_PHONE: "[PC Preview] unknow ATTR_PHONE", + ATTR_PORTRAIT: "[PC Preview] unknow ATTR_PORTRAIT", + ATTR_POSTAL_ADDRESS: "[PC Preview] unknow ATTR_POSTAL_ADDRESS", + ATTR_RELATION: "[PC Preview] unknow ATTR_RELATION", + ATTR_SIP_ADDRESS: "[PC Preview] unknow ATTR_SIP_ADDRESS", + ATTR_WEBSITE: "[PC Preview] unknow ATTR_WEBSITE", + }, addContact: function (...args) { console.warn("contact.addContact interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_convertxml.js b/runtime/main/extend/systemplugin/napi/ohos_convertxml.js index 89db4709..78c48f43 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_convertxml.js +++ b/runtime/main/extend/systemplugin/napi/ohos_convertxml.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -16,19 +16,42 @@ import { paramMock } from "../utils" export function mockConvertXml() { - const result = { - ConvertXML: function (...args) { - console.warn("convertXml.ConvertXML interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return ConvertXMLMock; - } - } + const ConvertXMLClass = class ConvertXML { + constructor(...args) { + console.warn("convertXml.ConvertXML.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.convert = function (...args) { + console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + return paramMock.paramObjectMock; + } + } + }; + const ConvertXMLMock = { - convert: function (...args) { - console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramObjectMock; - } - } - return result; + ConvertXML : ConvertXMLClass + }; + + const ConvertOptionsMock = { + trim : '[PC preview] unknow trim', + ignoreDeclaration : '[PC preview] unknow ignoreDeclaration', + ignoreInstruction : '[PC preview] unknow ignoreInstruction', + ignoreAttributes : '[PC preview] unknow ignoreAttributes', + ignoreComment : '[PC preview] unknow ignoreComment', + ignoreCDATA : '[PC preview] unknow ignoreCDATA', + ignoreDoctype : '[PC preview] unknow ignoreDoctype', + ignoreText : '[PC preview] unknow ignoreText', + declarationKey : '[PC preview] unknow declarationKey', + instructionKey : '[PC preview] unknow instructionKey', + attributesKey : '[PC preview] unknow attributesKey', + textKey : '[PC preview] unknow textKey', + cdataKey : '[PC preview] unknow cdataKey', + doctypeKey : '[PC preview] unknow doctypeKey', + commentKey : '[PC preview] unknow commentKey', + parentKey : '[PC preview] unknow parentKey', + typeKey : '[PC preview] unknow typeKey', + nameKey : '[PC preview] unknow nameKey', + elementsKey : '[PC preview] unknow elementsKey' + }; + return ConvertXMLMock; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js index c444525d..26f86584 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_DataShareResultSet.js @@ -15,6 +15,13 @@ import {paramMock} from "../utils" +export const DataType = { + TYPE_NULL: 0, + TYPE_LONG: 1, + TYPE_DOUBLE: 2, + TYPE_STRING: 3, + TYPE_BLOB: 4 +}; export const DataShareResultSetMock = { columnNames: "[PC Preview] unknow columnNames", columnCount: "[PC Preview] unknow columnCount", diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 23aa2fc2..36977af0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -15,6 +15,15 @@ import { paramMock } from "../utils" +const ValueTypes = '[PC Preview] unknow value type' + +const StorageObserver = { + key: '[PC Preview] unknown key' +}; +const MAX_KEY_LENGTH = 80; + +const MAX_VALUE_LENGTH = 8192; + export function mockDataStorage() { const storage = { storageMock, @@ -72,17 +81,17 @@ export function mockDataStorage() { getSync: function () { console.warn("Storage.getSync interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") - return paramValueTypeMock + return ValueTypes }, get: function (...args) { console.warn("Storage.get 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, paramValueTypeMock) + args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes) } else { return new Promise((resolve) => { - resolve(paramValueTypeMock) + resolve(ValueTypes) }) } }, @@ -171,13 +180,13 @@ export function mockDataStorage() { console.warn("Storage.on 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 - args[len - 1].call(this, storageObserverMock) + args[len - 1].call(this, StorageObserver) }, off: function (...args) { console.warn("Storage.off 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 - args[len - 1].call(this, storageObserverMock) + args[len - 1].call(this, storageObserver) } } return storage diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js index 7febfb95..a803141b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_dataSharePredicates.js @@ -15,7 +15,7 @@ import { paramMock } from "../utils" export function mockDataSharePredicates() { - const DataSharePredicatesClass = class DataSharePredicate { + const DataSharePredicatesClass = class DataSharePredicates { constructor() { this.equalTo = function (...args) { console.warn("DataSharePredicates.equalTo interface mocked in the Previewer. How this interface works on the" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js index 0c2335d0..ad34651e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_distributedDataObject.js @@ -62,7 +62,7 @@ export function mockDistributedObject() { const RevokeSaveSuccessResponse = { sessionId: "[[PC Preview] unknow sessionId]" }; - const distributedObjectMock = { + const distributedDataObject = { createDistributedObject: function (...args) { console.warn("distributedObject.createDistributedObject interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device."); @@ -74,5 +74,5 @@ export function mockDistributedObject() { return 'just test'; } }; - return distributedObjectMock; -} \ No newline at end of file + return distributedDataObject; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 795a2642..e9ac4c8c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -205,6 +205,16 @@ export function mockRdb() { const storeConfig = { name: "[PC Preview] unknown name" } + + const SyncMode = { + SYNC_MODE_PUSH: 0, + SYNC_MODE_PULL: 1 + } + + const SubscribeType = { + SUBSCRIBE_TYPE_REMOTE: 0 + } + const rdbStore = { insert: function (...args) { console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js index b712a291..0ef3f567 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js +++ b/runtime/main/extend/systemplugin/napi/ohos_events_emitter.js @@ -55,6 +55,9 @@ export function mockEmitter() { console.warn("emitter.emit interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); }, + EventData, + InnerEvent, + EventPriority } return emitter } diff --git a/runtime/main/extend/systemplugin/napi/ohos_faultLogger.js b/runtime/main/extend/systemplugin/napi/ohos_faultLogger.js new file mode 100644 index 00000000..b99ac3b4 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_faultLogger.js @@ -0,0 +1,58 @@ +/* + * 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" + +function buildMockInfo(interfaceName) { + return interfaceName + " interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device." +} + +export function mockFaultLogger() { + const FaultType = { + NO_SPECIFIC : 0, + CPP_CRASH : 2, + JS_CRASH : 3, + APP_FREEZE : 4 + } + const FaultLogInfo = { + pid: "[PC Preview] unknow pid", + uid: "[PC Preview] unknow uid", + type: FaultType, + timestamp: "[PC Preview] unknow timestamp", + reason: "[PC Preview] unknow reason", + module: "[PC Preview] unknow module", + summary: "[PC Preview] unknow summary", + fullLog: "[PC Preview] unknow fullLog", + } + const FaultLogger = { + FaultType, + FaultLogInfo, + querySelfFaultLog: function(...args) { + console.warn(buildMockInfo("FaultLogger.querySelfFaultLog")) + var array = new Array() + array.push(FaultLogInfo) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, array) + } else { + return new Promise((resolve) => { + resolve(array) + }); + } + }, + } + return FaultLogger +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index f06e905c..d9fc9eb9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.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 @@ -16,16 +16,29 @@ import { paramMock } from "../utils" export function mockFileManager() { + const FileInfo = { + name: '[PC preview] unknow name', + path: '[PC preview] unknow path', + type: '[PC preview] unknow type', + size: '[PC preview] unknow size', + addedTime: '[PC preview] unknow addedTime', + modifiedTime: '[PC preview] unknow modifiedTime' + }; + const DevInfo = { + name: '[PC preview] unknow name' + }; const filemanager = { + FileInfo: FileInfo, + DevInfo: DevInfo, getRoot: function (...args) { console.warn("filemanager.getRoot 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.paramArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(new Array(FileInfo)); }) } }, @@ -34,10 +47,10 @@ export function mockFileManager() { " 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.paramArrayMock) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(new Array(FileInfo)); }) } }, @@ -52,7 +65,7 @@ export function mockFileManager() { resolve(paramMock.paramStringMock); }) } - }, + } } return filemanager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_i18n.js b/runtime/main/extend/systemplugin/napi/ohos_i18n.js index 5aa4ad09..c76854bd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_i18n.js +++ b/runtime/main/extend/systemplugin/napi/ohos_i18n.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockI18N() { - const result = { + const i18n = { getDisplayCountry: function(...args) { console.warn("I18N.getDisplayCountry interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -75,7 +75,7 @@ export function mockI18N() { getCalendar: function(...args) { console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return CalendarMock; + return new CalendarClass(); }, isRTL: function(...args) { console.warn("I18N.isRTL interface mocked in the Previewer. How this interface works on the Previewer" + @@ -85,73 +85,19 @@ export function mockI18N() { getLineInstance: function(...args) { console.warn("I18N.getLineInstance interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return BreakIteratorMock; + return new BreakIteratorClass(); }, getTimeZone: function(...args) { console.warn("I18N.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return new TimeZoneClass(); }, - Util: { - unitConvert: function(...args) { - console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } - }, - IndexUtil: { - getInstance: function() { - console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IndexUtilMock; - } - }, - Character: { - isDigit: function(...args) { - console.warn("I18N.Character.isDigit interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isSpaceChar: function(...args) { - console.warn("I18N.Character.isSpaceChar interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isWhitespace: function(...args) { - console.warn("I18N.Character.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isRTL: function(...args) { - console.warn("I18N.Character.isRTL interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isIdeograph: function(...args) { - console.warn("I18N.Character.isIdeograph interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isLetter: function(...args) { - console.warn("I18N.Character.isLetter interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isLowerCase: function(...args) { - console.warn("I18N.Character.isLowerCase interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isUpperCase: function(...args) { - console.warn("I18N.Character.isUpperCase interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - getType: function(...args) { - console.warn("I18N.Character.getType interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, + getInstance: function() { + console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new IndexUtilClass(); }, + Character: CharacterClass, is24HourClock: function() { console.warn("I18N.is24HourClock interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -193,127 +139,28 @@ export function mockI18N() { " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - PhoneNumberFormat: PhoneNumberFormatClass - } - const CalendarMock = { - setTime: function(...args) { - console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - set: function(...args) { - console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setTimeZone: function(...args) { - console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - getTimeZone: function() { - console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + + PhoneNumberFormat: PhoneNumberFormatClass, + Transliterator: TransliteratorClass, + getAppPreferredLanguage: function() { + console.warn("I18N.getAppPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramStringMock; }, - getFirstDayOfWeek: function() { - console.warn("I18N.Calendar.getFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - setFirstDayOfWeek: function(...args) { - console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - getMinimalDaysInFirstWeek: function() { - console.warn("I18N.Calendar.getMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - setMinimalDaysInFirstWeek: function(...args) { - console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - get: function(...args) { - console.warn("I18N.Calendar.get interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getDisplayName: function(...args) { - console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - isWeekend: function(...args) { - console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, } - const BreakIteratorMock = { - current: function() { - console.warn("I18N.BreakIterator.current interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - first: function() { - console.warn("I18N.BreakIterator.first interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - last: function() { - console.warn("I18N.BreakIterator.last interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - next: function(...args) { - console.warn("I18N.BreakIterator.next interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - previous: function() { - console.warn("I18N.BreakIterator.previous interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - setLineBreakText: function() { - console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - following: function() { - console.warn("I18N.BreakIterator.following interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getLineBreakText: function() { - console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - isBoundary: function(...args) { - console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, + const PhoneNumberFormatOptions = { + type: '[PC preview] unknow type', } - const IndexUtilMock = { - getIndexList: function() { - console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new Array(paramMock.paramStringMock); - }, - addLocale: function(...args) { - console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - getIndex: function(...args) { - console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - } + const UnitInfo = { + unit: '[PC preview] unknow unit', + measureSystem: '[PC preview] unknow measureSystem', } - return result; + return i18n; } export const TimeZoneClass = class TimeZone{ constructor() { + console.warn("I18N.TimeZone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") this.getID = function() { console.warn("I18N.TimeZone.getID interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -356,7 +203,7 @@ TimeZoneClass.getTimezoneFromCity = function(...args) { " may be different from that on a real device.") return new TimeZoneClass(); }; -const PhoneNumberFormatClass = class PhoneNumberFormat{ +export const PhoneNumberFormatClass = class PhoneNumberFormat{ constructor(...args) { console.warn("I18N.PhoneNumberFormat.constructor interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -370,10 +217,224 @@ const PhoneNumberFormatClass = class PhoneNumberFormat{ " may be different from that on a real device.") return paramMock.paramStringMock; }; + this.getLocationName = function(...args) { + console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; } } -PhoneNumberFormatClass.getLocationName = function(...args) { - console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; +export const TransliteratorClass = class Transliterator { + constructor() { + console.warn("I18N.Transliterator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.transform = function(...args) { + console.warn("I18N.Transliterator.transform interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + } +} +TransliteratorClass.getAvailableIDs = function() { + console.warn("I18N.Transliterator.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return new Array(paramMock.paramStringMock); +} +TransliteratorClass.getInstance = function(...args) { + console.warn("I18N.Transliterator.getInstance interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return new TransliteratorClass(); +} +const IndexUtilClass = class IndexUtil { + constructor() { + console.warn("I18N.IndexUtil interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.getIndexList = function() { + console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Array(paramMock.paramStringMock); + }; + this.addLocale = function(...args) { + console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getIndex = function(...args) { + console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + } +} +const BreakIteratorClass = class BreakIterator { + constructor() { + console.warn("I18N.BreakIterator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.current = function() { + console.warn("I18N.BreakIterator.current 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.first = function() { + console.warn("I18N.BreakIterator.first 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.last = function() { + console.warn("I18N.BreakIterator.last 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.next = function(...args) { + console.warn("I18N.BreakIterator.next 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.previous = function() { + console.warn("I18N.BreakIterator.previous 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.setLineBreakText = function() { + console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.following = function() { + console.warn("I18N.BreakIterator.following 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.getLineBreakText = function() { + console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + this.isBoundary = function(...args) { + console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + } +} +const CalendarClass = class Calendar { + constructor() { + console.warn("I18N.Calendar interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.setTime = function(...args) { + console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.set = function(...args) { + console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.setTimeZone = function(...args) { + console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getTimeZone = function() { + console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + this.getFirstDayOfWeek = function() { + console.warn("I18N.Calendar.getFirstDayOfWeek 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.setFirstDayOfWeek = function(...args) { + console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getMinimalDaysInFirstWeek = function() { + console.warn("I18N.Calendar.getMinimalDaysInFirstWeek 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.setMinimalDaysInFirstWeek = function(...args) { + console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.get = function(...args) { + console.warn("I18N.Calendar.get 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.getDisplayName = function(...args) { + console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + this.isWeekend = function(...args) { + console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + } +} +export const UtilClass = class Util { + constructor() { + console.warn("I18N.Util interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.unitConvert = function(...args) { + console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + this.getDateOrder = function(...args) { + console.warn("I18N.Util.getDateOrder interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + } + } +} +export const CharacterClass = class Character { + constructor() { + console.warn("I18N.Character interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.isDigit = function(...args) { + console.warn("I18N.Character.isDigit 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.isSpaceChar = function(...args) { + console.warn("I18N.Character.isSpaceChar 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.isWhitespace = function(...args) { + console.warn("I18N.Character.isWhitespace 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.isRTL = function(...args) { + console.warn("I18N.Character.isRTL 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.isIdeograph = function(...args) { + console.warn("I18N.Character.isIdeograph 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.isLetter = function(...args) { + console.warn("I18N.Character.isLetter 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.isLowerCase = function(...args) { + console.warn("I18N.Character.isLowerCase 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.isUpperCase = function(...args) { + console.warn("I18N.Character.isUpperCase 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.getType = function(...args) { + console.warn("I18N.Character.getType interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + } } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js index ca1a920b..4596334c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js @@ -39,14 +39,8 @@ export function mockInputMethod() { } ] const InputMethodProperty = { - methodId: "[PC Preview] unknow method id", - bundleName: "[PC Preview] unknow bundle name", - abilityName: "[PC Preview] unknow ability name", - configurationPage: "[PC Preview] unknow configuration page", - isSystemIme: true, - typeCount: 1, - defaultImeId: 2, - keyboardTypes: KeyboardTypeArry + packageName :"[PC Preview] unknow packageName", + methodId: "[PC Preview] unknow method id" } const InputMethodPropertyArry = [ { @@ -137,7 +131,7 @@ export function mockInputMethod() { }, } const inputMethod = { - MAX_TYPE_MUN: 128, + MAX_TYPE_NUM: 128, getInputMethodController: function () { console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") @@ -147,7 +141,24 @@ export function mockInputMethod() { console.warn("inputmethod.getInputMethodSetting interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return InputMethodSettingMock; - } + }, + getCurrentInputMethod: function () { + console.warn("inputmethod.getCurrentInputMethod interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return InputMethodProperty; + }, + switchInputMethod: function (...args) { + console.warn("inputMethod.switchInputMethod 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, } return inputMethod } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index 7024338b..d7722b82 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -15,36 +15,6 @@ import { paramMock } from "../utils" -const NOTIFY = "[PC Preview] unknow" -const Properties = [ - 'ENTER_KEY_TYPE_NEXT', - 'ENTER_KEY_TYPE_PREVIOUS', - 'ENTER_KEY_TYPE_UNSPECIFIED', - 'ENTER_KEY_TYPE_SEARCH', - 'ENTER_KEY_TYPE_GO', - 'ENTER_KEY_TYPE_SEND', - 'ENTER_KEY_TYPE_DONE', - 'DISPLAY_MODE_PART', - 'DISPLAY_MODE_FULL', - 'OPTION_AUTO_CAP_CHARACTERS', - 'OPTION_AUTO_CAP_WORDS', - 'OPTION_AUTO_CAP_SENTENCES', - 'OPTION_NO_FULLSCREEN', - 'OPTION_ASCII', - 'OPTION_NONE', - 'OPTION_MULTI_LINE', - 'FLAG_SINGLE_LINE', - 'FLAG_SELECTING', - 'PATTERN_TEXT', - 'PATTERN_NUMBER', - 'PATTERN_NULL', - 'PATTERN_PHONE', - 'PATTERN_DATETIME', - 'PATTERN_URI', - 'PATTERN_EMAIL', - 'PATTERN_PASSWORD' -] - export function mockInputMethodEngine() { const EditingText = { textContent: "[PC Preview] unknow textContent", @@ -65,6 +35,10 @@ export function mockInputMethodEngine() { enterKeyType: 2, inputOption: 3 } + const KeyEvent = { + keyCode: "[PC Preview] unknow keyCode", + keyAction: "[PC Preview] unknow keyAction" + } const RichContent = { contentURI: "[PC Preview] unknow contentURI", linkURI: "[PC Preview] unknow linkURI", @@ -376,7 +350,7 @@ export function mockInputMethodEngine() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] == 'keyDown' || args[0] == 'keyUp') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, KeyEvent); } else if (args[0] == 'selectionChange') { args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock); } else if (args[0] == 'cursorContextChange') { @@ -413,11 +387,33 @@ export function mockInputMethodEngine() { console.warn("inputMethodEngine.createKeyboardDelegate interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return KeyboardDelegateMock; - } - } - - for (let Property of Properties) { - inputMethodEngine[Property] = NOTIFY + " " + Property + }, + ENTER_KEY_TYPE_UNSPECIFIED: "[PC Preview] unknow ENTER_KEY_TYPE_UNSPECIFIED", + ENTER_KEY_TYPE_GO: "[PC Preview] unknow ENTER_KEY_TYPE_GO", + ENTER_KEY_TYPE_SEARCH: "[PC Preview] unknow ENTER_KEY_TYPE_SEARCH", + ENTER_KEY_TYPE_SEND: "[PC Preview] unknow ENTER_KEY_TYPE_SEND", + ENTER_KEY_TYPE_NEXT: "[PC Preview] unknow ENTER_KEY_TYPE_NEXT", + ENTER_KEY_TYPE_DONE: "[PC Preview] unknow ENTER_KEY_TYPE_DONE", + ENTER_KEY_TYPE_PREVIOUS: "[PC Preview] unknow ENTER_KEY_TYPE_PREVIOUS", + PATTERN_NULL: "[PC Preview] unknow PATTERN_NULL", + PATTERN_TEXT: "[PC Preview] unknow PATTERN_TEXT", + PATTERN_NUMBER: "[PC Preview] unknow PATTERN_NUMBER", + PATTERN_PHONE: "[PC Preview] unknow PATTERN_PHONE", + PATTERN_DATETIME: "[PC Preview] unknow PATTERN_DATETIME", + PATTERN_EMAIL: "[PC Preview] unknow PATTERN_EMAIL", + PATTERN_URI: "[PC Preview] unknow PATTERN_URI", + PATTERN_PASSWORD: "[PC Preview] unknow PATTERN_PASSWORD", + FLAG_SELECTING: "[PC Preview] unknow FLAG_SELECTING", + FLAG_SINGLE_LINE: "[PC Preview] unknow FLAG_SINGLE_LINE", + DISPLAY_MODE_PART: "[PC Preview] unknow DISPLAY_MODE_PART", + DISPLAY_MODE_FULL: "[PC Preview] unknow DISPLAY_MODE_FULL", + OPTION_ASCII: "[PC Preview] unknow OPTION_ASCII", + OPTION_NONE: "[PC Preview] unknow OPTION_NONE", + OPTION_AUTO_CAP_CHARACTERS: "[PC Preview] unknow OPTION_AUTO_CAP_CHARACTERS", + OPTION_AUTO_CAP_SENTENCES: "[PC Preview] unknow OPTION_AUTO_CAP_SENTENCES", + OPTION_AUTO_WORDS: "[PC Preview] unknow OPTION_AUTO_WORDS", + OPTION_MULTI_LINE: "[PC Preview] unknow OPTION_MULTI_LINE", + OPTION_NO_FULLSCREEN: "[PC Preview] unknow OPTION_NO_FULLSCREEN" } return inputMethodEngine } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_intl.js b/runtime/main/extend/systemplugin/napi/ohos_intl.js index 53b2bd68..69d80406 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_intl.js +++ b/runtime/main/extend/systemplugin/napi/ohos_intl.js @@ -168,6 +168,7 @@ export function mockIntl() { currencyDisplay: '[PC preview] unknow currencyDisplay', unit: '[PC preview] unknow unit', unitDisplay: '[PC preview] unknow unitDisplay', + unitUsage: '[PC preview] unknow unitUsage', signDisplay: '[PC preview] unknow signDisplay', compactDisplay: '[PC preview] unknow compactDisplay', notation: '[PC preview] unknow notation', @@ -199,10 +200,24 @@ export function mockIntl() { minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits', maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits', } - const RelativeTimeFormatResolvedOptionsMock = { + const RelativeTimeFormatResolvedOptions = { + locale: '[PC preview] unknow locale', + style: '[PC preview] unknow style', + numeric: '[PC preview] unknow numeric', + numberingSystem: '[PC preview] unknow numberingSystem', + } + const RelativeTimeFormatInputOptions = { localeMatcher: '[PC preview] unknow localeMatcher', numeric: '[PC preview] unknow numeric', style: '[PC preview] unknow style', } + const LocaleOptions = { + calendar: '[PC preview] unknow calendar', + collation: '[PC preview] unknow collation', + hourCycle: '[PC preview] unknow hourCycle', + numberingSystem: '[PC preview] unknow numberingSystem', + numeric: '[PC preview] unknow numeric', + caseFirst: '[PC preview] unknow caseFirst', + } return result; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js index 8de8a9c0..af10a417 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_audio.js @@ -792,6 +792,37 @@ export function mockMultimediaAudio() { SHARE_MODE: 0, INDEPENDENT_MODE: 1 }, + DeviceRole: { + INPUT_DEVICE: 1, + OUTPUT_DEVICE: 2 + }, + DeviceType: { + INVALID: 0, + EARPIECE: 1, + SPEAKER: 2, + WIRED_HEADSET: 3, + WIRED_HEADPHONES: 4, + BLUETOOTH_SCO: 7, + BLUETOOTH_A2DP: 8, + MIC: 15, + USB_HEADSET: 22 + }, + InterruptHint: { + INTERRUPT_HINT_NONE: 0, + INTERRUPT_HINT_RESUME: 1, + INTERRUPT_HINT_PAUSE: 2, + INTERRUPT_HINT_STOP: 3, + INTERRUPT_HINT_DUCK: 4, + INTERRUPT_HINT_UNDUCK: 5 + }, + InterruptActionType: { + TYPE_ACTIVATED: 0, + TYPE_INTERRUPT: 1 + }, + DeviceChangeType: { + CONNECT: 0, + DISCONNECT: 1 + }, getAudioManager: function () { console.warn("audio.getAudioManager interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js new file mode 100644 index 00000000..8cf529a9 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -0,0 +1,436 @@ +/* + * 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 mockMultimediaAVSession() { + const AVMetadata = { + assetId: "[PC Preview] unknow assetId", + title: "[PC Preview] unknow title", + artist: "[PC Preview] unknow artist", + author: "[PC Preview] unknow author", + album: "[PC Preview] unknow album", + writer: "[PC Preview] unknow writer", + composer: "[PC Preview] unknow composer", + duration: "[PC Preview] unknow duration", + mediaImage: "[PC Preview] unknow mediaImage", + publishDate: "[PC Preview] unknow publishDate", + subtitle: "[PC Preview] unknow subtitle", + description: "[PC Preview] unknow description", + lyric: "[PC Preview] unknow lyric", + previousAssetId: "[PC Preview] unknow previousAssetId", + nextAssetId: "[PC Preview] unknow nextAssetId" + } + + const AVPlaybackState = { + state: "[PC Preview] unknow state", + speed: "[PC Preview] unknow speed", + position: PlaybackPosition, + bufferedTime: "[PC Preview] unknow bufferedTime", + loopMode: "[PC Preview] unknow loopMode", + isFavorite: "[PC Preview] unknow isFavorite" + } + + const PlaybackPosition = { + elapsedTime: "[PC Preview] unknow elapsedTime", + updateTime: "[PC Preview] unknow updateTime" + } + + const OutputDeviceInfo = { + isRemote: "[PC Preview] unknow isRemote", + deviceId: [paramMock.paramStringMock], + deviceName: [paramMock.paramStringMock] + } + + const AVSessionDescriptor = { + sessionId: "[PC Preview] unknow sessionId", + type: "[PC Preview] unknow type", + sessionTag: "[PC Preview] unknow sessionTag", + elementName: "[PC Preview] unknow elementName", + isActive: "[PC Preview] unknow isActive", + isTopSession: "[PC Preview] unknow isTopSession", + outputDevice: + "[PC Preview] unknow outputDevice" + } + + const AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + + const AVSession = { + sessionId: "[PC Preview] unknow sessionId", + setAVMetadata: function (...args) { + console.warn("AVSession.setAVMetadata 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setAVPlaybackState: function (...args) { + console.warn("AVSession.setAVPlaybackState 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setLaunchAbility: function (...args) { + console.warn("AVSession.setLaunchAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + setAudioStreamId: function (...args) { + console.warn("AVSession.setAudioStreamId 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getController: function (...args) { + console.warn("AVSession.getController 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, AVSessionController); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionController); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSession.getOutputDevice 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, OutputDeviceInfo); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfo); + }) + } + }, + on: function (...args) { + console.warn("AVSession.on 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 (args[0] == 'play' || args[0] == 'pause' ||args[0] == 'stop' ||args[0] == 'playNext' + ||args[0] == 'playPrevious' ||args[0] == 'fastForward' ||args[0] == 'rewind') { + args[len - 1].call(this); + } else if(args[0] == 'seek' || args[0] == 'setSpeed') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if(args[0] == 'setLoopMode') { + var loopMode = "[PC Preview] unknow LoopMode"; + args[len - 1].call(this, loopMode); + } else if(args[0] == 'toggleFavorite') { + args[len - 1].call(this, paramMock.paramStringMock); + } else if(args[0] == 'handleKeyEvent') { + args[len - 1].call(this, paramMock.paramObjectMock); + } else if(args[0] == 'outputDeviceChanged') { + args[len - 1].call(this, OutputDeviceInfo); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + activate: function (...args) { + console.warn("AVSession.activate 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + deactivate: function (...args) { + console.warn("AVSession.deactivate 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + destroy: function (...args) { + console.warn("AVSession.destroy 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + } + + const AVSessionController = { + sessionId: "[PC Preview] unknow sessionId", + getAVPlaybackState: function (...args) { + console.warn("AVSessionController.getAVPlaybackState 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, AVPlaybackState); + } else { + return new Promise((resolve, reject) => { + resolve(AVPlaybackState); + }) + } + }, + getAVMetadata: function (...args) { + console.warn("AVSessionController.getAVMetadata 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, AVMetadata); + } else { + return new Promise((resolve, reject) => { + resolve(AVMetadata); + }) + } + }, + getOutputDevice: function (...args) { + console.warn("AVSessionController.getOutputDevice 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, OutputDeviceInfo); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfo); + }) + } + }, + sendAVKeyEvent: function (...args) { + console.warn("AVSessionController.sendAVKeyEvent 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getLaunchAbility: function (...args) { + console.warn("AVSessionController.getLaunchAbility 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.paramObjectMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramObjectMock); + }) + } + }, + getRealPlaybackPositionSync: function (...args) { + console.warn("AVSessionController.getRealPlaybackPositionSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isActive: function (...args) { + console.warn("AVSessionController.isActive 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + destroy: function (...args) { + console.warn("AVSessionController.destroy 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + getValidCommands: function (...args) { + console.warn("AVSessionController.getValidCommands 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, AVControlCommandType); + } else { + return new Promise((resolve, reject) => { + resolve(AVControlCommandType); + }) + } + }, + sendControlCommand: function (...args) { + console.warn("AVSessionController.sendControlCommand 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + on: function (...args) { + console.warn("AVSessionController.on 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 (args[0] == 'metadataChanged') { + args[len-1].call(this, AVMetadata); + } else if (args[0] == 'playbackStateChanged') { + args[len-1].call(this, AVPlaybackState); + } else if (args[0] == 'sessionDestroyed') { + args[len-1].call(this); + } else if (args[0] == 'activeStateChanged') { + args[len-1].call(this, paramMock.paramBooleanMock); + } else if (args[0] == 'validCommandChanged') { + args[len-1].call(this, AVControlCommandType); + } else if (args[0] == 'outputDeviceChanged') { + args[len-1].call(this, OutputDeviceInfo); + } + }, + off: function (...args) { + console.warn("AVSessionController.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } + } + + const avsession = { + createAVSession: function (...args) { + console.warn("AVSession.createAVSession 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, AVSession); + } else { + return new Promise((resolve, reject) => { + resolve(AVSession); + }) + } + + }, + getAllSessionDescriptors: function (...args) { + console.warn("AVSession.getAllSessionDescriptors 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 + var desArr = Array(AVSessionDescriptor); + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, desArr); + } else { + return new Promise((resolve, reject) => { + resolve(desArr); + }) + } + }, + createController: function (...args) { + console.warn("AVSession.createController 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, AVSessionController); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionController); + }) + } + }, + castAudio: function (...args) { + console.warn("AVSession.castAudio 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + on: function (...args) { + console.warn("AVSession.on 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 (args[0] == 'sessionCreated' || args[0] == 'sessionDestroyed' || args[0] == 'topSessionChanged') { + args[len - 1].call(this, AVSessionDescriptor); + } else if (args[0] == 'sessionServiceDied') { + args[len - 1].call(this); + } + }, + off: function (...args) { + console.warn("AVSession.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + sendSystemAVKeyEvent: function (...args) { + console.warn("AVSession.sendSystemAVKeyEvent 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + sendSystemControlCommand: function (...args) { + console.warn("AVSession.sendSystemControlCommand 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + } + return avsession +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js index 44a90354..1c906517 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js @@ -18,12 +18,10 @@ import { paramMock } from "../utils" export function mockMultimediaCamera() { const Camera = { cameraId: '[PC preview] unknow pid', - cameraPosition: '[PC preview] unknow cameraPosition', - cameraType: '[PC preview] unknow cameraType', - connectionType: '[PC preview] unknow connectionType' + cameraPosition: CameraPosition, + cameraType: CameraType, + connectionType: ConnectionType } - const FlashMode = '[PC preview] unknow flashMode' - const FocusMode = '[PC preview] unknow focusMode' const multimediaCameraMock = { getCameraManager: function (...args) { console.warn('camera.getCameraManager interface mocked in the Previewer. How this interface works on the' + @@ -62,7 +60,7 @@ export function mockMultimediaCamera() { } }, createPhotoOutput: function (...args) { - console.warn('camera.createPreviewOutput interface mocked in the Previewer. How this interface works on the' + + console.warn('camera.createPhotoOutput 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') { @@ -86,6 +84,16 @@ export function mockMultimediaCamera() { } }, } + const CameraStatus = { + CAMERA_STATUS_APPEAR: 0, + CAMERA_STATUS_DISAPPEAR: 1, + CAMERA_STATUS_AVAILABLE: 2, + CAMERA_STATUS_UNAVAILABLE: 3 + } + const CameraStatusInfo = { + camera: Camera, + status: CameraStatus + } const CameraManager = { getCameras: function (...args) { console.warn('CameraManager.getCameras interface mocked in the Previewer. How this interface works on the' + @@ -114,8 +122,58 @@ export function mockMultimediaCamera() { on: function (...args) { console.warn('CameraManager.on 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') { + if(args[0] == 'cameraStatus'){ + args[len - 1].call(this, paramMock.businessErrorMock, CameraStatusInfo); + } + } } } + const CameraPosition = { + CAMERA_POSITION_UNSPECIFIED: 0, + CAMERA_POSITION_BACK: 1, + CAMERA_POSITION_FRONT: 2 + } + const CameraType = { + CAMERA_TYPE_UNSPECIFIED: 0, + CAMERA_TYPE_WIDE_ANGLE: 1, + CAMERA_TYPE_ULTRA_WIDE: 2, + CAMERA_TYPE_TELEPHOTO: 3, + CAMERA_TYPE_TRUE_DEPTH: 4 + } + const ConnectionType = { + CAMERA_CONNECTION_BUILT_IN: 0, + CAMERA_CONNECTION_USB_PLUGIN: 1, + CAMERA_CONNECTION_REMOTE: 2 + } + const Size = { + height: '[PC preview] unknow height', + width: '[PC preview] unknow width' + } + const CameraInputErrorCode = { + ERROR_UNKNOWN: -1 + } + const CameraInputError = { + code: CameraInputErrorCode + } + const FlashMode = { + FLASH_MODE_CLOSE: 0, + FLASH_MODE_OPEN: 1, + FLASH_MODE_AUTO: 2, + FLASH_MODE_ALWAYS_OPEN: 3 + } + const FocusMode = { + FOCUS_MODE_MANUAL: 0, + FOCUS_MODE_CONTINUOUS_AUTO: 1, + FOCUS_MODE_AUTO: 2, + FOCUS_MODE_LOCKED: 3 + } + const FocusState = { + FOCUS_STATE_SCAN: 0, + FOCUS_STATE_FOCUSED: 1, + FOCUS_STATE_UNFOCUSED: 2 + } const CameraInput = { getCameraId: function (...args) { console.warn('CameraInput.getCameraId interface mocked in the Previewer. How this interface works on the' + @@ -226,7 +284,7 @@ export function mockMultimediaCamera() { } }, getZoomRatio: function (...args) { - console.warn('CameraInput.getZoomRatioRange interface mocked in the Previewer. How this interface works on the' + + console.warn('CameraInput.getZoomRatio 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') { @@ -264,8 +322,22 @@ export function mockMultimediaCamera() { on: function (...args) { console.warn('CameraInput.on 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') { + if(args[0] == 'focusStateChange'){ + args[len - 1].call(this, paramMock.businessErrorMock, FocusState); + } else if (args[0] == 'error') { + args[len - 1].call(this, paramMock.businessErrorMock, CameraInputError); + } + } } } + const CaptureSessionErrorCode = { + ERROR_UNKNOWN: -1 + } + const CaptureSessionError = { + code: CaptureSessionErrorCode + } const CaptureSession = { beginConfig: function (...args) { console.warn('CaptureSession.beginConfig interface mocked in the Previewer. How this interface works on the' + @@ -328,7 +400,7 @@ export function mockMultimediaCamera() { } }, removeOutput: function (...args) { - console.warn('CaptureSession.removeInput interface mocked in the Previewer. How this interface works on the' + + console.warn('CaptureSession.removeOutput 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') { @@ -378,8 +450,20 @@ export function mockMultimediaCamera() { on: function (...args) { console.warn('CaptureSession.on 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') { + if(args[0] == 'error'){ + args[len - 1].call(this, paramMock.businessErrorMock, CaptureSessionError); + } + } } } + const PreviewOutputErrorCode = { + ERROR_UNKNOWN: -1 + } + const PreviewOutputError = { + code: PreviewOutputErrorCode + } const PreviewOutput = { release: function (...args) { console.warn('PreviewOutput.release interface mocked in the Previewer. How this interface works on the' + @@ -394,10 +478,49 @@ export function mockMultimediaCamera() { } }, on: function (...args) { - console.warn('PreviewOutput.release interface mocked in the Previewer. How this interface works on the' + + console.warn('PreviewOutput.on 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') { + if(args[0] == 'frameStart'){ + args[len - 1].call(this, paramMock.businessErrorMock); + } else if (args[0] == 'frameEnd') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else if (args[0] == 'error') { + args[len - 1].call(this, paramMock.businessErrorMock, PreviewOutputError); + } + } }, } + const ImageRotation = { + ROTATION_0: 0, + ROTATION_90: 90, + ROTATION_180: 180, + ROTATION_270: 270 + } + const QualityLevel = { + QUALITY_LEVEL_HIGH: 0, + QUALITY_LEVEL_MEDIUM: 1, + QUALITY_LEVEL_LOW: 2 + } + const PhotoCaptureSetting = { + quality:QualityLevel, + rotation: ImageRotation + } + const FrameShutterInfo = { + captureId: '[PC preview] unknow captureId', + timestamp: '[PC preview] unknow timestamp' + } + const CaptureEndInfo = { + captureId: '[PC preview] unknow captureId', + frameCount: '[PC preview] unknow frameCount' + } + const PhotoOutputErrorCode = { + ERROR_UNKNOWN: -1 + } + const PhotoOutputError = { + code: PhotoOutputErrorCode + } const PhotoOutput = { capture: function (...args) { console.warn('PhotoOutput.capture interface mocked in the Previewer. How this interface works on the' + @@ -426,8 +549,26 @@ export function mockMultimediaCamera() { on: function (...args) { console.warn('PhotoOutput.on 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') { + if(args[0] == 'captureStart'){ + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else if (args[0] == 'frameShutter') { + args[len - 1].call(this, paramMock.businessErrorMock, FrameShutterInfo); + } else if (args[0] == 'captureEnd') { + args[len - 1].call(this, paramMock.businessErrorMock, CaptureEndInfo); + } else if (args[0] == 'error') { + args[len - 1].call(this, paramMock.businessErrorMock, PhotoOutputError); + } + } } } + const VideoOutputErrorCode = { + ERROR_UNKNOWN: -1 + } + const VideoOutputError = { + code: VideoOutputErrorCode + } const VideoOutput = { start: function (...args) { console.warn('VideoOutput.start interface mocked in the Previewer. How this interface works on the' + @@ -468,6 +609,16 @@ export function mockMultimediaCamera() { on: function (...args) { console.warn('VideoOutput.on 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') { + if(args[0] == 'frameStart'){ + args[len - 1].call(this, paramMock.businessErrorMock); + } else if (args[0] == 'frameEnd') { + args[len - 1].call(this, paramMock.businessErrorMock); + } else if (args[0] == 'error') { + args[len - 1].call(this, paramMock.businessErrorMock, VideoOutputError); + } + } } } return multimediaCameraMock diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_image.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_image.js index fda1ed75..e681f359 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_image.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_image.js @@ -95,6 +95,95 @@ export const PixelMapMock = { " may be different from that on a real device.") return paramMock.paramNumberMock }, + getDensity: function (...args) { + console.warn("PixelMap.getDensity interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock + }, + opacity: function (...args) { + console.warn("PixelMap.opacity 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(); + }) + } + }, + createAlphaPixelmap: function (...args) { + console.warn("PixelMap.createAlphaPixelmap 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,PixelMapMock); + } else { + return new Promise((resolve, reject) => { + resolve(PixelMapMock); + }) + } + }, + scale: function (...args) { + console.warn("PixelMap.scale 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(); + }) + } + }, + translate: function (...args) { + console.warn("PixelMap.translate 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(); + }) + } + }, + rotate: function (...args) { + console.warn("PixelMap.rotate 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(); + }) + } + }, + flip: function (...args) { + console.warn("PixelMap.flip 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(); + }) + } + }, + crop: function (...args) { + console.warn("PixelMap.flip 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(); + }) + } + }, release: function (...args) { console.warn("PixelMap.release interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -151,6 +240,11 @@ export function mockMultimediaImage() { alphaType: "[PC Preview] unknow alphaType", scaleMode: "[PC Preview] unknow scaleMode" } + const SourceOptionsMock = { + sourceDensity:"[PC Preview] unknow sourceDensity", + sourcePixelFormat:"[PC Preview] unknow sourcePixelFormat", + sourceSize:SizeMock + } const ImageSourceMock = { getImageInfo: function (...args) { @@ -201,17 +295,41 @@ export function mockMultimediaImage() { }) } }, - release: function (...args) { - console.warn("ImageSource.release 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(); - }) - } + modifyImageProperty: function (...args) { + console.warn("ImageSource.modifyImageProperty 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(); + }) + } + }, + updateData: function (...args) { + console.warn("ImageSource.updateData 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(); + }) + } + }, + release: function (...args) { + console.warn("ImageSource.release 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(); + }) + } }, supportedFormats: "[PC Preview] unknow supportedFormats" } @@ -299,8 +417,8 @@ export function mockMultimediaImage() { }) } }, - readLatestImage: function (...args) { - console.warn("ImageReceiver.readLatestImage interface mocked in the Previewer. How this interface works on the Previewer" + + readNextImage: function (...args) { + console.warn("ImageReceiver.readNextImage 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') { @@ -355,8 +473,8 @@ export function mockMultimediaImage() { UNPREMUL: 3, }, ScaleMode: { + FIT_TARGET_SIZE: 0, CENTER_CROP: 1, - FIT_TARGET_SIZE: 2, }, ComponentType: { YUV_Y: 1, @@ -381,6 +499,11 @@ export function mockMultimediaImage() { " on the Previewer may be different from that on a real device.") return ImageSourceMock; }, + CreateIncrementalSource: function () { + console.warn("image.CreateIncrementalSource interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return ImageSourceMock; + }, createImagePacker: function () { console.warn("image.createImagePacker interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js index e7ca398f..5517e7d7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js @@ -58,7 +58,9 @@ export function mockMultimediaMedia() { } }, src: '[PC Preview] unknow src', + fdSrc: AVFileDescriptor, loop: '[PC Preview] unknow loop', + audioInterruptMode: InterruptMode, currentTime: '[PC Preview] unknow currentTime', duration: '[PC Preview] unknow duration', state: '[PC Preview] unknow state', @@ -221,12 +223,15 @@ export function mockMultimediaMedia() { } const videoPlayerMock = { url: '[PC Preview] unknow url', + fdSrc: AVFileDescriptor, loop: '[PC Preview] unknow loop', currentTime: '[PC Preview] unknow currentTime', duration: '[PC Preview] unknow duration', state: '[PC Preview] unknow state', width: '[PC Preview] unknow width', height: '[PC Preview] unknow height', + audioInterruptMode: InterruptMode, + videoScaleType: mediaMock.VideoScaleType, setDisplaySurface: function (...args) { console.warn("VideoPlayer.setDisplaySurface interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -359,11 +364,28 @@ export function mockMultimediaMedia() { }); } }, + selectBitrate: function (...args) { + console.warn("VideoPlayer.selectBitrate 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.paramNumberMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }); + } + }, on: function (...args) { console.warn("VideoPlayer.on interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }, } + const AVFileDescriptorMock = { + fd: '[PC Preview] unknow fd', + offset: '[PC Preview] unknow audioChannels', + length: '[PC Preview] unknow audioCodec', + } const videoRecorderProfileMock = { audioBitrate: '[PC Preview] unknow audioBitrate', audioChannels: '[PC Preview] unknow audioChannels', @@ -385,9 +407,13 @@ export function mockMultimediaMedia() { location: locationMock, } const mediaDescriptionMock = { - key: '[PC Preview] unknow key', + "key": 'paramMock.paramObjectMock', } - const multimediaMediaMock = { + const InterruptModeMock = { + SHARE_MODE: 0, + INDEPENDENT_MODE: 1 + } + const mediaMock = { MediaErrorCode : { MSERR_OK: 0, MSERR_NO_MEMORY: 1, @@ -437,6 +463,10 @@ export function mockMultimediaMedia() { SPEED_FORWARD_1_75_X: 3, SPEED_FORWARD_2_00_X: 4, }, + VideoScaleType : { + VIDEO_SCALE_TYPE_FIT: 0, + VIDEO_SCALE_TYPE_FIT_CROP: 1, + }, ContainerFormatType : { CFT_MPEG_4: "mp4", CFT_MPEG_4A: "m4a", @@ -507,5 +537,5 @@ export function mockMultimediaMedia() { } }, } - return multimediaMediaMock; + return mediaMock; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_connection.js b/runtime/main/extend/systemplugin/napi/ohos_net_connection.js index a0ed0ba5..14ae9d87 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_connection.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_connection.js @@ -1,387 +1,288 @@ -/* - * 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 { paramMock } from "../utils" - -export function mockConnection() { - const NetAddress = "[PC Preview] unknow NetAddress" - const NetHandle = { - netId: "[PC Preview] unknow netId", - bindSocket: function () { - console.warn("NetHandle.bindSocket 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - openConnection: function () { - console.warn("NetHandle.openConnection 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, HttpRequest); - } else { - return new Promise((resolve, reject) => { - resolve(HttpRequest); - }) - } - }, - getAddressesByName: function () { - console.warn("NetHandle.getAddressesByName 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, NetAddress); - } else { - return new Promise((resolve, reject) => { - resolve(NetAddress); - }) - } - }, - getAddressByName: function () { - console.warn("NetHandle.getAddressByName 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, NetAddress); - } else { - return new Promise((resolve, reject) => { - resolve(NetAddress); - }) - } - }, - } - const NetBearType = "[PC Preview] unknow NetBearType" - const NetCapabilities = { - bearerTypes: function () { - console.warn("NetCapabilities.bearerTypes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - var netBearTypeArray = new Array(); - netBearTypeArray.push(NetBearType); - return netBearTypeArray; - } - } - const NetCap = "[PC Preview] unknow NetCap" - const ConnectionProperties = { - interfaceName: "[PC Preview] unknow interfaceName", - isUsePrivateDns: "[PC Preview] unknow isUsePrivateDns", - privateDnsServerName: "[PC Preview] unknow privateDnsServerName", - domains: "[PC Preview] unknow domains", - httpProxy: "[PC Preview] unknow httpProxy", - linkAddresses: function () { - console.warn("ConnectionProperties.linkAddresses interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - var LinkAddress = new Array(); - LinkAddress.push(NetBearType); - return LinkAddress; - }, - dnses: function () { - console.warn("ConnectionProperties.dnses interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - var NetAddress = new Array(); - NetAddress.push(NetBearType); - return NetAddress; - }, - routes: function () { - console.warn("ConnectionProperties.routes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - var RouteInfo = new Array(); - RouteInfo.push(NetBearType); - return RouteInfo; - }, - mtu: "[PC Preview] unknow mtu" - } - const HttpProxy = { - host: "[PC Preview] unknow host", - port: "[PC Preview] unknow port", - parsedExclusionList: "[PC Preview] unknow parsedExclusionList" - } - const blocked = "[PC Preview] unknow blocked" - const BackgroundPolicy = "[PC Preview] unknow BackgroundPolicy" - const connection = { - on: function (...args) { - console.warn("net.connection.on 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') { - if (args[0] === 'netAvailable') { - args[len - 1].call(this, paramMock.businessErrorMock, NetHandle); - } else if (args[0] === 'netBlockStatusChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { NetHandle, blocked }); - } else if (args[0] === 'netCapabilitiesChange') { - args[len - 1].call(this, { NetHandle, NetCap }); - } else if (args[0] === 'netConnectionPropertiesChange') { - args[len - 1].call(this, { NetHandle, ConnectionProperties }); - } else if (args[0] === 'netLosing') { - args[len - 1].call(this, { - NetHandle, - maxMsToLive: "[PC Preview] unknow maxMsToLive" - }); - } else if (args[0] === 'netLost') { - args[len - 1].call(this, paramMock.businessErrorMock, NetHandle); - } else if (args[0] === 'netUnavailable') { - args[len - 1].call(this, paramMock.businessErrorMock); - } - } - }, - off: function (...args) { - console.warn("net.connection.off 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') { - if (args[0] === 'netAvailable') { - args[len - 1].call(this, paramMock.businessErrorMock, NetHandle); - } else if (args[0] === 'netBlockStatusChange') { - args[len - 1].call(this, { NetHandle, blocked }); - } else if (args[0] === 'netCapabilitiesChange') { - args[len - 1].call(this, { NetHandle, NetCap }); - } else if (args[0] === 'netConnectionPropertiesChange') { - args[len - 1].call(this, { NetHandle, ConnectionProperties }); - } else if (args[0] === 'netLosing') { - args[len - 1].call(this, { - NetHandle, - maxMsToLive: "[PC Preview] unknow maxMsToLive" - }); - } else if (args[0] === 'netLost') { - args[len - 1].call(this, paramMock.businessErrorMock, NetHandle); - } else if (args[0] === 'netUnavailable') { - args[len - 1].call(this, paramMock.businessErrorMock); - } - } - }, - addNetStatusCallback: function (...args) { - console.warn("net.connection.addNetStatusCallback 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - removeNetStatusCallback: function (...args) { - console.warn("net.connection.removeNetStatusCallback 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - getAppNet: function (...args) { - console.warn("net.connection.getAppNet 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, NetHandle); - } else { - return new Promise((resolve, reject) => { - resolve(NetHandle); - }) - } - }, - setAppNet: function (...args) { - console.warn("net.connection.setAppNet 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - getDefaultNet: function (...args) { - console.warn("net.connection.getDefaultNet 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, NetHandle); - } else { - return new Promise((resolve, reject) => { - resolve(NetHandle); - }) - } - }, - getAllNets: function (...args) { - console.warn("net.connection.getAllNets 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, NetHandle); - } else { - return new Promise((resolve, reject) => { - resolve(NetHandle); - }) - } - }, - getDefaultHttpProxy: function (...args) { - console.warn("net.connection.getDefaultHttpProxy 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, HttpProxy); - } else { - return new Promise((resolve, reject) => { - resolve(HttpProxy); - }) - } - }, - getConnectionProperties: function (...args) { - console.warn("net.connection.getConnectionProperties 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, ConnectionProperties); - } else { - return new Promise((resolve, reject) => { - resolve(ConnectionProperties); - }) - } - }, - getNetCapabilities: function (...args) { - console.warn("net.connection.getNetCapabilities 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, NetCapabilities); - } else { - return new Promise((resolve, reject) => { - resolve(NetCapabilities); - }) - } - }, - getBackgroundPolicy: function (...args) { - console.warn("net.connection.getBackgroundPolicy 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, BackgroundPolicy); - } else { - return new Promise((resolve, reject) => { - resolve(BackgroundPolicy); - }) - } - }, - isDefaultNetMetered: function (...args) { - console.warn("net.connection.isDefaultNetMetered 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.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - hasDefaultNet: function (...args) { - console.warn("net.connection.hasDefaultNet 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.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - enableAirplaneMode: function (...args) { - console.warn("net.connection.enableAirplaneMode 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - disableAirplaneMode: function (...args) { - console.warn("net.connection.disableAirplaneMode 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - enableDistributedCellularData: function (...args) { - console.warn("net.connection.enableDistributedCellularData 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - disableDistributedCellularData: function (...args) { - console.warn("net.connection.disableDistributedCellularData 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - reportNetConnected: function (...args) { - console.warn("net.connection.reportNetConnected 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - reportNetDisconnected: function (...args) { - console.warn("net.connection.reportNetDisconnected 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - } - return connection -} +/* + * 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 + * + * 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 const NetCap = { + NET_CAPABILITY_MMS: 0, + NET_CAPABILITY_NOT_METERED: 11, + NET_CAPABILITY_INTERNET: 12, + NET_CAPABILITY_NOT_VPN: 15, + NET_CAPABILITY_VALIDATED: 16 +}; + +export const NetBearType = { + BEARER_CELLULAR: 0, + BEARER_WIFI: 1, + BEARER_ETHERNET: 3 +}; + +export function mockConnection() { + const NetSpecifier = { + netCapabilities: NetCapabilities, + bearerPrivateIdentifier: '[PC preview] unknow bearerPrivateIdentifier' + } + + const NetCapabilities = { + linkUpBandwidthKbps: '[PC preview] unknow linkUpBandwidthKbps', + linkDownBandwidthKbps: '[PC preview] unknow linkDownBandwidthKbps', + networkCap:[NetCap], + bearerTypes:[NetBearType] + } + + const ConnectionProperties = { + interfaceName: '[PC preview] unknow interfaceName', + domains: '[PC preview] unknow domains', + linkAddresses: [LinkAddress], + dnses: [NetAddress], + routes: [RouteInfo], + mtu: '[PC preview] unknow mtu' + } + + const LinkAddress = { + address: NetAddress, + prefixLength: '[PC preview] unknow prefixLength' + } + + const NetAddress = { + address: '[PC preview] unknow address', + family: '[PC preview] unknow family', + port: '[PC preview] unknow port' + } + + const RouteInfo = { + interface: '[PC preview] unknow interface', + destination: LinkAddress, + gateway: NetAddress, + hasGateway: '[PC preview] unknow hasGateway', + isDefaultRoute: '[PC preview] unknow isDefaultRoute' + } + + const NetConnection = { + on: function (...args) { + console.warn("NetConnection.on 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') { + if (args[0] === 'netAvailable') { + args[len - 1].call(this, NetHandle); + } else if (args[0] === 'netBlockStatusChange') { + var array = new Array(NetHandle, paramMock.paramBooleanMock); + args[len - 1].call(this, array); + } else if (args[0] === 'netCapabilitiesChange') { + var array = new Array(NetHandle, NetCapabilities); + args[len - 1].call(this, array); + } else if (args[0] === 'netConnectionPropertiesChange') { + var array = new Array(NetHandle, ConnectionProperties); + args[len - 1].call(this, array); + } else if (args[0] === 'netLost') { + args[len - 1].call(this, NetHandle); + } else if (args[0] === 'netUnavailable') { + args[len - 1].call(this); + } + } + }, + + register: function (...args) { + console.warn("NetConnection.register 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) + } + }, + + unregister: function (...args) { + console.warn("NetConnection.unregister 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) + } + } + } + + const NetHandle = { + netId: '[PC preview] unknow netId', + + getAddressesByName: function (...args) { + console.warn("NetHandle.getAddressesByName 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, [NetAddress]) + } else { + return new Promise((resolve, reject) => { + resolve([NetAddress]) + }) + } + }, + + getAddressByName: function (...args) { + console.warn("NetHandle.getAddressByName 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, NetAddress) + } else { + return new Promise((resolve, reject) => { + resolve(NetAddress) + }) + } + } + } + + const connection = { + NetCap, + NetBearType, + createNetConnection: function () { + console.warn("connection.createNetConnection interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return NetConnection; + }, + + getDefaultNet: function (...args) { + console.warn("connection.getDefaultNet 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, NetHandle) + } else { + return new Promise((resolve) => { + resolve(NetHandle) + }) + } + }, + + getAllNets: function (...args) { + console.warn("connection.getAllNets 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, [NetHandle]) + } else { + return new Promise((resolve) => { + resolve([NetHandle]) + }) + } + }, + + getConnectionProperties: function (...args) { + console.warn("connection.getConnectionProperties 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, ConnectionProperties) + } else { + return new Promise((resolve) => { + resolve(ConnectionProperties) + }) + } + }, + + getNetCapabilities: function (...args) { + console.warn("connection.getNetCapabilities 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, NetCapabilities) + } else { + return new Promise((resolve) => { + resolve(NetCapabilities) + }) + } + }, + + hasDefaultNet: function (...args) { + console.warn("connection.hasDefaultNet 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + + enableAirplaneMode: function (...args) { + console.warn("connection.enableAirplaneMode 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + disableAirplaneMode: function (...args) { + console.warn("connection.disableAirplaneMode 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + reportNetConnected: function (...args) { + console.warn("connection.reportNetConnected 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + reportNetDisconnected: function (...args) { + console.warn("connection.reportNetDisconnected 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + getAddressesByName: function (...args) { + console.warn("connection.getAddressesByName 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, [NetAddress]) + } else { + return new Promise((resolve) => { + resolve([NetAddress]) + }) + } + }, + }; + + return connection; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_http.js b/runtime/main/extend/systemplugin/napi/ohos_net_http.js index 18c21004..74c949c4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_http.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_http.js @@ -15,65 +15,72 @@ import { paramMock } from "../utils" +export const RequestMethod = { + OPTIONS: "OPTIONS", + GET: "GET", + HEAD: "HEAD", + POST: "POST", + PUT: "PUT", + DELETE: "DELETE", + TRACE: "TRACE", + CONNECT: "CONNECT" +}; + +export const ResponseCode = { + OK: 200, + CREATED: 201, + ACCEPTED: 202, + NOT_AUTHORITATIVE: 203, + NO_CONTENT: 204, + RESET: 205, + PARTIAL: 206, + MULT_CHOICE: 300, + MOVED_PERM: 301, + MOVED_TEMP: 302, + SEE_OTHER: 303, + NOT_MODIFIED: 304, + USE_PROXY: 305, + BAD_REQUEST: 400, + UNAUTHORIZED: 401, + PAYMENT_REQUIRED: 402, + FORBIDDEN: 403, + NOT_FOUND: 404, + BAD_METHOD: 405, + NOT_ACCEPTABLE: 406, + PROXY_AUTH: 407, + CLIENT_TIMEOUT: 408, + CONFLICT: 409, + GONE: 410, + LENGTH_REQUIRED: 411, + PRECON_FAILED: 412, + ENTITY_TOO_LARGE: 413, + REQ_TOO_LONG: 414, + UNSUPPORTED_TYPE: 415, + INTERNAL_ERROR: 500, + NOT_IMPLEMENTED: 501, + BAD_GATEWAY: 502, + UNAVAILABLE: 503, + GATEWAY_TIMEOUT: 504, + VERSION: 505 +}; + export function mockHttp() { - const HttpResponseCacheOptions = { - filePath: "[PC Preview] unknow filePath", - fileChildPath: "[PC Preview] unknow fileChildPath", - cacheSize: "[PC Preview] unknow cacheSize" - } - const HttpResponseCache = { - close: function (...args) { - console.warn("net.HttpResponseCache.close 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - delete: function (...args) { - console.warn("net.HttpResponseCache.delete 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - flush: function (...args) { - console.warn("net.HttpResponseCache.flush 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - } - } - const HttpResponseMock = { + const HttpResponse = { result: "[PC Preview] unknow result", - responseCode: "[PC Preview] unknow responseCode", - header: "[PC Preview] unknow header" + responseCode: ResponseCode, + header: "[PC Preview] unknow header", + cookies: "[PC Preview] unknow cookies" } - const HttpRequestMock = { + const HttpRequest = { request: function (...args) { console.warn("HttpRequest.request 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, HttpResponseMock); + args[len - 1].call(this, paramMock.businessErrorMock, HttpResponse); } else { return new Promise((resolve, reject) => { - resolve(HttpResponseMock); + resolve(HttpResponse); }) } }, @@ -86,7 +93,11 @@ export function mockHttp() { " 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.paramObjectMock); + if (args[0] === 'headerReceive') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock); + } else if (args[0] === 'headersReceive') { + args[len - 1].call(this, paramMock.paramObjectMock); + } } }, off: function (...args) { @@ -94,40 +105,40 @@ export function mockHttp() { " 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.paramObjectMock); + if (args[0] === 'headerReceive') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock); + } else if (args[0] === 'headersReceive') { + args[len - 1].call(this, paramMock.paramObjectMock); + } + } + }, + once: function (...args) { + console.warn("HttpRequest.once 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.paramObjectMock); } } } + + const HttpRequestOptions = { + method: RequestMethod, + extraData: "[PC Preview] unknow extraData", + header: "[PC Preview] unknow header", + readTimeout: "[PC Preview] unknow readTimeout", + connectTimeout: "[PC Preview] unknow connectTimeout" + } + const http = { + RequestMethod, + ResponseCode, createHttp: function () { console.warn("net.http.createHttp interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return HttpRequestMock; + return HttpRequest; }, - getInstalledHttpResponseCache: function (...args) { - console.warn("net.http.getInstalledHttpResponseCache 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, HttpResponseCache); - } else { - return new Promise((resolve, reject) => { - resolve(HttpResponseCache); - }) - } - }, - createHttpResponseCache: function (...args) { - console.warn("net.http.createHttpResponseCache 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, HttpResponseCacheOptions); - } else { - return new Promise((resolve, reject) => { - resolve(HttpResponseCache); - }) - } - } } - return http + + return http; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_socket.js b/runtime/main/extend/systemplugin/napi/ohos_net_socket.js index 446d1d78..c889c7e9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_socket.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_socket.js @@ -21,17 +21,20 @@ export function mockSocket() { isClose: "[PC Preview] unknow isClose", isConnected: "[PC Preview] unknow isConnected" } + const SocketRemoteInfo = { address: "[PC Preview] unknow address", family: "[PC Preview] unknow family", port: "[PC Preview] unknow port", size: "[PC Preview] unknow size" } + const NetAddress = { address: "[PC Preview] unknow saddressize", family: "[PC Preview] unknow family", port: "[PC Preview] unknow port " } + const UDPSocket = { bind: function (...args) { console.warn("UDPSocket.bind interface mocked in the Previewer. How this interface works on the Previewer" + @@ -99,12 +102,11 @@ export function mockSocket() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'message') { - args[len - 1].call(this, { - message: "[PC Preview] unknow message", - remoteInfo: SocketRemoteInfo - }); + args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo}); } else if (args[0] === 'listening') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this); + } else if (args[0] === 'close') { + args[len - 1].call(this); } else if (args[0] === 'error') { args[len - 1].call(this, paramMock.businessErrorMock); } @@ -116,12 +118,11 @@ export function mockSocket() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'message') { - args[len - 1].call(this, { - message: "[PC Preview] unknow message", - remoteInfo: SocketRemoteInfo - }); + args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo}); } else if (args[0] === 'listening') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this); + } else if (args[0] === 'close') { + args[len - 1].call(this); } else if (args[0] === 'error') { args[len - 1].call(this, paramMock.businessErrorMock); } @@ -220,12 +221,11 @@ export function mockSocket() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'message') { - args[len - 1].call(this, { - message: "[PC Preview] unknow message", - remoteInfo: SocketRemoteInfo - }); - } else if (args[0] === 'listening') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo}); + } else if (args[0] === 'connect') { + args[len - 1].call(this); + } else if (args[0] === 'close') { + args[len - 1].call(this); } else if (args[0] === 'error') { args[len - 1].call(this, paramMock.businessErrorMock); } @@ -237,18 +237,53 @@ export function mockSocket() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'message') { - args[len - 1].call(this, { - message: "[PC Preview] unknow message", - remoteInfo: SocketRemoteInfo - }); - } else if (args[0] === 'listening') { - args[len - 1].call(this, paramMock.businessErrorMock); + args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo}); + } else if (args[0] === 'connect') { + args[len - 1].call(this); + } else if (args[0] === 'close') { + args[len - 1].call(this); } else if (args[0] === 'error') { args[len - 1].call(this, paramMock.businessErrorMock); } } } } + + const UDPSendOptions = { + data: "[PC Preview] unknow data", + address: NetAddress + } + + const ExtraOptionsBase = { + receiveBufferSize: "[PC Preview] unknow receiveBufferSize", + sendBufferSize: "[PC Preview] unknow sendBufferSize", + reuseAddress: "[PC Preview] unknow reuseAddress", + socketTimeout: "[PC Preview] unknow socketTimeout" + } + + const UDPExtraOptions = { + broadcast: "[PC Preview] unknow broadcast" + } + + const TCPConnectOptions = { + address: NetAddress, + timeout: "[PC Preivew] unknow timeout", + } + + const TCPSendOptions = { + data: "[PC Preview] unknow data", + encoding: "[PC Preview] unknow encoding", + } + + const TCPExtraOptions = { + keepAlive: "[PC Preview] unknow keepAlive", + OOBInline: "[PC Preview] unknow OOBInline", + TCPNoDelay: "[PC Preview] unknow TCPNoDelay", + socketLinger: { + on: "[PC Preview] unknow on", + linger: "[PC Preview] unknow linger" + } + } const socket = { constructUDPSocketInstance: function () { console.warn("net.socket.constructUDPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" + @@ -261,5 +296,6 @@ export function mockSocket() { return TCPSocket; } } - return socket -} \ No newline at end of file + + return socket; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js b/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js index ec457c36..eb88c7dc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js @@ -16,7 +16,13 @@ import { paramMock } from "../utils" export function mockWebSocket() { - global.systemplugin.net = {} + const WebSocketRequestOptions = { + header: "[PC Preview] unknow header" + } + const WebSocketCloseOptions = { + code: "[PC Preview] unknow code", + reason: "[PC Preview] unknow reason" + } const WebSocketMock = { connect: function (...args) { console.warn("WebSocket.connect interface mocked in the Previewer. How this interface works on the Previewer" + @@ -101,4 +107,4 @@ export function mockWebSocket() { } } return webSocket -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_notification.js b/runtime/main/extend/systemplugin/napi/ohos_notification.js index 6aa55fb7..cab703c9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_notification.js +++ b/runtime/main/extend/systemplugin/napi/ohos_notification.js @@ -419,6 +419,9 @@ export function mockNotification() { }); } }, + SlotType, + ContentType, + SlotLevel, subscribe: function (...args) { console.warn('notification.subscribe interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -778,7 +781,13 @@ export function mockNotification() { resolve(paramMock.paramBooleanMock); }) } - } + }, + BundleOption, + NotificationKey, + DoNotDisturbType, + DoNotDisturbDate, + DeviceRemindType, + SourceType } return notification } diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index efedd4d0..bda091b4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.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 @@ -20,10 +20,160 @@ export function mockPasteBoard() { getPrimaryText: function () { console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow primarytext" + return paramMock.paramStringMock + }, + addHtmlRecord: function (...args) { + console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addWantRecord: function (...args) { + console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addRecord: function (...args) { + console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addTextRecord: function (...args) { + console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addUriRecord: function (...args) { + console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + getMimeTypes: function () { + console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + return new Array(paramMock.paramStringMock); + }, + getPrimaryHtml: function () { + console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + getPrimaryWant: function () { + console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getPrimaryWant" + }, + getPrimaryMimeType: function () { + console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + getPrimaryUri: function () { + console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + getProperty: function () { + console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return PasteDataPropertyMock; + }, + getRecordAt: function (...args) { + console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + getRecordCount: function () { + console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getTag: function () { + console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock + }, + hasMimeType: function (...args) { + console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + removeRecordAt: function (...args) { + console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + replaceRecordAt: function (...args) { + console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock } } + const PasteDataRecordMock = { + htmlText: '[PC preview] unknow htmlText', + want: '[PC preview] unknow want', + mimeType: '[PC preview] unknow mimeType', + plainText: '[PC preview] unknow plainText', + uri: '[PC preview] unknow uri', + convertToText: function (...args) { + console.warn("PasteDataRecord.convertToText 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.paramStringMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + } + } + const PasteDataPropertyMock = { + additions: '[PC preview] unknow additions', + mimeTypes: new Array('[PC preview] unknow MIMETYPE_TEXT_PLAIN'), + tag: '[PC preview] unknow tag', + timestamp: '[PC preview] unknow timestamp', + localOnly: '[PC preview] unknow localOnly', + } const SystemPasteboardMock = { + on: function (...args) { + console.warn("SystemPasteboard.on 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') { + if (args[0] == 'update') { + args[len - 1].call(this); + } + } + }, + off: function (...args) { + console.warn("SystemPasteboard.off 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') { + if (args[0] == 'update') { + args[len - 1].call(this); + } + } + }, + clear: function (...args) { + console.warn("SystemPasteboard.clear 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) + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + hasPasteData: function (...args) { + console.warn("SystemPasteboard.hasPasteData 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.paramBooleanMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, getPasteData: function (...args) { console.warn("SystemPasteboard.getPasteData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -50,11 +200,51 @@ export function mockPasteBoard() { } } const pasteboard = { - createPlainTextData: function () { + MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM', + MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML', + MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', + MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN', + MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI', + createPlainTextData: function (...args) { console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, + createHtmlData: function (...args) { + console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createUriData: function (...args) { + console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createWantData: function (...args) { + console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createHtmlTextRecord: function (...args) { + console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createWantRecord: function (...args) { + console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createUriRecord: function (...args) { + console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createPlainTextRecord: function (...args) { + console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, getSystemPasteboard: function () { console.warn("pasteboard.getSystemPasteboard interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_process.js b/runtime/main/extend/systemplugin/napi/ohos_process.js index 6438c629..f0bfa030 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_process.js +++ b/runtime/main/extend/systemplugin/napi/ohos_process.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockProcess() { - const result = { + const process = { runCmd: function (...args) { console.warn("process.runCmd interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -155,5 +155,5 @@ export function mockProcess() { " may be different from that on a real device.") } } - return result; + return process; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index f82bdcc6..32cfa49f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_request.js +++ b/runtime/main/extend/systemplugin/napi/ohos_request.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 @@ -13,38 +13,250 @@ * limitations under the License. */ -import { hasComplete } from "../utils" +import { paramMock } from "../utils" export function mockRequest() { - const uploadResponseMock = { - code: "[PC Preview]: unknow code", - data: "[PC Preview]: unknow data", - headers: "[PC Preview]: unknow headers" - } - const downloadResponse = { - token: "[PC Preview]: unknow token" - } - const onDownloadCompleteMock = { - uri: "[PC Preview]: unknow uri" - } + const DownloadConfig = { + url: "[PC Preview] unknow uri", + header: "[PC Preview] unknow header", + enableMetered: "[PC Preview] unknow enableMetered", + enableRoaming: "[PC Preview] unknow enableRoaming", + description: "[PC Preview] unknow description", + networkType: "[PC Preview] unknow networkType", + filePath: "[PC Preview] unknow filePath", + title: "[PC Preview] unknow title", + }; + + const DownloadInfo = { + description: "[PC Preview] unknow description", + downloadedBytes: "[PC Preview] unknow downloadedBytes", + downloadId: "[PC Preview] unknow downloadId", + failedReason: "[PC Preview] unknow failedReason", + fileName: "[PC Preview] unknow fileName", + filePath: "[PC Preview] unknow filePath", + pausedReason: "[PC Preview] unknow pausedReason", + status: "[PC Preview] unknow status", + targetURI: "[PC Preview] unknow targetURI", + downloadTitle: "[PC Preview] unknow downloadTitle", + downloadTotalBytes: "[PC Preview] unknow downloadTotalBytes", + }; + + const DownloadTask = { + on: function (...args) { + console.warn("downloadTask.on 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') { + if (args[0] == 'progress') { + const receivedSize = "[PC Preview] unknow receivedSize" + const totalSize = "[PC Preview] unknow totalSize" + args[len - 1].call(this, receivedSize, totalSize) + } else if (args[0] == 'complete' | 'pause' | 'remove') { + args[len - 1].call(this) + } else if (args[0] == 'fail') { + const err = "[PC Preview] unknow err" + args[len - 1].call(this, err) + } + } + }, + + off: function (...args) { + console.warn("downloadTask.off 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') { + if (args[0] == 'progress') { + const receivedSize = "[PC Preview] unknow receivedSize" + const totalSize = "[PC Preview] unknow totalSize" + args[len - 1].call(this, receivedSize, totalSize) + } else if (args[0] == 'complete' | 'pause' | 'remove') { + args[len - 1].call(this) + } else if (args[0] == 'fail') { + const err = "[PC Preview]: unknow err" + args[len - 1].call(this, err) + } + } + }, + + remove: function (...args) { + console.warn("downloadTask.remove 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + + pause: function (...args) { + console.warn("downloadTask.pause 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + resume: function (...args) { + console.warn("downloadTask.resume 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + query: function (...args) { + console.warn("downloadTask.query 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, downloadInfoMock) + } else { + return new Promise((resolve) => { + resolve(downloadInfoMock) + }) + } + }, + + queryMimeType: function (...args) { + console.warn("downloadTask.queryMimeType 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.paramStringMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }) + } + }, + }; + + const File = { + filename: "[PC Preview] unknow filename", + name: "[PC Preview] unknow name", + uri: "[PC Preview] unknow uri", + type: "[PC Preview] unknow type", + }; + + const RequestData = { + name: "[PC Preview] unknow name", + value: "[PC Preview] unknow value", + }; + + const UploadConfig = { + url: "[PC Preview] unknow uri", + header: "[PC Preview] unknow header", + method: "[PC Preview] unknow method", + files: [File], + data: [RequestData], + }; + + const UploadTask = { + on: function (...args) { + console.warn("uploadTask.on 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') { + if (args[0] == 'progress') { + const uploadedSize = "[PC Preview] unknow receivedSize" + const totalSize = "[PC Preview] unknow totalSize" + args[len - 1].call(this, uploadedSize, totalSize) + } else if (args[0] == 'headerReceive') { + const header = "[PC Preview] unknow header" + args[len - 1].call(this, header) + } + } + }, + + off: function (...args) { + console.warn("uploadTask.off 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') { + if (args[0] == 'progress') { + const uploadedSize = "[PC Preview] unknow receivedSize" + const totalSize = "[PC Preview] unknow totalSize" + args[len - 1].call(this, uploadedSize, totalSize) + } else if (args[0] == 'headerReceive') { + const header = "[PC Preview] unknow header" + args[len - 1].call(this, header) + } + } + }, + + remove: function (...args) { + console.warn("uploadTask.remove 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + }; + const request = { - upload: function (...args) { - console.warn("system.request.upload interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - args[0].success(uploadResponseMock) - hasComplete(args[0].complete) - }, + NETWORK_MOBILE: '[PC preview] unknow NETWORK_MOBILE', + NETWORK_WIFI: '[PC preview] unknow NETWORK_WIFI', + ERROR_CANNOT_RESUME: '[PC preview] unknow ERROR_CANNOT_RESUME', + ERROR_DEVICE_NOT_FOUND: '[PC preview] unknow ERROR_DEVICE_NOT_FOUND', + ERROR_FILE_ALREADY_EXISTS: '[PC preview] unknow ERROR_FILE_ALREADY_EXISTS', + ERROR_FILE_ERROR: '[PC preview] unknow ERROR_FILE_ERROR', + ERROR_HTTP_DATA_ERROR: '[PC preview] unknow ERROR_HTTP_DATA_ERROR', + ERROR_INSUFFICIENT_SPACE: '[PC preview] unknow ERROR_INSUFFICIENT_SPACE', + ERROR_TOO_MANY_REDIRECTS: '[PC preview] unknow ERROR_TOO_MANY_REDIRECTS', + ERROR_UNHANDLED_HTTP_CODE: '[PC preview] unknow ERROR_UNHANDLED_HTTP_CODE', + ERROR_UNKNOWN: '[PC preview] unknow ERROR_UNKNOWN', + PAUSED_QUEUED_FOR_WIFI: '[PC preview] unknow PAUSED_QUEUED_FOR_WIFI', + PAUSED_UNKNOWN: '[PC preview] unknow PAUSED_UNKNOWN', + PAUSED_WAITING_FOR_NETWORK: '[PC preview] unknow PAUSED_WAITING_FOR_NETWORK', + PAUSED_WAITING_TO_RETRY: '[PC preview] unknow PAUSED_WAITING_TO_RETRY', + SESSION_FAILED: '[PC preview] unknow SESSION_FAILED', + SESSION_PAUSED: '[PC preview] unknow SESSION_PAUSED', + SESSION_PENDING: '[PC preview] unknow SESSION_PENDING', + SESSION_RUNNING: '[PC preview] unknow SESSION_RUNNING', + SESSION_SUCCESSFUL: '[PC preview] unknow SESSION_SUCCESSFUL', + download: function (...args) { - console.warn("system.request.download interface mocked in the Previewer. How this interface works on the" + + console.warn("request.download interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - args[0].success(downloadResponse) - hasComplete(args[0].complete) + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, DownloadTask) + } else { + return new Promise((resolve) => { + resolve(DownloadTask); + }) + } }, - onDownloadComplete: function (...args) { - console.warn("system.request.onDownloadComplete interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - args[0].success(onDownloadCompleteMock) - hasComplete(args[0].complete) + + upload: function (...args) { + console.warn("request.upload 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, UploadTask) + } else { + return new Promise((resolve) => { + resolve(UploadTask) + }) + } } } return request diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 893f232c..2d3c9501 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -52,6 +52,45 @@ export function mockScreenLock() { resolve(); }) } + }, + on: function (...args) { + console.warn("screenLock.on 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') { + if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation') { + args[len - 1].call(this); + } else if (args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this, paramMock.paramNumberMock); + } else if (args[0] == 'screenlockEnabled') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + } + }, + off: function (...args) { + console.warn("screenLock.off 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') { + if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' + || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation' + || args[0] == 'screenlockEnabled' || args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { + args[len - 1].call(this); + } + } + }, + sendScreenLockEvent: function (...args) { + console.warn("screenLock.sendScreenLockEvent 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.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }) + } } } return screenLock diff --git a/runtime/main/extend/systemplugin/napi/ohos_security_huks.js b/runtime/main/extend/systemplugin/napi/ohos_security_huks.js old mode 100644 new mode 100755 index f6d9b1d0..eea719a7 --- a/runtime/main/extend/systemplugin/napi/ohos_security_huks.js +++ b/runtime/main/extend/systemplugin/napi/ohos_security_huks.js @@ -17,22 +17,22 @@ import { paramMock } from "../utils" export function mockHuks() { - const HuksParamMock = { - tag: '[PC preview] unknow tag', + const HuksParam = { + tag: huks.HuksTag, value: '[PC preview] unknow value', } - const HuksHandleMock = { + const HuksHandle = { errorCode: '[PC preview] unknow errorCode', handle: '[PC preview] unknow handle', - token: '[PC preview] unknow token', + token: paramMock.paramArrayMock, } - const HuksOptionsMock = { + const HuksOptions = { properties: [HuksParamMock], - inData: '[PC preview] unknow inData', + inData: paramMock.paramArrayMock, } - const HuksResultMock = { + const HuksResult = { errorCode: '[PC preview] unknow errorCode', - outData: '[PC preview] unknow outData', + outData: paramMock.paramArrayMock, properties: [HuksParamMock], certChains: [paramMock.paramStringMock], } diff --git a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js index 3189193f..3270c0a2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js +++ b/runtime/main/extend/systemplugin/napi/ohos_securitylabel.js @@ -29,6 +29,10 @@ export function mockSecurityLabel() { }) } }, + setSecurityLabelSync: function (...args) { + console.warn("securitylabel.setSecurityLabelSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, getSecurityLabel: function (...args) { console.warn("securitylabel.getSecurityLabel interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -41,6 +45,11 @@ export function mockSecurityLabel() { }) } }, + getSecurityLabelSync: function (...args) { + console.warn("securitylabel.getSecurityLabelSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, } return securitylabel; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index fddc787f..46cac30a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -19,12 +19,14 @@ export function mockSensor() { const AccelerometerResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + timestamp: '[PC preview] unknown timestamp' } const LinearAccelerometerResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + timestamp: '[PC preview] unknown timestamp' } const AccelerometerUncalibratedResponse = { x: '[PC preview] unknown x', @@ -32,28 +34,33 @@ export function mockSensor() { z: '[PC preview] unknown z', biasX: '[PC preview] unknown biasX', biasY: '[PC preview] unknown biasY', - biasZ: '[PC preview] unknown biasZ' + biasZ: '[PC preview] unknown biasZ', + timestamp: '[PC preview] unknown timestamp' } const GravityResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + timestamp: '[PC preview] unknown timestamp' } const OrientationResponse = { alpha: '[PC preview] unknown alpha', beta: '[PC preview] unknown beta', - gamma: '[PC preview] unknown gamma' + gamma: '[PC preview] unknown gamma', + timestamp: '[PC preview] unknown timestamp' } const RotationVectorResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', z: '[PC preview] unknown z', - w: '[PC preview] unknown w' + w: '[PC preview] unknown w', + timestamp: '[PC preview] unknown timestamp' } const GyroscopeResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + timestamp: '[PC preview] unknown timestamp' } const GyroscopeUncalibratedResponse = { x: '[PC preview] unknown x', @@ -61,24 +68,30 @@ export function mockSensor() { z: '[PC preview] unknown z', biasX: '[PC preview] unknown biasX', biasY: '[PC preview] unknown biasY', - biasZ: '[PC preview] unknown biasZ' + biasZ: '[PC preview] unknown biasZ', + timestamp: '[PC preview] unknown timestamp' } const SignificantMotionResponse = { - scalar: '[PC preview] unknown scalar' + scalar: '[PC preview] unknown scalar', + timestamp: '[PC preview] unknown timestamp' } const ProximityResponse = { - distance: '[PC preview] unknown distance' + distance: '[PC preview] unknown distance', + timestamp: '[PC preview] unknown timestamp' } const LightResponse = { - intensity: '[PC preview] unknown intensity' + intensity: '[PC preview] unknown intensity', + timestamp: '[PC preview] unknown timestamp' } const HallResponse = { - status: '[PC preview] unknown status' + status: '[PC preview] unknown status', + timestamp: '[PC preview] unknown timestamp' } const MagneticFieldResponse = { x: '[PC preview] unknown x', y: '[PC preview] unknown y', - z: '[PC preview] unknown z' + z: '[PC preview] unknown z', + timestamp: '[PC preview] unknown timestamp' } const MagneticFieldUncalibratedResponse = { x: '[PC preview] unknown x', @@ -86,28 +99,36 @@ export function mockSensor() { z: '[PC preview] unknown z', biasX: '[PC preview] unknown biasX', biasY: '[PC preview] unknown biasY', - biasZ: '[PC preview] unknown biasZ' + biasZ: '[PC preview] unknown biasZ', + timestamp: '[PC preview] unknown timestamp' } const PedometerResponse = { - steps: '[PC preview] unknown steps' + steps: '[PC preview] unknown steps', + timestamp: '[PC preview] unknown timestamp' } const HumidityResponse = { - humidity: '[PC preview] unknown humidity' + humidity: '[PC preview] unknown humidity', + timestamp: '[PC preview] unknown timestamp' } const PedometerDetectResponse = { - scalar: '[PC preview] unknown scalar' + scalar: '[PC preview] unknown scalar', + timestamp: '[PC preview] unknown timestamp' } const AmbientTemperatureResponse = { - temperature: '[PC preview] unknown temperature' + temperature: '[PC preview] unknown temperature', + timestamp: '[PC preview] unknown timestamp' } const BarometerResponse = { - pressure: '[PC preview] unknown pressure' + pressure: '[PC preview] unknown pressure', + timestamp: '[PC preview] unknown timestamp' } const HeartRateResponse = { - heartRate: '[PC preview] unknown heartRate' + heartRate: '[PC preview] unknown heartRate', + timestamp: '[PC preview] unknown timestamp' } const WearDetectionResponse = { - value: '[PC preview] unknown value' + value: '[PC preview] unknown value', + timestamp: '[PC preview] unknown timestamp' } const Options = { interval: '[PC preview] unknown value' @@ -122,10 +143,11 @@ export function mockSensor() { totalIntensity: '[PC preview] unknown totalIntensity' } const PedometerDetectionResponse = { - scalar: '[PC preview] unknown scalar' + scalar: '[PC preview] unknown scalar', + timestamp: '[PC preview] unknown timestamp' } const Response = { - timestamp: '[PC preview] unknown z' + timestamp: '[PC preview] unknown timestamp' } const LocationOptions = { latitude: '[PC preview] unknown latitude', @@ -162,6 +184,7 @@ export function mockSensor() { SENSOR_TYPE_ID_ORIENTATION: 256, SENSOR_TYPE_ID_GRAVITY: 257, SENSOR_TYPE_ID_LINEAR_ACCELERATION: 258, + SENSOR_TYPE_ID_LINEAR_ACCELEROMETER: 258, SENSOR_TYPE_ID_ROTATION_VECTOR: 259, SENSOR_TYPE_ID_AMBIENT_TEMPERATURE: 260, SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED: 261, @@ -170,11 +193,13 @@ export function mockSensor() { SENSOR_TYPE_ID_PEDOMETER_DETECTION: 265, SENSOR_TYPE_ID_PEDOMETER: 266, SENSOR_TYPE_ID_HEART_RATE: 278, + SENSOR_TYPE_ID_HEART_BEAT_RATE: 278, SENSOR_TYPE_ID_WEAR_DETECTION: 280, SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED: 281 } const sensor = { Sensor, + SensorType, on: function (...args) { console.warn('sensor.on interface mocked in the Previewer. How this interface works on the' + 'Previewer may be different from that on a real device.') diff --git a/runtime/main/extend/systemplugin/napi/ohos_settings.js b/runtime/main/extend/systemplugin/napi/ohos_settings.js index 72d3a7b2..4ae14fbe 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_settings.js +++ b/runtime/main/extend/systemplugin/napi/ohos_settings.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 @@ -16,22 +16,182 @@ import { paramMock } from "../utils" export function mockSettings() { - const settingsMock = { - getUri: function (...args) { - console.warn("settings.getUri interface mocked in the Previewer. How this interface works on the" + + const date = { + DATE_FORMAT: "[PC Preview] unknow DATE_FORMAT", + TIME_FORMAT: "[PC Preview] unknow TIME_FORMAT", + AUTO_GAIN_TIME: "[PC Preview] unknow AUTO_GAIN_TIME", + AUTO_GAIN_TIME_ZONE: "[PC Preview] unknow AUTO_GAIN_TIME_ZONE", + }; + const display = { + FONT_SCALE: "[PC Preview] unknow FONT_SCALE", + SCREEN_BRIGHTNESS_STATUS: "[PC Preview] unknow SCREEN_BRIGHTNESS_STATUS", + AUTO_SCREEN_BRIGHTNESS: "[PC Preview] unknow AUTO_SCREEN_BRIGHTNESS", + AUTO_SCREEN_BRIGHTNESS_MODE: "[PC Preview] unknow AUTO_SCREEN_BRIGHTNESS_MODE", + MANUAL_SCREEN_BRIGHTNESS_MODE: "[PC Preview] unknow MANUAL_SCREEN_BRIGHTNESS_MODE", + SCREEN_OFF_TIMEOUT: "[PC Preview] unknow SCREEN_OFF_TIMEOUT", + DEFAULT_SCREEN_ROTATION: "[PC Preview] unknow DEFAULT_SCREEN_ROTATION", + ANIMATOR_DURATION_SCALE: "[PC Preview] unknow ANIMATOR_DURATION_SCALE", + TRANSITION_ANIMATION_SCALE: "[PC Preview] unknow TRANSITION_ANIMATION_SCALE", + WINDOW_ANIMATION_SCALE: "[PC Preview] unknow WINDOW_ANIMATION_SCALE", + DISPLAY_INVERSION_STATUS: "[PC Preview] unknow DISPLAY_INVERSION_STATUS", + }; + const general = { + SETUP_WIZARD_FINISHED: "[PC Preview] unknow SETUP_WIZARD_FINISHED", + END_BUTTON_ACTION: "[PC Preview] unknow END_BUTTON_ACTION", + ACCELEROMETER_ROTATION_STATUS: "[PC Preview] unknow ACCELEROMETER_ROTATION_STATUS", + AIRPLANE_MODE_STATUS: "[PC Preview] unknow AIRPLANE_MODE_STATUS", + DEVICE_PROVISION_STATUS: "[PC Preview] unknow DEVICE_PROVISION_STATUS", + HDC_STATUS: "[PC Preview] unknow HDC_STATUS", + BOOT_COUNTING: "[PC Preview] unknow BOOT_COUNTING", + CONTACT_METADATA_SYNC_STATUS: "[PC Preview] unknow CONTACT_METADATA_SYNC_STATUS", + DEVELOPMENT_SETTINGS_STATUS: "[PC Preview] unknow DEVELOPMENT_SETTINGS_STATUS", + DEVICE_NAME: "[PC Preview] unknow DEVICE_NAME", + USB_STORAGE_STATUS: "[PC Preview] unknow USB_STORAGE_STATUS", + DEBUGGER_WAITING: "[PC Preview] unknow DEBUGGER_WAITING", + DEBUG_APP_PACKAGE: "[PC Preview] unknow DEBUG_APP_PACKAGE", + ACCESSIBILITY_STATUS: "[PC Preview] unknow ACCESSIBILITY_STATUS", + ACTIVATED_ACCESSIBILITY_SERVICES: "[PC Preview] unknow ACTIVATED_ACCESSIBILITY_SERVICES", + GEOLOCATION_ORIGINS_ALLOWED: "[PC Preview] unknow GEOLOCATION_ORIGINS_ALLOWED", + SKIP_USE_HINTS: "[PC Preview] unknow SKIP_USE_HINTS", + TOUCH_EXPLORATION_STATUS: "[PC Preview] unknow TOUCH_EXPLORATION_STATUS", + }; + const input = { + DEFAULT_INPUT_METHOD: "[PC Preview] unknow DEFAULT_INPUT_METHOD", + ACTIVATED_INPUT_METHOD_SUB_MODE: "[PC Preview] unknow ACTIVATED_INPUT_METHOD_SUB_MODE", + ACTIVATED_INPUT_METHODS: "[PC Preview] unknow ACTIVATED_INPUT_METHODS", + SELECTOR_VISIBILITY_FOR_INPUT_METHOD: "[PC Preview] unknow SELECTOR_VISIBILITY_FOR_INPUT_METHOD", + AUTO_CAPS_TEXT_INPUT: "[PC Preview] unknow AUTO_CAPS_TEXT_INPUT", + AUTO_PUNCTUATE_TEXT_INPUT: "[PC Preview] unknow AUTO_PUNCTUATE_TEXT_INPUT", + AUTO_REPLACE_TEXT_INPUT: "[PC Preview] unknow AUTO_REPLACE_TEXT_INPUT", + SHOW_PASSWORD_TEXT_INPUT: "[PC Preview] unknow SHOW_PASSWORD_TEXT_INPUT", + }; + const network = { + DATA_ROAMING_STATUS: "[PC Preview] unknow DATA_ROAMING_STATUS", + HTTP_PROXY_CFG: "[PC Preview] unknow HTTP_PROXY_CFG", + NETWORK_PREFERENCE_USAGE: "[PC Preview] unknow NETWORK_PREFERENCE_USAGE", + }; + const phone = { + RTT_CALLING_STATUS: "[PC Preview] unknow RTT_CALLING_STATUS", + }; + const sound = { + VIBRATE_WHILE_RINGING: "[PC Preview] unknow VIBRATE_WHILE_RINGING", + DEFAULT_ALARM_ALERT: "[PC Preview] unknow DEFAULT_ALARM_ALERT", + DTMF_TONE_TYPE_WHILE_DIALING: "[PC Preview] unknow DTMF_TONE_TYPE_WHILE_DIALING", + DTMF_TONE_WHILE_DIALING: "[PC Preview] unknow DTMF_TONE_WHILE_DIALING", + AFFECTED_MODE_RINGER_STREAMS: "[PC Preview] unknow AFFECTED_MODE_RINGER_STREAMS", + AFFECTED_MUTE_STREAMS: "[PC Preview] unknow AFFECTED_MUTE_STREAMS", + DEFAULT_NOTIFICATION_SOUND: "[PC Preview] unknow DEFAULT_NOTIFICATION_SOUND", + DEFAULT_RINGTONE: "[PC Preview] unknow DEFAULT_RINGTONE", + SOUND_EFFECTS_STATUS: "[PC Preview] unknow SOUND_EFFECTS_STATUS", + VIBRATE_STATUS: "[PC Preview] unknow VIBRATE_STATUS", + HAPTIC_FEEDBACK_STATUS: "[PC Preview] unknow HAPTIC_FEEDBACK_STATUS", + }; + const TTS = { + DEFAULT_TTS_PITCH: "[PC Preview] unknow DEFAULT_TTS_PITCH", + DEFAULT_TTS_RATE: "[PC Preview] unknow DEFAULT_TTS_RATE", + DEFAULT_TTS_SYNTH: "[PC Preview] unknow DEFAULT_TTS_SYNTH", + ENABLED_TTS_PLUGINS: "[PC Preview] unknow ENABLED_TTS_PLUGINS", + }; + const wireless = { + BLUETOOTH_DISCOVER_ABILITY_STATUS: "[PC Preview] unknow DEFAULT_TTBLUETOOTH_DISCOVER_ABILITY_STATUSS_PITCH", + BLUETOOTH_DISCOVER_TIMEOUT: "[PC Preview] unknow BLUETOOTH_DISCOVER_TIMEOUT", + AIRPLANE_MODE_RADIOS: "[PC Preview] unknow AIRPLANE_MODE_RADIOS", + BLUETOOTH_STATUS: "[PC Preview] unknow BLUETOOTH_STATUS", + BLUETOOTH_RADIO: "[PC Preview] unknow BLUETOOTH_RADIO", + CELL_RADIO: "[PC Preview] unknow CELL_RADIO", + NFC_RADIO: "[PC Preview] unknow NFC_RADIO", + WIFI_RADIO: "[PC Preview] unknow WIFI_RADIO", + OWNER_LOCKDOWN_WIFI_CFG: "[PC Preview] unknow OWNER_LOCKDOWN_WIFI_CFG", + WIFI_DHCP_MAX_RETRY_COUNT: "[PC Preview] unknow WIFI_DHCP_MAX_RETRY_COUNT", + WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT: "[PC Preview] unknow WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT", + WIFI_STATUS: "[PC Preview] unknow WIFI_STATUS", + WIFI_WATCHDOG_STATUS: "[PC Preview] unknow WIFI_WATCHDOG_STATUS", + }; + const settings = { + date, + display, + general, + input, + network, + phone, + sound, + TTS, + wireless, + getURI: function (...args) { + console.warn("settings.getURI interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); - return paramMock.paramStringMock; + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramObjectMock) + }) + } }, getValue: function (...args) { console.warn("settings.getValue interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); - return paramMock.paramStringMock; + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramObjectMock) + }) + } }, setValue: function (...args) { console.warn("settings.setValue interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); - return paramMock.paramBooleanMock; + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + enableAirplaneMode: function (...args) { + console.warn("settings.enableAirplaneMode 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + canShowFloating: function (...args) { + console.warn("settings.canShowFloating 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + getUriSync: function (...args) { + console.warn("settings.getUriSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + return paramMock.paramStringMock + }, + getValueSync: function (...args) { + console.warn("settings.getValueSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + return paramMock.paramStringMock + }, + setValueSync: function (...args) { + console.warn("settings.getValueSync interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + return paramMock.paramBooleanMock }, }; - return settingsMock; + return settings; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index c954be1e..4f4c7511 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -16,13 +16,22 @@ import { paramMock } from '../utils'; export function mockStorageStatistics() { - const BundleStatsMock = { + const BundleStats = { appSize: '[PC preview] unknow appSize', cacheSize: '[PC preview] unknow cacheSize', dataSize: '[PC preview] unknow dataSize' }; + const StorageStats= { + total: '[PC preview] unknow total', + audio: '[PC preview] unknow audio', + video: '[PC preview] unknow video', + image: '[PC preview] unknow image', + file: '[PC preview] unknow file', + app: '[PC preview] unknow app' + } const storageStatistics = { - BundleStats: BundleStatsMock, + BundleStats: BundleStats, + StorageStats: StorageStats, getTotalSizeOfVolume: function(...args) { console.warn('storageStatistics.getTotalSizeOfVolume interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -58,6 +67,66 @@ export function mockStorageStatistics() { resolve(BundleStatsMock); }); } + }, + getCurrentBundleStats: function(...args) { + console.warn('storageStatistics.getCurrentBundleStats 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, BundleStats); + } else { + return new Promise((resolve, reject) => { + resolve(BundleStats); + }); + } + }, + getSystemSize: function(...args) { + console.warn('storageStatistics.getSystemSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getUserStorageStats: function(...args) { + console.warn('storageStatistics.getUserStorageStats 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, StorageStats); + } else { + return new Promise((resolve, reject) => { + resolve(StorageStats); + }); + } + }, + getTotalSize: function(...args) { + console.warn('storageStatistics.getTotalSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + getFreeSize: function(...args) { + console.warn('storageStatistics.getFreeSize 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, reject) => { + resolve(paramMock.paramNumberMock); + }); + } } }; return storageStatistics; diff --git a/runtime/main/extend/systemplugin/napi/ohos_systemTimer.js b/runtime/main/extend/systemplugin/napi/ohos_systemTimer.js index ce16e5a0..0eeefe7b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_systemTimer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_systemTimer.js @@ -1,74 +1,82 @@ -/* - * 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 { paramMock } from "../utils" - -export function mockSystemTimer() { - const systemTimer = { - TIMER_TYPE_REALTIME: '[PC preview] unknow TIMER_TYPE_REALTIME', - TIMER_TYPE_WAKEUP: '[PC preview] unknow TIMER_TYPE_WAKEUP', - TIMER_TYPE_EXACT: '[PC preview] unknow TIMER_TYPE_EXACT', - TIMER_TYPE_IDLE: '[PC preview] unknow TIMER_TYPE_IDLE', - createTimer: function (...args) { - console.warn("systemTimer.createTimer 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - startTimer: function (...args) { - console.warn("systemTimer.startTimer 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) - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - stopTimer: function (...args) { - console.warn("systemTimer.stopTimer 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) - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - destroyTimer: function (...args) { - console.warn("systemTimer.destroyTimer 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) - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - } - } - return systemTimer -} \ No newline at end of file +/* + * 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 + * + * 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" +import { WantAgent } from "./ohos_wantAgent" + +export function mockSystemTimer() { + const systemTimer = { + TIMER_TYPE_REALTIME: '[PC preview] unknow TIMER_TYPE_REALTIME', + TIMER_TYPE_WAKEUP: '[PC preview] unknow TIMER_TYPE_WAKEUP', + TIMER_TYPE_EXACT: '[PC preview] unknow TIMER_TYPE_EXACT', + TIMER_TYPE_IDLE: '[PC preview] unknow TIMER_TYPE_IDLE', + createTimer: function (...args) { + console.warn("systemTimer.createTimer 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + startTimer: function (...args) { + console.warn("systemTimer.startTimer 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) + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + stopTimer: function (...args) { + console.warn("systemTimer.stopTimer 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) + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + destroyTimer: function (...args) { + console.warn("systemTimer.destroyTimer 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) + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } + } + const TimerOptions = { + type: '[PC Preview] unknown type', + repeat: '[PC Preview] unknown repeat', + interval: '[PC Preview] unknown interval', + wantAgent: WantAgent, + callback:'[PC Preview] unknown interval' + } + return systemTimer +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js index 64ef7ab0..e9f0a908 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js @@ -14,27 +14,194 @@ */ import { paramMock } from "../utils" - +export const ImsCallMode = { + CALL_MODE_AUDIO_ONLY: 0, + CALL_MODE_SEND_ONLY: 1, + CALL_MODE_RECEIVE_ONLY: 2, + CALL_MODE_SEND_RECEIVE: 3, + CALL_MODE_VIDEO_PAUSED: 4, +} +export const AudioDevice = { + DEVICE_MIC: "[PC Preview] unknow DEVICE_MIC", + DEVICE_SPEAKER: "[PC Preview] unknow DEVICE_SPEAKER", + DEVICE_WIRED_HEADSET: "[PC Preview] unknow DEVICE_WIRED_HEADSET", + DEVICE_BLUETOOTH_SCO: "[PC Preview] unknow DEVICE_BLUETOOTH_SCO", +} +export const CallRestrictionType = { + RESTRICTION_TYPE_ALL_INCOMING: 0, + RESTRICTION_TYPE_ALL_OUTGOING: 1, + RESTRICTION_TYPE_INTERNATIONAL: 2, + RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME: 3, + RESTRICTION_TYPE_ROAMING_INCOMING: 4, + RESTRICTION_TYPE_ALL_CALLS: 5, + RESTRICTION_TYPE_OUTGOING_SERVICES: 6, + RESTRICTION_TYPE_INCOMING_SERVICES: 7, +} +export const CallTransferInfo = { + transferNum: "[PC Preview] unknow transferNum", + type: CallTransferType, + settingType: CallTransferSettingType, +} +export const CallTransferSettingType = { + CALL_TRANSFER_DISABLE: 0, + CALL_TRANSFER_ENABLE: 1, + CALL_TRANSFER_REGISTRATION: 3, + CALL_TRANSFER_ERASURE: 4, +} +export const CallTransferType = { + TRANSFER_TYPE_UNCONDITIONAL: 0, + TRANSFER_TYPE_BUSY: 1, + TRANSFER_TYPE_NO_REPLY: 2, + TRANSFER_TYPE_NOT_REACHABLE: 3, +} +export const ConferenceState = { + TEL_CONFERENCE_IDLE: 0, + TEL_CONFERENCE_ACTIVE: 1, + TEL_CONFERENCE_DISCONNECTING: 2, + TEL_CONFERENCE_DISCONNECTED: 3, +}; +export const CallType = { + TYPE_CS: 0, + TYPE_IMS: 1, + TYPE_OTT: 2, + TYPE_ERR_CALL: 3, +} +export const VideoStateType = { + TYPE_VOICE: 0, + TYPE_VIDEO: 1, +} +export const DetailedCallState = { + CALL_STATUS_ACTIVE: 0, + CALL_STATUS_HOLDING: 1, + CALL_STATUS_DIALING: 2, + CALL_STATUS_ALERTING: 3, + CALL_STATUS_INCOMING: 4, + CALL_STATUS_WAITING: 5, + CALL_STATUS_DISCONNECTED: 6, + CALL_STATUS_DISCONNECTING: 7, + CALL_STATUS_IDLE: 8, +} +export const CallState = { + CALL_STATE_UNKNOWN: -1, + CALL_STATE_IDLE: 0, + CALL_STATE_RINGING: 1, + CALL_STATE_OFFHOOK: 2, +} +export const CallRestrictionInfo = { + type: CallRestrictionType, + password: "[PC Preview] unknow password", + mode: CallRestrictionMode, +} +export const DialOptions = { + extras: "[PC Preview] unknow extras", + accountId: "[PC Preview] unknow accountId", + videoState: VideoStateType, + dialScene: DialScene, + dialType: DialType, +} +export const DialScene = { + CALL_NORMAL: 0, + CALL_PRIVILEGED: 1, + CALL_EMERGENCY: 2, +} +export const DialType = { + DIAL_CARRIER_TYPE: 0, + DIAL_VOICE_MAIL_TYPE: 1, + DIAL_OTT_TYPE: 2, +} +export const CallRestrictionMode = { + RESTRICTION_MODE_DEACTIVATION: 0, + RESTRICTION_MODE_ACTIVATION: 1, +} +export const CallEventOptions = { + eventId: CallAbilityEventId +} +export const NumberFormatOptions = { + countryCode: "[PC Preview] unknow countryCode" +} +export const CallAbilityEventId = { + EVENT_DIAL_NO_CARRIER: 1, + EVENT_INVALID_FDN_NUMBER: 2, +} +export const RejectMessageOptions = { + messageContent: "[PC Preview] unknow messageContent" +} +export const CallWaitingStatus = { + CALL_WAITING_DISABLE: 0, + CALL_WAITING_ENABLE: 1, +}; +export const RestrictionStatus = { + RESTRICTION_DISABLE: 0, + RESTRICTION_ENABLE: 1, +}; +export const TransferStatus = { + TRANSFER_DISABLE: 0, + TRANSFER_ENABLE: 1, +}; +export const CallAttributeOptions = { + accountNumber: "[PC Preview] unknow accountNumber", + speakerphoneOn: "[PC Preview] unknow speakerphoneOn", + accountId: "[PC Preview] unknow accountId", + videoState: VideoStateType, + startTime: "[PC Preview] unknow startTime", + isEcc: "[PC Preview] unknow isEcc", + callType: CallType, + callId: "[PC Preview] unknow callId", + callState: DetailedCallState, + conferenceState: ConferenceState, + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", +} +export const EmergencyNumberOptions = { + slotId: "[PC Preview] unknow slotId" +} +export const CallTransferResult = { + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", +} +export const DisconnectedDetails = { + UNASSIGNED_NUMBER: 1, + NO_ROUTE_TO_DESTINATION: 3, + CHANNEL_UNACCEPTABLE: 6, + OPERATOR_DETERMINED_BARRING: 8, + NORMAL_CALL_CLEARING: 16, + USER_BUSY: 17, + NO_USER_RESPONDING: 18, + USER_ALERTING_NO_ANSWER: 19, + CALL_REJECTED: 21, + NUMBER_CHANGED: 22, + DESTINATION_OUT_OF_ORDER: 27, + INVALID_NUMBER_FORMAT: 28, + NETWORK_OUT_OF_ORDER: 38, + TEMPORARY_FAILURE: 41, + INVALID_PARAMETER: 1025, + SIM_NOT_EXIT: 1026, + SIM_PIN_NEED: 1027, + CALL_NOT_ALLOW: 1029, + SIM_INVALID: 1045, + UNKNOWN: 1279, +}; export function mockCall() { - const CallWaitingStatus = "[PC Preview] unknow CallWaitingStatus"; - const RestrictionStatus = "[PC Preview] unknow RestrictionStatus"; - const CallAttributeOptions = { - accountNumber: "[PC Preview] unknow accountNumber", - speakerphoneOn: "[PC Preview] unknow speakerphoneOn", - accountId: "[PC Preview] unknow accountId", - videoState: "[PC Preview] unknow videoState", - startTime: "[PC Preview] unknow startTime", - isEcc: "[PC Preview] unknow isEcc", - callType: "[PC Preview] unknow callType", - callId: "[PC Preview] unknow callId", - callState: "[PC Preview] unknow callState", - conferenceState: "[PC Preview] unknow conferenceState" - } - const CallTransferResult = { - status: "[PC Preview] unknow status", - number: "[PC Preview] unknow number", - } const call = { + ImsCallMode, + AudioDevice, + CallRestrictionType, + TransferStatus, + CallTransferSettingType, + CallWaitingStatus, + CallTransferType, + ConferenceState, + DisconnectedDetails, + CallAbilityEventId, + CallType, + VideoStateType, + DetailedCallState, + CallState, + DialScene, + RestrictionStatus, + CallTransferResult, + DialType, + CallRestrictionMode, dial: function (...args) { console.warn("telephony.call.dial interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -420,7 +587,9 @@ export function mockCall() { if (args[0] == 'callDetailsChange') { args[len - 1].call(this, CallAttributeOptions); } else if (args[0] == 'callEventChange') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, CallEventOptions); + } else if (args[0] == 'callDisconnectedCause') { + args[len - 1].call(this, DisconnectedDetails); } } }, @@ -432,10 +601,72 @@ export function mockCall() { if (args[0] == 'callDetailsChange') { args[len - 1].call(this, CallAttributeOptions); } else if (args[0] == 'callEventChange') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, CallEventOptions); + } else if (args[0] == 'callDisconnectedCause') { + args[len - 1].call(this, DisconnectedDetails); } } }, + cancelMuted: function (...args) { + console.warn("telephony.call.cancelMuted 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + joinConference: function (...args) { + console.warn("telephony.call.joinConference 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + disableImsSwitch: function (...args) { + console.warn("telephony.call.disableImsSwitch 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + enableImsSwitch: function (...args) { + console.warn("telephony.call.enableImsSwitch 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + updateImsCallMode: function (...args) { + console.warn("telephony.call.updateImsCallMode 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, isNewCallAllowed: function (...args) { console.warn("telephony.call.isNewCallAllowed interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -532,6 +763,18 @@ export function mockCall() { }) } }, + isImsSwitchEnabled: function (...args) { + console.warn("telephony.call.isImsSwitchEnabled 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, setMuted: function (...args) { console.warn("telephony.call.setMuted interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js index b6af9c3d..1319640f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js @@ -14,9 +14,24 @@ */ import { paramMock } from "../utils" - +export const DataFlowType = { + DATA_FLOW_TYPE_NONE: 0, + DATA_FLOW_TYPE_DOWN: 1, + DATA_FLOW_TYPE_UP: 2, + DATA_FLOW_TYPE_UP_DOWN: 3, + DATA_FLOW_TYPE_DORMANT: 4, +}; +export const DataConnectState = { + DATA_STATE_UNKNOWN: -1, + DATA_STATE_DISCONNECTED: 0, + DATA_STATE_CONNECTING: 1, + DATA_STATE_CONNECTED: 2, + DATA_STATE_SUSPENDED: 3, +}; export function mockData() { const data = { + DataFlowType, + DataConnectState, getDefaultCellularDataSlotId: function (...args) { console.warn("telephony.data.getDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js index bba534f2..0f3ef44e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js @@ -14,13 +14,30 @@ */ import { paramMock } from "../utils" - +import { CardType, SimState } from "./ohos_telephony_sim" +export const LockReason = { + SIM_NONE: "[PC Preview] unknow SIM_NONE", + SIM_PIN: "[PC Preview] unknow SIM_PIN", + SIM_PUK: "[PC Preview] unknow SIM_PUK", + SIM_PN_PIN: "[PC Preview] unknow SIM_PN_PIN", + SIM_PN_PUK: "[PC Preview] unknow SIM_PN_PUK", + SIM_PU_PIN: "[PC Preview] unknow SIM_PU_PIN", + SIM_PU_PUK: "[PC Preview] unknow SIM_PU_PUK", + SIM_PP_PIN: "[PC Preview] unknow SIM_PP_PIN", + SIM_PP_PUK: "[PC Preview] unknow SIM_PP_PUK", + SIM_PC_PIN: "[PC Preview] unknow SIM_PC_PIN", + SIM_PC_PUK: "[PC Preview] unknow SIM_PC_PUK", + SIM_SIM_PIN: "[PC Preview] unknow SIM_SIM_PIN", + SIM_SIM_PUK: "[PC Preview] unknow SIM_SIM_PUK", +}; +export const SimStateData = { + type: CardType, + state: SimState, + reason: LockReason, +} export function mockObserver() { - const SimStateData = { - type: "[PC Preview] unknow type", - state: "[PC Preview] unknow state", - } const observer = { + LockReason, on: function (...args) { console.warn("telephony.observer.on interface mocked in the Previewer. How this interface works on the Previewer may " + "be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js index 9922ed01..56de5d38 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js @@ -14,44 +14,194 @@ */ import { paramMock } from "../utils" - -const NetworkState = { +export const PreferredNetworkMode = { + PREFERRED_NETWORK_MODE_GSM: 1, + PREFERRED_NETWORK_MODE_WCDMA: 2, + PREFERRED_NETWORK_MODE_LTE: 3, + PREFERRED_NETWORK_MODE_LTE_WCDMA: 4, + PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM: 5, + PREFERRED_NETWORK_MODE_WCDMA_GSM: 6, + PREFERRED_NETWORK_MODE_CDMA: 7, + PREFERRED_NETWORK_MODE_EVDO: 8, + PREFERRED_NETWORK_MODE_EVDO_CDMA: 9, + PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA: 10, + PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA: 11, + PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA: 12, + PREFERRED_NETWORK_MODE_TDSCDMA: 13, + PREFERRED_NETWORK_MODE_TDSCDMA_GSM: 14, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA: 15, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM: 16, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA: 17, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM: 18, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA: 19, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM: 20, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA: 21, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA: 22, + PREFERRED_NETWORK_MODE_NR: 31, + PREFERRED_NETWORK_MODE_NR_LTE: 32, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA: 33, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM: 34, + PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA: 35, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA: 36, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA: 37, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM: 38, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA: 39, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM: 40, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA: 41, + PREFERRED_NETWORK_MODE_MAX_VALUE: 99, +}; +export const RadioTechnology = { + RADIO_TECHNOLOGY_UNKNOWN: 0, + RADIO_TECHNOLOGY_GSM: 1, + RADIO_TECHNOLOGY_1XRTT: 2, + RADIO_TECHNOLOGY_WCDMA: 3, + RADIO_TECHNOLOGY_HSPA: 4, + RADIO_TECHNOLOGY_HSPAP: 5, + RADIO_TECHNOLOGY_TD_SCDMA: 6, + RADIO_TECHNOLOGY_EVDO: 7, + RADIO_TECHNOLOGY_EHRPD: 8, + RADIO_TECHNOLOGY_LTE: 9, + RADIO_TECHNOLOGY_LTE_CA: 10, + RADIO_TECHNOLOGY_IWLAN: 11, + RADIO_TECHNOLOGY_NR: 12 +} +export const NetworkType = { + NETWORK_TYPE_UNKNOWN: "[PC Preview] unknow NETWORK_TYPE_UNKNOWN", + NETWORK_TYPE_GSM: "[PC Preview] unknow NETWORK_TYPE_GSM", + NETWORK_TYPE_CDMA: "[PC Preview] unknow NETWORK_TYPE_CDMA", + NETWORK_TYPE_WCDMA: "[PC Preview] unknow NETWORK_TYPE_WCDMA", + NETWORK_TYPE_TDSCDMA: "[PC Preview] unknow NETWORK_TYPE_TDSCDMA", + NETWORK_TYPE_LTE: "[PC Preview] unknow NETWORK_TYPE_LTE", + NETWORK_TYPE_NR: "[PC Preview] unknow NETWORK_TYPE_NR", +}; +export const WcdmaCellInformation = { + lac: "[PC Preview] unknow lac", + cellId: "[PC Preview] unknow cellId", + psc: "[PC Preview] unknow psc", + uarfcn: "[PC Preview] unknow uarfcn", + mcc: "[PC Preview] unknow mcc", + mnc: "[PC Preview] unknow mnc", +} +export const NetworkSelectionModeOptions = { + slotId: "[PC Preview] unknow slotId", + selectMode: NetworkSelectionMode, + networkInformation: NetworkInformation, + resumeSelection: "[PC Preview] unknow resumeSelection", +} +export const NsaState = { + NSA_STATE_NOT_SUPPORT: 1, + NSA_STATE_NO_DETECT: 2, + NSA_STATE_CONNECTED_DETECT: 3, + NSA_STATE_IDLE_DETECT: 4, + NSA_STATE_DUAL_CONNECTED: 5, + NSA_STATE_SA_ATTACHED: 6 +} +export const NetworkInformation = { + operatorName: "[PC Preview] unknow operatorName", + operatorNumeric: "[PC Preview] unknow operatorNumeric", + state: NetworkInformationState, + radioTech: "[PC Preview] unknow radioTech", +} +export const NetworkInformationState = { + NETWORK_UNKNOWN: "[PC Preview] unknow NETWORK_UNKNOWN", + NETWORK_AVAILABLE: "[PC Preview] unknow NETWORK_AVAILABLE", + NETWORK_CURRENT: "[PC Preview] unknow NETWORK_CURRENT", + NETWORK_FORBIDDEN: "[PC Preview] unknow NETWORK_FORBIDDEN", +} +export const TdscdmaCellInformation = { + lac: "[PC Preview] unknow lac", + cellId: "[PC Preview] unknow cellId", + cpid: "[PC Preview] unknow cpid", + uarfcn: "[PC Preview] unknow uarfcn", + mcc: "[PC Preview] unknow mcc", + mnc: "[PC Preview] unknow mnc", +} +export const NetworkState = { longOperatorName: "[PC Preview] unknow longOperatorName", shortOperatorName: "[PC Preview] unknow shortOperatorName", plmnNumeric: "[PC Preview] unknow plmnNumeric", isRoaming: "[PC Preview] unknow isRoaming", - regState: "[PC Preview] unknow regState", - nsaState: "[PC Preview] unknow nsaState", + regState: RegState, + cfgTech: RadioTechnology, + nsaState: NsaState, isCaActive: "[PC Preview] unknow isCaActive", isEmergency: "[PC Preview] unknow isEmergency", } -const SignalInformation = { - signalType: "[PC Preview] unknow signalType", - signalLevel: "[PC Preview] unknow signalLevel" +export const NrCellInformation = { + nrArfcn: "[PC Preview] unknow nrArfcn", + pci: "[PC Preview] unknow pci", + tac: "[PC Preview] unknow tac", + nci: "[PC Preview] unknow nci", + mcc: "[PC Preview] unknow mcc", + mnc: "[PC Preview] unknow mnc", } -const DataFlowType = "[PC Preview] unknow DataFlowType" -const DataConnectState = "[PC Preview] unknow DataConnectState" -const CellInformation = { - networkType: "[PC Preview] unknow networkType", +export const NetworkSelectionMode = { + NETWORK_SELECTION_UNKNOWN: "[PC Preview] unknow NETWORK_SELECTION_UNKNOWN", + NETWORK_SELECTION_AUTOMATIC: "[PC Preview] unknow NETWORK_SELECTION_AUTOMATIC", + NETWORK_SELECTION_MANUAL: "[PC Preview] unknow NETWORK_SELECTION_MANUAL", +}; +export const GsmCellInformation = { + lac: "[PC Preview] unknow lac", + cellId: "[PC Preview] unknow cellId", + arfcn: "[PC Preview] unknow arfcn", + bsic: "[PC Preview] unknow bsic", + mcc: "[PC Preview] unknow mcc", + mnc: "[PC Preview] unknow mnc", +} +export const LteCellInformation = { + cgi: "[PC Preview] unknow cgi", + pci: "[PC Preview] unknow pci", + tac: "[PC Preview] unknow tac", + earfcn: "[PC Preview] unknow earfcn", + bandwidth: "[PC Preview] unknow bandwidth", + mcc: "[PC Preview] unknow mcc", + mnc: "[PC Preview] unknow mnc", + isSupportEndc: "[PC Preview] unknow isSupportEndc", +} +export const RegState = { + REG_STATE_NO_SERVICE: 0, + REG_STATE_IN_SERVICE: 1, + REG_STATE_EMERGENCY_CALL_ONLY: 2, + REG_STATE_POWER_OFF: 3, +}; +export const CdmaCellInformation = { + baseId: "[PC Preview] unknow baseId", + latitude: "[PC Preview] unknow latitude", + longitude: "[PC Preview] unknow longitude", + nid: "[PC Preview] unknow nid", + sid: "[PC Preview] unknow sid" +} +export const NrOptionMode = { + NR_OPTION_UNKNOWN: "[PC Preview] unknow NR_OPTION_UNKNOWN", + NR_OPTION_NSA_ONLY: "[PC Preview] unknow NR_OPTION_NSA_ONLY", + NR_OPTION_SA_ONLY: "[PC Preview] unknow NR_OPTION_SA_ONLY", + NR_OPTION_NSA_AND_SA: "[PC Preview] unknow NR_OPTION_NSA_AND_SA", +}; +export const CellInformation = { + networkType: NetworkType, isCamped: "[PC Preview] unknow isCamped", timeStamp: "[PC Preview] unknow timeStamp", - signalInformation: "[PC Preview] unknow signalInformation", - data: "[PC Preview] unknow unkown data" + signalInformation: SignalInformation, + data: CdmaCellInformation, +}; +export const SignalInformation = { + signalType: NetworkType, + signalLevel: "[PC Preview] unknow signalLevel", +}; +export const NetworkSearchResult = { + isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", + networkSearchResult: [NetworkInformation], } export function mockRadio() { - const NetworkSearchResult = { - isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", - networkSearchResult: [{ - operatorName: "[PC Preview] unknow operatorName", - operatorNumeric: "[PC Preview] unknow operatorNumeric", - state: "[PC Preview] unknow state", - radioTech: "[PC Preview] unknow radioTech" - }] - } - const PreferredNetworkMode = "[PC Preview] unknow PreferredNetworkMode" - const NrOptionMode = "[PC Preview] unknow NrOptionMode" - const NetworkSelectionMode = "[PC Preview] unknow unkown NetworkSelectionMode" const radio = { + RegState, + NrOptionMode, + PreferredNetworkMode, + RadioTechnology, + NetworkType, + NetworkInformationState, + NsaState, + NetworkSelectionMode, getRadioTech: function (...args) { console.warn("telephony.radio.getRadioTech interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -75,7 +225,7 @@ export function mockRadio() { " 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, NetworkState); + args[len - 1].call(this, NetworkState); } else { return new Promise((resolve, reject) => { resolve(NetworkState); @@ -94,6 +244,18 @@ export function mockRadio() { }) } }, + setPrimarySlotId: function (...args) { + console.warn("telephony.radio.setPrimarySlotId 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, getCellInformation: function (...args) { console.warn("telephony.radio.getCellInformation interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js index 7325cee3..1faba27d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js @@ -14,35 +14,90 @@ */ import { paramMock } from "../utils" - +export const LockInfo = { + lockType: LockType, + password: "[PC Preview] unknow password", + state: LockState, +} +export const LockType = { + PIN_LOCK: 1, + FDN_LOCK: 2, +}; +export const LockState = { + LOCK_OFF: 0, + LOCK_ON: 1, +}; +export const PersoLockType = { + PN_PIN_LOCK: "[PC Preview] unknow PN_PIN_LOCK", + PN_PUK_LOCK: "[PC Preview] unknow PN_PUK_LOCK", + PU_PIN_LOCK: "[PC Preview] unknow PU_PIN_LOCK", + PU_PUK_LOCK: "[PC Preview] unknow PU_PUK_LOCK", + PP_PIN_LOCK: "[PC Preview] unknow PP_PIN_LOCK", + PP_PUK_LOCK: "[PC Preview] unknow PP_PUK_LOCK", + PC_PIN_LOCK: "[PC Preview] unknow PC_PIN_LOCK", + PC_PUK_LOCK: "[PC Preview] unknow PC_PUK_LOCK", + SIM_PIN_LOCK: "[PC Preview] unknow SIM_PIN_LOCK", + SIM_PUK_LOCK: "[PC Preview] unknow SIM_PUK_LOCK", +}; +export const PersoLockInfo = { + lockType: PersoLockType, + password: "[PC Preview] unknow password", +} +export const DiallingNumbersInfo = { + alphaTag: "[PC Preview] unknow alphaTag", + number: "[PC Preview] unknow number", + recordNumber: "[PC Preview] unknow recordNumber", + pin2: "[PC Preview] unknow pin2", +} +export const CardType = { + UNKNOWN_CARD: -1, + SINGLE_MODE_SIM_CARD: 10, + SINGLE_MODE_USIM_CARD: 20, + SINGLE_MODE_RUIM_CARD: 30, + DUAL_MODE_CG_CARD: 40, + CT_NATIONAL_ROAMING_CARD: 41, + CU_DUAL_MODE_CARD: 42, + DUAL_MODE_TELECOM_LTE_CARD: 43, + DUAL_MODE_UG_CARD: 50, + SINGLE_MODE_ISIM_CARD: 60 +}; +export const IccAccountInfo = { + simId: "[PC Preview] unknow simId", + slotIndex: "[PC Preview] unknow slotIndex", + isEsim: "[PC Preview] unknow isEsim", + isActive: "[PC Preview] unknow isActive", + iccId: "[PC Preview] unknow iccId", + showName: "[PC Preview] unknow showName", + showNumber: "[PC Preview] unknow showNumber", +} +export const SimState = { + SIM_STATE_UNKNOWN: "[PC Preview] unknow SIM_STATE_UNKNOWN", + SIM_STATE_NOT_PRESENT: "[PC Preview] unknow SIM_STATE_NOT_PRESENT", + SIM_STATE_LOCKED: "[PC Preview] unknow SIM_STATE_LOCKED", + SIM_STATE_NOT_READY: "[PC Preview] unknow SIM_STATE_NOT_READY", + SIM_STATE_READY: "[PC Preview] unknow SIM_STATE_READY", + SIM_STATE_LOADED: "[PC Preview] unknow SIM_STATE_LOADED", +}; +export const ContactType = { + GENERAL_CONTACT: 1, + FIXED_DIALING: 2, +}; +export const OperatorConfig = { + field: "[PC Preview] unknow field", + value: "[PC Preview] unknow value" +} +export const LockStatusResponse = { + result: "[PC Preview] unknow result", + remain: "[PC Preview] unknow remain", +} export function mockSim() { - const IccAccountInfo = { - simId: "[PC Preview] unknow simId", - slotIndex: "[PC Preview] unknow slotIndex", - isEsim: "[PC Preview] unknow isEsim", - isActive: "[PC Preview] unknow isActive", - iccId: "[PC Preview] unknow iccId", - showName: "[PC Preview] unknow showName", - showNumber: "[PC Preview] unknow showNumber" - } - const OperatorConfigMock = { - field: "[PC Preview] unknow field", - value: "[PC Preview] unknow value" - } - const LockStatusResponse = { - result: "[PC Preview] unknow result", - remain: "[PC Preview] unknow remain" - } - const DiallingNumbersInfo = { - efid: "[PC Preview] unknow efid", - recordNumber: "[PC Preview] unknow recordNumber", - alphaTag: "[PC Preview] unknow alphaTag", - number: "[PC Preview] unknow number", - emails: "[PC Preview] unknow emails" - } - const CardType = "[PC Preview] unknow CardType"; - const SimState = "[PC Preview] unknow SimState"; const sim = { + ContactType, + SimState, + CardType, + PersoLockType, + LockState, + LockType, isSimActive: function (...args) { console.warn("telephony.sim.isSimActive interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -127,6 +182,18 @@ export function mockSim() { }) } }, + getLockState: function (...args) { + console.warn("telephony.sim.getLockState 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, LockState); + } else { + return new Promise((resolve, reject) => { + resolve(LockState); + }) + } + }, getCardType: function (...args) { console.warn("telephony.sim.getCardType interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -312,6 +379,18 @@ export function mockSim() { }) } }, + setVoiceMailInfo: function (...args) { + console.warn("telephony.sim.setVoiceMailInfo 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, deactivateSim: function (...args) { console.warn("telephony.sim.deactivateSim interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -324,6 +403,18 @@ export function mockSim() { }) } }, + sendEnvelopeCmd: function (...args) { + console.warn("telephony.sim.sendEnvelopeCmd 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, setShowName: function (...args) { console.warn("telephony.sim.setShowName interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -336,6 +427,18 @@ export function mockSim() { }) } }, + sendTerminalResponseCmd: function (...args) { + console.warn("telephony.sim.sendTerminalResponseCmd 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, getShowName: function (...args) { console.warn("telephony.sim.getShowName interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -396,6 +499,18 @@ export function mockSim() { }) } }, + unlockSimLock: function (...args) { + console.warn("telephony.sim.unlockSimLock 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, unlockPuk: function (...args) { console.warn("telephony.sim.unlockPuk interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js index 1d890b48..b78411ea 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js @@ -14,31 +14,274 @@ */ import { paramMock } from "../utils" - +export const SimShortMessage = { + shortMessage: ShortMessage, + simMessageStatus: SimMessageStatus, + indexOnSim: "[PC Preview] unknow indexOnSim" +} +export const ShortMessage = { + visibleMessageBody: "[PC Preview] unknow visibleMessageBody", + visibleRawAddress: "[PC Preview] unknow visibleRawAddress", + messageClass: ShortMessageClass, + protocolId: "[PC Preview] unknow protocolId", + scAddress: "[PC Preview] unknow scAddress", + scTimestamp: "[PC Preview] unknow scTimestamp", + isReplaceMessage: "[PC Preview] unknow isReplaceMessage", + hasReplyPath: "[PC Preview] unknow hasReplyPath", + pdu: ["[PC Preview] unknow pdu"], + status: "[PC Preview] unknow status", + isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage", + emailAddress: "[PC Preview] unknow emailAddress", + emailMessageBody: "[PC Preview] unknow emailMessageBody", + userRawData: ["[PC Preview] unknow userRawData"], + isEmailMessage: "[PC Preview] unknow isEmailMessage", +} +export const SimMessageStatus = { + SIM_MESSAGE_STATUS_FREE: 0, + SIM_MESSAGE_STATUS_READ: 1, + SIM_MESSAGE_STATUS_UNREAD: 3, + SIM_MESSAGE_STATUS_SENT: 5, + SIM_MESSAGE_STATUS_UNSENT: 7, +} +export const MmsInformation = { + messageType: MessageType, + mmsType: MmsSendReq, + attachment: [MmsAttachment] +} +export const MessageType = { + TYPE_MMS_SEND_REQ: 128, + TYPE_MMS_SEND_CONF: 129, + TYPE_MMS_NOTIFICATION_IND: 130, + TYPE_MMS_RESP_IND: 131, + TYPE_MMS_RETRIEVE_CONF: 132, + TYPE_MMS_ACKNOWLEDGE_IND: 133, + TYPE_MMS_DELIVERY_IND: 134, + TYPE_MMS_READ_REC_IND: 135, + TYPE_MMS_READ_ORIG_IND: 136, +}; +export const MmsAttachment = { + contentId: "[PC Preview] unknow contentId", + contentLocation: "[PC Preview] unknow contentLocation", + contentDisposition: DispositionType, + contentTransferEncoding: "[PC Preview] unknow contentTransferEncoding", + contentType: "[PC Preview] unknow contentType", + isSmil: "[PC Preview] unknow isSmil", + path: "[PC Preview] unknow path", + inBuff: "[PC Preview] unknow inBuff", + fileName: "[PC Preview] unknow fileName", + charset: MmsCharSets, +} +export const DispositionType = { + FROM_DATA: 0, + ATTACHMENT: 1, + INLINE: 2, +} +export const MmsCharSets = { + BIG5: 0X07EA, + ISO_10646_UCS_2: 0X03E8, + ISO_8859_1: 0X04, + ISO_8859_2: 0X05, + ISO_8859_3: 0X06, + ISO_8859_4: 0X07, + ISO_8859_5: 0X08, + ISO_8859_6: 0X09, + ISO_8859_7: 0X10, + ISO_8859_8: 0X11, + ISO_8859_9: 0X12, + SHIFT_JIS: 0X11, + US_ASCII: 0X03, + UTF_8: 0X6A, +} +export const MmsRetrieveConf = { + transactionId: "[PC Preview] unknow transactionId", + messageId: "[PC Preview] unknow messageId", + date: "[PC Preview] unknow date", + contentType: "[PC Preview] unknow contentType", + to: [MmsAddress], + version: MmsVersionType, + from: MmsAddress, + cc: [MmsAddress], + subject: ["[PC Preview] unknow subject"], + priority: MmsPriorityType, + deliveryReport: "[PC Preview] unknow deliveryReport", + readReport: "[PC Preview] unknow readReport", + retrieveStatus: "[PC Preview] unknow retrieveStatus", + retrieveText: ["[PC Preview] unknow retrieveText"], +} +export const MmsAcknowledgeInd = { + transactionId: "[PC Preview] unknow transactionId", + version: MmsVersionType, + reportAllowed: ReportType, +} +export const MmsDeliveryInd = { + transactionId: "[PC Preview] unknow transactionId", + date: "[PC Preview] unknow date", + to: [MmsAddress], + status: "[PC Preview] unknow status", + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", +} +export const MmsReadRecInd = { + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", + to: [MmsAddress], + from: MmsAddress, + readStatus: "[PC Preview] unknow readStatus", + date: "[PC Preview] unknow date", +} +export const MmsReadOrigInd = { + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", + to: [MmsAddress], + from: MmsAddress, + date: "[PC Preview] unknow date", + readStatus: "[PC Preview] unknow readStatus", +} +export const MmsRespInd = { + transactionId: "[PC Preview] unknow transactionId", + status: "[PC Preview] unknow transactionId", + version: MmsVersionType, + reportAllowed: ReportType, +} +export const CBConfigOptions = { + slotId: "[PC Preview] unknow slotId", + enable: "[PC Preview] unknow enable", + startMessageId: "[PC Preview] unknow startMessageId", + endMessageId: "[PC Preview] unknow endMessageId", + ranType: RanType +} +export const SimMessageOptions = { + slotId: "[PC Preview] unknow slotId", + smsc: "[PC Preview] unknow smsc", + pdu: "[PC Preview] unknow pdu", + status: SimMessageStatus, +} +export const UpdateSimMessageOptions = { + slotId: "[PC Preview] unknow slotId", + msgIndex: "[PC Preview] unknow msgIndex", + newStatus: SimMessageStatus, + pdu: "[PC Preview] unknow pdu", + smsc: "[PC Preview] unknow smsc", +} +export const SendMessageOptions = { + slotId: "[PC Preview] unknow slotId", + destinationHost: "[PC Preview] unknow destinationHost", + serviceCenter: "[PC Preview] unknow serviceCenter", + content: "[PC Preview] unknow content", + destinationPort: "[PC Preview] unknow destinationPort", + sendCallback: ISendShortMessageCallback, + deliveryCallback: IDeliveryShortMessageCallback, +} +export const IDeliveryShortMessageCallback = { + pdu: "[PC Preview] unknow pdu", +} +export const ISendShortMessageCallback = { + result: SendSmsResult, + url: "[PC Preview] unknow url", + isLastPart: "[PC Preview] unknow isLastPart", +} +export const SendSmsResult = { + SEND_SMS_SUCCESS: 0, + SEND_SMS_FAILURE_UNKNOWN: 1, + SEND_SMS_FAILURE_RADIO_OFF: 2, + SEND_SMS_FAILURE_SERVICE_UNAVAILABLE: 3 +} +export const ShortMessageClass = { + UNKNOWN: "[PC Preview] unknow UNKNOWN", + INSTANT_MESSAGE: "[PC Preview] unknow INSTANT_MESSAGE", + OPTIONAL_MESSAGE: "[PC Preview] unknow OPTIONAL_MESSAGE", + SIM_MESSAGE: "[PC Preview] unknow SIM_MESSAGE", + FORWARD_MESSAGE: "[PC Preview] unknow FORWARD_MESSAGE", +} +export const RanType = { + TYPE_GSM: 1, + TYPE_CDMA: 2, +} +export const ReportType = { + MMS_YES: 128, + MMS_NO: 129, +} +export const MmsNotificationInd = { + transactionId: "[PC Preview] unknow transactionId", + messageClass: "[PC Preview] unknow messageClass", + messageSize: "[PC Preview] unknow messageSize", + expiry: "[PC Preview] unknow expiry", + contentLocation: "[PC Preview] unknow contentLocation", + version: MmsVersionType, + from: MmsAddress, + subject: "[PC Preview] unknow subject", + deliveryReport: ["[PC Preview] unknow deliveryReport"], + contentClass: "[PC Preview] unknow contentClass", +} +export const MmsAddress = { + address: "[PC Preview] unknow address", + charset: MmsCharSets, +} +export const MmsVersionType = { + MMS_VERSION_1_0: 0x10, + MMS_VERSION_1_1: 0x11, + MMS_VERSION_1_2: 0x12, + MMS_VERSION_1_3: 0x13, +} +export const MmsPriorityType = { + MMS_LOW: 128, + MMS_NORMAL: 129, + MMS_HIGH: 130, +} +export const MmsSendReq = { + from: MmsAddress, + transactionId: "[PC Preview] unknow transactionId", + contentType: "[PC Preview] unknow contentType", + version: MmsVersionType, + to: [MmsAddress], + date: "[PC Preview] unknow date", + cc: [MmsAddress], + bcc: [MmsAddress], + subject: ["[PC Preview] unknow subject"], + messageClass: "[PC Preview] unknow messageClass", + expiry: "[PC Preview] unknow expiry", + priority: MmsPriorityType, + senderVisibility: "[PC Preview] unknow senderVisibility", + deliveryReport: ["[PC Preview] unknow deliveryReport"], + readReport: "[PC Preview] unknow readReport", + responseState: "[PC Preview] unknow responseState", + transactionId: "[PC Preview] unknow transactionId", + version: "[PC Preview] unknow version", + messageId: "[PC Preview] unknow messageId", +} +export const MmsSendConf = { + responseState: "[PC Preview] unknow responseState", + transactionId: "[PC Preview] unknow transactionId", + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", +} +export const SmsSegmentsInfo = { + splitCount: "[PC Preview] unknow splitCount", + encodeCount: "[PC Preview] unknow encodeCount", + encodeCountRemaining: "[PC Preview] unknow encodeCountRemaining", + scheme: SmsEncodingScheme, +} +export const SmsEncodingScheme = { + SMS_ENCODING_UNKNOWN: 0, + SMS_ENCODING_7BIT: 1, + SMS_ENCODING_8BIT: 2, + SMS_ENCODING_16BIT: 3, +} export function mockSMS() { - const SimShortMessage = { - shortMessage: "[PC Preview] unknow shortMessage", - simMessageStatus: "[PC Preview] unknow simMessageStatus", - indexOnSim: "[PC Preview] unknow indexOnSim" - } - const ShortMessage = { - visibleMessageBody: "[PC Preview] unknow visibleMessageBody", - visibleRawAddress: "[PC Preview] unknow visibleRawAddress", - messageClass: "[PC Preview] unknow messageClass", - protocolId: "[PC Preview] unknow protocolId", - scAddress: "[PC Preview] unknow scAddress", - scTimestamp: "[PC Preview] unknow scTimestamp", - isReplaceMessage: "[PC Preview] unknow isReplaceMessage", - hasReplyPath: "[PC Preview] unknow hasReplyPath", - pdu: ["[PC Preview] unknow pdu"], - status: "[PC Preview] unknow status", - isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage", - emailAddress: "[PC Preview] unknow emailAddress", - emailMessageBody: "[PC Preview] unknow emailMessageBody", - userRawData: ["[PC Preview] unknow userRawData"], - isEmailMessage: "[PC Preview] unknow isEmailMessage", - } const sms = { + SimMessageStatus, + SmsEncodingScheme, + DispositionType, + SendSmsResult, + MessageType, + ShortMessage, + MmsCharSets, + MmsPriorityType, + MmsVersionType, + ReportType, + SimShortMessage, + RanType, + ShortMessageClass, splitMessage: function (...args) { console.warn("telephony.sms.splitMessage interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -63,6 +306,78 @@ export function mockSMS() { }) } }, + getSmsSegmentsInfo: function (...args) { + console.warn("telephony.sms.getSmsSegmentsInfo 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, SmsSegmentsInfo); + } else { + return new Promise((resolve, reject) => { + resolve(SmsSegmentsInfo); + }) + } + }, + isImsSmsSupported: function (...args) { + console.warn("telephony.sms.isImsSmsSupported 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getImsShortMessageFormat: function (...args) { + console.warn("telephony.sms.getImsShortMessageFormat 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.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + decodeMms: function (...args) { + console.warn("telephony.sms.decodeMms 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, MmsInformation); + } else { + return new Promise((resolve, reject) => { + resolve(MmsInformation); + }) + } + }, + encodeMms: function (...args) { + console.warn("telephony.sms.encodeMms 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.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + isImsSmsSuppo: function (...args) { + console.warn("telephony.sms.isImsSmsSuppo 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.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, sendMessage: function (...args) { console.warn("telephony.sms.sendMessage interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js new file mode 100644 index 00000000..550bd76e --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -0,0 +1,493 @@ +/* + * 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' + +const warnMessage = + ' interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.' + +export const ResizeDirection = { + LEFT: 0, + RIGHT: 1, + UP: 2, + DOWN: 3, + LEFT_UP: 4, + LEFT_DOWN: 5, + RIGHT_UP: 6, + RIGHT_DOWN: 7 +} + +export const MatchPattern = { + EQUALS: 0, + CONTAINS: 1, + STARTS_WITH: 2, + ENDS_WITH: 3 +} + +export const WindowMode = { + FULLSCREEN: 0, + PRIMARY: 1, + SECONDARY: 2, + FLOATING: 3 +} + +export const Point = { + X: '[PC Preview] unknown X', + Y: '[PC Preview] unknown Y' +} + +export const Rect = { + leftX: '[PC Preview] unknown leftX', + topY: '[PC Preview] unknown topY', + rightX: '[PC Preview] unknown rightX', + bottomY: '[PC Preview] unknown bottomY' +} + +export const WindowFilter = { + bundleName: '[PC Preview] unknown bundleName', + title: '[PC Preview] unknown title', + focused: '[PC Preview] unknown focused', + actived: '[PC Preview] unknown actived' +} + +const ByClass = class ByMock { + constructor() { + console.warn('uitest.By.constructor' + warnMessage); + this.id = function(...args) { + console.warn('uitest.By.id' + warnMessage) + return new ByClass() + }; + this.text = function(...args) { + console.warn('uitest.By.text' + warnMessage) + return new ByClass() + }; + this.key = function(...args) { + console.warn('uitest.By.key' + warnMessage) + return new ByClass() + }; + this.type = function(...args) { + console.warn('uitest.By.type' + warnMessage) + return new ByClass() + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return new ByClass() + }; + this.focused = function(...args) { + console.warn('uitest.By.focused' + warnMessage) + return new ByClass() + }; + this.selected = function(...args) { + console.warn('uitest.By.selected' + warnMessage) + return new ByClass() + }; + this.clickable = function(...args) { + console.warn('uitest.By.clickable' + warnMessage) + return new ByClass() + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return new ByClass() + }; + this.longClickable = function(...args) { + console.warn('uitest.By.longClickable' + warnMessage) + return new ByClass() + }; + this.scrollable = function(...args) { + console.warn('uitest.By.scrollable' + warnMessage) + return new ByClass() + }; + this.checkable = function(...args) { + console.warn('uitest.By.checkable' + warnMessage) + return new ByClass() + }; + this.checked = function(...args) { + console.warn('uitest.By.checked' + warnMessage) + return new ByClass() + }; + this.isBefore = function(...args) { + console.warn('uitest.By.isBefore' + warnMessage) + return new ByClass() + }; + this.isAfter = function(...args) { + console.warn('uitest.By.isAfter' + warnMessage) + return new ByClass() + }; + } +} + +const UiDriverClass = class UiDriverMock { + constructor() { + console.warn('uitest.UiDriver.constructor' + warnMessage); + this.delayMs = function(...args) { + console.warn('uitest.UiDriver.delayMs' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.findComponent = function(...args) { + console.warn('uitest.UiDriver.findComponent' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.findWindow = function(...args) { + console.warn('uitest.UiDriver.findWindow' + warnMessage) + return new Promise((resolve) => { + resolve(new UiWindowClass()) + }); + }; + this.findComponents = function(...args) { + console.warn('uitest.UiDriver.findComponents' + warnMessage) + return new Promise((resolve) => { + resolve(new Array(new UiComponentClass())) + }); + }; + this.waitForComponent = function(...args) { + console.warn('uitest.UiDriver.waitForComponent' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.screenCap = function(...args) { + console.warn('uitest.UiDriver.screenCap' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.assertComponentExist = function(...args) { + console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pressBack = function(...args) { + console.warn('uitest.UiDriver.pressBack' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.triggerKey = function(...args) { + console.warn('uitest.UiDriver.triggerKey' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.triggerCombineKeys = function(...args) { + console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.click = function(...args) { + console.warn('uitest.UiDriver.click' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.longClick = function(...args) { + console.warn('uitest.UiDriver.longClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiDriver.doubleClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.swipe = function(...args) { + console.warn('uitest.UiDriver.swipe' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.drag = function(...args) { + console.warn('uitest.UiDriver.drag' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + } +} + +UiDriverClass.create = function () { + console.warn('uitest.UiDriver.create' + warnMessage) + return new UiDriverClass() +} + +const UiComponentClass = class UiComponentMock { + constructor() { + console.warn('uitest.UiComponent.constructor' + warnMessage); + this.getId = function(...args) { + console.warn('uitest.UiComponent.getId' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock) + }); + }; + this.getText = function(...args) { + console.warn('uitest.UiComponent.getText' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getKey = function(...args) { + console.warn('uitest.UiComponent.getKey' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getType = function(...args) { + console.warn('uitest.UiComponent.getType' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.isEnabled = function(...args) { + console.warn('uitest.UiComponent.isEnabled' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isFocused = function(...args) { + console.warn('uitest.UiComponent.isFocused' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isSelected = function(...args) { + console.warn('uitest.UiComponent.isSelected' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isClickable = function(...args) { + console.warn('uitest.UiComponent.isClickable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isLongClickable = function(...args) { + console.warn('uitest.UiComponent.isLongClickable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isScrollable = function(...args) { + console.warn('uitest.UiComponent.isScrollable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isCheckable = function(...args) { + console.warn('uitest.UiComponent.isCheckable' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isChecked = function(...args) { + console.warn('uitest.UiComponent.isChecked' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.getBounds = function(...args) { + console.warn('uitest.UiComponent.getBounds' + warnMessage) + return new Promise((resolve) => { + resolve(Rect) + }); + }; + this.getBoundsCenter = function(...args) { + console.warn('uitest.UiComponent.getBoundsCenter' + warnMessage) + return new Promise((resolve) => { + resolve(Point) + }); + }; + this.click = function(...args) { + console.warn('uitest.UiComponent.click' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.longClick = function(...args) { + console.warn('uitest.UiComponent.longClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiComponent.doubleClick' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollToTop = function(...args) { + console.warn('uitest.UiComponent.scrollToTop' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollToBottom = function(...args) { + console.warn('uitest.UiComponent.scrollToBottom' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.inputText = function(...args) { + console.warn('uitest.UiComponent.inputText' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.clearText = function(...args) { + console.warn('uitest.UiComponent.clearText' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.scrollSearch = function(...args) { + console.warn('uitest.UiComponent.scrollSearch' + warnMessage) + return new Promise((resolve) => { + resolve(new UiComponentClass()) + }); + }; + this.dragTo = function(...args) { + console.warn('uitest.UiComponent.dragTo' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pinchOut = function(...args) { + console.warn('uitest.UiComponent.pinchOut' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + this.pinchIn = function(...args) { + console.warn('uitest.UiComponent.pinchIn' + warnMessage) + return new Promise((resolve) => { + resolve() + }); + }; + } +} + +const UiWindowClass = class UiWindowMock { + constructor() { + console.warn('uitest.UiWindow.constructor' + warnMessage); + this.getBundleName = function(...args) { + console.warn('uitest.UiWindow.getBundleName' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getBounds = function(...args) { + console.warn('uitest.UiWindow.getBounds' + warnMessage) + return new Promise((resolve) => { + resolve(Rect) + }); + }; + this.getTitle = function(...args) { + console.warn('uitest.UiWindow.getTitle' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); + }; + this.getWindowMode = function(...args) { + console.warn('uitest.UiWindow.getWindowMode' + warnMessage) + return new Promise((resolve) => { + resolve(WindowMode) + }); + }; + this.isFocused = function(...args) { + console.warn('uitest.UiWindow.isFocused' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.isActived = function(...args) { + console.warn('uitest.UiWindow.isActived' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.focus = function(...args) { + console.warn('uitest.UiWindow.focus' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.moveTo = function(...args) { + console.warn('uitest.UiWindow.moveTo' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.resize = function(...args) { + console.warn('uitest.UiWindow.resize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.split = function(...args) { + console.warn('uitest.UiWindow.split' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.maximize = function(...args) { + console.warn('uitest.UiWindow.maximize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.resume = function(...args) { + console.warn('uitest.UiWindow.resume' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.minimize = function(...args) { + console.warn('uitest.UiWindow.minimize' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + this.close = function(...args) { + console.warn('uitest.UiWindow.close' + warnMessage) + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }); + }; + }; +} + +export function mockUiTest() { + const module = { + ResizeDirection: ResizeDirection, + MatchPattern: MatchPattern, + WindowMode: WindowMode, + Point: Point, + Rect: Rect, + WindowFilter: WindowFilter, + BY: new ByClass(), + UiDriver: UiDriverClass, + UiComponent: UiComponentClass, + UiWindow: UiWindowClass + }; + return module +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index d78eeb32..deba644b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -142,10 +142,10 @@ export function mockUpdate() { " 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); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(); }) } }, @@ -198,10 +198,10 @@ export function mockUpdate() { " 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); + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); + resolve(); }) } }, @@ -246,6 +246,15 @@ export function mockUpdate() { UpgradeStatus, EventClassify, EventId, + UpgradeInfo, + BusinessType, + DownloadOptions, + ResumeDownloadOptions, + PauseDownloadOptions, + UpgradeOptions, + ClearOptions, + EventClassifyInfo, + UpgradeFile, getOnlineUpdater: function (...args) { console.warn("update.getOnlineUpdater interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -271,7 +280,6 @@ const BusinessVendor = { const BusinessSubType = { FIRMWARE: 1, - PARAM: 2, } const ComponentType = { @@ -298,12 +306,16 @@ const NetType = { CELLULAR: 1, METERED_WIFI: 2, NOT_METERED_WIFI: 4, + WIFI: 6, + CELLULAR_AND_WIFI: 7 } const Order = { DOWNLOAD: 1, INSTALL: 2, + DOWNLOAD_AND_INSTALL: 3, APPLY: 4, + INSTALL_AND_APPLY: 6 } const UpgradeStatus = { @@ -413,3 +425,44 @@ const EventInfo = { eventId: EventId.EVENT_TASK_RECEIVE, taskBody: TaskBody, } + +const UpgradeInfo = { + upgradeApp: "[PC Preview] unknown upgradeApp", + businessType: BusinessType +} + +const BusinessType = { + vendor: BusinessVendor, + subType: BusinessSubType +} + +const DownloadOptions = { + allowNetwork: NetType, + order: Order +} + +const ResumeDownloadOptions = { + allowNetwork: NetType +} + +const PauseDownloadOptions = { + isAllowAutoResume: true +} + +const UpgradeOptions = { + order: Order +} + +const ClearOptions = { + status: UpgradeStatus +} + +const EventClassifyInfo = { + eventClassify: EventClassify, + extraInfo: "[PC Preview] unknown extraInfo" +} + +const UpgradeFile = { + fileType: ComponentType, + filePath: "[PC Preview] unknown filePath" +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_uri.js b/runtime/main/extend/systemplugin/napi/ohos_uri.js index a4577161..0af4e601 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uri.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uri.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockUri() { - const result = { + const uri = { URI: function (...args) { console.warn("uri.URI interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -24,6 +24,10 @@ export function mockUri() { } } const URIMock = { + constructor(...args) { + console.warn("uri.URI.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, toString: function (...args) { console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -45,7 +49,7 @@ export function mockUri() { return paramMock.paramObjectMock; }, scheme: '[PC preview] unknow scheme', - userinfo: '[PC preview] unknow userinfo', + userInfo: '[PC preview] unknow userInfo', host: '[PC preview] unknow host', port: '[PC preview] unknow port', path: '[PC preview] unknow path', @@ -54,5 +58,5 @@ export function mockUri() { authority: '[PC preview] unknow authority', ssp: '[PC preview] unknow ssp' } - return result; + return uri; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_url.js b/runtime/main/extend/systemplugin/napi/ohos_url.js index a29acc3c..5afb7350 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_url.js +++ b/runtime/main/extend/systemplugin/napi/ohos_url.js @@ -91,28 +91,28 @@ export function mockUrl() { ' may be different from that on a real device.'); return paramMock.paramStringMock; }; - } - [Symbol.iterator]() { - console.warn('url.URLSearchParams.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer' + - ' may be different from that on a real device.'); - let index = 0; - const IteratorTwoStringMock = { - next: () => { - if (index < 1) { - const returnValue = [paramMock.paramStringMock, paramMock.paramStringMock]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn('url.URLSearchParams.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + let index = 0; + const IteratorTwoStringMock = { + next: () => { + if (index < 1) { + const returnValue = [paramMock.paramStringMock, paramMock.paramStringMock]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorTwoStringMock; + }; + return IteratorTwoStringMock; + } } }; const URLClass = class URL { @@ -143,9 +143,9 @@ export function mockUrl() { this.username = '[PC preview] unknow username'; } }; - const result = { + const urlMock = { URLSearchParams: URLSearchParamsClass, URL: URLClass }; - return result; + return urlMock; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_usb.js b/runtime/main/extend/systemplugin/napi/ohos_usb.js index 98954003..8555f676 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_usb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_usb.js @@ -88,8 +88,10 @@ export function mockUsb() { const PortModeType = { NONE: '[PC Preview] unknow NONE', - DFP: '[PC Preview] unknow DFP', UFP: '[PC Preview] unknow UFP', + DFP: '[PC Preview] unknow DFP', + DRP: '[PC Preview] unknow DRP', + NUM_MODES: '[PC Preview] unknow NUM_MODES', }; const USBPortStatus = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_userIAM_faceAuth.js b/runtime/main/extend/systemplugin/napi/ohos_userIAM_faceAuth.js new file mode 100644 index 00000000..0e0c5948 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_userIAM_faceAuth.js @@ -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; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_userIAM_userAuth.js b/runtime/main/extend/systemplugin/napi/ohos_userIAM_userAuth.js index bb84f325..9f8b02aa 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_userIAM_userAuth.js +++ b/runtime/main/extend/systemplugin/napi/ohos_userIAM_userAuth.js @@ -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; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_util.js b/runtime/main/extend/systemplugin/napi/ohos_util.js index 1f205b14..017e87ac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util.js @@ -1,553 +1,593 @@ -/* - * 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 { paramMock } from "../utils" - -export function mockUtil() { - const result = { - printf: function (...args) { - console.warn("util.printf interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - getErrorString: function (...args) { - console.warn("util.getErrorString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - callbackWrapper: function (...args) { - console.warn("util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - promiseWrapper: function (...args) { - console.warn("util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - TextDecoder: function (...args) { - console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return TextDecoderMock; - }, - TextEncoder: function (...args) { - console.warn("util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return TextEncoderMock; - }, - RationalNumber: function (...args) { - console.warn("util.RationalNumber interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return RationalNumberMock; - }, - LruBuffer: function (...args) { - console.warn("util.Lrubuffer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return LrubufferMock; - }, - Scope: function (...args) { - console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return ScopeMock; - }, - Base64: function (...args) { - console.warn("util.Base64 interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return Base64Mock; - }, - Types: function (...args) { - console.warn("util.Types interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return TypesMock; - } - } - const TextDecoderMock = { - encoding: '[PC preview] unknow encoding', - fatal: '[PC preview] unknow fatal', - ignoreBOM: '[PC preview] unknow ignoreBOM', - decode: function (...args) { - console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - } - } - const TextEncoderMock = { - encoding: '[PC preview] unknow encoding', - encode: function (...args) { - console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const arr = new Uint8Array() - return arr; - }, - encodeInto: function (...args) { - console.warn("TextEncoder.encodeInto interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramObjectMock; - } - } - const RationalNumberMock = { - createRationalFromString: function (...args) { - console.warn("RationalNumber.createRationalFromString​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - compareTo: function (...args) { - console.warn("RationalNumber.compareTo​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - equals: function (...args) { - console.warn("RationalNumber.equals​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - valueOf: function (...args) { - console.warn("RationalNumber.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getCommonDivisor: function (...args) { - console.warn("RationalNumber.getCommonDivisor​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getDenominator: function (...args) { - console.warn("RationalNumber.getDenominator​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getNumerator: function (...args) { - console.warn("RationalNumber.getNumerator​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - isFinite: function (...args) { - console.warn("RationalNumber.isFinite​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isNaN: function (...args) { - console.warn("RationalNumber.isNaN​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isZero: function (...args) { - console.warn("RationalNumber.isZero​ interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - toString: function (...args) { - console.warn("RationalNumber.toString interface mocked in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramStringMock; - } - } - const LrubufferMock = { - length: '[PC preview] unknow length', - updateCapacity: function (...args) { - console.warn("Lrubuffer.updateCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - }, - toString: function (...args) { - console.warn("Lrubuffer.toString interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramStringMock; - }, - getCapacity: function (...args) { - console.warn("Lrubuffer.getCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - clear: function (...args) { - console.warn("Lrubuffer.clear interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - }, - getCreateCount: function (...args) { - console.warn("Lrubuffer.getCreateCount interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getMissCount: function (...args) { - console.warn("Lrubuffer.getMissCount interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getRemovalCount: function (...args) { - console.warn("Lrubuffer.getRemovalCount interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getMatchCount: function (...args) { - console.warn("Lrubuffer.getMatchCount interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getPutCount: function (...args) { - console.warn("Lrubuffer.getPutCount interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramNumberMock; - }, - isEmpty: function (...args) { - console.warn("Lrubuffer.isEmpty​ interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - get: function (...args) { - console.warn("Lrubuffer.get interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - put: function (...args) { - console.warn("Lrubuffer.put interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - values: function (...args) { - console.warn("Lrubuffer.values interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - keys: function (...args) { - console.warn("Lrubuffer.keys​ interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - remove: function (...args) { - console.warn("Lrubuffer.remove interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - afterRemoval: function (...args) { - console.warn("Lrubuffer.afterRemoval interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - }, - contains: function (...args) { - console.warn("Lrubuffer.contains​ interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - createDefault: function (...args) { - console.warn("Lrubuffer.createDefault​ interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - entries: function (...args) { - console.warn("Lrubuffer.entries interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - }, - [Symbol.iterator]: function (...args) { - console.warn("Lrubuffer.[Symbol.iterator] interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramObjectMock; - } - } - const ScopeMock = { - toString: function (...args) { - console.warn("Scope.toString interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramStringMock; - }, - intersect: function (...args) { - console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeMock; - }, - intersect: function (...args) { - console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeMock; - }, - getUpper: function (...args) { - console.warn("Scope.getUpper interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeTypeMock; - }, - getLower: function (...args) { - console.warn("Scope.getLower interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeTypeMock; - }, - expand: function (...args) { - console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeMock; - }, - expand: function (...args) { - console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeMock; - }, - expand: function (...args) { - console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeMock; - }, - contains: function (...args) { - console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - contains: function (...args) { - console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - clamp: function (...args) { - console.warn("Scope.clamp interface mockecd in the Previewer. How this interface works on the Previewer" + - "may be different from that on a real device.") - return paramMock.paramScopeTypeMock; - } - } - const Base64Mock = { - encodeSync: function (...args) { - console.warn("Base64.encodeSync interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const arr = new Uint8Array() - return arr; - }, - encodeToStringSync: function (...args) { - console.warn("Base64.encodeToStringSync interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - decodeSync: function (...args) { - console.warn("Base64.decodeSync interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const arr = new Uint8Array() - return arr; - }, - encode: function (...args) { - console.warn("Base64.encode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const arr = new Uint8Array() - return new Promise((resolve, reject) => { - resolve(arr); - }) - }, - encodeToString: function (...args) { - console.warn("Base64.encodeToString interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - }, - decode: function (...args) { - console.warn("Base64.decode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const arr = new Uint8Array() - return new Promise((resolve, reject) => { - resolve(arr); - }) - } - } - const TypesMock = { - isAnyArrayBuffer: function (...args) { - console.warn("Types.isAnyArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isArrayBufferView: function (...args) { - console.warn("Types.isArrayBufferView interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isArgumentsObject: function (...args) { - console.warn("Types.isArgumentsObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isArrayBuffer: function (...args) { - console.warn("Types.isArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isAsyncFunction: function (...args) { - console.warn("Types.isAsyncFunction interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isBigInt64Array: function (...args) { - console.warn("Types.isBigInt64Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isBigUint64Array: function (...args) { - console.warn("Types.isBigUint64Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isBooleanObject: function (...args) { - console.warn("Types.isBooleanObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isBoxedPrimitive: function (...args) { - console.warn("Types.isBoxedPrimitive interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isDataView: function (...args) { - console.warn("Types.isDataView interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isDate: function (...args) { - console.warn("Types.isDate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isExternal: function (...args) { - console.warn("Types.isExternal interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isFloat32Array: function (...args) { - console.warn("Types.isFloat32Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isFloat64Array: function (...args) { - console.warn("Types.isFloat64Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isGeneratorFunction: function (...args) { - console.warn("Types.isGeneratorFunction interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isGeneratorObject: function (...args) { - console.warn("Types.isGeneratorObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isInt8Array: function (...args) { - console.warn("Types.isInt8Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isInt16Array: function (...args) { - console.warn("Types.isInt16Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isInt32Array: function (...args) { - console.warn("Types.isInt32Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isMap: function (...args) { - console.warn("Types.isMap interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isMapIterator: function (...args) { - console.warn("Types.isMapIterator interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isModuleNamespaceObject: function (...args) { - console.warn("Types.isModuleNamespaceObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isNativeError: function (...args) { - console.warn("Types.isNativeError interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isNumberObject: function (...args) { - console.warn("Types.isNumberObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isPromise: function (...args) { - console.warn("Types.isPromise interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isProxy: function (...args) { - console.warn("Types.isProxy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isRegExp: function (...args) { - console.warn("Types.isRegExp interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isSet: function (...args) { - console.warn("Types.isSet interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isSetIterator: function (...args) { - console.warn("Types.isSetIterator interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isSharedArrayBuffer: function (...args) { - console.warn("Types.isSharedArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isStringObject: function (...args) { - console.warn("Types.isStringObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isSymbolObject: function (...args) { - console.warn("Types.isSymbolObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isTypedArray: function (...args) { - console.warn("Types.isTypedArray interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isUint8Array: function (...args) { - console.warn("Types.isUint8Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isUint8ClampedArray: function (...args) { - console.warn("Types.isUint8ClampedArray interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isUint16Array: function (...args) { - console.warn("Types.isUint16Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isUint32Array: function (...args) { - console.warn("Types.isUint32Array interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isWeakMap: function (...args) { - console.warn("Types.isWeakMap interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isWeakSet: function (...args) { - console.warn("Types.isWeakSet interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - } - } - return result; +/* + * 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 mockUtil() { + const util = { + printf: function (...args) { + console.warn("util.printf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getErrorString: function (...args) { + console.warn("util.getErrorString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + callbackWrapper: function (...args) { + console.warn("util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + promiseWrapper: function (...args) { + console.warn("util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + TextDecoder: function (...args) { + console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return TextDecoderMock; + }, + TextEncoder: function (...args) { + console.warn("util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return TextEncoderMock; + }, + RationalNumber: function (...args) { + console.warn("util.RationalNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return RationalNumberMock; + }, + LruBuffer: function (...args) { + console.warn("util.LruBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return LruBufferMock; + }, + ScopeComparable: function (...args) { + console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return ScopeComparableMock; + }, + Scope: function (...args) { + console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return ScopeMock; + }, + Base64: function (...args) { + console.warn("util.Base64 interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return Base64Mock; + }, + types: function (...args) { + console.warn("util.types interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return TypesMock; + } + } + const TextDecoderMock = { + encoding: "[PC preview] unknow encoding", + fatal: "[PC preview] unknow fatal", + ignoreBOM: "[PC preview] unknow ignoreBOM", + constructor(...args) { + console.warn("util.TextDecoder.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + decode: function (...args) { + console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + } + } + const TextEncoderMock = { + encoding: "[PC preview] unknow encoding", + constructor(...args) { + console.warn("util.TextEncoder.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + encode: function (...args) { + console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const arr = new Uint8Array() + return arr; + }, + encodeInto: function (...args) { + console.warn("TextEncoder.encodeInto interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + } + } + const RationalNumberMock = { + constructor(...args) { + console.warn("util.RationalNumber.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + createRationalFromString: function (...args) { + console.warn("RationalNumber.createRationalFromString​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + compareTo: function (...args) { + console.warn("RationalNumber.compareTo​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + equals: function (...args) { + console.warn("RationalNumber.equals​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + valueOf: function (...args) { + console.warn("RationalNumber.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getCommonDivisor: function (...args) { + console.warn("RationalNumber.getCommonDivisor​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDenominator: function (...args) { + console.warn("RationalNumber.getDenominator​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getNumerator: function (...args) { + console.warn("RationalNumber.getNumerator​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isFinite: function (...args) { + console.warn("RationalNumber.isFinite​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isNaN: function (...args) { + console.warn("RationalNumber.isNaN​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isZero: function (...args) { + console.warn("RationalNumber.isZero​ interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + toString: function (...args) { + console.warn("RationalNumber.toString interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramStringMock; + } + } + const LruBufferMock = { + length: "[PC preview] unknow length", + constructor(...args) { + console.warn("util.LruBuffer.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + updateCapacity: function (...args) { + console.warn("LruBuffer.updateCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + }, + toString: function (...args) { + console.warn("LruBuffer.toString interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getCapacity: function (...args) { + console.warn("LruBuffer.getCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + clear: function (...args) { + console.warn("LruBuffer.clear interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + }, + getCreateCount: function (...args) { + console.warn("LruBuffer.getCreateCount interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getMissCount: function (...args) { + console.warn("LruBuffer.getMissCount interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getRemovalCount: function (...args) { + console.warn("LruBuffer.getRemovalCount interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getMatchCount: function (...args) { + console.warn("LruBuffer.getMatchCount interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getPutCount: function (...args) { + console.warn("LruBuffer.getPutCount interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isEmpty: function (...args) { + console.warn("LruBuffer.isEmpty​ interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + get: function (...args) { + console.warn("LruBuffer.get interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + put: function (...args) { + console.warn("LruBuffer.put interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + values: function (...args) { + console.warn("LruBuffer.values interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + keys: function (...args) { + console.warn("LruBuffer.keys​ interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + remove: function (...args) { + console.warn("LruBuffer.remove interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + afterRemoval: function (...args) { + console.warn("LruBuffer.afterRemoval interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + }, + contains: function (...args) { + console.warn("LruBuffer.contains​ interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + createDefault: function (...args) { + console.warn("LruBuffer.createDefault​ interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + entries: function (...args) { + console.warn("LruBuffer.entries interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + [Symbol.iterator]: function (...args) { + console.warn("LruBuffer.[Symbol.iterator] interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramObjectMock; + } + } + const ScopeComparableMock = { + compareTo: function(...args) { + console.warn("ScopeComparable.compareTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + } + } + const ScopeMock = { + constructor(...args) { + console.warn("util.Scope.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + toString: function (...args) { + console.warn("Scope.toString interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramStringMock; + }, + intersect: function (...args) { + console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeMock; + }, + intersect: function (...args) { + console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeMock; + }, + getUpper: function (...args) { + console.warn("Scope.getUpper interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeTypeMock; + }, + getLower: function (...args) { + console.warn("Scope.getLower interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeTypeMock; + }, + expand: function (...args) { + console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeMock; + }, + expand: function (...args) { + console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeMock; + }, + expand: function (...args) { + console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeMock; + }, + contains: function (...args) { + console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + contains: function (...args) { + console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + clamp: function (...args) { + console.warn("Scope.clamp interface mockecd in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramScopeTypeMock; + } + } + const Base64Mock = { + constructor(...args) { + console.warn("util.Base64.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + encodeSync: function (...args) { + console.warn("Base64.encodeSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const arr = new Uint8Array() + return arr; + }, + encodeToStringSync: function (...args) { + console.warn("Base64.encodeToStringSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + decodeSync: function (...args) { + console.warn("Base64.decodeSync interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const arr = new Uint8Array() + return arr; + }, + encode: function (...args) { + console.warn("Base64.encode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const arr = new Uint8Array() + return new Promise((resolve, reject) => { + resolve(arr); + }) + }, + encodeToString: function (...args) { + console.warn("Base64.encodeToString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + }, + decode: function (...args) { + console.warn("Base64.decode interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const arr = new Uint8Array() + return new Promise((resolve, reject) => { + resolve(arr); + }) + } + } + const TypesMock = { + constructor(...args) { + console.warn("util.Types.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + isAnyArrayBuffer: function (...args) { + console.warn("types.isAnyArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isArrayBufferView: function (...args) { + console.warn("types.isArrayBufferView interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isArgumentsObject: function (...args) { + console.warn("types.isArgumentsObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isArrayBuffer: function (...args) { + console.warn("types.isArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isAsyncFunction: function (...args) { + console.warn("types.isAsyncFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isBigInt64Array: function (...args) { + console.warn("types.isBigInt64Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isBigUint64Array: function (...args) { + console.warn("types.isBigUint64Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isBooleanObject: function (...args) { + console.warn("types.isBooleanObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isBoxedPrimitive: function (...args) { + console.warn("types.isBoxedPrimitive interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isDataView: function (...args) { + console.warn("types.isDataView interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isDate: function (...args) { + console.warn("types.isDate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isExternal: function (...args) { + console.warn("types.isExternal interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isFloat32Array: function (...args) { + console.warn("types.isFloat32Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isFloat64Array: function (...args) { + console.warn("types.isFloat64Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isGeneratorFunction: function (...args) { + console.warn("types.isGeneratorFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isGeneratorObject: function (...args) { + console.warn("types.isGeneratorObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isInt8Array: function (...args) { + console.warn("types.isInt8Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isInt16Array: function (...args) { + console.warn("types.isInt16Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isInt32Array: function (...args) { + console.warn("types.isInt32Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isMap: function (...args) { + console.warn("types.isMap interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isMapIterator: function (...args) { + console.warn("types.isMapIterator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isModuleNamespaceObject: function (...args) { + console.warn("types.isModuleNamespaceObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isNativeError: function (...args) { + console.warn("types.isNativeError interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isNumberObject: function (...args) { + console.warn("types.isNumberObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isPromise: function (...args) { + console.warn("types.isPromise interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isProxy: function (...args) { + console.warn("types.isProxy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isRegExp: function (...args) { + console.warn("types.isRegExp interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isSet: function (...args) { + console.warn("types.isSet interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isSetIterator: function (...args) { + console.warn("types.isSetIterator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isSharedArrayBuffer: function (...args) { + console.warn("types.isSharedArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isStringObject: function (...args) { + console.warn("types.isStringObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isSymbolObject: function (...args) { + console.warn("types.isSymbolObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isTypedArray: function (...args) { + console.warn("types.isTypedArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isUint8Array: function (...args) { + console.warn("types.isUint8Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isUint8ClampedArray: function (...args) { + console.warn("types.isUint8ClampedArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isUint16Array: function (...args) { + console.warn("types.isUint16Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isUint32Array: function (...args) { + console.warn("types.isUint32Array interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isWeakMap: function (...args) { + console.warn("types.isWeakMap interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isWeakSet: function (...args) { + console.warn("types.isWeakSet interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + } + } + return util; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js b/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js index 2aa9eccc..793e7f38 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockArrayList() { const paramArrayList = { - paramAnyMock : '[PC Preview] unknow any', - paramArrayListMock : '[PC Preview] unknow ArrayList' + paramAnyMock: '[PC Preview] unknow any', + paramArrayListMock: '[PC Preview] unknow ArrayList' } const ArrayListClass = class ArrayList { constructor(...args) { @@ -121,27 +121,27 @@ export function mockArrayList() { console.warn("ArrayList.trimToCurrentLength interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }; - } - [Symbol.iterator](){ - console.warn("ArrayList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramArrayList.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("ArrayList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramArrayList.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return ArrayListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js b/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js index 716cf890..807a3021 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js @@ -65,27 +65,27 @@ export function mockDeque() { args[0].call(this, paramDeque.businessErrorMock) } }; - } - [Symbol.iterator]() { - console.warn("Deque.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramDeque.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("Deque.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramDeque.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return DequeClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js index 4b8e75f9..4ffffdf0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js @@ -107,28 +107,28 @@ export function mockHashMap() { }; return IteratorEntriesMock; }; - } - [Symbol.iterator]() { - console.warn("HashMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramHashMap.paramIterMock_K, paramHashMap.paramIterMock_V]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("HashMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramHashMap.paramIterMock_K, paramHashMap.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return HashMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js index 8d9d4ff1..9475eae4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js @@ -74,29 +74,29 @@ export function mockHashSet() { } }; return IteratorEntriesMock; - } - } - [Symbol.iterator]() { - console.warn("HashSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramHashSet.paramAnyMock, paramHashSet.paramAnyMock]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; - } - } }; - return IteratorMock; + this[Symbol.iterator] = function (...args) { + console.warn("HashSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramHashSet.paramAnyMock, paramHashSet.paramAnyMock]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } } } return HashSetClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js index b62ed140..9a869876 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js @@ -144,28 +144,28 @@ export function mockLightWeightMap() { }; return IteratorVMock; }; - } - [Symbol.iterator]() { - console.warn("LightWeightMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramLightWeightMap.paramAnyMock_K, paramLightWeightMap.paramAnyMock_V]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("LightWeightMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramLightWeightMap.paramAnyMock_K, paramLightWeightMap.paramAnyMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return LightWeightMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js index 8108592c..afdb1c42 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockLightWeightSet() { const paramLightWeightSet = { - paramAnyMock : '[PC Preview] unknow any', - paramIterMock_T : '[PC Preview] unknow IterableIterator_t' + paramAnyMock: '[PC Preview] unknow any', + paramIterMock_T: '[PC Preview] unknow IterableIterator_t' } const LightWeightSetClass = class LightWeightSet { constructor(...args) { @@ -119,35 +119,35 @@ export function mockLightWeightSet() { } }; return IteratorEntriesMock; - } + }; this.isEmpty = function (...args) { console.warn("LightWeightSet.isEmpty 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[Symbol.iterator] = function (...args) { + console.warn("LightWeightSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; } } - [Symbol.iterator]() { - console.warn("LightWeightSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; - } - } - }; - return IteratorMock; - } } - return LightWeightSetClass; + return LightWeightSetClass; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js b/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js index 0addf9ff..f3a419f7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js @@ -125,27 +125,27 @@ export function mockLinkedList() { " may be different from that on a real device.") return paramMock.paramArrayMock; }; - } - [Symbol.iterator]() { - console.warn("LinkedList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramLinkedList.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("LinkedList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramLinkedList.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return LinkedListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_List.js b/runtime/main/extend/systemplugin/napi/ohos_util_List.js index 38d5cd69..a2587ceb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_List.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_List.js @@ -125,10 +125,9 @@ export function mockList() { " may be different from that on a real device.") return paramMock.paramBooleanMock; }; - } - [Symbol.iterator]() { - console.warn("List.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + this[Symbol.iterator] = function (...args) { + console.warn("List.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") let index = 0; const IteratorMock = { next: () => { @@ -146,6 +145,7 @@ export function mockList() { } }; return IteratorMock; + } } } return ListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js b/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js index c945a5aa..e8c9a551 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js @@ -106,28 +106,28 @@ export function mockPlainArray() { args[0].call(this, paramMock.businessErrorMock) } }; - } - [Symbol.iterator]() { - console.warn("PlainArray.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramPlainArray.paramIterMock_K, paramPlainArray.paramIterMock_V]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("PlainArray.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramPlainArray.paramIterMock_K, paramPlainArray.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return PlainArrayClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js b/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js index 89eeae03..4edce0f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js @@ -47,27 +47,27 @@ export function mockQueue() { args[0].call(this, paramMock.businessErrorMock) } }; - } - [Symbol.iterator]() { - console.warn("Queue.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramQueue.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("Queue.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramQueue.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return QueueClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js b/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js index 25d07f23..23e52e69 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js @@ -57,27 +57,27 @@ export function mockStack() { args[0].call(this, paramMock.businessErrorMock) } }; - } - [Symbol.iterator]() { - console.warn("Stack.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramStack.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("Stack.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramStack.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return StackClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js index 93d7fa5c..4798cbd2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockTreeMap() { const paramTreeMap = { - paramIterMock_K : '[PC Preview] unknow iterableiterator_k', - paramIterMock_V : '[PC Preview] unknow iterableiterator_v' + paramIterMock_K: '[PC Preview] unknow iterableiterator_k', + paramIterMock_V: '[PC Preview] unknow iterableiterator_v' } const TreeMapClass = class TreeMap { constructor(...args) { @@ -125,28 +125,28 @@ export function mockTreeMap() { }; return IteratorEntriesMock; }; - } - [Symbol.iterator]() { - console.warn("TreeMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - const returnValue = [paramTreeMap.paramIterMock_K, paramTreeMap.paramIterMock_V]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("TreeMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramTreeMap.paramIterMock_K, paramTreeMap.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return TreeMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js index f76b23ec..ee44c088 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js @@ -17,9 +17,9 @@ import { paramMock } from "../utils" export function mockTreeSet() { const paramTreeSet = { - paramAnyMock : '[PC Preview] unknow any', - paramIterMock_TT : '[PC Preview] unknow IterableIterator_tt', - paramIterMock : '[PC Preview] unknow IterableIterator' + paramAnyMock: '[PC Preview] unknow any', + paramIterMock_TT: '[PC Preview] unknow IterableIterator_tt', + paramIterMock: '[PC Preview] unknow IterableIterator' } const TreeSetClass = class TreeSet { constructor(...args) { @@ -100,34 +100,34 @@ export function mockTreeSet() { this.entries = function (...args) { console.warn("TreeSet.entries interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - const IteratorVMock = { - *[Symbol.iterator]() { - yield paramTreeSet.paramIterMock; - } - }; - return IteratorVMock; - }; - } - [Symbol.iterator]() { - console.warn("TreeSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramTreeSet.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramTreeSet.paramIterMock; } - } + }; + return IteratorVMock; }; - return IteratorMock; + this[Symbol.iterator] = function (...args) { + console.warn("TreeSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramTreeSet.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } } } return TreeSetClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js b/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js index 99ee215c..83fcad63 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js @@ -17,9 +17,9 @@ import { paramMock } from "../utils" export function mockVector() { const paramVector = { - paramAnyMock : '[PC Preview] unknow any', - paramVectorMock : '[PC Preview] unknow Vector', - paramIterMock : '[PC Preview] unknow IterableIterator' + paramAnyMock: '[PC Preview] unknow any', + paramVectorMock: '[PC Preview] unknow Vector', + paramIterMock: '[PC Preview] unknow IterableIterator' } const VectorClass = class Vector { @@ -163,27 +163,27 @@ export function mockVector() { console.warn("Vector.copyToArray interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") }; - } - [Symbol.iterator]() { - console.warn("Vector.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - let index = 0; - const IteratorMock = { - next: () => { - if (index < 1) { - index++; - return { - value: paramVector.paramAnyMock, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn("Vector.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramVector.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorMock; + }; + return IteratorMock; + } } } return VectorClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 9adf2ac3..4854b912 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -14,19 +14,27 @@ */ import { paramMock } from "../utils" -import {VolumeMock} from './volume/volumeInfo' export function mockVolumeManager() { + const Volume = { + id: '[PC preview] unknow id', + uuid: '[PC preview] unknow uuid', + description: '[PC preview] unknow description', + removeAble: '[PC preview] unknow removeAble', + path: '[PC preview] unknow path', + state: '[PC preview] unknow state' + }; const volumeManager = { + Volume: Volume, getAllVolumes: function (...args) { console.warn("volumeManager.getAllVolumes 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(VolumeMock)); + args[len - 1].call(this, paramMock.businessErrorMock, new Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(VolumeMock)); + resolve(new Array(Volume)); }) } }, @@ -54,6 +62,66 @@ export function mockVolumeManager() { }) } }, + getVolumeByUuid: function (...args) { + console.warn("volumeManager.getVolumeByUuid 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, Volume); + } else { + return new Promise((resolve, reject) => { + resolve(Volume); + }) + } + }, + getVolumeById: function (...args) { + console.warn("volumeManager.getVolumeById 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, Volume); + } else { + return new Promise((resolve, reject) => { + resolve(Volume); + }) + } + }, + setVolumeDescription: function (...args) { + console.warn("volumeManager.setVolumeDescription 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + format: function (...args) { + console.warn("volumeManager.format 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + partition: function (...args) { + console.warn("volumeManager.partition 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + } } return volumeManager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js b/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js index 3a8e0a14..e8af46e3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js +++ b/runtime/main/extend/systemplugin/napi/ohos_wallpaper.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 @@ -48,6 +48,18 @@ export function mockWallpaper() { }) } }, + getFile: function (...args) { + console.warn("wallpaper.getFile 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, getMinHeight: function (...args) { console.warn("wallpaper.getMinHeight interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_wifi.js b/runtime/main/extend/systemplugin/napi/ohos_wifi.js index 6f38f121..a08836c4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_wifi.js +++ b/runtime/main/extend/systemplugin/napi/ohos_wifi.js @@ -16,7 +16,88 @@ import { paramMock } from "../utils" export function mockWifi() { - const linkedInfoMock = { + const EapMethod = { + EAP_NONE : 0, + EAP_PEAP : 1, + EAP_TLS : 2, + EAP_TTLS : 3, + EAP_PWD : 4, + EAP_SIM : 5, + EAP_AKA : 6, + EAP_AKA_PRIME : 7, + EAP_UNAUTH_TLS : 8, + } + + const Phase2Method = { + PHASE2_NONE : 0, + PHASE2_PAP : 1, + PHASE2_MSCHAP : 2, + PHASE2_MSCHAPV2 : 3, + PHASE2_GTC : 4, + PHASE2_SIM : 5, + PHASE2_AKA : 6, + PHASE2_AKA_PRIME : 7, + } + + const WifiSecurityType = { + WIFI_SEC_TYPE_INVALID : 0, + WIFI_SEC_TYPE_OPEN : 1, + WIFI_SEC_TYPE_WEP : 2, + WIFI_SEC_TYPE_PSK : 3, + WIFI_SEC_TYPE_SAE : 4, + WIFI_SEC_TYPE_EAP : 5, + WIFI_SEC_TYPE_EAP_SUITE_B : 6, + WIFI_SEC_TYPE_OWE : 7, + WIFI_SEC_TYPE_WAPI_CERT : 8, + WIFI_SEC_TYPE_WAPI_PSK : 9, + } + + const IpType = { + STATIC : 0, + DHCP : 1, + UNKNOWN : 2, + } + + const SuppState = { + DISCONNECTED : 0, + INTERFACE_DISABLED : 1, + INACTIVE : 2, + SCANNING : 3, + AUTHENTICATING : 4, + ASSOCIATING : 5, + ASSOCIATED : 6, + FOUR_WAY_HANDSHAKE : 7, + GROUP_HANDSHAKE : 8, + COMPLETED : 9, + UNINITIALIZED : 10, + INVALID : 11, + } + + const ConnState = { + SCANNING : 0, + CONNECTING : 1, + AUTHENTICATING : 2, + OBTAINING_IPADDR : 3, + CONNECTED : 4, + DISCONNECTING : 5, + DISCONNECTED : 6, + UNKNOWN : 7, + } + + const P2pConnectState = { + DISCONNECTED : 0, + CONNECTED : 1, + } + + const P2pDeviceStatus = { + CONNECTED : 0, + INVITED : 1, + FAILED : 2, + AVAILABLE : 3, + UNAVAILABLE : 4, + } + + const WifiLinkedInfo = { ssid: '[PC preview] unknow ssid', bssid: '[PC preview] unknow bssid', networkId: '[PC preview] unknow networkId', @@ -28,77 +109,119 @@ export function mockWifi() { isRestricted: '[PC preview] unknow isRestricted', chload: '[PC preview] unknow chload', snr: '[PC preview] unknow snr', + macType: '[PC preview] unknow macType', macAddress: '[PC preview] unknow macAddress', ipAddress: '[PC preview] unknow ipAddress', - suppState: '[PC preview] unknow suppState', - connState: '[PC preview] unknow connState' + suppState: SuppState.INVALID, + connState: ConnState.DISCONNECTED, } - const ipInfoMock = { + const IpInfo = { ipAddress: '[PC preview] unknow ipAddress', gateway: '[PC preview] unknow gateway', netmask: '[PC preview] unknow netmask', primaryDns: '[PC preview] unknow primaryDns', secondDns: '[PC preview] unknow secondDns', serverIp: '[PC preview] unknow serverIp', - leaseDuration: '[PC preview] unknow leaseDuration' + leaseDuration: '[PC preview] unknow leaseDuration', } - const wifiScanInfoMock = { + const WifiInfoElem = { + eid: '[PC preview] unknow eid', + content: '[PC preview] unknow content', + } + + const WifiScanInfo = { ssid: '[PC preview] unknow ssid', bssid: '[PC preview] unknow bssid', - securityType: '[PC preview] unknow securityType', + capabilities: '[PC preview] unknow capabilities', + securityType: WifiSecurityType.WIFI_SEC_TYPE_OPEN, rssi: '[PC preview] unknow rssi', band: '[PC preview] unknow band', frequency: '[PC preview] unknow frequency', + channelWidth: '[PC preview] unknow channelWidth', + centerFrequency0: '[PC preview] unknow centerFrequency0', + centerFrequency1: '[PC preview] unknow centerFrequency1', + infoElems: [WifiInfoElem], timestamp: '[PC preview] unknow timestamp', } - const wifiDeviceConfigMock = { + const IpConfig = { + ipAddress: '[PC preview] unknow ipAddress', + gateway: '[PC preview] unknow gateway', + dnsServers: [paramMock.paramNumberMock], + domains: [paramMock.paramStringMock], + } + + const WifiEapConfig = { + eapMethod: EapMethod.EAP_NONE, + phase2Method: Phase2Method.PHASE2_NONE, + identity: '[PC preview] unknow identity', + anonymousIdentity: '[PC preview] unknow anonymousIdentity', + password: '[PC preview] unknow password', + caCertAliases: '[PC preview] unknow caCertAliases', + caPath: '[PC preview] unknow caPath', + clientCertAliases: '[PC preview] unknow clientCertAliases', + altSubjectMatch: '[PC preview] unknow altSubjectMatch', + domainSuffixMatch: '[PC preview] unknow domainSuffixMatch', + realm: '[PC preview] unknow realm', + plmn: '[PC preview] unknow plmn', + eapSubId: '[PC preview] unknow eapSubId', + } + + const WifiDeviceConfig = { ssid: '[PC preview] unknow ssid', bssid: '[PC preview] unknow bssid', preSharedKey: '[PC preview] unknow preSharedKey', isHiddenSsid: '[PC preview] unknow isHiddenSsid', - securityType: '[PC preview] unknow securityType', + securityType: WifiSecurityType.WIFI_SEC_TYPE_OPEN, + creatorUid: '[PC preview] unknow creatorUid', + disableReason: '[PC preview] unknow disableReason', + netId: '[PC preview] unknow netId', + randomMacType: '[PC preview] unknow randomMacType', + randomMacAddr: '[PC preview] unknow randomMacAddr', + ipType: IpType.DHCP, + staticIp: IpConfig, + eapConfig: WifiEapConfig, } - const wifiHotspotConfigMock = { + const WifiHotspotConfig = { ssid: '[PC preview] unknow ssid', - securityType: '[PC preview] unknow securityType', + securityType: WifiSecurityType.WIFI_SEC_TYPE_OPEN, band: '[PC preview] unknow band', preSharedKey: '[PC preview] unknow preSharedKey', maxConn: '[PC preview] unknow maxConn', } - const wifiStationInfoMock = { + const WifiStationInfo = { name: '[PC preview] unknow name', macAddress: '[PC preview] unknow macAddress', ipAddress: '[PC preview] unknow ipAddress', } - const p2pLinkedInfoMock = { - connectState: '[PC preview] unknow connectState', + const P2pLinkedInfo = { + connectState: P2pConnectState.DISCONNECTED, isGroupOwner: '[PC preview] unknow isGroupOwner', groupOwnerAddr: '[PC preview] unknow groupOwnerAddr', } - const WifiP2pDeviceMock = { + const WifiP2pDevice = { deviceName: '[PC preview] unknow deviceName', deviceAddress: '[PC preview] unknow deviceAddress', primaryDeviceType: '[PC preview] unknow primaryDeviceType', - deviceStatus: '[PC preview] unknow deviceStatus', + deviceStatus: P2pDeviceStatus.UNAVAILABLE, groupCapabilitys: '[PC preview] unknow groupCapabilitys', } - const p2pGroupInfoMock = { + const P2pGroupInfo = { isP2pGo: '[PC preview] unknow connectState', - ownerInfo: WifiP2pDeviceMock, + ownerInfo: WifiP2pDevice, passphrase: '[PC preview] unknow passphrase', interface: '[PC preview] unknow interface', groupName: '[PC preview] unknow groupName', networkId: '[PC preview] unknow networkId', frequency: '[PC preview] unknow frequency', - clientDevices: [WifiP2pDeviceMock], + clientDevices: [WifiP2pDevice], goIpAddress: '[PC preview] unknow goIpAddress', } @@ -132,14 +255,20 @@ export function mockWifi() { " 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, [wifiScanInfoMock]) + args[len - 1].call(this, paramMock.businessErrorMock, [WifiScanInfo]) } else { return new Promise((resolve) => { - resolve([wifiScanInfoMock]) + resolve([WifiScanInfo]) }) } }, + getScanInfosSync: function (...args) { + console.warn("wifi.getScanInfosSync interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return [WifiScanInfo]; + }, + addDeviceConfig: function (...args) { console.warn("wifi.addDeviceConfig interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -153,6 +282,70 @@ export function mockWifi() { } }, + addUntrustedConfig: function (...args) { + console.warn("wifi.addUntrustedConfig 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + + removeUntrustedConfig: function (...args) { + console.warn("wifi.removeUntrustedConfig 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.paramBooleanMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock) + }) + } + }, + + addCandidateConfig: function (...args) { + console.warn("wifi.addCandidateConfig 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) + }) + } + }, + + removeCandidateConfig: function (...args) { + console.warn("wifi.removeCandidateConfig 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + + getCandidateConfigs: function (...args) { + console.warn("wifi.getCandidateConfigs interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return [WifiDeviceConfig]; + }, + + connectToCandidateConfig: function (...args) { + console.warn("wifi.connectToCandidateConfig interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return; + }, + connectToNetwork: function (...args) { console.warn("wifi.connectToNetwork interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") @@ -182,10 +375,10 @@ export function mockWifi() { " 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, linkedInfoMock) + args[len - 1].call(this, paramMock.businessErrorMock, WifiLinkedInfo) } else { return new Promise((resolve) => { - resolve(linkedInfoMock) + resolve(WifiLinkedInfo) }) } }, @@ -217,7 +410,7 @@ export function mockWifi() { getIpInfo: function (...args) { console.warn("wifi.getIpInfo interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return ipInfoMock; + return IpInfo; }, getCountryCode: function (...args) { @@ -241,7 +434,7 @@ export function mockWifi() { getDeviceConfigs: function (...args) { console.warn("wifi.getDeviceConfigs interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return [wifiDeviceConfigMock]; + return [WifiDeviceConfig]; }, updateNetwork: function (...args) { @@ -280,6 +473,12 @@ export function mockWifi() { return paramMock.paramBooleanMock; }, + isHotspotDualBandSupported: function (...args) { + console.warn("wifi.isHotspotDualBandSupported interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isHotspotActive: function (...args) { console.warn("wifi.isHotspotActive interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") @@ -295,13 +494,13 @@ export function mockWifi() { getHotspotConfig: function (...args) { console.warn("wifi.getHotspotConfig interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return wifiHotspotConfigMock; + return WifiHotspotConfig; }, getStations: function (...args) { console.warn("wifi.getStations interface mocked in the Previewer." + " How this interface works on the Previewer may be different from that on a real device.") - return [wifiStationInfoMock]; + return [WifiStationInfo]; }, on: function (...args) { @@ -319,10 +518,10 @@ export function mockWifi() { "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, p2pLinkedInfoMock) + args[len - 1].call(this, paramMock.businessErrorMock, P2pLinkedInfo) } else { return new Promise((resolve) => { - resolve(p2pLinkedInfoMock) + resolve(P2pLinkedInfo) }) } }, @@ -332,23 +531,36 @@ export function mockWifi() { " 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, p2pGroupInfoMock) + args[len - 1].call(this, paramMock.businessErrorMock, P2pGroupInfo) } else { return new Promise((resolve) => { - resolve(p2pGroupInfoMock) + resolve(P2pGroupInfo) }) } }, - getP2pDevices: function (...args) { - console.warn("wifi.getP2pDevices interface mocked in the Previewer. How this interface works on the Previewer" + + getP2pPeerDevices: function (...args) { + console.warn("wifi.getP2pPeerDevices 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, [WifiP2pDeviceMock]) + args[len - 1].call(this, paramMock.businessErrorMock, [WifiP2pDevice]) } else { return new Promise((resolve) => { - resolve([WifiP2pDeviceMock]) + resolve([WifiP2pDevice]) + }) + } + }, + + getP2pLocalDevice: function (...args) { + console.warn("wifi.getP2pLocalDevice 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, WifiP2pDevice) + } else { + return new Promise((resolve) => { + resolve(WifiP2pDevice) }) } }, @@ -395,6 +607,19 @@ export function mockWifi() { return paramMock.paramBooleanMock; }, + getP2pGroups: function (...args) { + console.warn("wifi.getP2pGroups 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, [P2pGroupInfo]) + } else { + return new Promise((resolve) => { + resolve([P2pGroupInfo]) + }) + } + }, + setDeviceName: function (...args) { console.warn("wifi.setDeviceName interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_wifiext.js b/runtime/main/extend/systemplugin/napi/ohos_wifiext.js new file mode 100644 index 00000000..2a4c71d5 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_wifiext.js @@ -0,0 +1,71 @@ +/* + * 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 mockWifiExt() { + const PowerModel = { + SLEEPING : 0, + GENERAL : 1, + THROUGH_WALL : 2, + } + + const wifiext = { + enableHotspot: function (...args) { + console.warn("wifiext.enableHotspot interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + disableHotspot: function (...args) { + console.warn("wifiext.disableHotspot interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + + getSupportedPowerModel: function (...args) { + console.warn("wifiext.getSupportedPowerModel 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, [PowerModel.GENERAL]) + } else { + return new Promise((resolve) => { + resolve([PowerModel.GENERAL]) + }) + } + }, + + getPowerModel: function (...args) { + console.warn("wifiext.getPowerModel 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, PowerModel.GENERAL) + } else { + return new Promise((resolve) => { + resolve(PowerModel.GENERAL) + }) + } + }, + + setPowerModel: function (...args) { + console.warn("wifiext.setPowerModel interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + } + return wifiext; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_worker.js b/runtime/main/extend/systemplugin/napi/ohos_worker.js index c522bd73..f4a06d4e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_worker.js +++ b/runtime/main/extend/systemplugin/napi/ohos_worker.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -16,71 +16,153 @@ import { paramMock } from "../utils" export function mockWorker() { - const result = { - Worker: function (params) { - console.warn("worker.Worker interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return WorkerMock; + const WorkerOptionsMock = { + type: '[PC preview] unknow type', + name: '[PC preview] unknow name', + shared: '[PC preview] unknow shared' + }; + + const EventMock = { + type: '[PC preview] unknow type', + timeStamp: '[PC preview] unknow timeStamp' + }; + + const ErrorEventMock = { + message: '[PC preview] unknow message', + filename: '[PC preview] unknow filename', + lineno: '[PC preview] unknow lineno', + colno: '[PC preview] unknow colno', + error: '[PC preview] unknow error' + }; + + const MessageEventMock = { + data: '[PC preview] unknow data' + }; + + const PostMessageOptionsMock = { + transfer:'[PC preview] unknow transfer' + }; + + const EventTargetMock = { + addEventListener : function (...args) { + console.warn('PostMessageOptions.addEventListener interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + }, + dispatchEvent : function (...args) { + console.warn('PostMessageOptions.dispatchEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return paramMock.paramBooleanMock; + }, + removeEventListener : function (...args) { + console.warn("PostMessageOptions.removeEventListener interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + removeAllListener : function (...args) { + console.warn("PostMessageOptions.removeAllListener interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); } - } - const WorkerMock = { - postMessage: function (...args) { - console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - terminate: function (...args) { - console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - on: function (...args) { - console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - once: function (...args) { - console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - off: function (...args) { - console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - addEventListener: function (...args) { - console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - dispatchEvent: function (...args) { - console.warn("Worker.dispatchEvent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - removeEventListener: function (...args) { - console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - removeAllListener: function (...args) { - console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - onmessage: function (...args) { - console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - onmessageerror: function (...agrs) { - console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, + }; + + const WorkerGlobalScopeMock = { + name: '[PC preview] unknow name', onerror: function (...args) { - console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("WorkerGlobalScope.onerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); }, - onclose: function (...args) { - console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + self: '[PC preview] unknow self' + }; + + const DedicatedWorkerGlobalScopeMock = { + onmessage: function (...args) { + console.warn("DedicatedWorkerGlobalScope.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); }, - onexit: function (...args) { - console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + onmessageerror: function (...args) { + console.warn("DedicatedWorkerGlobalScope.onmessageerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + close : function (...args) { + console.warn("DedicatedWorkerGlobalScope.close interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + postMessage : function (...args) { + console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + postMessage : function (...args) { + console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); } - } - return result; -} \ No newline at end of file + }; + + const WorkerClass = class Worker { + constructor(...args){ + console.warn('Worker.constructor interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + this.postMessage = function (...args) { + console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.terminate = function (...args) { + console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.on = function (...args) { + console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.once = function (...args) { + console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.off = function (...args) { + console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.addEventListener = function (...args) { + console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.dispatchEvent = function (...args) { + console.warn("Worker.dispatchEvent 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.removeEventListener = function (...args) { + console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.removeAllListener = function (...args) { + console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.onmessage = function (...args) { + console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onmessageerror = function (...agrs) { + console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.onerror = function (...args) { + console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onclose = function (...args) { + console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onexit = function (...args) { + console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } + } + }; + + const workerMock = { + Worker : WorkerClass, + parentPort : '[PC preview] unknow parentPort' + }; + return workerMock; +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_xml.js b/runtime/main/extend/systemplugin/napi/ohos_xml.js index 531e9964..772d814e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_xml.js +++ b/runtime/main/extend/systemplugin/napi/ohos_xml.js @@ -1,80 +1,168 @@ -/* - * 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 { paramMock } from "../utils" - -export function mockXml() { - const result = { - XmlSerializer: function (...args) { - console.warn("xml.XmlSerializer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return XmlSerializerMock; - }, - XmlPullParser: function (...args) { - console.warn("xml.XmlPullParser interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return XmlPullParserMock; - } - } - const XmlSerializerMock = { - setAttributes: function (...args) { - console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - addEmptyElement: function (...args) { - console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setDeclaration: function (...args) { - console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - startElement: function (...args) { - console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - endElement: function (...args) { - console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setNamespace: function (...args) { - console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setCommnet: function (...args) { - console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setCData: function (...args) { - console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setText: function (...args) { - console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setDocType: function (...args) { - console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } - } - const XmlPullParserMock = { - parse: function (...args) { - console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } - } - return result; -} +/* + * 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 mockXml() { + const XmlSerializerClass = class XmlSerializer { + constructor(...args) { + console.warn("XmlSerializer.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.setAttributes = function (...args) { + console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.addEmptyElement = function (...args) { + console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setDeclaration = function (...args) { + console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.startElement = function (...args) { + console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.endElement = function (...args) { + console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setNamespace = function (...args) { + console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setComment = function (...args) { + console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setCData = function (...args) { + console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setText = function (...args) { + console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setDocType = function (...args) { + console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } + } + }; + + const XmlPullParserClass = class XmlPullParser { + constructor(...args) { + console.warn("XmlPullParser.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.parse = function (...args) { + console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } + } + }; + + const xmlMock = { + XmlSerializer : XmlSerializerClass, + XmlPullParser : XmlPullParserClass, + + EventType : { + START_DOCUMENT: 0, + END_DOCUMENT: 1, + START_TAG: 2, + END_TAG: 3, + TEXT: 4, + CDSECT: 5, + COMMENT: 6, + DOCDECL: 7, + INSTRUCTION: 8, + ENTITY_REFERENCE: 9, + WHITESPACE: 10 + } + }; + + const ParseInfoMock = { + getColumnNumber: function () { + console.warn("ParseInfo.getColumnNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDepth: function () { + console.warn("ParseInfo.getDepth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getLineNumber: function () { + console.warn("ParseInfo.getLineNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getName: function () { + console.warn("ParseInfo.getName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getNamespace: function () { + console.warn("ParseInfo.getNamespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getPrefix: function () { + console.warn("ParseInfo.getPrefix interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getText: function () { + console.warn("ParseInfo.getText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + isEmptyElementTag: function () { + console.warn("ParseInfo.isEmptyElementTag interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isWhitespace: function () { + console.warn("ParseInfo.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getAttributeCount: function () { + console.warn("ParseInfo.getAttributeCount 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 ParseOptionsMock = { + supportDoctype: '[PC preview] unknow supportDoctype', + ignoreNameSpace: '[PC preview] unknow ignoreNameSpace', + tagValueCallbackFunction: function(...args) { + console.warn("ParseOptions.tagValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + attributeValueCallbackFunction: function(...args) { + console.warn("ParseOptions.attributeValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + tokenValueCallbackFunction: function(...args) { + console.warn("ParseOptions.tokenValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + } + }; + return xmlMock; +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_zlib.js b/runtime/main/extend/systemplugin/napi/ohos_zlib.js index 3ad3a5d7..d0a632c1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_zlib.js +++ b/runtime/main/extend/systemplugin/napi/ohos_zlib.js @@ -13,57 +13,52 @@ * limitations under the License. */ export const MemLevel = { - MEM_LEVEL_MIN: 1, - MEM_LEVEL_MAX: 9, - MEM_LEVEL_DEFAULT: 8 + MEM_LEVEL_MIN: 1, + MEM_LEVEL_MAX: 9, + MEM_LEVEL_DEFAULT: 8 }; export const ErrorCode = { - ERROR_CODE_OK: 0, - ERROR_CODE_ERRNO: -1, + ERROR_CODE_OK: 0, + ERROR_CODE_ERRNO: -1, }; export const CompressLevel = { - COMPRESS_LEVEL_NO_COMPRESSION: 0, - COMPRESS_LEVEL_BEST_SPEED: 1, - COMPRESS_LEVEL_BEST_COMPRESSION: 9, - COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 + COMPRESS_LEVEL_NO_COMPRESSION: 0, + COMPRESS_LEVEL_BEST_SPEED: 1, + COMPRESS_LEVEL_BEST_COMPRESSION: 9, + COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1 }; export const CompressStrategy = { - COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, - COMPRESS_STRATEGY_FILTERED: 1, - COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, - COMPRESS_STRATEGY_RLE: 3, - COMPRESS_STRATEGY_FIXED: 4 + COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0, + COMPRESS_STRATEGY_FILTERED: 1, + COMPRESS_STRATEGY_HUFFMAN_ONLY: 2, + COMPRESS_STRATEGY_RLE: 3, + COMPRESS_STRATEGY_FIXED: 4 }; export const Options = { - level: CompressLevel, - memLevel: MemLevel, - strategy: CompressStrategy, + level: CompressLevel, + memLevel: MemLevel, + strategy: CompressStrategy, }; -export function mockZlib() { - const zlib = { - ErrorCode, - MemLevel, - CompressLevel, - CompressStrategy, - Options: { - level: CompressLevel, - memLevel: MemLevel, - strategy: CompressStrategy, - }, - - zipFile(...args) { - console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve() - }) - }, +export function mockZlib() { + const zlib = { + ErrorCode, + MemLevel, + CompressLevel, + CompressStrategy, + Options, + zipFile: function(...args) { + console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve) => { + resolve(); + }) + }, - unzipFile(...args) { - console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve() - }) + unzipFile: function(...args) { + console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve) => { + resolve(); + }) + } } - } - return zlib; + return zlib; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js index d3acf68f..6c6b07a0 100644 --- a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js +++ b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js @@ -17,5 +17,5 @@ export const TriggerInfo = { code: '[PC preview] unknow code', want: new WantClass(), permission: '[PC preview] unknow permission', - extraInfo: {}, -}; \ No newline at end of file + extraInfo: {"key": "unknown any"}, +}; diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js index c0e91b07..a968baca 100644 --- a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js +++ b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js @@ -20,5 +20,5 @@ export const WantAgentInfo = { operationType: OperationType, requestCode: '[PC preview] unknow requestCode', wantAgentFlags: [WantAgentFlags], - extraInfo: {}, -}; \ No newline at end of file + extraInfo: {"key": "unknown any"}, +}; diff --git a/runtime/main/extend/systemplugin/ohos/pasteboard.js b/runtime/main/extend/systemplugin/ohos/pasteboard.js deleted file mode 100644 index 92111e88..00000000 --- a/runtime/main/extend/systemplugin/ohos/pasteboard.js +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 { paramMock } from "../utils"; - -export function mockPasteBoard() { - const PasteDataMock = { - getPrimaryText: function () { - console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow primarytext" - }, - addHtmlRecord: function () { - console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addWantRecord: function () { - console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addRecord: function () { - console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addTextRecord: function () { - console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addUriRecord: function () { - console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - getMimeTypes: function () { - console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device."); - let mimeTypes = new Array(); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); - return mimeTypes; - }, - getPrimaryHtml: function () { - console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryHtml" - }, - getPrimaryWant: function () { - console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryWant" - }, - getPrimaryMimeType: function () { - console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryMimeType" - }, - getPrimaryUri: function () { - console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryUri" - }, - getProperty: function () { - console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return PasteDataPropertyMock; - }, - getRecordAt: function () { - console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - getRecordCount: function () { - console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getRecordCount" - }, - getTag: function () { - console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getTag" - }, - hasMimeType: function () { - console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow hasMimeType" - }, - removeRecordAt: function () { - console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow removeRecordAt" - }, - replaceRecordAt: function () { - console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow replaceRecordAt" - } - } - const PasteDataRecordMock = { - htmlText: '[PC preview] unknow htmlText', - want: '[PC preview] unknow want', - mimeType: '[PC preview] unknow mimeType', - plainText: '[PC preview] unknow plainText', - uri: '[PC preview] unknow uri', - convertToText: function (...args) { - console.warn("PasteDataRecord.convertToText 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.paramStringMock) - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - } - } - const PasteDataPropertyMock = { - additions: '[PC preview] unknow additions', - mimeTypes: new Array('[PC preview] unknow MIMETYPE_TEXT_PLAIN'), - tag: '[PC preview] unknow tag', - timestamp: '[PC preview] unknow timestamp', - localOnly: '[PC preview] unknow localOnly', - } - const SystemPasteboardMock = { - on: function (...args) { - console.warn("SystemPasteboard.on 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') { - if (args[0] == 'update') { - args[len - 1].call(this); - } - } - }, - off: function (...args) { - console.warn("SystemPasteboard.off 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') { - if (args[0] == 'update') { - args[len - 1].call(this); - } - } - }, - clear: function (...args) { - console.warn("SystemPasteboard.clear 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) - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - }, - hasPasteData: function (...args) { - console.warn("SystemPasteboard.hasPasteData 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.paramBooleanMock) - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getPasteData: function (...args) { - console.warn("SystemPasteboard.getPasteData 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, PasteDataMock) - } else { - return new Promise((resolve, reject) => { - resolve(PasteDataMock); - }) - } - }, - setPasteData: function (...args) { - console.warn("SystemPasteboard.setPasteData 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); - } else { - return new Promise((resolve, reject) => { - resolve(); - }) - } - } - } - global.ohosplugin.pasteboard = { - MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM', - MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML', - MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', - MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN', - MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI', - createPlainTextData: function () { - console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createHtmlData: function () { - console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createUriData: function () { - console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createWantData: function () { - console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createHtmlTextRecord: function () { - console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createWantRecord: function () { - console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createUriRecord: function () { - console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createPlainTextRecord: function () { - console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - getSystemPasteboard: function () { - console.warn("pasteboard.getSystemPasteboard interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return SystemPasteboardMock; - } - } -} diff --git a/runtime/preparation/init.ts b/runtime/preparation/init.ts index 289fee83..5e923af8 100644 --- a/runtime/preparation/init.ts +++ b/runtime/preparation/init.ts @@ -201,5 +201,7 @@ const ComponentsInfo: components[] = [ { 'methods': ['takePhoto', 'startRecorder', 'closeRecorder', 'scrollTo', 'createIntersectionObserver', 'addChild'], 'type': 'camera' - } + }, + { 'methods': ['getInspector'], 'type': 'toolbar' }, + { 'methods': ['getInspector'], 'type': 'toolbar-item' } ];