From e7c6617bc13453da7a97adda907beee33af23c66 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Fri, 1 Jul 2022 17:16:59 +0800 Subject: [PATCH 001/103] =?UTF-8?q?=E4=B8=BA=E6=97=A0=E9=9A=9C=E7=A2=8D?= =?UTF-8?q?=E7=9A=84d.ts=E6=B7=BB=E5=8A=A0mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- .../main/extend/systemplugin/accessibility.js | 136 ++++---- .../systemplugin/napi/accessibilityConfig.js | 311 ++++++++++++++++++ .../napi/accessibilityExtensionAbility.js | 59 ++++ .../napi/accessibilityExtensionContext.js | 188 +++++++++++ 4 files changed, 634 insertions(+), 60 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/accessibilityConfig.js create mode 100644 runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js create mode 100644 runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/accessibility.js index cb2bbe10..8f3e00d9 100644 --- a/runtime/main/extend/systemplugin/accessibility.js +++ b/runtime/main/extend/systemplugin/accessibility.js @@ -16,84 +16,93 @@ import { paramMock } from './utils'; export function mockAccessibility() { - const AbilityTypeMock = { - audible: 'audible', - generic: 'generic', - haptic: 'haptic', - spoken: 'spoken', - visual: 'visual' - }; + const AbilityTypeMock = '[PC Preview] unknown AbilityType'; - const CapabilityMock = { - retrieve: 'retrieve', - touchGuide: 'touchGuide', - keyEventObserver: 'keyEventObserver', - zoom: 'zoom', - gesture: 'gesture' - }; + const CapabilityMock = '[PC Preview] unknown Capability'; - const EventTypeMock = '[PC Preview] unknow EventType'; + const EventTypeMock = '[PC Preview] unknown EventType'; const AccessibilityAbilityInfoMock = { - id: '[PC Preview] unknow id', - name: '[PC Preview] unknow name', - bundleName: '[PC Preview] unknow bundleName', + 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] unknow description', + description: '[PC Preview] unknown description', eventTypes: [EventTypeMock] }; - const CaptionsFontEdgeTypeMock = '[PC Preview] unknow CaptionsFontEdgeType'; + const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType'; - const CaptionsFontFamilyMock = '[PC Preview] unknow CaptionsFontFamily'; + const CaptionsFontFamilyMock = '[PC Preview] unknown 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' + 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] unknow enabled', - style: [CaptionStyleMock] + enabled: '[PC Preview] unknown enabled', + style: CaptionStyleMock, + 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, CaptionStyleMock); + } + } + }, + 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, CaptionStyleMock); + } + } + }, }; - const WindowUpdateTypeMock = '[PC Preview] unknow WindowUpdateType'; + const WindowUpdateTypeMock = '[PC Preview] unknown WindowUpdateType'; - const ActionMock = '[PC Preview] unknow Action'; + const ActionMock = '[PC Preview] unknown Action'; + + const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit'; - 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.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] 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'; + this.contents = '[PC Preview] unknown contents'; + 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 StateEventMock = { - eventType: '[PC Preview] unknow eventType', - state: '[PC Preview] unknow state', - description: '[PC Preview] unknow description' - }; - global.systemplugin.accessibility = { + const accessibility = { EventInfo: EventInfoClass, isOpenAccessibility: function (...args) { console.warn('accessibility.isOpenAccessibility interface mocked in the Previewer. How this interface works on the' + @@ -123,14 +132,26 @@ export function mockAccessibility() { 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); + 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 > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock); + 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) { @@ -157,17 +178,12 @@ export function mockAccessibility() { }); } }, - getCaptionsManager: function (...args) { + 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.'); - 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]); - }); - } + return CaptionsManagerMock; } }; + + return accessibility; } diff --git a/runtime/main/extend/systemplugin/napi/accessibilityConfig.js b/runtime/main/extend/systemplugin/napi/accessibilityConfig.js new file mode 100644 index 00000000..0993dbb0 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/accessibilityConfig.js @@ -0,0 +1,311 @@ +/* + * 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 DaltonizationColorFilterMock = '[PC Preview] unknown DaltonizationColorFilter'; + + const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily'; + + const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType'; + + const CaptionStyleMock = { + 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 configBoolMock = { + set: function (...args) { + console.warn('accessibilityConfig configBoolMock.set interface mocked 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(); + }); + } + }, + get: function (...args) { + console.warn('accessibilityConfig configBoolMock.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, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig configBoolMock.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') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + }, + off: function (...args) { + console.warn('accessibilityConfig configBoolMock.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') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } + }, + }; + + const daltonizationColorFilterMock = { + set: function (...args) { + console.warn('accessibilityConfig daltonizationColorFilterMock.set interface mocked 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(paramMock.businessErrorMock); + }); + } + }, + get: function (...args) { + console.warn('accessibilityConfig daltonizationColorFilterMock.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, DaltonizationColorFilterMock); + } else { + return new Promise((resolve, reject) => { + resolve(DaltonizationColorFilterMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig highContrastText.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') { + args[len - 1].call(this, DaltonizationColorFilterMock); + } + }, + off: function (...args) { + console.warn('accessibilityConfig highContrastText.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') { + args[len - 1].call(this, DaltonizationColorFilterMock); + } + }, + }; + + const configNumberBlock = { + set: function (...args) { + console.warn('accessibilityConfig configNumberBlock.set interface mocked 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(paramMock.businessErrorMock); + }); + } + }, + get: function (...args) { + console.warn('accessibilityConfig configNumberBlock.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, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig configNumberBlock.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') { + args[len - 1].call(this, paramMock.paramNumberMock); + } + }, + off: function (...args) { + console.warn('accessibilityConfig configNumberBlock.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') { + args[len - 1].call(this, paramMock.paramNumberMock); + } + }, + }; + + const configShortkeyTargetBlock = { + set: function (...args) { + console.warn('accessibilityConfig configShortkeyTargetBlock.set interface mocked 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(paramMock.businessErrorMock); + }); + } + }, + get: function (...args) { + console.warn('accessibilityConfig configShortkeyTargetBlock.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, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig configNumbconfigShortkeyTargetBlockerBlock.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') { + args[len - 1].call(this, paramMock.paramStringMock); + } + }, + off: function (...args) { + console.warn('accessibilityConfig configShortkeyTargetBlock.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') { + args[len - 1].call(this, paramMock.paramStringMock); + } + }, + }; + + const captionStyleMock = { + set: function (...args) { + console.warn('accessibilityConfig captionStyleMock.set interface mocked 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(paramMock.businessErrorMock); + }); + } + }, + get: function (...args) { + console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); + } else { + return new Promise((resolve, reject) => { + resolve(CaptionStyleMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig captionStyleMock.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') { + args[len - 1].call(this, CaptionStyleMock); + } + }, + off: function (...args) { + console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); + } + }, + }; + + 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, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + 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, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }); + } + }, + on: function (...args) { + console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { + args[len - 1].call(this); + } + } + }, + off: function (...args) { + console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { + args[len - 1].call(this); + } + } + }, + highContrastText: configBoolMock, + invertColor: configBoolMock, + daltonizationColorFilter: daltonizationColorFilterMock, + contentTimeout: configNumberBlock, + animationOff: configBoolMock, + brightnessDiscount: configNumberBlock, + screenMagnifier: configBoolMock, + audioMono: configBoolMock, + audioBalance: configBoolMock, + mouseKey: configNumberBlock, + mouseAutoClick: configNumberBlock, + shortkey: configBoolMock, + shortkey_target: configShortkeyTargetBlock, + caption: configBoolMock, + captionStyle: captionStyleMock, + }; + return config; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js b/runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js new file mode 100644 index 00000000..f388afbd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.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 { mockAccessibilityExtensionContext } from './accessibilityExtensionContext'; + +export function mockAccessibilityExtensionAbility() { + const accessibilityEventMock = { + eventType: '[PC Preview] unknown eventType', + target: '[PC Preview] unknown target', + timeStamp: '[PC Preview] unknown timeStamp', + notificationContent: '[PC Preview] unknown notificationContent' + }; + + const accessibilityExtensionAbilityClass = class accessibilityExtensionAbility { + context = null; + onConnect = null; + onDisconnect = null; + onAccessibilityEvent = null; + onKeyEvent = null; + constructor() { + this.context = mockAccessibilityExtensionContext(); + 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.'); + return; + }; + 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.'); + return; + }; + 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.'); + return; + }; + 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; + }; + } + }; + + return new accessibilityExtensionAbilityClass(); +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js new file mode 100644 index 00000000..00071f7e --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js @@ -0,0 +1,188 @@ +/* + * 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 './application/abilityContext' + +export function mockAccessibilityExtensionContext() { + const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; + + const RectMock = { + left: '[PC Preview] unknown left', + top: '[PC Preview] unknown top', + width: '[PC Preview] unknown width', + height: '[PC Preview] unknown height' + }; + + const ActionNameMock = '[PC Preview] unknown action name'; + + const ElementAttributeValueMock = '[PC Preview] unknown element attribute value'; + + const AccessibilityElementMock = { + 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.'); + 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.'); + switch (args[0]) { + case 'rect': + case 'screenRect': + return new Promise((resolve, reject) => { + resolve(RectMock); + }); + case 'parent': + case 'rootElement': + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + case 'children': + return new Promise((resolve, reject) => { + resolve([AccessibilityElementMock]); + }); + default: + return new Promise((resolve, reject) => { + resolve(ElementAttributeValueMock); + }); + } + }, + 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.'); + return new Promise((resolve, reject) => { + resolve([ActionNameMock]); + }); + }, + 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.'); + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + }, + findElement: 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.'); + if (args[0] === 'content') { + return new Promise((resolve, reject) => { + resolve([AccessibilityElementMock]); + }); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + } + }, + }; + + const accessibilityExtensionContextClass = class accessibilityExtensionContext extends ExtensionContextClass { + setEventTypeFilter = null; + setTargetBundleName = null; + getFocusElement = null; + getWindowRootElement = null; + getWindows = null; + executeCommonAction = null; + gestureInject = null; + constructor() { + 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, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }; + + 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, paramMock.paramBooleanMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } + }; + + 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, AccessibilityElementMock); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + } + }; + + 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, AccessibilityElementMock); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + } + }; + + 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, [AccessibilityElementMock]); + } else { + return new Promise((resolve, reject) => { + resolve([AccessibilityElementMock]); + }); + } + }; + + this.gestureInject = function (...args) { + console.warn('accessibilityExtensionContext.gestureInject interface mocked 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 new accessibilityExtensionContextClass(); +} \ No newline at end of file From 3423d2a8d86bd136af530d5efe84927fc1842c63 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Tue, 5 Jul 2022 10:34:51 +0800 Subject: [PATCH 002/103] =?UTF-8?q?=E4=B8=BA=E6=97=A0=E9=9A=9C=E7=A2=8D?= =?UTF-8?q?=E7=9A=84d.ts=E6=B7=BB=E5=8A=A0mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- .../main/extend/systemplugin/accessibility.js | 57 ++++++---- .../napi/accessibilityExtensionContext.js | 103 +++++++++++++----- ...Config.js => ohos_accessibility_Config.js} | 98 ++++++++--------- ...lication_AccessibilityExtensionAbility.js} | 16 +-- 4 files changed, 166 insertions(+), 108 deletions(-) mode change 100644 => 100755 runtime/main/extend/systemplugin/accessibility.js mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js rename runtime/main/extend/systemplugin/napi/{accessibilityConfig.js => ohos_accessibility_Config.js} (72%) mode change 100644 => 100755 rename runtime/main/extend/systemplugin/napi/{accessibilityExtensionAbility.js => ohos_application_AccessibilityExtensionAbility.js} (75%) mode change 100644 => 100755 diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/accessibility.js old mode 100644 new mode 100755 index 8f3e00d9..7ef3527b --- a/runtime/main/extend/systemplugin/accessibility.js +++ b/runtime/main/extend/systemplugin/accessibility.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 @@ -50,8 +50,8 @@ export function mockAccessibility() { enabled: '[PC Preview] unknown enabled', style: CaptionStyleMock, 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.'); + 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') { @@ -62,8 +62,8 @@ export function mockAccessibility() { } }, 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.'); + 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') { @@ -82,9 +82,24 @@ export function mockAccessibility() { const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit'; const EventInfoClass = class EventInfo { + type = null; + windowUpdateType = null; + bundleName = null; + componentType = null; + pageId = null; + description = null; + triggerAction = null; + textMoveUnit = null; + contents = null; + lastContent = null; + beginIndex = null; + currentIndex = null; + endIndex = null; + itemCount = null; + 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.'); + 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'; @@ -105,8 +120,8 @@ export function mockAccessibility() { 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.'); + 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); @@ -117,8 +132,8 @@ export function mockAccessibility() { } }, 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.'); + 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); @@ -129,8 +144,8 @@ export function mockAccessibility() { } }, 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.'); + 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') { @@ -143,8 +158,8 @@ export function mockAccessibility() { } }, 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.'); + 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') { @@ -155,8 +170,8 @@ export function mockAccessibility() { } }, 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.'); + 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]); @@ -167,14 +182,14 @@ export function mockAccessibility() { } }, 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.'); + 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(); + resolve(null); }); } }, @@ -186,4 +201,4 @@ export function mockAccessibility() { }; return accessibility; -} +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js old mode 100644 new mode 100755 index 00071f7e..b53e574d --- a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js @@ -32,65 +32,108 @@ export function mockAccessibilityExtensionContext() { const AccessibilityElementMock = { 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.'); - return new Promise((resolve, reject) => { - resolve([ElementAttributeNameMock]); - }); + 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 'rect': case 'screenRect': - return new Promise((resolve, reject) => { - resolve(RectMock); - }); + value = RectMock; + break; case 'parent': case 'rootElement': - return new Promise((resolve, reject) => { - resolve(AccessibilityElementMock); - }); + value = AccessibilityElementMock; + break; case 'children': - return new Promise((resolve, reject) => { - resolve([AccessibilityElementMock]); - }); + value = [AccessibilityElementMock]; + break; default: - return new Promise((resolve, reject) => { - resolve(ElementAttributeValueMock); - }); + value = ElementAttributeValueMock; + 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.'); - return new Promise((resolve, reject) => { - resolve([ActionNameMock]); - }); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ActionNameMock); + } else { + return new Promise((resolve, reject) => { + resolve(ActionNameMock); + }); + } }, 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.'); - return new Promise((resolve, reject) => { - resolve(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, reject) => { + resolve(paramMock.paramBooleanMock); + }); + } }, findElement: 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.'); - if (args[0] === 'content') { - return new Promise((resolve, reject) => { - resolve([AccessibilityElementMock]); - }); + const result = (args[0] === 'content') ? [AccessibilityElementMock] : AccessibilityElementMock; + 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(AccessibilityElementMock); + resolve(result); }); } }, }; + const gesturePathClass = class GesturePath { + positions = null; + durationTime = null; + constructor(d) { + console.warn('gesturePathClass.constructor interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + this.positions = []; + this.durationTime = d; + } + } + + const gesturePointClass = class GesturePoint { + positionX = null; + positionY = null; + constructor(x, y) { + console.warn('gesturePointClass.constructor interface mocked in the Previewer.' + + ' How this interface works on the Previewer may be different from that on a real device.'); + this.positionX = y; + this.positionY = y; + } + } + const accessibilityExtensionContextClass = class accessibilityExtensionContext extends ExtensionContextClass { setEventTypeFilter = null; setTargetBundleName = null; @@ -101,8 +144,8 @@ export function mockAccessibilityExtensionContext() { gestureInject = null; constructor() { 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.'); + 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.' + diff --git a/runtime/main/extend/systemplugin/napi/accessibilityConfig.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js old mode 100644 new mode 100755 similarity index 72% rename from runtime/main/extend/systemplugin/napi/accessibilityConfig.js rename to runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js index 0993dbb0..130a0bb5 --- a/runtime/main/extend/systemplugin/napi/accessibilityConfig.js +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js @@ -33,20 +33,20 @@ export function mockAccessibilityConfig() { const configBoolMock = { set: function (...args) { - console.warn('accessibilityConfig configBoolMock.set interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configBoolMock.set interface mocked 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(); + resolve(null); }); } }, get: function (...args) { - console.warn('accessibilityConfig configBoolMock.get interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configBoolMock.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, paramMock.paramBooleanMock); @@ -57,16 +57,16 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig configBoolMock.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configBoolMock.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') { args[len - 1].call(this, paramMock.paramBooleanMock); } }, off: function (...args) { - console.warn('accessibilityConfig configBoolMock.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configBoolMock.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') { args[len - 1].call(this, paramMock.paramBooleanMock); @@ -76,8 +76,8 @@ export function mockAccessibilityConfig() { const daltonizationColorFilterMock = { set: function (...args) { - console.warn('accessibilityConfig daltonizationColorFilterMock.set interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig daltonizationColorFilterMock.set interface mocked 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); @@ -88,8 +88,8 @@ export function mockAccessibilityConfig() { } }, get: function (...args) { - console.warn('accessibilityConfig daltonizationColorFilterMock.get interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig daltonizationColorFilterMock.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, DaltonizationColorFilterMock); @@ -100,16 +100,16 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig highContrastText.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig highContrastText.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') { args[len - 1].call(this, DaltonizationColorFilterMock); } }, off: function (...args) { - console.warn('accessibilityConfig highContrastText.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig highContrastText.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') { args[len - 1].call(this, DaltonizationColorFilterMock); @@ -119,8 +119,8 @@ export function mockAccessibilityConfig() { const configNumberBlock = { set: function (...args) { - console.warn('accessibilityConfig configNumberBlock.set interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configNumberBlock.set interface mocked 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); @@ -131,8 +131,8 @@ export function mockAccessibilityConfig() { } }, get: function (...args) { - console.warn('accessibilityConfig configNumberBlock.get interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configNumberBlock.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, paramMock.paramNumberMock); @@ -143,16 +143,16 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig configNumberBlock.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configNumberBlock.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') { args[len - 1].call(this, paramMock.paramNumberMock); } }, off: function (...args) { - console.warn('accessibilityConfig configNumberBlock.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configNumberBlock.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') { args[len - 1].call(this, paramMock.paramNumberMock); @@ -162,8 +162,8 @@ export function mockAccessibilityConfig() { const configShortkeyTargetBlock = { set: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.set interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configShortkeyTargetBlock.set interface mocked 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); @@ -174,8 +174,8 @@ export function mockAccessibilityConfig() { } }, get: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.get interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig configShortkeyTargetBlock.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, paramMock.paramStringMock); @@ -186,16 +186,16 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig configNumbconfigShortkeyTargetBlockerBlock.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configShortkeyTargetBlock.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') { args[len - 1].call(this, paramMock.paramStringMock); } }, off: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig configShortkeyTargetBlock.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') { args[len - 1].call(this, paramMock.paramStringMock); @@ -205,8 +205,8 @@ export function mockAccessibilityConfig() { const captionStyleMock = { set: function (...args) { - console.warn('accessibilityConfig captionStyleMock.set interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig captionStyleMock.set interface mocked 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); @@ -217,8 +217,8 @@ export function mockAccessibilityConfig() { } }, get: function (...args) { - console.warn('accessibilityConfig captionStyleMock.get interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); @@ -229,16 +229,16 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig captionStyleMock.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig captionStyleMock.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') { args[len - 1].call(this, CaptionStyleMock); } }, off: function (...args) { - console.warn('accessibilityConfig captionStyleMock.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); @@ -248,8 +248,8 @@ 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.'); + 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, paramMock.paramBooleanMock); @@ -260,8 +260,8 @@ export function mockAccessibilityConfig() { } }, 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.'); + 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, paramMock.paramBooleanMock); @@ -272,8 +272,8 @@ export function mockAccessibilityConfig() { } }, on: function (...args) { - console.warn('accessibilityConfig config.on interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { @@ -282,8 +282,8 @@ export function mockAccessibilityConfig() { } }, off: function (...args) { - console.warn('accessibilityConfig config.off interface mocked in the Previewer. How this interface works on the Previewer may be' + - ' different from that on a real device.'); + console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js old mode 100644 new mode 100755 similarity index 75% rename from runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js rename to runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js index f388afbd..75782ace --- a/runtime/main/extend/systemplugin/napi/accessibilityExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js @@ -33,23 +33,23 @@ export function mockAccessibilityExtensionAbility() { constructor() { this.context = mockAccessibilityExtensionContext(); 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.'); + 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.'); return; }; 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.'); + 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.'); return; }; 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.'); + 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.'); return; }; 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.'); + 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; }; } From 7f2d4f30b31e0e8d5ca7af7c509300990b332529 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Tue, 5 Jul 2022 11:06:22 +0800 Subject: [PATCH 003/103] =?UTF-8?q?=E5=AF=B9=E5=BA=94d.ts=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- .../extend/systemplugin/napi/accessibilityExtensionContext.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js index b53e574d..5c6d7063 100755 --- a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js @@ -113,12 +113,12 @@ export function mockAccessibilityExtensionContext() { }; const gesturePathClass = class GesturePath { - positions = null; + points = null; durationTime = null; constructor(d) { console.warn('gesturePathClass.constructor interface mocked in the Previewer.' + ' How this interface works on the Previewer may be different from that on a real device.'); - this.positions = []; + this.points = []; this.durationTime = d; } } From df05215994efb1f57eff35adbc4f0532bef8fab6 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Tue, 12 Jul 2022 13:21:56 +0800 Subject: [PATCH 004/103] =?UTF-8?q?=E6=8F=90=E4=BA=A4mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mupceet --- .../main/extend/systemplugin/accessibility.js | 16 +--------------- .../napi/ohos_accessibility_Config.js | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/accessibility.js index 7ef3527b..9bcd34ce 100755 --- a/runtime/main/extend/systemplugin/accessibility.js +++ b/runtime/main/extend/systemplugin/accessibility.js @@ -82,20 +82,6 @@ export function mockAccessibility() { const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit'; const EventInfoClass = class EventInfo { - type = null; - windowUpdateType = null; - bundleName = null; - componentType = null; - pageId = null; - description = null; - triggerAction = null; - textMoveUnit = null; - contents = null; - lastContent = null; - beginIndex = null; - currentIndex = null; - endIndex = null; - itemCount = null; constructor(jsonObject) { console.warn('accessibility.EventInfoClass.constructor interface mocked in the Previewer.' + @@ -189,7 +175,7 @@ export function mockAccessibility() { args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(null); + resolve(); }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js index 130a0bb5..1a8bc84d 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js @@ -40,7 +40,7 @@ export function mockAccessibilityConfig() { args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { - resolve(null); + resolve(); }); } }, From e07758c96e07ed16c863e4b6e1cfc5a2f924ab54 Mon Sep 17 00:00:00 2001 From: yinyong Date: Tue, 12 Jul 2022 14:39:38 +0800 Subject: [PATCH 005/103] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=20multimedi?= =?UTF-8?q?a=5Favsession=5Fstandard=20=E6=A8=A1=E5=9D=97MOCK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinyong --- .../main/extend/systemplugin/napi/index.js | 3 + .../napi/ohos_multimedia_av_session.js | 435 ++++++++++++++++++ 2 files changed, 438 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..ec9c739f 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -100,6 +100,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' @@ -452,6 +453,8 @@ export function mockRequireNapiFun() { return mockMultimediaMedia(); case "multimedia.image": return mockMultimediaImage(); + case "multimedia.avsession": + return mockMultimediaAVSession(); case "multimedia.camera": return mockMultimediaCamera(); case "multimedia.audio": 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..89d89f11 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -0,0 +1,435 @@ +/* + * 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 AVMetadataMock = { + 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 AVPlaybackStateMock = { + state: "[PC Preview] unknow state", + speed: "[PC Preview] unknow speed", + position: PlaybackPositionMock, + bufferedTime: "[PC Preview] unknow bufferedTime", + loopMode: "[PC Preview] unknow loopMode", + isFavorite: "[PC Preview] unknow isFavorite" + } + + const PlaybackPositionMock = { + elapsedTime: "[PC Preview] unknow elapsedTime", + updateTime: "[PC Preview] unknow updateTime" + } + + const OutputDeviceInfoMock = { + isRemote: "[PC Preview] unknow isRemote", + deviceId: [paramMock.paramStringMock], + deviceName: [paramMock.paramStringMock] + } + + const AVSessionDescriptorMock = { + 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 AVSessionMock = { + 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, AVSessionControllerMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionControllerMock); + }) + } + }, + 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, OutputDeviceInfoMock); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfoMock); + }) + } + }, + 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 loopModeMock = "[PC Preview] unknow LoopMode"; + args[len - 1].call(this, loopModeMock); + } 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, OutputDeviceInfoMock); + } + }, + 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 AVSessionControllerMock = { + 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, AVPlaybackStateMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVPlaybackStateMock); + }) + } + }, + 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, AVMetadataMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVMetadataMock); + }) + } + }, + 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, OutputDeviceInfoMock); + } else { + return new Promise((resolve, reject) => { + resolve(OutputDeviceInfoMock); + }) + } + }, + 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 + let AVControlCommandType = ['play','pause','stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + 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, AVMetadataMock); + } else if (args[0] == 'playbackStateChanged') { + args[len-1].call(this, AVPlaybackStateMock); + } 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') { + let AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; + args[len-1].call(this, AVControlCommandType); + } else if (args[0] == 'outputDeviceChanged') { + args[len-1].call(this, OutputDeviceInfoMock); + } + }, + 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, AVSessionMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionMock); + }) + } + + }, + 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(AVSessionDescriptorMock); + 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, AVSessionControllerMock); + } else { + return new Promise((resolve, reject) => { + resolve(AVSessionControllerMock); + }) + } + }, + 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, AVSessionDescriptorMock); + } 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 +} From 1b275b8b62b8d1902fb66649e57a385a8a13a4ba Mon Sep 17 00:00:00 2001 From: yinyong Date: Tue, 12 Jul 2022 16:18:07 +0800 Subject: [PATCH 006/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinyong --- .../napi/ohos_multimedia_av_session.js | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js index 89d89f11..8cf529a9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_av_session.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockMultimediaAVSession() { - const AVMetadataMock = { + const AVMetadata = { assetId: "[PC Preview] unknow assetId", title: "[PC Preview] unknow title", artist: "[PC Preview] unknow artist", @@ -34,37 +34,40 @@ export function mockMultimediaAVSession() { nextAssetId: "[PC Preview] unknow nextAssetId" } - const AVPlaybackStateMock = { + const AVPlaybackState = { state: "[PC Preview] unknow state", speed: "[PC Preview] unknow speed", - position: PlaybackPositionMock, + position: PlaybackPosition, bufferedTime: "[PC Preview] unknow bufferedTime", loopMode: "[PC Preview] unknow loopMode", isFavorite: "[PC Preview] unknow isFavorite" } - const PlaybackPositionMock = { + const PlaybackPosition = { elapsedTime: "[PC Preview] unknow elapsedTime", updateTime: "[PC Preview] unknow updateTime" } - const OutputDeviceInfoMock = { + const OutputDeviceInfo = { isRemote: "[PC Preview] unknow isRemote", deviceId: [paramMock.paramStringMock], deviceName: [paramMock.paramStringMock] } - const AVSessionDescriptorMock = { + 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" + outputDevice: + "[PC Preview] unknow outputDevice" } - - const AVSessionMock = { + + 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" + @@ -119,10 +122,10 @@ export function mockMultimediaAVSession() { " 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, AVSessionControllerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController); } else { return new Promise((resolve, reject) => { - resolve(AVSessionControllerMock); + resolve(AVSessionController); }) } }, @@ -131,10 +134,10 @@ export function mockMultimediaAVSession() { " 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, OutputDeviceInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo); } else { return new Promise((resolve, reject) => { - resolve(OutputDeviceInfoMock); + resolve(OutputDeviceInfo); }) } }, @@ -148,14 +151,14 @@ export function mockMultimediaAVSession() { } else if(args[0] == 'seek' || args[0] == 'setSpeed') { args[len - 1].call(this, paramMock.paramNumberMock); } else if(args[0] == 'setLoopMode') { - var loopModeMock = "[PC Preview] unknow LoopMode"; - args[len - 1].call(this, loopModeMock); + 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, OutputDeviceInfoMock); + args[len - 1].call(this, OutputDeviceInfo); } }, off: function (...args) { @@ -200,17 +203,17 @@ export function mockMultimediaAVSession() { } } - const AVSessionControllerMock = { + 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, AVPlaybackStateMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVPlaybackState); } else { return new Promise((resolve, reject) => { - resolve(AVPlaybackStateMock); + resolve(AVPlaybackState); }) } }, @@ -219,10 +222,10 @@ export function mockMultimediaAVSession() { " 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, AVMetadataMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVMetadata); } else { return new Promise((resolve, reject) => { - resolve(AVMetadataMock); + resolve(AVMetadata); }) } }, @@ -231,10 +234,10 @@ export function mockMultimediaAVSession() { " 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, OutputDeviceInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OutputDeviceInfo); } else { return new Promise((resolve, reject) => { - resolve(OutputDeviceInfoMock); + resolve(OutputDeviceInfo); }) } }, @@ -295,7 +298,6 @@ export function mockMultimediaAVSession() { 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 - let AVControlCommandType = ['play','pause','stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AVControlCommandType); } else { @@ -321,18 +323,17 @@ export function mockMultimediaAVSession() { " may be different from that on a real device.") const len = args.length if (args[0] == 'metadataChanged') { - args[len-1].call(this, AVMetadataMock); + args[len-1].call(this, AVMetadata); } else if (args[0] == 'playbackStateChanged') { - args[len-1].call(this, AVPlaybackStateMock); + 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') { - let AVControlCommandType = ['play', 'pause', 'stop', 'playNext', 'playPrevious', 'fastForward', 'rewind', 'seek', 'setSpeed', 'setLoopMode', 'toggleFavorite']; args[len-1].call(this, AVControlCommandType); } else if (args[0] == 'outputDeviceChanged') { - args[len-1].call(this, OutputDeviceInfoMock); + args[len-1].call(this, OutputDeviceInfo); } }, off: function (...args) { @@ -347,10 +348,10 @@ export function mockMultimediaAVSession() { " 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, AVSessionMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSession); } else { return new Promise((resolve, reject) => { - resolve(AVSessionMock); + resolve(AVSession); }) } @@ -359,7 +360,7 @@ export function mockMultimediaAVSession() { 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(AVSessionDescriptorMock); + var desArr = Array(AVSessionDescriptor); if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, desArr); } else { @@ -373,10 +374,10 @@ export function mockMultimediaAVSession() { " 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, AVSessionControllerMock); + args[len - 1].call(this, paramMock.businessErrorMock, AVSessionController); } else { return new Promise((resolve, reject) => { - resolve(AVSessionControllerMock); + resolve(AVSessionController); }) } }, @@ -397,7 +398,7 @@ export function mockMultimediaAVSession() { " 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, AVSessionDescriptorMock); + args[len - 1].call(this, AVSessionDescriptor); } else if (args[0] == 'sessionServiceDied') { args[len - 1].call(this); } From 33462cfae1031a5479eaec7b59a40669ad085eec Mon Sep 17 00:00:00 2001 From: wu-chengwen Date: Tue, 12 Jul 2022 17:49:31 +0800 Subject: [PATCH 007/103] fix(usb):add DRP and NUM_MODES mock Signed-off-by: wu-chengwen --- runtime/main/extend/systemplugin/napi/ohos_usb.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 = { From 18ad3d513afd7b59a974c54458f2d9220b725efe Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Wed, 13 Jul 2022 19:28:47 +0800 Subject: [PATCH 008/103] update js mock Signed-off-by: zhangxingxia --- runtime/main/extend/systemplugin/napi/index.js | 4 ++-- .../extend/systemplugin/napi/ohos_fileManager.js | 16 ++++++++++++---- .../systemplugin/napi/ohos_securitylabel.js | 9 +++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 6f709cac..704dc192 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -390,7 +390,7 @@ export function mockRequireNapiFun() { return mockConvertXml(); case "statfs": return mockStatfs(); - case "filemanager": + case "fileManager": return mockFileManager(); case "environment": return mockEnvironment(); @@ -410,7 +410,7 @@ export function mockRequireNapiFun() { return mockBackgroundTaskManager(); case "bundleState": return mockBundleState(); - case "securitylabel": + case "securityLabel": return mockSecurityLabel(); case "workScheduler": return mockWorkScheduler(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index f06e905c..47ae70a4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -16,16 +16,24 @@ import { paramMock } from "../utils" export function mockFileManager() { + const fileInfoMock = { + 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 filemanager = { 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, Array(fileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(Array(fileInfoMock)); }) } }, @@ -34,10 +42,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, Array(fileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); + resolve(Array(fileInfoMock)); }) } }, 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; } From 3ad391576d515d11bf7cb2db355c0d70b26e4b02 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Thu, 14 Jul 2022 14:50:23 +0800 Subject: [PATCH 009/103] update jsmock Signed-off-by: zhangxingxia --- .../main/extend/systemplugin/napi/index.js | 4 +- .../systemplugin/napi/ohos_fileManager.js | 19 +++-- .../napi/ohos_storageStatistics.js | 69 ++++++++++++++++++ .../systemplugin/napi/ohos_volumeManager.js | 70 ++++++++++++++++++- .../systemplugin/napi/volume/volumeInfo.js | 23 ------ 5 files changed, 152 insertions(+), 33 deletions(-) delete mode 100644 runtime/main/extend/systemplugin/napi/volume/volumeInfo.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 704dc192..4ebe5be6 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -394,9 +394,9 @@ export function mockRequireNapiFun() { return mockFileManager(); case "environment": return mockEnvironment(); - case "storagestatistics": + case "storageStatistics": return mockStorageStatistics(); - case "volumemanager": + case "volumeManager": return mockVolumeManager(); case "settings": return mockSettings(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index 47ae70a4..b753134e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -16,24 +16,29 @@ import { paramMock } from "../utils" export function mockFileManager() { - const fileInfoMock = { + const FileInfoMock = { 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', + modifiedTime: '[PC preview] unknow modifiedTime' + }; + const DevInfoMock = { + name: '[PC preview] unknow name' }; const filemanager = { + FileInfo: FileInfoMock, + DevInfo: DevInfoMock, 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, Array(fileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(Array(fileInfoMock)); + resolve(Array(FileInfoMock)); }) } }, @@ -42,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, Array(fileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfoMock)) } else { return new Promise((resolve, reject) => { - resolve(Array(fileInfoMock)); + resolve(Array(FileInfoMock)); }) } }, @@ -60,7 +65,7 @@ export function mockFileManager() { resolve(paramMock.paramStringMock); }) } - }, + } } return filemanager; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index c954be1e..d8e5ded9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -21,8 +21,17 @@ export function mockStorageStatistics() { cacheSize: '[PC preview] unknow cacheSize', dataSize: '[PC preview] unknow dataSize' }; + const StorageStatsMock = { + 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, + StorageStats: StorageStatsMock, 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, BundleStatsMock); + } else { + return new Promise((resolve, reject) => { + resolve(BundleStatsMock); + }); + } + }, + 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, StorageStatsMock); + } else { + return new Promise((resolve, reject) => { + resolve(StorageStatsMock); + }); + } + }, + 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_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 9adf2ac3..f7d0e5ac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -14,10 +14,18 @@ */ import { paramMock } from "../utils" -import {VolumeMock} from './volume/volumeInfo' export function mockVolumeManager() { + 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' + }; const volumeManager = { + Volume: VolumeMock, 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."); @@ -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, VolumeMock); + } else { + return new Promise((resolve, reject) => { + resolve(VolumeMock); + }) + } + }, + 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, VolumeMock); + } else { + return new Promise((resolve, reject) => { + resolve(VolumeMock); + }) + } + }, + 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/volume/volumeInfo.js b/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js deleted file mode 100644 index 529b1fe8..00000000 --- a/runtime/main/extend/systemplugin/napi/volume/volumeInfo.js +++ /dev/null @@ -1,23 +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. - */ - -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 From 5c4f8c9c3b61203b54639c31586cf67d49cae3d6 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Thu, 14 Jul 2022 14:55:49 +0800 Subject: [PATCH 010/103] update jsmock Signed-off-by: zhangxingxia --- .../systemplugin/napi/ohos_fileManager.js | 18 +++++++++--------- .../napi/ohos_storageStatistics.js | 16 ++++++++-------- .../systemplugin/napi/ohos_volumeManager.js | 16 ++++++++-------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index b753134e..6491bda7 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,7 +16,7 @@ import { paramMock } from "../utils" export function mockFileManager() { - const FileInfoMock = { + const FileInfo = { name: '[PC preview] unknow name', path: '[PC preview] unknow path', type: '[PC preview] unknow type', @@ -24,21 +24,21 @@ export function mockFileManager() { addedTime: '[PC preview] unknow addedTime', modifiedTime: '[PC preview] unknow modifiedTime' }; - const DevInfoMock = { + const DevInfo = { name: '[PC preview] unknow name' }; const filemanager = { - FileInfo: FileInfoMock, - DevInfo: DevInfoMock, + 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, Array(FileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfoMock)); + resolve(Array(FileInfo)); }) } }, @@ -47,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, Array(FileInfoMock)) + args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfoMock)); + resolve(Array(FileInfo)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js index d8e5ded9..4f4c7511 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js +++ b/runtime/main/extend/systemplugin/napi/ohos_storageStatistics.js @@ -16,12 +16,12 @@ 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 StorageStatsMock = { + const StorageStats= { total: '[PC preview] unknow total', audio: '[PC preview] unknow audio', video: '[PC preview] unknow video', @@ -30,8 +30,8 @@ export function mockStorageStatistics() { app: '[PC preview] unknow app' } const storageStatistics = { - BundleStats: BundleStatsMock, - StorageStats: StorageStatsMock, + 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.'); @@ -73,10 +73,10 @@ export function mockStorageStatistics() { ' 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, BundleStatsMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleStats); } else { return new Promise((resolve, reject) => { - resolve(BundleStatsMock); + resolve(BundleStats); }); } }, @@ -97,10 +97,10 @@ export function mockStorageStatistics() { ' 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, StorageStatsMock); + args[len - 1].call(this, paramMock.businessErrorMock, StorageStats); } else { return new Promise((resolve, reject) => { - resolve(StorageStatsMock); + resolve(StorageStats); }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index f7d0e5ac..412dda53 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockVolumeManager() { - const VolumeMock = { + const Volume = { id: '[PC preview] unknow id', uuid: '[PC preview] unknow uuid', description: '[PC preview] unknow description', @@ -25,16 +25,16 @@ export function mockVolumeManager() { state: '[PC preview] unknow state' }; const volumeManager = { - Volume: VolumeMock, + 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, Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(VolumeMock)); + resolve(Array(Volume)); }) } }, @@ -67,10 +67,10 @@ export function mockVolumeManager() { " 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, VolumeMock); + args[len - 1].call(this, paramMock.businessErrorMock, Volume); } else { return new Promise((resolve, reject) => { - resolve(VolumeMock); + resolve(Volume); }) } }, @@ -79,10 +79,10 @@ export function mockVolumeManager() { " 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, VolumeMock); + args[len - 1].call(this, paramMock.businessErrorMock, Volume); } else { return new Promise((resolve, reject) => { - resolve(VolumeMock); + resolve(Volume); }) } }, From 4fba819d0a734ad2248acdadc2e18f4125c89482 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 12:40:42 +0800 Subject: [PATCH 011/103] =?UTF-8?q?uitest=20MockAPI=E5=A2=9E=E5=8A=A0.=20S?= =?UTF-8?q?igned-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../main/extend/systemplugin/napi/index.js | 3 + .../extend/systemplugin/napi/ohos_uitest.js | 350 ++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_uitest.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 5d7c060e..0d1a921b 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -172,6 +172,7 @@ 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' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -493,6 +494,8 @@ export function mockRequireNapiFun() { return mockTouchEvent(); case "continuation.continuationManager": return mockContinationManager(); + case "uitest": + return mockUiTest(); default: return global.requireNapiPreview(...args); } 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..16000859 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -0,0 +1,350 @@ +/* + * 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.' + +const MatchPatternMock = { + EQUALS: 0, + CONTAINS: 1, + STARTS_WITH: 2, + ENDS_WITH: 3 +} + +const ByMockClass = class ByMock { + constructor() { + console.warn('uitest.By.constructor' + warnMessage); + this.id = function(...args) { + console.warn('uitest.By.id' + warnMessage) + return paramMock.paramObjectMock + }; + this.text = function(...args) { + console.warn('uitest.By.text' + warnMessage) + return paramMock.paramObjectMock + }; + this.key = function(...args) { + console.warn('uitest.By.key' + warnMessage) + return paramMock.paramObjectMock + }; + this.type = function(...args) { + console.warn('uitest.By.type' + warnMessage) + return paramMock.paramObjectMock + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return paramMock.paramObjectMock + }; + this.focused = function(...args) { + console.warn('uitest.By.focused' + warnMessage) + return paramMock.paramObjectMock + }; + this.selected = function(...args) { + console.warn('uitest.By.selected' + warnMessage) + return paramMock.paramObjectMock + }; + this.clickable = function(...args) { + console.warn('uitest.By.clickable' + warnMessage) + return paramMock.paramObjectMock + }; + this.enabled = function(...args) { + console.warn('uitest.By.enabled' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClickable = function(...args) { + console.warn('uitest.By.longClickable' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollable = function(...args) { + console.warn('uitest.By.scrollable' + warnMessage) + return paramMock.paramObjectMock + }; + this.checkable = function(...args) { + console.warn('uitest.By.checkable' + warnMessage) + return paramMock.paramObjectMock + }; + this.checked = function(...args) { + console.warn('uitest.By.checked' + warnMessage) + return paramMock.paramObjectMock + }; + this.isBefore = function(...args) { + console.warn('uitest.By.isBefore' + warnMessage) + return paramMock.paramObjectMock + }; + this.isAfter = function(...args) { + console.warn('uitest.By.isAfter' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const BYMock = new ByMockClass() + +const UiDriverMockClass = class UiDriverMock { + constructor() { + console.warn('uitest.UiDriver.constructor' + warnMessage); + this.create = function(...args) { + console.warn('uitest.UiDriver.create' + warnMessage) + return paramMock.paramObjectMock + }; + this.delayMs = function(...args) { + console.warn('uitest.UiDriver.delayMs' + warnMessage) + return paramMock.paramObjectMock + }; + this.findComponent = function(...args) { + console.warn('uitest.UiDriver.findComponent' + warnMessage) + return paramMock.paramObjectMock + }; + this.findWindow = function(...args) { + console.warn('uitest.UiDriver.findWindow' + warnMessage) + return paramMock.paramObjectMock + }; + this.findComponents = function(...args) { + console.warn('uitest.UiDriver.findComponents' + warnMessage) + return paramMock.paramObjectMock + }; + this.waitForComponent = function(...args) { + console.warn('uitest.UiDriver.waitForComponent' + warnMessage) + return paramMock.paramObjectMock + }; + this.screenCap = function(...args) { + console.warn('uitest.UiDriver.screenCap' + warnMessage) + return paramMock.paramObjectMock + }; + this.assertComponentExist = function(...args) { + console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) + return paramMock.paramObjectMock + }; + this.pressBack = function(...args) { + console.warn('uitest.UiDriver.pressBack' + warnMessage) + return paramMock.paramObjectMock + }; + this.triggerKey = function(...args) { + console.warn('uitest.UiDriver.triggerKey' + warnMessage) + return paramMock.paramObjectMock + }; + this.triggerCombineKeys = function(...args) { + console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) + return paramMock.paramObjectMock + }; + this.click = function(...args) { + console.warn('uitest.UiDriver.click' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClick = function(...args) { + console.warn('uitest.UiDriver.longClick' + warnMessage) + return paramMock.paramObjectMock + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiDriver.doubleClick' + warnMessage) + return paramMock.paramObjectMock + }; + this.swipe = function(...args) { + console.warn('uitest.UiDriver.swipe' + warnMessage) + return paramMock.paramObjectMock + }; + this.drag = function(...args) { + console.warn('uitest.UiDriver.drag' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const UIDriverMock = new UiDriverMockClass() + +const UiComponentMockClass = class UiComponentMock { + constructor() { + console.warn('uitest.UiComponent.constructor' + warnMessage); + this.getId = function(...args) { + console.warn('uitest.UiComponent.getId.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getText = function(...args) { + console.warn('uitest.UiComponent.getText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getKey = function(...args) { + console.warn('uitest.UiComponent.getKey.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getType = function(...args) { + console.warn('uitest.UiComponent.getType.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isEnabled = function(...args) { + console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isFocused = function(...args) { + console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isSelected = function(...args) { + console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isClickable = function(...args) { + console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isLongClickable = function(...args) { + console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isScrollable = function(...args) { + console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isCheckable = function(...args) { + console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isChecked = function(...args) { + console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBounds = function(...args) { + console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBoundsCenter = function(...args) { + console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.click = function(...args) { + console.warn('uitest.UiComponent.click.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.longClick = function(...args) { + console.warn('uitest.UiComponent.longClick.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.doubleClick = function(...args) { + console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollToTop = function(...args) { + console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollToBottom = function(...args) { + console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.inputText = function(...args) { + console.warn('uitest.UiComponent.inputText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.clearText = function(...args) { + console.warn('uitest.UiComponent.clearText.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.scrollSearch = function(...args) { + console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.dragTo = function(...args) { + console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.pinchOut = function(...args) { + console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.pinchIn = function(...args) { + console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) + return paramMock.paramObjectMock + }; + } +} + +const UIComponentMock = new UiComponentMockClass() + +const UiWindowMockClass = class UiWindowMock { + constructor() { + console.warn('uitest.UiWindowMock.constructor' + warnMessage); + this.getBundleName = function(...args) { + console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getBounds = function(...args) { + console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getTitle = function(...args) { + console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.getWindowMode = function(...args) { + console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isFocused = function(...args) { + console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.isActived = function(...args) { + console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.focuse = function(...args) { + console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.moveTo = function(...args) { + console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.resize = function(...args) { + console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.split = function(...args) { + console.warn('uitest.UiWindowMock.split.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.maximize = function(...args) { + console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.resume = function(...args) { + console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.minimize = function(...args) { + console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) + return paramMock.paramObjectMock + }; + this.close = function(...args) { + console.warn('uitest.UiWindowMock.close.warn' + warnMessage) + return paramMock.paramObjectMock + }; + }; +} + +const UIWindowMock = new UiWindowMockClass() + +export function mockUiTest() { + const module = { + MatchPattern: MatchPatternMock, + BY: BYMock, + UiDriver: UIDriverMock, + UiComponent: UIComponentMock, + UiWindow: UIWindowMock + }; + return module +} \ No newline at end of file From b44e95f0f51eea8280f5a274ca449dcf1d9d5e00 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Sat, 16 Jul 2022 15:23:31 +0800 Subject: [PATCH 012/103] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_screenLock.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 893f232c..7aefba1e 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, paramMock.businessErrorMock); + } 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, paramMock.businessErrorMock); + } + } + }, + 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 From 49fdfc3e4aa58a174bfae00f5b4400aa73869473 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Sat, 16 Jul 2022 17:38:57 +0800 Subject: [PATCH 013/103] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_screenLock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 7aefba1e..edf5f1d1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -60,7 +60,7 @@ export function mockScreenLock() { 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, paramMock.businessErrorMock); + 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') { @@ -76,7 +76,7 @@ export function mockScreenLock() { 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, paramMock.businessErrorMock); + args[len - 1].call(this); } } }, From 8f6e17018dfb8d93ef95053b5549cffe03e523c8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 18:24:12 +0800 Subject: [PATCH 014/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 327 +++++++++++++----- 1 file changed, 239 insertions(+), 88 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 16000859..736530f7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -19,332 +19,483 @@ const warnMessage = ' interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.' -const MatchPatternMock = { +export const ResizeDirectionMock = { + LEFT: 0, + RIGHT: 1, + UP: 2, + DOWN: 3, + LEFT_UP: 4, + LEFT_DOWN: 5, + RIGHT_UP: 6, + RIGHT_DOWN: 7 +} + +export const MatchPatternMock = { EQUALS: 0, CONTAINS: 1, STARTS_WITH: 2, ENDS_WITH: 3 } +export const WindowModeMock = { + FULLSCREEN: 0, + PRIMARY: 1, + SECONDARY: 2, + FLOATING: 3 +} + +const PointMockClass = class PointMock { + constructor() { + X: '[PC Preview] unknown X'; + Y: '[PC Preview] unknown Y'; + } +} + +const RectMockClass = class RectMock { + constructor() { + leftX: '[PC Preview] unknown leftX'; + topY: '[PC Preview] unknown topY'; + rightX: '[PC Preview] unknown rightX'; + bottomY: '[PC Preview] unknown bottomY'; + } +} + +const WindowFilterMockClass = class WindowFilterMock { + constructor() { + bundleName: '[PC Preview] unknown bundleName'; + title: '[PC Preview] unknown title'; + focused: '[PC Preview] unknown focused'; + actived: '[PC Preview] unknown actived'; + } +} + const ByMockClass = class ByMock { constructor() { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return paramMock.paramObjectMock + return new BYMock() }; } } -const BYMock = new ByMockClass() - -const UiDriverMockClass = class UiDriverMock { +const UiDriverClass = class UiDriverMock { constructor() { console.warn('uitest.UiDriver.constructor' + warnMessage); - this.create = function(...args) { - console.warn('uitest.UiDriver.create' + warnMessage) - return paramMock.paramObjectMock - }; this.delayMs = function(...args) { console.warn('uitest.UiDriver.delayMs' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.findComponent = function(...args) { console.warn('uitest.UiDriver.findComponent' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.findWindow = function(...args) { console.warn('uitest.UiDriver.findWindow' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiWindowMock()) + }); }; this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.waitForComponent = function(...args) { console.warn('uitest.UiDriver.waitForComponent' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.screenCap = function(...args) { console.warn('uitest.UiDriver.screenCap' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.assertComponentExist = function(...args) { console.warn('uitest.UiDriver.assertComponentExist' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pressBack = function(...args) { console.warn('uitest.UiDriver.pressBack' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.triggerKey = function(...args) { console.warn('uitest.UiDriver.triggerKey' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.triggerCombineKeys = function(...args) { console.warn('uitest.UiDriver.triggerCombineKeys' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.click = function(...args) { console.warn('uitest.UiDriver.click' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.longClick = function(...args) { console.warn('uitest.UiDriver.longClick' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.doubleClick = function(...args) { console.warn('uitest.UiDriver.doubleClick' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.swipe = function(...args) { console.warn('uitest.UiDriver.swipe' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.drag = function(...args) { console.warn('uitest.UiDriver.drag' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; } } -const UIDriverMock = new UiDriverMockClass() +UiDriverClass.create = function () { + this.create = function(...args) { + console.warn('uitest.UiDriver.create' + warnMessage) + return new UiDriverMock() + } +} -const UiComponentMockClass = class UiComponentMock { +const UiComponentClass = class UiComponentMock { constructor() { console.warn('uitest.UiComponent.constructor' + warnMessage); this.getId = function(...args) { console.warn('uitest.UiComponent.getId.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock) + }); }; this.getText = function(...args) { console.warn('uitest.UiComponent.getText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getKey = function(...args) { console.warn('uitest.UiComponent.getKey.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getType = function(...args) { console.warn('uitest.UiComponent.getType.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.isEnabled = function(...args) { console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isFocused = function(...args) { console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isSelected = function(...args) { console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isClickable = function(...args) { console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isLongClickable = function(...args) { console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isScrollable = function(...args) { console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isCheckable = function(...args) { console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isChecked = function(...args) { console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.getBounds = function(...args) { console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(RectMock) + }); }; this.getBoundsCenter = function(...args) { console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(PointMock) + }); }; this.click = function(...args) { console.warn('uitest.UiComponent.click.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.longClick = function(...args) { console.warn('uitest.UiComponent.longClick.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.doubleClick = function(...args) { console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollToTop = function(...args) { console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollToBottom = function(...args) { console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.inputText = function(...args) { console.warn('uitest.UiComponent.inputText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.clearText = function(...args) { console.warn('uitest.UiComponent.clearText.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.scrollSearch = function(...args) { console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(new UiComponentMock()) + }); }; this.dragTo = function(...args) { console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pinchOut = function(...args) { console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; this.pinchIn = function(...args) { console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve() + }); }; } } -const UIComponentMock = new UiComponentMockClass() - -const UiWindowMockClass = class UiWindowMock { +const UiWindowClass = class UiWindowMock { constructor() { console.warn('uitest.UiWindowMock.constructor' + warnMessage); this.getBundleName = function(...args) { console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getBounds = function(...args) { console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(RectMock) + }); }; this.getTitle = function(...args) { console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramStringMock) + }); }; this.getWindowMode = function(...args) { console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(WindowModeMock) + }); }; this.isFocused = function(...args) { console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.isActived = function(...args) { console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.focuse = function(...args) { console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.moveTo = function(...args) { console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.resize = function(...args) { console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.split = function(...args) { console.warn('uitest.UiWindowMock.split.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.maximize = function(...args) { console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.resume = function(...args) { console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.minimize = function(...args) { console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; this.close = function(...args) { console.warn('uitest.UiWindowMock.close.warn' + warnMessage) - return paramMock.paramObjectMock + return new Promise((resolve) => { + resolve(paramMock.paramBoolMock) + }); }; }; } -const UIWindowMock = new UiWindowMockClass() - export function mockUiTest() { const module = { + ResizeDirection: ResizeDirectionMock, MatchPattern: MatchPatternMock, - BY: BYMock, - UiDriver: UIDriverMock, - UiComponent: UIComponentMock, - UiWindow: UIWindowMock + WindowMode: WindowModeMock, + Point: PointMockClass, + Rect: RectMockClass, + WindowFilter: WindowFilterMockClass, + BY: ByMockClass, + UiDriver: UiDriverClass, + UiComponent: UiComponentClass, + UiWindow: UiWindowClass }; return module } \ No newline at end of file From 3399f33eb7ec5e56d6bd845837c6dc5a6395a6b5 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Sat, 16 Jul 2022 18:35:24 +0800 Subject: [PATCH 015/103] Signed-off-by: ma-shaoyin Changes to be committed: --- .../napi/ohos_inputmethodengine.js | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index 7024338b..d6b55a6e 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: 1, + keyAction: 2, + } const RichContent = { contentURI: "[PC Preview] unknow contentURI", linkURI: "[PC Preview] unknow linkURI", @@ -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 From acd75033edcfe6f75562308280bdc42e4cd1e32b Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Sat, 16 Jul 2022 18:51:38 +0800 Subject: [PATCH 016/103] Signed-off-by: ma-shaoyin Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index d6b55a6e..f7d6c51a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -350,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') { From 2acb01f913899b0babc9127533b4d8044c769dab Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 16 Jul 2022 19:40:34 +0800 Subject: [PATCH 017/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 736530f7..f5fb094c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -74,63 +74,63 @@ const ByMockClass = class ByMock { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return new BYMock() + return new ByMock() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return new BYMock() + return new ByMock() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return new BYMock() + return new ByMock() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return new BYMock() + return new ByMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new BYMock() + return new ByMock() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return new BYMock() + return new ByMock() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return new BYMock() + return new ByMock() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return new BYMock() + return new ByMock() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new BYMock() + return new ByMock() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return new BYMock() + return new ByMock() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return new BYMock() + return new ByMock() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return new BYMock() + return new ByMock() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return new BYMock() + return new ByMock() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return new BYMock() + return new ByMock() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return new BYMock() + return new ByMock() }; } } @@ -492,7 +492,7 @@ export function mockUiTest() { Point: PointMockClass, Rect: RectMockClass, WindowFilter: WindowFilterMockClass, - BY: ByMockClass, + BY: new ByMockClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, UiWindow: UiWindowClass From 1770385fc2f004a83f11f60676c66175ddc1e0ca Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 09:36:12 +0800 Subject: [PATCH 018/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- runtime/main/extend/systemplugin/napi/ohos_uitest.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index f5fb094c..961ce571 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -69,7 +69,7 @@ const WindowFilterMockClass = class WindowFilterMock { } } -const ByMockClass = class ByMock { +const ByClass = class ByMock { constructor() { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { @@ -159,7 +159,7 @@ const UiDriverClass = class UiDriverMock { this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new Array(new UiComponentMock())) }); }; this.waitForComponent = function(...args) { @@ -232,10 +232,8 @@ const UiDriverClass = class UiDriverMock { } UiDriverClass.create = function () { - this.create = function(...args) { console.warn('uitest.UiDriver.create' + warnMessage) - return new UiDriverMock() - } + return new UiDriverClass() } const UiComponentClass = class UiComponentMock { @@ -492,7 +490,7 @@ export function mockUiTest() { Point: PointMockClass, Rect: RectMockClass, WindowFilter: WindowFilterMockClass, - BY: new ByMockClass(), + BY: new ByClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, UiWindow: UiWindowClass From e0244cd308ba8a603e8bac963ee610b838f3a0e3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 10:48:36 +0800 Subject: [PATCH 019/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 961ce571..780032c0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -19,7 +19,7 @@ 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 ResizeDirectionMock = { +export const ResizeDirection = { LEFT: 0, RIGHT: 1, UP: 2, @@ -30,28 +30,28 @@ export const ResizeDirectionMock = { RIGHT_DOWN: 7 } -export const MatchPatternMock = { +export const MatchPattern = { EQUALS: 0, CONTAINS: 1, STARTS_WITH: 2, ENDS_WITH: 3 } -export const WindowModeMock = { +export const WindowMode = { FULLSCREEN: 0, PRIMARY: 1, SECONDARY: 2, FLOATING: 3 } -const PointMockClass = class PointMock { +export const Point = { constructor() { X: '[PC Preview] unknown X'; Y: '[PC Preview] unknown Y'; } } -const RectMockClass = class RectMock { +export const Rect = { constructor() { leftX: '[PC Preview] unknown leftX'; topY: '[PC Preview] unknown topY'; @@ -60,7 +60,7 @@ const RectMockClass = class RectMock { } } -const WindowFilterMockClass = class WindowFilterMock { +export const WindowFilter = { constructor() { bundleName: '[PC Preview] unknown bundleName'; title: '[PC Preview] unknown title'; @@ -74,63 +74,63 @@ const ByClass = class ByMock { console.warn('uitest.By.constructor' + warnMessage); this.id = function(...args) { console.warn('uitest.By.id' + warnMessage) - return new ByMock() + return new ByClass() }; this.text = function(...args) { console.warn('uitest.By.text' + warnMessage) - return new ByMock() + return new ByClass() }; this.key = function(...args) { console.warn('uitest.By.key' + warnMessage) - return new ByMock() + return new ByClass() }; this.type = function(...args) { console.warn('uitest.By.type' + warnMessage) - return new ByMock() + return new ByClass() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new ByMock() + return new ByClass() }; this.focused = function(...args) { console.warn('uitest.By.focused' + warnMessage) - return new ByMock() + return new ByClass() }; this.selected = function(...args) { console.warn('uitest.By.selected' + warnMessage) - return new ByMock() + return new ByClass() }; this.clickable = function(...args) { console.warn('uitest.By.clickable' + warnMessage) - return new ByMock() + return new ByClass() }; this.enabled = function(...args) { console.warn('uitest.By.enabled' + warnMessage) - return new ByMock() + return new ByClass() }; this.longClickable = function(...args) { console.warn('uitest.By.longClickable' + warnMessage) - return new ByMock() + return new ByClass() }; this.scrollable = function(...args) { console.warn('uitest.By.scrollable' + warnMessage) - return new ByMock() + return new ByClass() }; this.checkable = function(...args) { console.warn('uitest.By.checkable' + warnMessage) - return new ByMock() + return new ByClass() }; this.checked = function(...args) { console.warn('uitest.By.checked' + warnMessage) - return new ByMock() + return new ByClass() }; this.isBefore = function(...args) { console.warn('uitest.By.isBefore' + warnMessage) - return new ByMock() + return new ByClass() }; this.isAfter = function(...args) { console.warn('uitest.By.isAfter' + warnMessage) - return new ByMock() + return new ByClass() }; } } @@ -147,25 +147,25 @@ const UiDriverClass = class UiDriverMock { this.findComponent = function(...args) { console.warn('uitest.UiDriver.findComponent' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.findWindow = function(...args) { console.warn('uitest.UiDriver.findWindow' + warnMessage) return new Promise((resolve) => { - resolve(new UiWindowMock()) + resolve(new UiWindowClass()) }); }; this.findComponents = function(...args) { console.warn('uitest.UiDriver.findComponents' + warnMessage) return new Promise((resolve) => { - resolve(new Array(new UiComponentMock())) + resolve(new Array(new UiComponentClass())) }); }; this.waitForComponent = function(...args) { console.warn('uitest.UiDriver.waitForComponent' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.screenCap = function(...args) { @@ -314,13 +314,13 @@ const UiComponentClass = class UiComponentMock { this.getBounds = function(...args) { console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) return new Promise((resolve) => { - resolve(RectMock) + resolve(Rect) }); }; this.getBoundsCenter = function(...args) { console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) return new Promise((resolve) => { - resolve(PointMock) + resolve(Point) }); }; this.click = function(...args) { @@ -368,7 +368,7 @@ const UiComponentClass = class UiComponentMock { this.scrollSearch = function(...args) { console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) return new Promise((resolve) => { - resolve(new UiComponentMock()) + resolve(new UiComponentClass()) }); }; this.dragTo = function(...args) { @@ -404,7 +404,7 @@ const UiWindowClass = class UiWindowMock { this.getBounds = function(...args) { console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) return new Promise((resolve) => { - resolve(RectMock) + resolve(Rect) }); }; this.getTitle = function(...args) { @@ -416,7 +416,7 @@ const UiWindowClass = class UiWindowMock { this.getWindowMode = function(...args) { console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) return new Promise((resolve) => { - resolve(WindowModeMock) + resolve(WindowMode) }); }; this.isFocused = function(...args) { @@ -484,12 +484,12 @@ const UiWindowClass = class UiWindowMock { export function mockUiTest() { const module = { - ResizeDirection: ResizeDirectionMock, - MatchPattern: MatchPatternMock, - WindowMode: WindowModeMock, - Point: PointMockClass, - Rect: RectMockClass, - WindowFilter: WindowFilterMockClass, + ResizeDirection: ResizeDirection, + MatchPattern: MatchPattern, + WindowMode: WindowMode, + Point: Point, + Rect: Rect, + WindowFilter: WindowFilter, BY: new ByClass(), UiDriver: UiDriverClass, UiComponent: UiComponentClass, From 528a60ff6c6cfab67ac28f4f9be8c05d6c3cb4db Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 14:23:07 +0800 Subject: [PATCH 020/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 780032c0..a7e236f8 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -240,151 +240,151 @@ const UiComponentClass = class UiComponentMock { constructor() { console.warn('uitest.UiComponent.constructor' + warnMessage); this.getId = function(...args) { - console.warn('uitest.UiComponent.getId.warn' + warnMessage) + console.warn('uitest.UiComponent.getId' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramNumberMock) }); }; this.getText = function(...args) { - console.warn('uitest.UiComponent.getText.warn' + warnMessage) + console.warn('uitest.UiComponent.getText' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getKey = function(...args) { - console.warn('uitest.UiComponent.getKey.warn' + warnMessage) + console.warn('uitest.UiComponent.getKey' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getType = function(...args) { - console.warn('uitest.UiComponent.getType.warn' + warnMessage) + console.warn('uitest.UiComponent.getType' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.isEnabled = function(...args) { - console.warn('uitest.UiComponent.isEnabled.warn' + warnMessage) + console.warn('uitest.UiComponent.isEnabled' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiComponent.isFocused.warn' + warnMessage) + console.warn('uitest.UiComponent.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isSelected = function(...args) { - console.warn('uitest.UiComponent.isSelected.warn' + warnMessage) + console.warn('uitest.UiComponent.isSelected' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isClickable = function(...args) { - console.warn('uitest.UiComponent.isClickable.warn' + warnMessage) + console.warn('uitest.UiComponent.isClickable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isLongClickable = function(...args) { - console.warn('uitest.UiComponent.isLongClickable.warn' + warnMessage) + console.warn('uitest.UiComponent.isLongClickable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isScrollable = function(...args) { - console.warn('uitest.UiComponent.isScrollable.warn' + warnMessage) + console.warn('uitest.UiComponent.isScrollable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isCheckable = function(...args) { - console.warn('uitest.UiComponent.isCheckable.warn' + warnMessage) + console.warn('uitest.UiComponent.isCheckable' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isChecked = function(...args) { - console.warn('uitest.UiComponent.isChecked.warn' + warnMessage) + console.warn('uitest.UiComponent.isChecked' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiComponent.getBounds.warn' + warnMessage) + console.warn('uitest.UiComponent.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getBoundsCenter = function(...args) { - console.warn('uitest.UiComponent.getBoundsCenter.warn' + warnMessage) + console.warn('uitest.UiComponent.getBoundsCenter' + warnMessage) return new Promise((resolve) => { resolve(Point) }); }; this.click = function(...args) { - console.warn('uitest.UiComponent.click.warn' + warnMessage) + console.warn('uitest.UiComponent.click' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.longClick = function(...args) { - console.warn('uitest.UiComponent.longClick.warn' + warnMessage) + console.warn('uitest.UiComponent.longClick' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.doubleClick = function(...args) { - console.warn('uitest.UiComponent.doubleClick.warn' + warnMessage) + console.warn('uitest.UiComponent.doubleClick' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollToTop = function(...args) { - console.warn('uitest.UiComponent.scrollToTop.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollToTop' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollToBottom = function(...args) { - console.warn('uitest.UiComponent.scrollToBottom.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollToBottom' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.inputText = function(...args) { - console.warn('uitest.UiComponent.inputText.warn' + warnMessage) + console.warn('uitest.UiComponent.inputText' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.clearText = function(...args) { - console.warn('uitest.UiComponent.clearText.warn' + warnMessage) + console.warn('uitest.UiComponent.clearText' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.scrollSearch = function(...args) { - console.warn('uitest.UiComponent.scrollSearch.warn' + warnMessage) + console.warn('uitest.UiComponent.scrollSearch' + warnMessage) return new Promise((resolve) => { resolve(new UiComponentClass()) }); }; this.dragTo = function(...args) { - console.warn('uitest.UiComponent.dragTo.warn' + warnMessage) + console.warn('uitest.UiComponent.dragTo' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.pinchOut = function(...args) { - console.warn('uitest.UiComponent.pinchOut.warn' + warnMessage) + console.warn('uitest.UiComponent.pinchOut' + warnMessage) return new Promise((resolve) => { resolve() }); }; this.pinchIn = function(...args) { - console.warn('uitest.UiComponent.pinchIn.warn' + warnMessage) + console.warn('uitest.UiComponent.pinchIn' + warnMessage) return new Promise((resolve) => { resolve() }); @@ -396,85 +396,85 @@ const UiWindowClass = class UiWindowMock { constructor() { console.warn('uitest.UiWindowMock.constructor' + warnMessage); this.getBundleName = function(...args) { - console.warn('uitest.UiWindowMock.getBundleName.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getBundleName' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiWindowMock.getBounds.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getTitle = function(...args) { - console.warn('uitest.UiWindowMock.getTitle.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getTitle' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getWindowMode = function(...args) { - console.warn('uitest.UiWindowMock.getWindowMode.warn' + warnMessage) + console.warn('uitest.UiWindowMock.getWindowMode' + warnMessage) return new Promise((resolve) => { resolve(WindowMode) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiWindowMock.isFocused.warn' + warnMessage) + console.warn('uitest.UiWindowMock.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isActived = function(...args) { - console.warn('uitest.UiWindowMock.isActived.warn' + warnMessage) + console.warn('uitest.UiWindowMock.isActived' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.focuse = function(...args) { - console.warn('uitest.UiWindowMock.focuse.warn' + warnMessage) + console.warn('uitest.UiWindowMock.focuse' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.moveTo = function(...args) { - console.warn('uitest.UiWindowMock.moveTo.warn' + warnMessage) + console.warn('uitest.UiWindowMock.moveTo' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resize = function(...args) { - console.warn('uitest.UiWindowMock.resize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.resize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.split = function(...args) { - console.warn('uitest.UiWindowMock.split.warn' + warnMessage) + console.warn('uitest.UiWindowMock.split' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.maximize = function(...args) { - console.warn('uitest.UiWindowMock.maximize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.maximize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resume = function(...args) { - console.warn('uitest.UiWindowMock.resume.warn' + warnMessage) + console.warn('uitest.UiWindowMock.resume' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.minimize = function(...args) { - console.warn('uitest.UiWindowMock.minimize.warn' + warnMessage) + console.warn('uitest.UiWindowMock.minimize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.close = function(...args) { - console.warn('uitest.UiWindowMock.close.warn' + warnMessage) + console.warn('uitest.UiWindowMock.close' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From ba4e7501ac5fc59093074f1ff8051d04d804a03c Mon Sep 17 00:00:00 2001 From: duanweiling Date: Mon, 18 Jul 2022 15:30:39 +0800 Subject: [PATCH 021/103] =?UTF-8?q?mock=20=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../extend/systemplugin/napi/ohos_data_dataSharePredicates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" + From 2711b1b6e89b70a7252b30ec7c19fec9026971e0 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Mon, 18 Jul 2022 15:55:02 +0800 Subject: [PATCH 022/103] Signed-off-by: ma-shaoyin Changes to be committed: --- .../main/extend/systemplugin/napi/ohos_inputmethodengine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index f7d6c51a..d7722b82 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -36,8 +36,8 @@ export function mockInputMethodEngine() { inputOption: 3 } const KeyEvent = { - keyCode: 1, - keyAction: 2, + keyCode: "[PC Preview] unknow keyCode", + keyAction: "[PC Preview] unknow keyAction" } const RichContent = { contentURI: "[PC Preview] unknow contentURI", From 4e75350066001a2c465e7c5b41a8738eee484cfb Mon Sep 17 00:00:00 2001 From: PaDaBoo Date: Mon, 18 Jul 2022 15:55:38 +0800 Subject: [PATCH 023/103] update Storage mock file Signed-off-by: PaDaBoo --- .../systemplugin/napi/ohos_data_Storage.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 23aa2fc2..53f373b3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -15,6 +15,17 @@ import { paramMock } from "../utils" +const ValueTypes = { + unknow: '[PC Preview] unknow value type' +}; + +const StorageObserverMock = { + key: '[PC Preview] unknown key' +}; +const MAX_KEY_LENGTH = 80; + +const MAX_VALUE_LENGTH = 8192; + export function mockDataStorage() { const storage = { storageMock, @@ -72,17 +83,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.unknow }, 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.unknow) } else { return new Promise((resolve) => { - resolve(paramValueTypeMock) + resolve(ValueTypes.unknow) }) } }, @@ -171,7 +182,7 @@ 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, StorageObserverMock) }, off: function (...args) { console.warn("Storage.off interface mocked in the Previewer. How this interface works on the Previewer may be" + From fe66bf7d0bc3d9f1e808f6cbafd14df22b19cad1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 15:59:30 +0800 Subject: [PATCH 024/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- runtime/main/extend/systemplugin/napi/ohos_uitest.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index a7e236f8..738af166 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -45,28 +45,22 @@ export const WindowMode = { } export const Point = { - constructor() { X: '[PC Preview] unknown X'; Y: '[PC Preview] unknown Y'; - } } export const Rect = { - constructor() { leftX: '[PC Preview] unknown leftX'; topY: '[PC Preview] unknown topY'; rightX: '[PC Preview] unknown rightX'; bottomY: '[PC Preview] unknown bottomY'; - } } export const WindowFilter = { - constructor() { bundleName: '[PC Preview] unknown bundleName'; title: '[PC Preview] unknown title'; focused: '[PC Preview] unknown focused'; actived: '[PC Preview] unknown actived'; - } } const ByClass = class ByMock { From 7e36d810ac46243a8c5c5f7c823a82b7186abfbd Mon Sep 17 00:00:00 2001 From: anyueling Date: Mon, 18 Jul 2022 16:20:15 +0800 Subject: [PATCH 025/103] =?UTF-8?q?API=20MOCK=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- .../extend/systemplugin/napi/ohos_request.js | 269 ++++++++++++++++-- 1 file changed, 244 insertions(+), 25 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index f82bdcc6..2f8ea44f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_request.js +++ b/runtime/main/extend/systemplugin/napi/ohos_request.js @@ -13,38 +13,257 @@ * limitations under the License. */ -import { hasComplete } from "../utils" +import { paramMock } from "../utils" export function mockRequest() { - const uploadResponseMock = { - code: "[PC Preview]: unknow code", + const downloadConfigMock = { + url: "[PC Preview]: unknow uri", + herder: "[PC Preview]: unknow herder", + 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 downloadInfoMock = { + 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("AYL.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("AYL.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) + } + } 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("AYL.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("AYL.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("AYL.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("AYL.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("AYL.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 fileMock = { + filename: "[PC Preview]: unknow filename", + name: "[PC Preview]: unknow name", + uri: "[PC Preview]: unknow uri", + type: "[PC Preview]: unknow type", + }; + + const requestDataMock = { + name: "[PC Preview]: unknow name", + value: "[PC Preview]: unknow value", + }; + + const uploadConfigMock = { + url: "[PC Preview]: unknow uri", + herder: "[PC Preview]: unknow herder", + method: "[PC Preview]: unknow method", + files: "[PC Preview]: unknow files", 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 UploadTask = { + on: function (...args) { + console.warn("AYL.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("AYL.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("AYL.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("AYL.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("AYL.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 From d698d8aee19bb72566c57d4ff7874fa11756ca1d Mon Sep 17 00:00:00 2001 From: PaDaBoo Date: Mon, 18 Jul 2022 16:45:01 +0800 Subject: [PATCH 026/103] update Storage mock file Signed-off-by: PaDaBoo --- .../systemplugin/napi/ohos_data_Storage.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js index 53f373b3..36977af0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_Storage.js @@ -15,11 +15,9 @@ import { paramMock } from "../utils" -const ValueTypes = { - unknow: '[PC Preview] unknow value type' -}; +const ValueTypes = '[PC Preview] unknow value type' -const StorageObserverMock = { +const StorageObserver = { key: '[PC Preview] unknown key' }; const MAX_KEY_LENGTH = 80; @@ -83,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 ValueTypes.unknow + 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, ValueTypes.unknow) + args[len - 1].call(this, paramMock.businessErrorMock, ValueTypes) } else { return new Promise((resolve) => { - resolve(ValueTypes.unknow) + resolve(ValueTypes) }) } }, @@ -182,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 From e06e2cf3927aeeeb63d1b4e3d20ac2b8b28eea86 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 Jul 2022 18:09:56 +0800 Subject: [PATCH 027/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 738af166..20eb6313 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -45,22 +45,22 @@ export const WindowMode = { } export const Point = { - X: '[PC Preview] unknown X'; - Y: '[PC Preview] unknown Y'; + 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'; + 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'; + bundleName: '[PC Preview] unknown bundleName', + title: '[PC Preview] unknown title', + focused: '[PC Preview] unknown focused', + actived: '[PC Preview] unknown actived' } const ByClass = class ByMock { @@ -425,8 +425,8 @@ const UiWindowClass = class UiWindowMock { resolve(paramMock.paramBoolMock) }); }; - this.focuse = function(...args) { - console.warn('uitest.UiWindowMock.focuse' + warnMessage) + this.focus = function(...args) { + console.warn('uitest.UiWindowMock.focus' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From 79e8669c0a772ce86a8a398523141e6555d156f9 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Tue, 19 Jul 2022 09:03:29 +0800 Subject: [PATCH 028/103] Signed-off-by: ma-shaoyin Changes to be committed: --- .../systemplugin/napi/ohos_inputmethod.js | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) 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 From 1a773d225eeed846b67aec5a66ba84fe7629ca27 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 19 Jul 2022 09:31:07 +0800 Subject: [PATCH 029/103] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_screenLock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index edf5f1d1..2d3c9501 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -69,7 +69,7 @@ export function mockScreenLock() { } }, off: function (...args) { - console.warn("screenLock.ofF interface mocked in the Previewer. How this interface works on the" + + 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') { From e289be0665a3e330ee571c30d9ffbff3e21c5936 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 Jul 2022 09:54:34 +0800 Subject: [PATCH 030/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index 20eb6313..c0be4ccd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -388,87 +388,87 @@ const UiComponentClass = class UiComponentMock { const UiWindowClass = class UiWindowMock { constructor() { - console.warn('uitest.UiWindowMock.constructor' + warnMessage); + console.warn('uitest.UiWindow.constructor' + warnMessage); this.getBundleName = function(...args) { - console.warn('uitest.UiWindowMock.getBundleName' + warnMessage) + console.warn('uitest.UiWindow.getBundleName' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getBounds = function(...args) { - console.warn('uitest.UiWindowMock.getBounds' + warnMessage) + console.warn('uitest.UiWindow.getBounds' + warnMessage) return new Promise((resolve) => { resolve(Rect) }); }; this.getTitle = function(...args) { - console.warn('uitest.UiWindowMock.getTitle' + warnMessage) + console.warn('uitest.UiWindow.getTitle' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramStringMock) }); }; this.getWindowMode = function(...args) { - console.warn('uitest.UiWindowMock.getWindowMode' + warnMessage) + console.warn('uitest.UiWindow.getWindowMode' + warnMessage) return new Promise((resolve) => { resolve(WindowMode) }); }; this.isFocused = function(...args) { - console.warn('uitest.UiWindowMock.isFocused' + warnMessage) + console.warn('uitest.UiWindow.isFocused' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.isActived = function(...args) { - console.warn('uitest.UiWindowMock.isActived' + warnMessage) + console.warn('uitest.UiWindow.isActived' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.focus = function(...args) { - console.warn('uitest.UiWindowMock.focus' + warnMessage) + console.warn('uitest.UiWindow.focus' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.moveTo = function(...args) { - console.warn('uitest.UiWindowMock.moveTo' + warnMessage) + console.warn('uitest.UiWindow.moveTo' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resize = function(...args) { - console.warn('uitest.UiWindowMock.resize' + warnMessage) + console.warn('uitest.UiWindow.resize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.split = function(...args) { - console.warn('uitest.UiWindowMock.split' + warnMessage) + console.warn('uitest.UiWindow.split' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.maximize = function(...args) { - console.warn('uitest.UiWindowMock.maximize' + warnMessage) + console.warn('uitest.UiWindow.maximize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.resume = function(...args) { - console.warn('uitest.UiWindowMock.resume' + warnMessage) + console.warn('uitest.UiWindow.resume' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.minimize = function(...args) { - console.warn('uitest.UiWindowMock.minimize' + warnMessage) + console.warn('uitest.UiWindow.minimize' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); }; this.close = function(...args) { - console.warn('uitest.UiWindowMock.close' + warnMessage) + console.warn('uitest.UiWindow.close' + warnMessage) return new Promise((resolve) => { resolve(paramMock.paramBoolMock) }); From 02d2642b6518e48473a5df1acd5739dfc66f5e1b Mon Sep 17 00:00:00 2001 From: wuyongning Date: Tue, 19 Jul 2022 11:02:15 +0800 Subject: [PATCH 031/103] add enum mock Signed-off-by: wuyongning --- runtime/main/extend/systemplugin/napi/ohos_data_rdb.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 795a2642..3a4f1208 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: "[PC Preview] unknown SYNC_MODE_PUSH", + SYNC_MODE_PULL: "[PC Preview] unknown SYNC_MODE_PULL" + } + + const SubscribeType = { + SUBSCRIBE_TYPE_REMOTE: "[PC Preview] unknown SUBSCRIBE_TYPE_REMOTE" + } + const rdbStore = { insert: function (...args) { console.warn("RdbStore.insert interface mocked in the Previewer. How this interface works on the" + From 83c4a195cf53fcf12f013fda0d6c50c511b17821 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Tue, 19 Jul 2022 11:18:44 +0800 Subject: [PATCH 032/103] fix err Signed-off-by: wuyongning --- runtime/main/extend/systemplugin/napi/ohos_data_rdb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js index 3a4f1208..e9ac4c8c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js +++ b/runtime/main/extend/systemplugin/napi/ohos_data_rdb.js @@ -207,12 +207,12 @@ export function mockRdb() { } const SyncMode = { - SYNC_MODE_PUSH: "[PC Preview] unknown SYNC_MODE_PUSH", - SYNC_MODE_PULL: "[PC Preview] unknown SYNC_MODE_PULL" + SYNC_MODE_PUSH: 0, + SYNC_MODE_PULL: 1 } const SubscribeType = { - SUBSCRIBE_TYPE_REMOTE: "[PC Preview] unknown SUBSCRIBE_TYPE_REMOTE" + SUBSCRIBE_TYPE_REMOTE: 0 } const rdbStore = { From 3094173b3f6825a290cc9303f8ea3dfe19bbd183 Mon Sep 17 00:00:00 2001 From: duanweiling Date: Tue, 19 Jul 2022 11:20:43 +0800 Subject: [PATCH 033/103] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanweiling --- .../systemplugin/napi/ohos_data_DataShareResultSet.js | 7 +++++++ 1 file changed, 7 insertions(+) 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", From 5204d3e4a5a337793b711ca74894c9dfffb0ad2f Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 Jul 2022 14:20:49 +0800 Subject: [PATCH 034/103] =?UTF-8?q?uitest=20MockAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0.=20Signed-off-by:=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Your Name --- .../extend/systemplugin/napi/ohos_uitest.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_uitest.js b/runtime/main/extend/systemplugin/napi/ohos_uitest.js index c0be4ccd..550bd76e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uitest.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uitest.js @@ -165,7 +165,7 @@ const UiDriverClass = class UiDriverMock { this.screenCap = function(...args) { console.warn('uitest.UiDriver.screenCap' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.assertComponentExist = function(...args) { @@ -260,49 +260,49 @@ const UiComponentClass = class UiComponentMock { this.isEnabled = function(...args) { console.warn('uitest.UiComponent.isEnabled' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isFocused = function(...args) { console.warn('uitest.UiComponent.isFocused' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isSelected = function(...args) { console.warn('uitest.UiComponent.isSelected' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isClickable = function(...args) { console.warn('uitest.UiComponent.isClickable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isLongClickable = function(...args) { console.warn('uitest.UiComponent.isLongClickable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isScrollable = function(...args) { console.warn('uitest.UiComponent.isScrollable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isCheckable = function(...args) { console.warn('uitest.UiComponent.isCheckable' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isChecked = function(...args) { console.warn('uitest.UiComponent.isChecked' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.getBounds = function(...args) { @@ -416,61 +416,61 @@ const UiWindowClass = class UiWindowMock { this.isFocused = function(...args) { console.warn('uitest.UiWindow.isFocused' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.isActived = function(...args) { console.warn('uitest.UiWindow.isActived' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.focus = function(...args) { console.warn('uitest.UiWindow.focus' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.moveTo = function(...args) { console.warn('uitest.UiWindow.moveTo' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.resize = function(...args) { console.warn('uitest.UiWindow.resize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.split = function(...args) { console.warn('uitest.UiWindow.split' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.maximize = function(...args) { console.warn('uitest.UiWindow.maximize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.resume = function(...args) { console.warn('uitest.UiWindow.resume' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.minimize = function(...args) { console.warn('uitest.UiWindow.minimize' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; this.close = function(...args) { console.warn('uitest.UiWindow.close' + warnMessage) return new Promise((resolve) => { - resolve(paramMock.paramBoolMock) + resolve(paramMock.paramBooleanMock) }); }; }; From e4c6942aed07f7e6f6efc4509fda46aba7afb255 Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Tue, 19 Jul 2022 14:45:41 +0800 Subject: [PATCH 035/103] update mock Signed-off-by: zhangxingxia --- runtime/main/extend/systemplugin/napi/ohos_fileManager.js | 8 ++++---- .../main/extend/systemplugin/napi/ohos_volumeManager.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js index 6491bda7..d9fc9eb9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_fileManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_fileManager.js @@ -35,10 +35,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, Array(FileInfo)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfo)); + resolve(new Array(FileInfo)); }) } }, @@ -47,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, Array(FileInfo)) + args[len - 1].call(this, paramMock.businessErrorMock, new Array(FileInfo)) } else { return new Promise((resolve, reject) => { - resolve(Array(FileInfo)); + resolve(new Array(FileInfo)); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js index 412dda53..4854b912 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_volumeManager.js @@ -31,10 +31,10 @@ export function mockVolumeManager() { " 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(Volume)); + args[len - 1].call(this, paramMock.businessErrorMock, new Array(Volume)); } else { return new Promise((resolve, reject) => { - resolve(Array(Volume)); + resolve(new Array(Volume)); }) } }, From 10e8cebef9fa647a3d7aba0d4402d61e1b8357b5 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 19 Jul 2022 17:16:31 +0800 Subject: [PATCH 036/103] Signed-off-by: lovechinamo Changes to be committed: --- .../main/extend/systemplugin/napi/ohos_wallpaper.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js b/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js index 3a8e0a14..c6e1304b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js +++ b/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js @@ -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.") From 812fed0b9fcc0ecff0c7669b70335ed2d11f49a2 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 19 Jul 2022 17:22:20 +0800 Subject: [PATCH 037/103] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 195 ++++++++++++- .../extend/systemplugin/ohos/pasteboard.js | 257 ------------------ 2 files changed, 194 insertions(+), 258 deletions(-) delete mode 100644 runtime/main/extend/systemplugin/ohos/pasteboard.js diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index efedd4d0..93649029 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -21,9 +21,162 @@ export function mockPasteBoard() { 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.") @@ -49,12 +202,52 @@ export function mockPasteBoard() { } } } - const pasteboard = { + 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.") 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; - } - } -} From 804dc39caea7b562bb42501a14637f87ea47fbfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Tue, 19 Jul 2022 15:15:38 +0800 Subject: [PATCH 038/103] =?UTF-8?q?=E5=8C=85=E7=AE=A1=E8=A1=A5=E9=BD=90moc?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../systemplugin/napi/bundle/abilityInfo.js | 3 + .../systemplugin/napi/bundle/bundleInfo.js | 2 +- .../napi/bundle/bundleInstaller.js | 1 + .../systemplugin/napi/bundle/hapModuleInfo.js | 5 ++ .../napi/bundle/launcherAbilityInfo.js | 4 +- .../systemplugin/napi/bundle/packInfo.js | 2 +- .../extend/systemplugin/napi/ohos_zlib.js | 79 +++++++++---------- 7 files changed, 50 insertions(+), 46 deletions(-) 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/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js index 7496aef6..d137641f 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,7 @@ 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], } \ 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/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 From a1d19deb73781a0aa58ddffe8d4888882497705c Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 09:55:14 +0800 Subject: [PATCH 039/103] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_wallpaper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js b/runtime/main/extend/systemplugin/napi/ohos_wallpaper.js index c6e1304b..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 From 9aa39d14768643f9889a2936efe64e7d8420d2bb Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 09:56:17 +0800 Subject: [PATCH 040/103] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_pasteboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index 93649029..bb66e601 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 @@ -202,7 +202,7 @@ export function mockPasteBoard() { } } } - global.ohosplugin.pasteboard = { + const 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', From d5659f8fd3b9aa5a2e6cb95db2c4f9c6d69e3865 Mon Sep 17 00:00:00 2001 From: anyueling Date: Wed, 20 Jul 2022 10:05:26 +0800 Subject: [PATCH 041/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- .../extend/systemplugin/napi/ohos_request.js | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index 2f8ea44f..6afa10cf 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_request.js +++ b/runtime/main/extend/systemplugin/napi/ohos_request.js @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockRequest() { - const downloadConfigMock = { + const DownloadConfig = { url: "[PC Preview]: unknow uri", herder: "[PC Preview]: unknow herder", enableMetered: "[PC Preview]: unknow enableMetered", @@ -27,7 +27,7 @@ export function mockRequest() { title: "[PC Preview]: unknow title", }; - const downloadInfoMock = { + const DownloadInfo = { description: "[PC Preview]: unknow description", downloadedBytes: "[PC Preview]: unknow downloadedBytes", downloadId: "[PC Preview]: unknow downloadId", @@ -43,7 +43,7 @@ export function mockRequest() { const DownloadTask = { on: function (...args) { - console.warn("AYL.downloadTask.on interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -61,7 +61,7 @@ export function mockRequest() { }, off: function (...args) { - console.warn("AYL.downloadTask.off interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -75,18 +75,11 @@ export function mockRequest() { const err = "[PC Preview]: unknow err" args[len - 1].call(this, err) } - } 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("AYL.downloadTask.remove interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -99,7 +92,7 @@ export function mockRequest() { }, pause: function (...args) { - console.warn("AYL.downloadTask.pause interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -112,7 +105,7 @@ export function mockRequest() { }, resume: function (...args) { - console.warn("AYL.downloadTask.resume interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -125,7 +118,7 @@ export function mockRequest() { }, query: function (...args) { - console.warn("AYL.downloadTask.query interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -138,7 +131,7 @@ export function mockRequest() { }, queryMimeType: function (...args) { - console.warn("AYL.downloadTask.queryMimeType interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -151,29 +144,29 @@ export function mockRequest() { }, }; - const fileMock = { + const File = { filename: "[PC Preview]: unknow filename", name: "[PC Preview]: unknow name", uri: "[PC Preview]: unknow uri", type: "[PC Preview]: unknow type", }; - const requestDataMock = { + const RequestData = { name: "[PC Preview]: unknow name", value: "[PC Preview]: unknow value", }; - const uploadConfigMock = { + const UploadConfig = { url: "[PC Preview]: unknow uri", herder: "[PC Preview]: unknow herder", method: "[PC Preview]: unknow method", - files: "[PC Preview]: unknow files", - data: "[PC Preview]: unknow data", + files: [File], + data: [RequestData], }; const UploadTask = { on: function (...args) { - console.warn("AYL.uploadTask.on interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -189,7 +182,7 @@ export function mockRequest() { }, off: function (...args) { - console.warn("AYL.uploadTask.off interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -205,7 +198,7 @@ export function mockRequest() { }, remove: function (...args) { - console.warn("AYL.uploadTask.remove interface mocked in the Previewer. How this interface works on the" + + 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') { @@ -241,7 +234,7 @@ export function mockRequest() { SESSION_SUCCESSFUL: '[PC preview] unknow SESSION_SUCCESSFUL', download: function (...args) { - console.warn("AYL.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.") const len = args.length if (typeof args[len - 1] === 'function') { @@ -254,7 +247,7 @@ export function mockRequest() { }, upload: function (...args) { - console.warn("AYL.request.upload interface mocked in the Previewer. How this interface works on the" + + 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') { From 079970ca6d35d7701bda39dd7d31eaa68951c327 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 16:33:26 +0800 Subject: [PATCH 042/103] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index bb66e601..ad840fcb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -20,7 +20,7 @@ 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 () { console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + @@ -48,12 +48,12 @@ export function mockPasteBoard() { let mimeTypes = new Array(); mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); - return mimeTypes; + 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 "[PC Preview] unknow getPrimaryHtml" + return paramMock.paramStringMock }, getPrimaryWant: function () { console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + @@ -63,12 +63,12 @@ export function mockPasteBoard() { 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" + 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 "[PC Preview] unknow getPrimaryUri" + return paramMock.paramStringMock }, getProperty: function () { console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + @@ -83,27 +83,27 @@ export function mockPasteBoard() { 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" + 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 "[PC Preview] unknow getTag" + return paramMock.paramStringMock }, 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" + return paramMock.paramBooleanMock }, 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" + return paramMock.paramBooleanMock }, 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" + return paramMock.paramBooleanMock } } const PasteDataRecordMock = { From 6f8ccb580b536c40ad840eaa8512a6e0dc5c8f40 Mon Sep 17 00:00:00 2001 From: wangxiyue Date: Wed, 20 Jul 2022 16:45:16 +0800 Subject: [PATCH 043/103] amend interface description Signed-off-by: wangxiyue --- .../systemplugin/napi/ohos_data_distributedDataObject.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; +} From 1da3c7df17640ddb8f576625b45ce23e148f87cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Wed, 20 Jul 2022 10:52:44 +0000 Subject: [PATCH 044/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/systemplugin/napi/ohos_update.js | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index d78eeb32..cc209a65 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -246,6 +246,16 @@ export function mockUpdate() { UpgradeStatus, EventClassify, EventId, + UpgradeInfo, + BusinessType, + DownloadOptions, + ResumeDownloadOptions, + PauseDownloadOptions, + UpgradeOptions, + ClearOptions, + EventClassifyInfo, + UpgradeFile, + UpgradeTaskCallback, 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 +281,6 @@ const BusinessVendor = { const BusinessSubType = { FIRMWARE: 1, - PARAM: 2, } const ComponentType = { @@ -413,3 +422,48 @@ const EventInfo = { eventId: EventId.EVENT_TASK_RECEIVE, taskBody: TaskBody, } + +const UpgradeInfo = { + upgradeApp: "com.ohos.ota.updateclient", + businessType: BusinessType +} + +const BusinessType = { + vendor: BusinessVendor, + subType: BusinessSubType +} + +const DownloadOptions = { + allowNetwork: NetType, + order: Order +} + +const ResumeDownloadOptions = { + allowNetwork: NetType +} + +const PauseDownloadOptions = { + isAllowAutoResume: boolean +} + +const UpgradeOptions = { + order: Order +} + +const ClearOptions = { + status: UpgradeStatus +} + +const EventClassifyInfo = { + eventClassify: EventClassify, + extraInfo: string +} + +const UpgradeFile = { + fileType: ComponentType, + filePath: string +} + +const UpgradeTaskCallback = { + UpgradeTaskCallback: (eventInfo) => {} +} \ No newline at end of file From 382a8b19b660868176c68c098e8bef340a9b2887 Mon Sep 17 00:00:00 2001 From: lin-jianwu Date: Wed, 20 Jul 2022 19:27:34 +0800 Subject: [PATCH 045/103] add part media mock Signed-off-by: lin-jianwu Change-Id: I2fb9242345134fda200b50f7a020abfed989ca40 --- .../napi/ohos_multimedia_media.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js index e7ca398f..8b92503a 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: '[PC Preview] unknow fdSrc', loop: '[PC Preview] unknow loop', + audioInterruptMode: '[PC Preview] unknow audioInterruptMode', 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: '[PC Preview] unknow fdSrc', 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: '[PC Preview] unknow audioInterruptMode', + videoScaleType: '[PC Preview] unknow 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(); + }); + } + }, 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', @@ -387,7 +409,7 @@ export function mockMultimediaMedia() { const mediaDescriptionMock = { key: '[PC Preview] unknow key', } - const multimediaMediaMock = { + const mediaMock = { MediaErrorCode : { MSERR_OK: 0, MSERR_NO_MEMORY: 1, @@ -437,6 +459,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 +533,5 @@ export function mockMultimediaMedia() { } }, } - return multimediaMediaMock; + return mediaMock; } From 4b576b554b5328ac04114ac663879de71e4dd965 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 19:58:52 +0800 Subject: [PATCH 046/103] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index ad840fcb..391d9df1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -22,23 +22,23 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return paramMock.paramStringMock }, - addHtmlRecord: function () { + 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 () { + 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 () { + 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 () { + 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 () { + 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.") }, @@ -75,7 +75,7 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return PasteDataPropertyMock; }, - getRecordAt: function () { + 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; @@ -90,17 +90,17 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return paramMock.paramStringMock }, - hasMimeType: function () { + 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 () { + 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 () { + 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 @@ -208,42 +208,42 @@ export function mockPasteBoard() { 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 () { + 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 () { + 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 () { + 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 () { + 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 () { + 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 () { + 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 () { + 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 () { + 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; From ed2085f6ada8c59ac7fef0cdf715066540350474 Mon Sep 17 00:00:00 2001 From: zhangfeng Date: Sat, 16 Jul 2022 09:05:02 +0000 Subject: [PATCH 047/103] update wifi and wifiext mock file Signed-off-by: zhangfeng --- .../main/extend/systemplugin/napi/index.js | 3 + .../extend/systemplugin/napi/ohos_wifi.js | 295 +++++++++++++++--- .../extend/systemplugin/napi/ohos_wifiext.js | 71 +++++ 3 files changed, 334 insertions(+), 35 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_wifiext.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 5d7c060e..6c24f301 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -70,6 +70,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' @@ -387,6 +388,8 @@ export function mockRequireNapiFun() { return mockSensor(); case "wifi": return mockWifi(); + case "wifiext": + return mockWifiExt(); case "usb": return mockUsb(); case "bundle": 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; +} From ad54bfe09230c723ad7c37fa042c4b00b1ffae81 Mon Sep 17 00:00:00 2001 From: lin-jianwu Date: Thu, 21 Jul 2022 09:48:38 +0800 Subject: [PATCH 048/103] fix review Signed-off-by: lin-jianwu Change-Id: I49ee2c492961a675fe20c7be77edb01d58332a54 --- .../napi/ohos_multimedia_media.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js index 8b92503a..78c3e6f2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js @@ -58,9 +58,9 @@ export function mockMultimediaMedia() { } }, src: '[PC Preview] unknow src', - fdSrc: '[PC Preview] unknow fdSrc', + fdSrc: AVFileDescriptor, loop: '[PC Preview] unknow loop', - audioInterruptMode: '[PC Preview] unknow audioInterruptMode', + audioInterruptMode: InterruptMode, currentTime: '[PC Preview] unknow currentTime', duration: '[PC Preview] unknow duration', state: '[PC Preview] unknow state', @@ -223,15 +223,15 @@ export function mockMultimediaMedia() { } const videoPlayerMock = { url: '[PC Preview] unknow url', - fdSrc: '[PC Preview] unknow fdSrc', + 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: '[PC Preview] unknow audioInterruptMode', - videoScaleType: '[PC Preview] unknow videoScaleType', + audioInterruptMode: InterruptMode, + videoScaleType: 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.") @@ -372,7 +372,7 @@ export function mockMultimediaMedia() { args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock); } else { return new Promise((resolve) => { - resolve(); + resolve(paramMock.paramNumberMock); }); } }, @@ -381,7 +381,7 @@ export function mockMultimediaMedia() { " may be different from that on a real device.") }, } - const avfileDescriptorMock = { + const AVFileDescriptorMock = { fd: '[PC Preview] unknow fd', offset: '[PC Preview] unknow audioChannels', length: '[PC Preview] unknow audioCodec', @@ -407,7 +407,11 @@ export function mockMultimediaMedia() { location: locationMock, } const mediaDescriptionMock = { - key: '[PC Preview] unknow key', + "key": 'paramMock.paramObjectMock', + } + const InterruptModeMock = { + SHARE_MODE: 0, + INDEPENDENT_MODE: 1 } const mediaMock = { MediaErrorCode : { From 885b2f6d63a6f2863d06867f8dbffc318f6039e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Thu, 21 Jul 2022 02:10:47 +0000 Subject: [PATCH 049/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/extend/systemplugin/napi/ohos_update.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index cc209a65..3e388ff6 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(); }) } }, @@ -306,13 +306,17 @@ const DescriptionType = { const NetType = { CELLULAR: 1, METERED_WIFI: 2, - NOT_METERED_WIFI: 4, + NOT_METERED_WIFI = 4, + WIFI = 6, + CELLULAR_AND_WIFI = 7 } const Order = { DOWNLOAD: 1, INSTALL: 2, - APPLY: 4, + DOWNLOAD_AND_INSTALL = 3, + APPLY = 4, + INSTALL_AND_APPLY = 6 } const UpgradeStatus = { From 2908ef5e4701f7f1e46cd929accfbef1fd794f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Thu, 21 Jul 2022 02:13:37 +0000 Subject: [PATCH 050/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/main/extend/systemplugin/napi/ohos_update.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index 3e388ff6..8059e0fe 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -306,17 +306,17 @@ const DescriptionType = { const NetType = { CELLULAR: 1, METERED_WIFI: 2, - NOT_METERED_WIFI = 4, - WIFI = 6, - CELLULAR_AND_WIFI = 7 + 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 + DOWNLOAD_AND_INSTALL: 3, + APPLY: 4, + INSTALL_AND_APPLY: 6 } const UpgradeStatus = { From 8fd48e755b9dd224cf7ec93805f532777581423f Mon Sep 17 00:00:00 2001 From: magekkkk Date: Thu, 21 Jul 2022 11:11:34 +0800 Subject: [PATCH 051/103] add audio mock for some missing enum Signed-off-by: magekkkk --- .../napi/ohos_multimedia_audio.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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.") From bf2955c3de8e28440105fc7bc3cdf5edd9067025 Mon Sep 17 00:00:00 2001 From: lin-jianwu Date: Thu, 21 Jul 2022 11:20:16 +0800 Subject: [PATCH 052/103] fix review Signed-off-by: lin-jianwu Change-Id: Idc36b47e30754fd2cb97ef8334218028a070fba3 --- runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js index 78c3e6f2..5517e7d7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_media.js @@ -231,7 +231,7 @@ export function mockMultimediaMedia() { width: '[PC Preview] unknow width', height: '[PC Preview] unknow height', audioInterruptMode: InterruptMode, - videoScaleType: VideoScaleType, + 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.") From 769b92d2675b3c22e6c5f4edb54897d4de7847d6 Mon Sep 17 00:00:00 2001 From: hwx1119949 <3052854011@qq.com> Date: Thu, 21 Jul 2022 11:34:15 +0800 Subject: [PATCH 053/103] mock bugfix Signed-off-by: hwx1119949 <3052854011@qq.com> Change-Id: I95e65fb9e97656e6054c84d9dd32c5c5c6f184d7 --- .../main/extend/systemplugin/napi/index.js | 2 +- .../napi/ohos_application_Want.js | 29 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 5d7c060e..0d094a80 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -191,7 +191,7 @@ export function mockRequireNapiFun() { return mockZlib(); case "screenshot": return mockScreenshot(); - case "WantAgent": + case "wantAgent": return mockWantAgent(); case "wallpaper": return mockWallpaper(); diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js index 1fad9fd2..0d242ba3 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -15,18 +15,17 @@ 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.flag = "[PC Preview] unknow flag"; + this.action = "[PC Preview] unknow action"; + this.parameters = {}; + this.entities = [paramMock.paramStringMock]; + this.moduleName = "[PC Preview] unknow moduleName"; + } +} + From ad3aa2a3f81c488262ffabfede49548de6a2cafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Thu, 21 Jul 2022 03:41:08 +0000 Subject: [PATCH 054/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/systemplugin/napi/ohos_update.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index 8059e0fe..f052ee8d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -428,44 +428,44 @@ const EventInfo = { } const UpgradeInfo = { - upgradeApp: "com.ohos.ota.updateclient", + upgradeApp: "[PC Preview] unknown upgradeApp", businessType: BusinessType } const BusinessType = { vendor: BusinessVendor, - subType: BusinessSubType + subType: BusinessSubType.FIRMWARE } const DownloadOptions = { - allowNetwork: NetType, - order: Order + allowNetwork: NetType.CELLULAR, + order: Order.DOWNLOAD_AND_INSTALL } const ResumeDownloadOptions = { - allowNetwork: NetType + allowNetwork: NetType.CELLULAR } const PauseDownloadOptions = { - isAllowAutoResume: boolean + isAllowAutoResume: true } const UpgradeOptions = { - order: Order + order: Order.INSTALL } const ClearOptions = { - status: UpgradeStatus + status: UpgradeStatus.UPGRADE_SUCCESS } const EventClassifyInfo = { eventClassify: EventClassify, - extraInfo: string + extraInfo: "[PC Preview] unknown extraInfo" } const UpgradeFile = { - fileType: ComponentType, - filePath: string + fileType: ComponentType.OTA, + filePath: "[PC Preview] unknown filePath" } const UpgradeTaskCallback = { From 4552b4f3af720c100feb1c2e5b33f412200ed1f0 Mon Sep 17 00:00:00 2001 From: fengzewu Date: Thu, 21 Jul 2022 11:48:35 +0800 Subject: [PATCH 055/103] add image js mock Signed-off-by: fengzewu --- .../napi/ohos_multimedia_image.js | 151 ++++++++++++++++-- 1 file changed, 137 insertions(+), 14 deletions(-) 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.") From dd40231b34fe75934999e91f1d553b227fb1b39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Thu, 21 Jul 2022 14:04:35 +0800 Subject: [PATCH 056/103] =?UTF-8?q?=E7=BA=A0=E6=AD=A3mock=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js | 2 +- runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 d137641f..8a85e2a5 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -38,4 +38,5 @@ export const HapModuleInfo = { mainElementName: "[PC preview] unknown mainElementName", extensionAbilityInfo: [ExtensionAbilityInfo], metadata: [Metadata], + hashValue: "[PC preview] unknown mainElementName", } \ No newline at end of file From 253c0686122eb9639bfd5c0976597e4e792ca724 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Thu, 21 Jul 2022 14:40:25 +0800 Subject: [PATCH 057/103] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_pasteboard.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index 391d9df1..bda091b4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -45,9 +45,6 @@ export function mockPasteBoard() { 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 new Array(paramMock.paramStringMock); }, getPrimaryHtml: function () { From d47589b994fd2d16c035804b2fc2e8eb1d6e4010 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Thu, 21 Jul 2022 14:45:58 +0800 Subject: [PATCH 058/103] fix review problem Signed-off-by: Mupceet --- .../AccessibilityExtensionContext.js} | 432 ++++++++---------- .../ohos_accessibility.js} | 377 ++++++++------- .../napi/ohos_accessibility_Config.js | 311 ------------- .../napi/ohos_accessibility_config.js | 46 ++ ...plication_AccessibilityExtensionAbility.js | 37 +- 5 files changed, 455 insertions(+), 748 deletions(-) rename runtime/main/extend/systemplugin/napi/{accessibilityExtensionContext.js => application/AccessibilityExtensionContext.js} (70%) mode change 100755 => 100644 rename runtime/main/extend/systemplugin/{accessibility.js => napi/ohos_accessibility.js} (85%) mode change 100755 => 100644 delete mode 100755 runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_accessibility_config.js diff --git a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js old mode 100755 new mode 100644 similarity index 70% rename from runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js rename to runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js index 5c6d7063..5f74242a --- a/runtime/main/extend/systemplugin/napi/accessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js @@ -1,231 +1,203 @@ -/* - * 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 './application/abilityContext' - -export function mockAccessibilityExtensionContext() { - const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; - - const RectMock = { - left: '[PC Preview] unknown left', - top: '[PC Preview] unknown top', - width: '[PC Preview] unknown width', - height: '[PC Preview] unknown height' - }; - - const ActionNameMock = '[PC Preview] unknown action name'; - - const ElementAttributeValueMock = '[PC Preview] unknown element attribute value'; - - const AccessibilityElementMock = { - 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 'rect': - case 'screenRect': - value = RectMock; - break; - case 'parent': - case 'rootElement': - value = AccessibilityElementMock; - break; - case 'children': - value = [AccessibilityElementMock]; - break; - default: - value = ElementAttributeValueMock; - 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, ActionNameMock); - } else { - return new Promise((resolve, reject) => { - resolve(ActionNameMock); - }); - } - }, - 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.performAction 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') ? [AccessibilityElementMock] : AccessibilityElementMock; - 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); - }); - } - }, - }; - - const gesturePathClass = class GesturePath { - points = null; - durationTime = null; - constructor(d) { - console.warn('gesturePathClass.constructor interface mocked in the Previewer.' + - ' How this interface works on the Previewer may be different from that on a real device.'); - this.points = []; - this.durationTime = d; - } - } - - const gesturePointClass = class GesturePoint { - positionX = null; - positionY = null; - constructor(x, y) { - console.warn('gesturePointClass.constructor interface mocked in the Previewer.' + - ' How this interface works on the Previewer may be different from that on a real device.'); - this.positionX = y; - this.positionY = y; - } - } - - const accessibilityExtensionContextClass = class accessibilityExtensionContext extends ExtensionContextClass { - setEventTypeFilter = null; - setTargetBundleName = null; - getFocusElement = null; - getWindowRootElement = null; - getWindows = null; - executeCommonAction = null; - gestureInject = null; - constructor() { - 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, paramMock.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }); - } - }; - - 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, paramMock.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }); - } - }; - - 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, AccessibilityElementMock); - } else { - return new Promise((resolve, reject) => { - resolve(AccessibilityElementMock); - }); - } - }; - - 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, AccessibilityElementMock); - } else { - return new Promise((resolve, reject) => { - resolve(AccessibilityElementMock); - }); - } - }; - - 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, [AccessibilityElementMock]); - } else { - return new Promise((resolve, reject) => { - resolve([AccessibilityElementMock]); - }); - } - }; - - this.gestureInject = function (...args) { - console.warn('accessibilityExtensionContext.gestureInject interface mocked 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 new accessibilityExtensionContextClass(); +/* + * 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 './abilityContext' + +export function mockAccessibilityExtensionContext() { + const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; + + const ElementAttributeValueMock = '[PC Preview] unknown element attribute value'; + + const RectMock = { + left: paramMock.paramNumberMock, + top: paramMock.paramNumberMock, + width: paramMock.paramNumberMock, + height: paramMock.paramNumberMock + }; + + const AccessibilityElementMock = { + 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 = [ElementAttributeValueMock]; + break; + case 'rect': + case 'screenRect': + value = RectMock; + break; + case 'parent': + case 'rootElement': + value = AccessibilityElementMock; + break; + case 'children': + value = [AccessibilityElementMock]; + break; + default: + value = ElementAttributeValueMock; + 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') ? [AccessibilityElementMock] : AccessibilityElementMock; + 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); + }); + } + }, + }; + + const AccessibilityExtensionContextClass = class AccessibilityExtensionContext extends ExtensionContextClass { + constructor() { + 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, AccessibilityElementMock); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + } + }; + + 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, AccessibilityElementMock); + } else { + return new Promise((resolve, reject) => { + resolve(AccessibilityElementMock); + }); + } + }; + + 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, [AccessibilityElementMock]); + } else { + return new Promise((resolve, reject) => { + resolve([AccessibilityElementMock]); + }); + } + }; + + 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(); + }); + } + }; + } + }; + + return new AccessibilityExtensionContextClass(); } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js old mode 100755 new mode 100644 similarity index 85% rename from runtime/main/extend/systemplugin/accessibility.js rename to runtime/main/extend/systemplugin/napi/ohos_accessibility.js index 9bcd34ce..f9f8a4fc --- a/runtime/main/extend/systemplugin/accessibility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js @@ -1,190 +1,189 @@ -/* - * 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 mockAccessibility() { - const AbilityTypeMock = '[PC Preview] unknown AbilityType'; - - const CapabilityMock = '[PC Preview] unknown Capability'; - - const EventTypeMock = '[PC Preview] unknown EventType'; - - const AccessibilityAbilityInfoMock = { - 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 CaptionStyleMock = { - 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: CaptionStyleMock, - 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, CaptionStyleMock); - } - } - }, - 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, CaptionStyleMock); - } - } - }, - }; - - const WindowUpdateTypeMock = '[PC Preview] unknown WindowUpdateType'; - - const ActionMock = '[PC Preview] unknown Action'; - - const TextMoveUnitMock = '[PC Preview] unknown 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] 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 contents'; - 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, [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 () { - 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; +/* + * 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 AccessibilityAbilityInfoMock = { + id: paramMock.paramStringMock, + name: paramMock.paramStringMock, + bundleName: paramMock.paramStringMock, + TargetBundleName: [paramMock.paramStringMock], + abilityTypes: [AbilityTypeMock], + capabilities: [CapabilityMock], + description: paramMock.paramStringMock, + eventTypes: [EventTypeMock] + }; + + const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType'; + + const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily'; + + const CaptionStyleMock = { + fontFamily: CaptionsFontFamilyMock, + fontScale: paramMock.paramNumberMock, + fontColor: '[PC Preview] unknown fontColor', + fontEdgeType: CaptionsFontEdgeTypeMock, + backgroundColor: '[PC Preview] unknown backgroundColor', + windowColor: '[PC Preview] unknown windowColor' + }; + + const CaptionsManagerMock = { + enabled: paramMock.paramBooleanMock, + style: CaptionStyleMock, + 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, CaptionStyleMock); + } + } + }, + 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, CaptionStyleMock); + } + } + }, + }; + + const WindowUpdateTypeMock = '[PC Preview] unknown WindowUpdateType'; + + const ActionMock = '[PC Preview] unknown Action'; + + const TextMoveUnitMock = '[PC Preview] unknown 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 = paramMock.paramStringMock; + this.componentType = paramMock.paramStringMock; + this.pageId = paramMock.paramNumberMock; + this.description = paramMock.paramStringMock; + this.triggerAction = ActionMock; + this.textMoveUnit = TextMoveUnitMock; + this.contents = [paramMock.paramStringMock]; + this.lastContent = paramMock.paramStringMock; + this.beginIndex = paramMock.paramNumberMock; + this.currentIndex = paramMock.paramNumberMock; + this.endIndex = paramMock.paramNumberMock; + this.itemCount = paramMock.paramNumberMock; + } + }; + + 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, [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 () { + 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 deleted file mode 100755 index 1a8bc84d..00000000 --- a/runtime/main/extend/systemplugin/napi/ohos_accessibility_Config.js +++ /dev/null @@ -1,311 +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'; - -export function mockAccessibilityConfig() { - const DaltonizationColorFilterMock = '[PC Preview] unknown DaltonizationColorFilter'; - - const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily'; - - const CaptionsFontEdgeTypeMock = '[PC Preview] unknown CaptionsFontEdgeType'; - - const CaptionStyleMock = { - 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 configBoolMock = { - set: function (...args) { - console.warn('accessibilityConfig configBoolMock.set interface mocked 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(); - }); - } - }, - get: function (...args) { - console.warn('accessibilityConfig configBoolMock.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, paramMock.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig configBoolMock.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') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } - }, - off: function (...args) { - console.warn('accessibilityConfig configBoolMock.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') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } - }, - }; - - const daltonizationColorFilterMock = { - set: function (...args) { - console.warn('accessibilityConfig daltonizationColorFilterMock.set interface mocked 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(paramMock.businessErrorMock); - }); - } - }, - get: function (...args) { - console.warn('accessibilityConfig daltonizationColorFilterMock.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, DaltonizationColorFilterMock); - } else { - return new Promise((resolve, reject) => { - resolve(DaltonizationColorFilterMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig highContrastText.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') { - args[len - 1].call(this, DaltonizationColorFilterMock); - } - }, - off: function (...args) { - console.warn('accessibilityConfig highContrastText.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') { - args[len - 1].call(this, DaltonizationColorFilterMock); - } - }, - }; - - const configNumberBlock = { - set: function (...args) { - console.warn('accessibilityConfig configNumberBlock.set interface mocked 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(paramMock.businessErrorMock); - }); - } - }, - get: function (...args) { - console.warn('accessibilityConfig configNumberBlock.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, paramMock.paramNumberMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramNumberMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig configNumberBlock.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') { - args[len - 1].call(this, paramMock.paramNumberMock); - } - }, - off: function (...args) { - console.warn('accessibilityConfig configNumberBlock.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') { - args[len - 1].call(this, paramMock.paramNumberMock); - } - }, - }; - - const configShortkeyTargetBlock = { - set: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.set interface mocked 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(paramMock.businessErrorMock); - }); - } - }, - get: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.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, paramMock.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.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') { - args[len - 1].call(this, paramMock.paramStringMock); - } - }, - off: function (...args) { - console.warn('accessibilityConfig configShortkeyTargetBlock.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') { - args[len - 1].call(this, paramMock.paramStringMock); - } - }, - }; - - const captionStyleMock = { - set: function (...args) { - console.warn('accessibilityConfig captionStyleMock.set interface mocked 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(paramMock.businessErrorMock); - }); - } - }, - get: function (...args) { - console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); - } else { - return new Promise((resolve, reject) => { - resolve(CaptionStyleMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig captionStyleMock.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') { - args[len - 1].call(this, CaptionStyleMock); - } - }, - off: function (...args) { - console.warn('accessibilityConfig captionStyleMock.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, CaptionStyleMock); - } - }, - }; - - 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, paramMock.paramBooleanMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - 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, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }); - } - }, - on: function (...args) { - console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { - args[len - 1].call(this); - } - } - }, - off: function (...args) { - console.warn('accessibilityConfig config.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] === 'enableAbilityListsStateChanged') { - args[len - 1].call(this); - } - } - }, - highContrastText: configBoolMock, - invertColor: configBoolMock, - daltonizationColorFilter: daltonizationColorFilterMock, - contentTimeout: configNumberBlock, - animationOff: configBoolMock, - brightnessDiscount: configNumberBlock, - screenMagnifier: configBoolMock, - audioMono: configBoolMock, - audioBalance: configBoolMock, - mouseKey: configNumberBlock, - mouseAutoClick: configNumberBlock, - shortkey: configBoolMock, - shortkey_target: configShortkeyTargetBlock, - caption: configBoolMock, - captionStyle: captionStyleMock, - }; - return config; -} \ 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_application_AccessibilityExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js index 75782ace..69ef4d3f 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js @@ -14,46 +14,47 @@ */ import { paramMock } from '../utils'; -import { mockAccessibilityExtensionContext } from './accessibilityExtensionContext'; +import { mockAccessibilityExtensionContext } from './application/AccessibilityExtensionContext'; -export function mockAccessibilityExtensionAbility() { - const accessibilityEventMock = { - eventType: '[PC Preview] unknown eventType', - target: '[PC Preview] unknown target', - timeStamp: '[PC Preview] unknown timeStamp', - notificationContent: '[PC Preview] unknown notificationContent' +const AccessibilityEventMock = { + eventType: '[PC Preview] unknown eventType', + target: '[PC Preview] unknown target', + timeStamp: '[PC Preview] unknown timeStamp', + notificationContent: '[PC Preview] unknown notificationContent' +}; + +const GesturePointMock = { + positionX: paramMock.paramNumberMock, + positionY: paramMock.paramNumberMock }; - const accessibilityExtensionAbilityClass = class accessibilityExtensionAbility { - context = null; - onConnect = null; - onDisconnect = null; - onAccessibilityEvent = null; - onKeyEvent = null; +const GesturePathMock = { + points: [GesturePointMock], + durationTime: paramMock.paramNumberMock +}; + +export function mockAccessibilityExtensionAbility() { + const AccessibilityExtensionAbilityClass = class AccessibilityExtensionAbility { constructor() { this.context = mockAccessibilityExtensionContext(); 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.'); - return; }; 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.'); - return; }; 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.'); - return; }; 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; }; } }; - return new accessibilityExtensionAbilityClass(); + return AccessibilityExtensionAbilityClass; } \ No newline at end of file From b837f7009d74a1ac6acff805eef29fce2a9d61fe Mon Sep 17 00:00:00 2001 From: zhi-min-huang Date: Wed, 20 Jul 2022 15:09:52 +0800 Subject: [PATCH 059/103] Add FaceAuth API Mock Signed-off-by: zhi-min-huang Change-Id: I02c6871c271f151f0b13570b039b1571a58d0965 --- .../main/extend/systemplugin/napi/index.js | 3 ++ .../napi/ohos_userIAM_faceAuth.js | 42 +++++++++++++++++++ .../napi/ohos_userIAM_userAuth.js | 19 +++++---- 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_userIAM_faceAuth.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 53aed7ae..ff34d52a 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -91,6 +91,7 @@ import { mockSecurityLabel } from './ohos_securitylabel' import { mockWorkScheduler } from './ohos_workScheduler' import { mockWorkSchedulerExtensionAbility } from './ohos_WorkSchedulerExtensionAbility' import { mockUserAuth } from './ohos_userIAM_userAuth' +import { mockFaceAuth } from './ohos_userIAM_faceAuth' import { mockArrayList } from './ohos_util_Arraylist' import { mockDeque } from './ohos_util_Deque' import { mockHashMap } from './ohos_util_HashMap' @@ -431,6 +432,8 @@ export function mockRequireNapiFun() { return mockWorkSchedulerExtensionAbility(); case "userIAM.userAuth": return mockUserAuth(); + case "userIAM.faceAuth": + return mockFaceAuth(); case "util.ArrayList": return mockArrayList(); case "util.Deque": 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 From f099fb602763bd6c2b49337d7064b8fb450fab71 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Thu, 21 Jul 2022 15:26:13 +0800 Subject: [PATCH 060/103] fix compile problem Signed-off-by: Mupceet --- runtime/main/extend/systemplugin/index.js | 2 -- runtime/main/extend/systemplugin/napi/index.js | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index aa9b3208..30c51278 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() { mockAbilityContinuationRegisterManager() mockRequireNapiFun() mockAbilityDataUriUtils() - mockAccessibility() mockAbilityParticleAbility() mockAbilityFormManager() mockAbilityAbilityAgent() diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 4415d0c2..9ac62d9a 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -161,6 +161,9 @@ import { mockDefaultAppManager } from './ohos_bundle_defaultAppManager' import { mockKeyEvent } from './ohos_multimodalInput_keyEvent' import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' +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]) { @@ -460,6 +463,12 @@ export function mockRequireNapiFun() { return mockMouseEvent(); case "multimodalInput.touchEvent": return mockTouchEvent(); + case "accessibility": + return mockAccessibility(); + case "accessibility.config": + return mockAccessibilityConfig(); + case "application.AccessibilityExtensionAbility": + return mockAccessibilityExtensionAbility(); default: return global.requireNapiPreview(...args); } From b946e605684fe56983f2d1a323402cbf2c697d5c Mon Sep 17 00:00:00 2001 From: shuyi Date: Tue, 19 Jul 2022 01:45:39 -0700 Subject: [PATCH 061/103] HUKS_API_MOCK Signed-off-by: shuyi --- .../systemplugin/napi/ohos_security_huks.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/ohos_security_huks.js 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], } From f78a6996ed95e7cfbc34fcb403293d586c33e406 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Thu, 21 Jul 2022 16:04:30 +0800 Subject: [PATCH 062/103] fix compile problem Signed-off-by: Mupceet --- .../napi/application/AccessibilityExtensionContext.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js index 5f74242a..bb351cd0 100644 --- a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js @@ -14,7 +14,7 @@ */ import { paramMock } from '../../utils' -import { ExtensionContextClass } from './abilityContext' +import { ExtensionContextClass } from './AbilityContext' export function mockAccessibilityExtensionContext() { const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; @@ -200,4 +200,4 @@ export function mockAccessibilityExtensionContext() { }; return new AccessibilityExtensionContextClass(); -} \ No newline at end of file +} From 3a253381ec6bbbd3e1c16a222cc94f7279a075f2 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 21 Jul 2022 16:29:03 +0800 Subject: [PATCH 063/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 124 +++++++++++++++++- 1 file changed, 118 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 70eb0116..09605e12 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -15,23 +15,135 @@ import { paramMock } from "../utils" -export const constraintSourceType = { +export const ConstraintSourceType = { CONSTRAINT_NOT_EXIST: 0, CONSTRAINT_TYPE_BASE: 1, CONSTRAINT_TYPE_DEVICE_OWNER: 2, CONSTRAINT_TYPE_PROFILE_OWNER: 3 }; +export const OsAccountTypeMock = { + ADMIN: 0, + NORMAL: 1, + GUEST: 2 +}; +export const FingerprintTips = { + FINGERPRINT_TIP_GOOD: 0, + FINGERPRINT_TIP_IMAGER_DIRTY: 1, + FINGERPRINT_TIP_INSUFFICIENT: 2, + FINGERPRINT_TIP_PARTIAL: 3, + FINGERPRINT_TIP_TOO_FAST: 4, + FINGERPRINT_TIP_TOO_SLOW: 5 +}; +export const FaceTipsCode = { + FACE_AUTH_TIP_TOO_BRIGHT: 1, + FACE_AUTH_TIP_TOO_DARK: 2, + FACE_AUTH_TIP_TOO_CLOSE: 3, + FACE_AUTH_TIP_TOO_FAR: 4, + FACE_AUTH_TIP_TOO_HIGH: 5, + FACE_AUTH_TIP_TOO_LOW: 6, + FACE_AUTH_TIP_TOO_RIGHT: 7, + FACE_AUTH_TIP_TOO_LEFT: 8, + FACE_AUTH_TIP_TOO_MUCH_MOTION: 9, + FACE_AUTH_TIP_POOR_GAZE: 10, + FACE_AUTH_TIP_NOT_DETECTED: 11 +}; +export const EesultCode = { + SUCCESS: 0, + FAIL: 1, + GENERAL_ERROR: 2, + CANCELED: 3, + TIMEOUT: 4, + TYPE_NOT_SUPPORT: 5, + TRUST_LEVEL_NOT_SUPPORT: 6, + BUSY: 7, + INVALID_PARAMETERS: 8, + LOCKED: 9, + NOT_ENROLLED: 10 +}; +export const module = { + FACE_AUTH: 1 +}; +export const authTrustLevel = { + ATL1: 10000, + ATL2: 20000, + ATL3: 30000, + ATL4: 40000 +}; +export const authSubType = { + PIN_SIX: 10000, + PIN_NUMBER: 10001, + PIN_MIXED: 10002, + FACE_2D: 20000, + FACE_3D: 20001 +}; +export const getPropertyType = { + AUTH_SUB_TYPE: 1, + REMAIN_TIMES: 2, + FREEZING_TIME: 3 +}; +export const setPropertyType = { + INIT_ALGORITHM: 1 +}; +export const authType = { + PIN: 1, + FACE: 2 +}; export function mockOsAccount() { const osAccountInfoMock = { - localId: "[PC Preview] unknown id", - localName: "[PC Preview] unknown name", + localId: "[PC Preview] unknown localId", + localName: "[PC Preview] unknown localName", type: "[PC Preview] unknown type", constraints: "[PC Preview] unknown constraints", + isVerified: "[PC Preview] unknown isVerified", + photo: "[PC Preview] unknown photo", + createTime: "[PC Preview] unknown createTime", + lastLoginTime: "[PC Preview] unknown lastLoginTime", + serialNumber: "[PC Preview] unknown serialNumber", + isActived: "[PC Preview] unknown isActived", + domainInfo: "[PC Preview] unknown domainInfo", distributedInfo: "[PC Preview] unknown distributedInfo" }; + const domainAccountInfoMock = { + domain: "[PC Preview] unknown domain", + accountName: "[PC Preview] unknown accountName" + }; const constraintSourceTypeInfoMock = { - localId: "[PC Preview] unknown id", - type: constraintSourceType, + localId: "[PC Preview] unknown localId", + type: "[PC Preview] unknown type" + }; + const getPropertyRequest = { + authType: "[PC Preview] unknown authType", + keys: "[PC Preview] unknown keys" + }; + const setPropertyRequest = { + authType: "[PC Preview] unknown authType", + key: "[PC Preview] unknown key", + setInfo: "[PC Preview] unknown setInfo" + }; + const executorProperty = { + result: "[PC Preview] unknown result", + authSubType: "[PC Preview] unknown authSubType", + remainTimes: "[PC Preview] unknown remainTimes", + freezingTime: "[PC Preview] unknown freezingTime" + }; + const authResult = { + token: "[PC Preview] unknown token", + remainTimes: "[PC Preview] unknown remainTimes", + ferezingTime: "[PC Preview] unknown freezingTime" + }; + const credentialInfo = { + credType: "[PC Preview] unknown credType", + credSubType: "[PC Preview] unknown credSubType", + token: "[PC Preview] unknown token" + }; + const requestResult = { + credentialId: "[PC Preview] unknown credentialId" + }; + const enrolledCredInfo = { + credentialId: "[PC Preview] unknown credentialId", + authType: "[PC Preview] unknown authType", + authSubType: "[PC Preview] unknown authSubType", + templateId: "[PC Preview] unknown templateId" }; const osAccountTypeMock = "[PC Preview] unknown type"; const accountManagerMock = { @@ -440,4 +552,4 @@ export function mockOsAccount() { constraintSourceType, } return osAccount -} \ No newline at end of file +} From 799860c776477f026c258586c7e9a60f4f608ccb Mon Sep 17 00:00:00 2001 From: lixingyang Date: Thu, 21 Jul 2022 18:38:52 +0800 Subject: [PATCH 064/103] Correct the inconsistency between Mock and d.ts of language compilation subsystem Signed-off-by: lixingyang https://gitee.com/openharmony/third_party_jsframework/issues/I5IA27 --- .../systemplugin/napi/ohos_convertxml.js | 53 +- .../extend/systemplugin/napi/ohos_process.js | 6 +- .../main/extend/systemplugin/napi/ohos_uri.js | 12 +- .../main/extend/systemplugin/napi/ohos_url.js | 4 +- .../extend/systemplugin/napi/ohos_util.js | 1144 +++++++++-------- .../extend/systemplugin/napi/ohos_worker.js | 210 ++- .../main/extend/systemplugin/napi/ohos_xml.js | 248 ++-- 7 files changed, 960 insertions(+), 717 deletions(-) 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_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_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..ece3c454 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_url.js +++ b/runtime/main/extend/systemplugin/napi/ohos_url.js @@ -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_util.js b/runtime/main/extend/systemplugin/napi/ohos_util.js index 1f205b14..0b0482e2 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_worker.js b/runtime/main/extend/systemplugin/napi/ohos_worker.js index c522bd73..7a465748 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,159 @@ 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 EventListenerMock = { + evt : function (...args) { + console.warn('EventListener.evt 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.") + }; + + 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.'); }, - 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.") + 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; }, - 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.") + 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 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 + }; + 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; +} From 2317657625e118e50b1cafc6f9400d652873d33e Mon Sep 17 00:00:00 2001 From: MangTsang Date: Wed, 13 Jul 2022 17:14:30 +0800 Subject: [PATCH 065/103] add timerOption mock Signed-off-by: MangTsang --- .../systemplugin/napi/ohos_systemTimer.js | 156 +++++++++--------- 1 file changed, 82 insertions(+), 74 deletions(-) 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 +} From 63a0ad78a95a7b3378ef2b81070482ba9d2381d4 Mon Sep 17 00:00:00 2001 From: sunyaozu Date: Thu, 21 Jul 2022 16:45:34 +0800 Subject: [PATCH 066/103] fix i18n and intl mock Signed-off-by: sunyaozu --- .../extend/systemplugin/napi/ohos_i18n.js | 417 ++++++++++-------- .../extend/systemplugin/napi/ohos_intl.js | 17 +- 2 files changed, 255 insertions(+), 179 deletions(-) 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_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 From 0d9b88026f7f59f6be5209814a31090d0e5c4585 Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Fri, 22 Jul 2022 09:02:57 +0800 Subject: [PATCH 067/103] aaaa Signed-off-by: liuyanzhi Change-Id: Icacfe143b9dc1284577699364ea3f2163d646692 --- .../main/extend/systemplugin/napi/ohos_commonEvent.js | 3 ++- .../extend/systemplugin/napi/ohos_events_emitter.js | 3 +++ .../extend/systemplugin/napi/ohos_notification.js | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) 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_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_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 } From 94e57fbcce5b2ffd01a7d97f5945fdc5d8422a05 Mon Sep 17 00:00:00 2001 From: xuzheheng Date: Mon, 18 Jul 2022 13:04:58 +0800 Subject: [PATCH 068/103] xuzheheng1@huawei.com Signed-off-by: xuzheheng Change-Id: I580a1b601f9c19165b231417d0bc2421ea751ee3 --- .../napi/ability/dataAbilityHelper.js | 289 ++++++++++++++++++ .../napi/ability/dataAbilityOperation.js | 33 ++ .../napi/ability/dataAbilityResult.js | 19 ++ .../napi/application/AbilityRunningInfo.js | 39 +++ .../napi/application/AbilityStageContext.js | 28 ++ .../napi/application/AbilityStateData.js | 28 ++ .../napi/application/AppStateData.js | 24 ++ .../napi/application/ApplicationContext.js | 59 ++++ .../application/ApplicationStateObserver.js | 37 +++ .../systemplugin/napi/application/Context.js | 2 + .../napi/application/ErrorObserver.js | 25 ++ .../systemplugin/napi/application/EventHub.js | 33 ++ .../napi/application/ExtensionContext.js | 30 ++ .../napi/application/ExtensionRunningInfo.js | 50 +++ .../napi/application/MissionInfo.js | 27 ++ .../napi/application/MissionListener.js | 37 +++ .../napi/application/MissionSnapshot.js | 30 ++ .../application/PermissionRequestResult.js | 25 ++ .../napi/application/ProcessData.js | 26 ++ .../napi/application/ProcessRunningInfo.js | 23 ++ .../application/ServiceExtensionContext.js | 131 ++++++++ .../napi/commonEvent/commonEventData.js | 4 +- .../commonEvent/commonEventPublishData.js | 4 +- .../continuation/continuationExtraParams.js | 4 +- .../main/extend/systemplugin/napi/index.js | 3 + .../notification/notificationActionButton.js | 4 +- .../napi/notification/notificationRequest.js | 4 +- .../notification/notificationSortingMap.js | 4 +- .../napi/notification/notificationTemplate.js | 4 +- .../napi/ohos_ability_particleAbility.js | 96 ++++++ .../napi/ohos_application_Configuration.js | 1 + .../napi/ohos_application_Want.js | 2 +- .../napi/ohos_application_errorManager.js | 0 .../napi/ohos_application_missionManager.js | 12 + .../napi/wantAgent/triggerInfo.js | 4 +- .../napi/wantAgent/wantAgentInfo.js | 4 +- 36 files changed, 1126 insertions(+), 19 deletions(-) create mode 100755 runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js create mode 100755 runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js create mode 100755 runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js create mode 100755 runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js create mode 100755 runtime/main/extend/systemplugin/napi/application/AbilityStateData.js create mode 100755 runtime/main/extend/systemplugin/napi/application/AppStateData.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ApplicationContext.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ErrorObserver.js create mode 100755 runtime/main/extend/systemplugin/napi/application/EventHub.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ExtensionContext.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/application/MissionInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/application/MissionListener.js create mode 100755 runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js create mode 100755 runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ProcessData.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/index.js create mode 100755 runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js 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..7899aa70 --- /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/ability/dataAbilityResult.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js new file mode 100755 index 00000000..b2905210 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js @@ -0,0 +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 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/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..f66265e2 --- /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/AppStateData.js b/runtime/main/extend/systemplugin/napi/application/AppStateData.js new file mode 100755 index 00000000..b198254a --- /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/Context.js b/runtime/main/extend/systemplugin/napi/application/Context.js index bc9339ef..b2a6752e 100644 --- a/runtime/main/extend/systemplugin/napi/application/Context.js +++ b/runtime/main/extend/systemplugin/napi/application/Context.js @@ -280,10 +280,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..0bfc644d --- /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/MissionInfo.js b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js new file mode 100755 index 00000000..bbf47676 --- /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..4e651615 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ProcessData.js @@ -0,0 +1,26 @@ +/* + * 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 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/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 old mode 100644 new mode 100755 index 49183417..9205454d --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -28,6 +28,7 @@ import { mockServiceExtensionAbility } from './ohos_application_ServiceExtension import { mockAbilityStage } from './ohos_application_AbilityStage' import { mockFormBindingData } from './ohos_application_formBindingData' import { mockAbilityManager } from './ohos_application_abilityManager' +import { mockParticleAbility } from './ohos_ability_particleAbility' import { mockAppManager } from './ohos_application_appManager' import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility' import { mockMissionManager } from "./ohos_application_missionManager" @@ -276,6 +277,8 @@ export function mockRequireNapiFun() { return mockSystemParameter(); case "ability.dataUriUtils": return mockDataUriUtils(); + case "ability.particleAbility": + return mockParticleAbility(); case "ability.featureAbility": return mockFeatureAbility(); case "application.Ability": 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_particleAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js new file mode 100755 index 00000000..62e0e61d --- /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_application_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js index 487bf868..1507e7cc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -19,4 +19,5 @@ export const Configuration = { direction: Direction, screenDensity: ScreenDensity, displayId: '[PC preview] unknow displayId', + hasPointerDevice: '[PC preview] unknow hasPointerDevice', } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js index 1fad9fd2..84d3f339 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -23,7 +23,7 @@ export const WantClass = class Want { 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.flags = "[PC Preview] unknow flags"; this.action = "[PC Preview] unknow action"; this.parameters = {}; this.entities = [paramMock.paramStringMock]; 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 diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js index ab5d68ad..86461545 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js @@ -92,6 +92,18 @@ export function mockMissionManager() { }); } }, + 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, MissionSnapshotMock); + } else { + return new Promise((resolve) => { + resolve(MissionSnapshotMock); + }); + } + }, lockMission: function (...args) { console.warn('missionManager.lockMission 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/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"}, +}; From 3b001581c7c19ed500185d61a405f6b353f40f73 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 11:11:49 +0800 Subject: [PATCH 069/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 09605e12..cdb31e26 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -21,7 +21,7 @@ export const ConstraintSourceType = { CONSTRAINT_TYPE_DEVICE_OWNER: 2, CONSTRAINT_TYPE_PROFILE_OWNER: 3 }; -export const OsAccountTypeMock = { +export const OsAccountType = { ADMIN: 0, NORMAL: 1, GUEST: 2 @@ -47,7 +47,7 @@ export const FaceTipsCode = { FACE_AUTH_TIP_POOR_GAZE: 10, FACE_AUTH_TIP_NOT_DETECTED: 11 }; -export const EesultCode = { +export const ResultCode = { SUCCESS: 0, FAIL: 1, GENERAL_ERROR: 2, @@ -60,36 +60,36 @@ export const EesultCode = { LOCKED: 9, NOT_ENROLLED: 10 }; -export const module = { +export const Module = { FACE_AUTH: 1 }; -export const authTrustLevel = { +export const AuthTrustLevel = { ATL1: 10000, ATL2: 20000, ATL3: 30000, ATL4: 40000 }; -export const authSubType = { +export const AuthSubType = { PIN_SIX: 10000, PIN_NUMBER: 10001, PIN_MIXED: 10002, FACE_2D: 20000, FACE_3D: 20001 }; -export const getPropertyType = { +export const GetPropertyType = { AUTH_SUB_TYPE: 1, REMAIN_TIMES: 2, FREEZING_TIME: 3 }; -export const setPropertyType = { +export const SetPropertyType = { INIT_ALGORITHM: 1 }; -export const authType = { +export const AuthType = { PIN: 1, FACE: 2 }; export function mockOsAccount() { - const osAccountInfoMock = { + const OsAccountInfoMock = { localId: "[PC Preview] unknown localId", localName: "[PC Preview] unknown localName", type: "[PC Preview] unknown type", @@ -103,50 +103,50 @@ export function mockOsAccount() { domainInfo: "[PC Preview] unknown domainInfo", distributedInfo: "[PC Preview] unknown distributedInfo" }; - const domainAccountInfoMock = { + const DomainAccountInfoMock = { domain: "[PC Preview] unknown domain", accountName: "[PC Preview] unknown accountName" }; - const constraintSourceTypeInfoMock = { + const ConstraintSourceTypeInfoMock = { localId: "[PC Preview] unknown localId", type: "[PC Preview] unknown type" }; - const getPropertyRequest = { + const GetPropertyRequest = { authType: "[PC Preview] unknown authType", keys: "[PC Preview] unknown keys" }; - const setPropertyRequest = { + const SetPropertyRequest = { authType: "[PC Preview] unknown authType", key: "[PC Preview] unknown key", setInfo: "[PC Preview] unknown setInfo" }; - const executorProperty = { + const ExecutorProperty = { result: "[PC Preview] unknown result", authSubType: "[PC Preview] unknown authSubType", remainTimes: "[PC Preview] unknown remainTimes", freezingTime: "[PC Preview] unknown freezingTime" }; - const authResult = { + const AuthResult = { token: "[PC Preview] unknown token", remainTimes: "[PC Preview] unknown remainTimes", ferezingTime: "[PC Preview] unknown freezingTime" }; - const credentialInfo = { + const CredentialInfo = { credType: "[PC Preview] unknown credType", credSubType: "[PC Preview] unknown credSubType", token: "[PC Preview] unknown token" }; - const requestResult = { + const RequestResult = { credentialId: "[PC Preview] unknown credentialId" }; - const enrolledCredInfo = { + const EnrolledCredInfo = { credentialId: "[PC Preview] unknown credentialId", authType: "[PC Preview] unknown authType", authSubType: "[PC Preview] unknown authSubType", templateId: "[PC Preview] unknown templateId" }; - const osAccountTypeMock = "[PC Preview] unknown type"; - const accountManagerMock = { + const OsAccountTypeMock = "[PC Preview] unknown type"; + const AccountManagerMock = { activateOsAccount: function (...args) { console.warn("AccountManager.activateOsAccount interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") From 18d700363cfe6da85c16be60593562638f7986a9 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 11:21:00 +0800 Subject: [PATCH 070/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index cdb31e26..de28a68f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -15,79 +15,6 @@ import { paramMock } from "../utils" -export const ConstraintSourceType = { - CONSTRAINT_NOT_EXIST: 0, - CONSTRAINT_TYPE_BASE: 1, - CONSTRAINT_TYPE_DEVICE_OWNER: 2, - CONSTRAINT_TYPE_PROFILE_OWNER: 3 -}; -export const OsAccountType = { - ADMIN: 0, - NORMAL: 1, - GUEST: 2 -}; -export const FingerprintTips = { - FINGERPRINT_TIP_GOOD: 0, - FINGERPRINT_TIP_IMAGER_DIRTY: 1, - FINGERPRINT_TIP_INSUFFICIENT: 2, - FINGERPRINT_TIP_PARTIAL: 3, - FINGERPRINT_TIP_TOO_FAST: 4, - FINGERPRINT_TIP_TOO_SLOW: 5 -}; -export const FaceTipsCode = { - FACE_AUTH_TIP_TOO_BRIGHT: 1, - FACE_AUTH_TIP_TOO_DARK: 2, - FACE_AUTH_TIP_TOO_CLOSE: 3, - FACE_AUTH_TIP_TOO_FAR: 4, - FACE_AUTH_TIP_TOO_HIGH: 5, - FACE_AUTH_TIP_TOO_LOW: 6, - FACE_AUTH_TIP_TOO_RIGHT: 7, - FACE_AUTH_TIP_TOO_LEFT: 8, - FACE_AUTH_TIP_TOO_MUCH_MOTION: 9, - FACE_AUTH_TIP_POOR_GAZE: 10, - FACE_AUTH_TIP_NOT_DETECTED: 11 -}; -export const ResultCode = { - SUCCESS: 0, - FAIL: 1, - GENERAL_ERROR: 2, - CANCELED: 3, - TIMEOUT: 4, - TYPE_NOT_SUPPORT: 5, - TRUST_LEVEL_NOT_SUPPORT: 6, - BUSY: 7, - INVALID_PARAMETERS: 8, - LOCKED: 9, - NOT_ENROLLED: 10 -}; -export const Module = { - FACE_AUTH: 1 -}; -export const AuthTrustLevel = { - ATL1: 10000, - ATL2: 20000, - ATL3: 30000, - ATL4: 40000 -}; -export const AuthSubType = { - PIN_SIX: 10000, - PIN_NUMBER: 10001, - PIN_MIXED: 10002, - FACE_2D: 20000, - FACE_3D: 20001 -}; -export const GetPropertyType = { - AUTH_SUB_TYPE: 1, - REMAIN_TIMES: 2, - FREEZING_TIME: 3 -}; -export const SetPropertyType = { - INIT_ALGORITHM: 1 -}; -export const AuthType = { - PIN: 1, - FACE: 2 -}; export function mockOsAccount() { const OsAccountInfoMock = { localId: "[PC Preview] unknown localId", @@ -538,6 +465,79 @@ export function mockOsAccount() { } }, }; + const ConstraintSourceType = { + CONSTRAINT_NOT_EXIST: 0, + CONSTRAINT_TYPE_BASE: 1, + CONSTRAINT_TYPE_DEVICE_OWNER: 2, + CONSTRAINT_TYPE_PROFILE_OWNER: 3 + }; + const OsAccountType = { + ADMIN: 0, + NORMAL: 1, + GUEST: 2 + }; + const FingerprintTips = { + FINGERPRINT_TIP_GOOD: 0, + FINGERPRINT_TIP_IMAGER_DIRTY: 1, + FINGERPRINT_TIP_INSUFFICIENT: 2, + FINGERPRINT_TIP_PARTIAL: 3, + FINGERPRINT_TIP_TOO_FAST: 4, + FINGERPRINT_TIP_TOO_SLOW: 5 + }; + const FaceTipsCode = { + FACE_AUTH_TIP_TOO_BRIGHT: 1, + FACE_AUTH_TIP_TOO_DARK: 2, + FACE_AUTH_TIP_TOO_CLOSE: 3, + FACE_AUTH_TIP_TOO_FAR: 4, + FACE_AUTH_TIP_TOO_HIGH: 5, + FACE_AUTH_TIP_TOO_LOW: 6, + FACE_AUTH_TIP_TOO_RIGHT: 7, + FACE_AUTH_TIP_TOO_LEFT: 8, + FACE_AUTH_TIP_TOO_MUCH_MOTION: 9, + FACE_AUTH_TIP_POOR_GAZE: 10, + FACE_AUTH_TIP_NOT_DETECTED: 11 + }; + const ResultCode = { + SUCCESS: 0, + FAIL: 1, + GENERAL_ERROR: 2, + CANCELED: 3, + TIMEOUT: 4, + TYPE_NOT_SUPPORT: 5, + TRUST_LEVEL_NOT_SUPPORT: 6, + BUSY: 7, + INVALID_PARAMETERS: 8, + LOCKED: 9, + NOT_ENROLLED: 10 + }; + const Module = { + FACE_AUTH: 1 + }; + const AuthTrustLevel = { + ATL1: 10000, + ATL2: 20000, + ATL3: 30000, + ATL4: 40000 + }; + const AuthSubType = { + PIN_SIX: 10000, + PIN_NUMBER: 10001, + PIN_MIXED: 10002, + FACE_2D: 20000, + FACE_3D: 20001 + }; + const GetPropertyType = { + AUTH_SUB_TYPE: 1, + REMAIN_TIMES: 2, + FREEZING_TIME: 3 + }; + const SetPropertyType = { + INIT_ALGORITHM: 1 + }; + const AuthType = { + PIN: 1, + FACE: 2 + }; const osAccount = { getAccountManager: function (...args) { console.warn("osAccount.getAccountManager interface mocked in the Previewer. " + From 14f2764d2106147ee1c2598b828df7590de98136 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Fri, 22 Jul 2022 11:45:26 +0800 Subject: [PATCH 071/103] fix mock review problem Signed-off-by: Mupceet --- runtime/main/extend/systemplugin/index.js | 1 - .../AccessibilityExtensionContext.js | 356 +++++++++--------- .../main/extend/systemplugin/napi/index.js | 6 +- .../systemplugin/napi/ohos_accessibility.js | 50 +-- ...plication_AccessibilityExtensionAbility.js | 24 +- 5 files changed, 217 insertions(+), 220 deletions(-) diff --git a/runtime/main/extend/systemplugin/index.js b/runtime/main/extend/systemplugin/index.js index 50d08416..cb5e503d 100644 --- a/runtime/main/extend/systemplugin/index.js +++ b/runtime/main/extend/systemplugin/index.js @@ -73,7 +73,6 @@ export function mockSystemPlugin() { mockAbilityFeatureAbility() mockAbilityContinuationRegisterManager() mockRequireNapiFun() - mockAbilityDataUriUtils() mockAbilityParticleAbility() mockAbilityFormManager() mockAbilityAbilityAgent() diff --git a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js index bb351cd0..1b527773 100644 --- a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js @@ -16,188 +16,184 @@ import { paramMock } from '../../utils' import { ExtensionContextClass } from './AbilityContext' -export function mockAccessibilityExtensionContext() { - const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; +const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; - const ElementAttributeValueMock = '[PC Preview] unknown element attribute value'; +const ElementAttributeValuesMock = '[PC Preview] unknown element attribute value'; - const RectMock = { - left: paramMock.paramNumberMock, - top: paramMock.paramNumberMock, - width: paramMock.paramNumberMock, - height: paramMock.paramNumberMock - }; +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 AccessibilityElementMock = { - 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 = [ElementAttributeValueMock]; - break; - case 'rect': - case 'screenRect': - value = RectMock; - break; - case 'parent': - case 'rootElement': - value = AccessibilityElementMock; - break; - case 'children': - value = [AccessibilityElementMock]; - break; - default: - value = ElementAttributeValueMock; - 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') ? [AccessibilityElementMock] : AccessibilityElementMock; - 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); - }); - } - }, - }; - - const AccessibilityExtensionContextClass = class AccessibilityExtensionContext extends ExtensionContextClass { - constructor() { - 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, AccessibilityElementMock); - } else { - return new Promise((resolve, reject) => { - resolve(AccessibilityElementMock); - }); - } - }; - - 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, AccessibilityElementMock); - } else { - return new Promise((resolve, reject) => { - resolve(AccessibilityElementMock); - }); - } - }; - - 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, [AccessibilityElementMock]); - } else { - return new Promise((resolve, reject) => { - resolve([AccessibilityElementMock]); - }); - } - }; - - 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(); - }); - } - }; +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; + } - return new AccessibilityExtensionContextClass(); -} + 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/index.js b/runtime/main/extend/systemplugin/napi/index.js index 7ee16d79..3a76f46e 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -170,12 +170,12 @@ import { mockDefaultAppManager } from './ohos_bundle_defaultAppManager' import { mockKeyEvent } from './ohos_multimodalInput_keyEvent' import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent' import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' -import { mockAccessibility } from './ohos_accessibility' -import { mockAccessibilityConfig } from './ohos_accessibility_config' -import { mockAccessibilityExtensionAbility } from './ohos_application_AccessibilityExtensionAbility' import { mockUiAppearance } from './ohos_uiAppearance' import { mockContinationManager } from './ohos_continuation_continuationManager' import { mockUiTest } from './ohos_uitest' +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]) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_accessibility.js b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js index f9f8a4fc..ba20e642 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_accessibility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_accessibility.js @@ -22,14 +22,14 @@ export function mockAccessibility() { const EventTypeMock = '[PC Preview] unknown EventType'; - const AccessibilityAbilityInfoMock = { - id: paramMock.paramStringMock, - name: paramMock.paramStringMock, - bundleName: paramMock.paramStringMock, - TargetBundleName: [paramMock.paramStringMock], + 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: paramMock.paramStringMock, + description: '[PC Preview] unknown description', eventTypes: [EventTypeMock] }; @@ -37,9 +37,9 @@ export function mockAccessibility() { const CaptionsFontFamilyMock = '[PC Preview] unknown CaptionsFontFamily'; - const CaptionStyleMock = { + const CaptionStyle = { fontFamily: CaptionsFontFamilyMock, - fontScale: paramMock.paramNumberMock, + fontScale: '[PC Preview] unknown fontScale', fontColor: '[PC Preview] unknown fontColor', fontEdgeType: CaptionsFontEdgeTypeMock, backgroundColor: '[PC Preview] unknown backgroundColor', @@ -47,8 +47,8 @@ export function mockAccessibility() { }; const CaptionsManagerMock = { - enabled: paramMock.paramBooleanMock, - style: CaptionStyleMock, + 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.'); @@ -57,7 +57,7 @@ export function mockAccessibility() { if (args[0] === 'enableChange') { args[len - 1].call(this, paramMock.paramBooleanMock); } else if (args[0] === 'styleChange') { - args[len - 1].call(this, CaptionStyleMock); + args[len - 1].call(this, CaptionStyle); } } }, @@ -69,7 +69,7 @@ export function mockAccessibility() { if (args[0] === 'enableChange') { args[len - 1].call(this, paramMock.paramBooleanMock); } else if (args[0] === 'styleChange') { - args[len - 1].call(this, CaptionStyleMock); + args[len - 1].call(this, CaptionStyle); } } }, @@ -82,23 +82,23 @@ export function mockAccessibility() { const TextMoveUnitMock = '[PC Preview] unknown TextMoveUnit'; const EventInfoClass = class EventInfo { - constructor(jsonObject) { + 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 = paramMock.paramStringMock; - this.componentType = paramMock.paramStringMock; - this.pageId = paramMock.paramNumberMock; - this.description = paramMock.paramStringMock; + 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 = [paramMock.paramStringMock]; - this.lastContent = paramMock.paramStringMock; - this.beginIndex = paramMock.paramNumberMock; - this.currentIndex = paramMock.paramNumberMock; - this.endIndex = paramMock.paramNumberMock; - this.itemCount = paramMock.paramNumberMock; + 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'; } }; @@ -159,10 +159,10 @@ export function mockAccessibility() { ' 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]); + args[len - 1].call(this, paramMock.businessErrorMock, [AccessibilityAbilityInfo]); } else { return new Promise((resolve, reject) => { - resolve([AccessibilityAbilityInfoMock]); + resolve([AccessibilityAbilityInfo]); }); } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js index 69ef4d3f..fe7eb1f7 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AccessibilityExtensionAbility.js @@ -14,29 +14,30 @@ */ import { paramMock } from '../utils'; -import { mockAccessibilityExtensionContext } from './application/AccessibilityExtensionContext'; +import { AccessibilityExtensionContext } from './application/AccessibilityExtensionContext'; -const AccessibilityEventMock = { +const AccessibilityEvent = { eventType: '[PC Preview] unknown eventType', target: '[PC Preview] unknown target', - timeStamp: '[PC Preview] unknown timeStamp', - notificationContent: '[PC Preview] unknown notificationContent' + timeStamp: '[PC Preview] unknown timeStamp' }; -const GesturePointMock = { - positionX: paramMock.paramNumberMock, - positionY: paramMock.paramNumberMock +const GesturePoint = { + positionX: '[PC Preview] unknown positionX', + positionY: '[PC Preview] unknown positionY' }; -const GesturePathMock = { - points: [GesturePointMock], - durationTime: paramMock.paramNumberMock +const GesturePath = { + points: [GesturePoint], + durationTime: '[PC Preview] unknown durationTime' }; export function mockAccessibilityExtensionAbility() { const AccessibilityExtensionAbilityClass = class AccessibilityExtensionAbility { constructor() { - this.context = mockAccessibilityExtensionContext(); + 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.'); @@ -52,6 +53,7 @@ export function mockAccessibilityExtensionAbility() { 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; }; } }; From 2afa5dc3c46289bc10f7900f332822895fe0ad0f Mon Sep 17 00:00:00 2001 From: lhb <443830197@qq.com> Date: Fri, 22 Jul 2022 10:04:11 +0800 Subject: [PATCH 072/103] add windowAnimationManager mock Signed-off-by: lhb <443830197@qq.com> Change-Id: I644c0184fa20861525cf5d0df1ff91076b3665c9 --- .../main/extend/systemplugin/napi/index.js | 3 + .../ohos_animation_windowAnimationManager.js | 79 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 8a16445e..56e6222e 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -174,6 +174,7 @@ 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' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -499,6 +500,8 @@ export function mockRequireNapiFun() { return mockContinationManager(); case "uitest": return mockUiTest(); + case "animation.windowAnimationManager": + return mockWindowAnimationManager(); default: return global.requireNapiPreview(...args); } 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 From c53481b5b8e2352997462500431167bebb503f93 Mon Sep 17 00:00:00 2001 From: linhaoran Date: Fri, 22 Jul 2022 14:42:39 +0800 Subject: [PATCH 073/103] Modify container Mock Signed-off-by: linhaoran --- .../systemplugin/napi/ohos_util_Arraylist.js | 44 +++++++------- .../systemplugin/napi/ohos_util_Deque.js | 40 ++++++------- .../systemplugin/napi/ohos_util_HashMap.js | 42 +++++++------- .../systemplugin/napi/ohos_util_HashSet.js | 44 +++++++------- .../napi/ohos_util_LightWeightMap.js | 42 +++++++------- .../napi/ohos_util_LightWeightSet.js | 52 ++++++++--------- .../systemplugin/napi/ohos_util_LinkedList.js | 40 ++++++------- .../systemplugin/napi/ohos_util_List.js | 8 +-- .../systemplugin/napi/ohos_util_PlainArray.js | 42 +++++++------- .../systemplugin/napi/ohos_util_Queue.js | 40 ++++++------- .../systemplugin/napi/ohos_util_Stack.js | 40 ++++++------- .../systemplugin/napi/ohos_util_TreeMap.js | 46 +++++++-------- .../systemplugin/napi/ohos_util_TreeSet.js | 58 +++++++++---------- .../systemplugin/napi/ohos_util_Vector.js | 46 +++++++-------- 14 files changed, 292 insertions(+), 292 deletions(-) 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; From 26d6091c0de12b265896cb4e62b056254837d9d2 Mon Sep 17 00:00:00 2001 From: lixingyang Date: Fri, 22 Jul 2022 14:50:28 +0800 Subject: [PATCH 074/103] Modify the mock of some interfaces of the language compilation subsystem Signed-off-by: lixingyang https://gitee.com/openharmony/third_party_jsframework/issues/I5IFH3 --- .../main/extend/systemplugin/napi/ohos_url.js | 42 ++++++++-------- .../extend/systemplugin/napi/ohos_util.js | 48 +++++++++---------- .../extend/systemplugin/napi/ohos_worker.js | 10 +--- 3 files changed, 47 insertions(+), 53 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_url.js b/runtime/main/extend/systemplugin/napi/ohos_url.js index ece3c454..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 { diff --git a/runtime/main/extend/systemplugin/napi/ohos_util.js b/runtime/main/extend/systemplugin/napi/ohos_util.js index 0b0482e2..017e87ac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util.js @@ -52,9 +52,9 @@ export function mockUtil() { return RationalNumberMock; }, LruBuffer: function (...args) { - console.warn("util.Lrubuffer interface mocked in the Previewer. How this interface works on the Previewer" + + 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; + return LruBufferMock; }, ScopeComparable: function (...args) { console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + @@ -170,106 +170,106 @@ export function mockUtil() { return paramMock.paramStringMock; } } - const LrubufferMock = { + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_worker.js b/runtime/main/extend/systemplugin/napi/ohos_worker.js index 7a465748..4958d5fd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_worker.js +++ b/runtime/main/extend/systemplugin/napi/ohos_worker.js @@ -43,13 +43,6 @@ export function mockWorker() { transfer:'[PC preview] unknow transfer' }; - const EventListenerMock = { - evt : function (...args) { - console.warn('EventListener.evt interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.') ; - } - }; - const EventTargetMock = { addEventListener : function (...args) { console.warn('PostMessageOptions.addEventListener interface mocked in the Previewer. How this interface works on the' + @@ -167,7 +160,8 @@ export function mockWorker() { }; const workerMock = { - Worker : WorkerClass + Worker : WorkerClass, + parentPort : '[PC preview] unknow parentPort' }; return workerMock; } From 995a76a81f0597a5a6b90eddfdccc9d5ff954896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Fri, 22 Jul 2022 09:38:06 +0000 Subject: [PATCH 075/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/extend/systemplugin/napi/ohos_update.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index f052ee8d..c5a40d7e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -434,16 +434,16 @@ const UpgradeInfo = { const BusinessType = { vendor: BusinessVendor, - subType: BusinessSubType.FIRMWARE + subType: BusinessSubType } const DownloadOptions = { - allowNetwork: NetType.CELLULAR, - order: Order.DOWNLOAD_AND_INSTALL + allowNetwork: NetType, + order: Order } const ResumeDownloadOptions = { - allowNetwork: NetType.CELLULAR + allowNetwork: NetType } const PauseDownloadOptions = { @@ -451,11 +451,11 @@ const PauseDownloadOptions = { } const UpgradeOptions = { - order: Order.INSTALL + order: Order } const ClearOptions = { - status: UpgradeStatus.UPGRADE_SUCCESS + status: UpgradeStatus } const EventClassifyInfo = { @@ -464,7 +464,7 @@ const EventClassifyInfo = { } const UpgradeFile = { - fileType: ComponentType.OTA, + fileType: ComponentType, filePath: "[PC Preview] unknown filePath" } From 98537bd4182ca240d50cc77a3fb25cbaf67d83f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B5=B7?= Date: Fri, 22 Jul 2022 09:49:40 +0000 Subject: [PATCH 076/103] =?UTF-8?q?Signed-off-by:=20=E6=B1=9F=E6=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/main/extend/systemplugin/napi/ohos_update.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index c5a40d7e..deba644b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -255,7 +255,6 @@ export function mockUpdate() { ClearOptions, EventClassifyInfo, UpgradeFile, - UpgradeTaskCallback, 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.") @@ -466,8 +465,4 @@ const EventClassifyInfo = { const UpgradeFile = { fileType: ComponentType, filePath: "[PC Preview] unknown filePath" -} - -const UpgradeTaskCallback = { - UpgradeTaskCallback: (eventInfo) => {} } \ No newline at end of file From 36972df05b56c65e39e8fbfdc2938221daf14d13 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 21:14:06 +0800 Subject: [PATCH 077/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 271 +++++++++++++++--- 1 file changed, 225 insertions(+), 46 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index de28a68f..a38a48aa 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -81,7 +81,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -93,7 +93,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -105,7 +105,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -117,7 +117,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -129,7 +129,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -141,7 +141,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -153,7 +153,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -165,7 +165,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -177,7 +177,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -189,7 +189,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -201,7 +201,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -213,7 +213,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -225,7 +225,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -237,7 +237,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -249,7 +249,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -258,12 +258,12 @@ export function mockOsAccount() { console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var osAccountInfoArrayMock = new Array(); - osAccountInfoArrayMock.push(osAccountInfoMock); + osAccountInfoArrayMock.push(OsAccountInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(osAccountInfoArrayMock); }) } @@ -272,12 +272,12 @@ export function mockOsAccount() { console.warn("AccountManager.queryActivatedOsAccountIds interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var osAccountIdsArrayMock = new Array(); - osAccountIdsArrayMock.push(osAccountInfoMock); + osAccountIdsArrayMock.push(OsAccountInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(osAccountIdsArrayMock); }) } @@ -287,10 +287,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -299,10 +299,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -311,10 +311,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -323,10 +323,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountInfoMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountInfoMock); }) } }, @@ -335,10 +335,10 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, osAccountTypeMock); + args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock); } else { - return new Promise((resolve, reject) => { - resolve(osAccountTypeMock); + return new Promise((resolve, _reject) => { + resolve(OsAccountTypeMock); }) } }, @@ -349,7 +349,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -361,7 +361,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramStringMock); }) } @@ -373,7 +373,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -385,7 +385,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -397,7 +397,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(); }) } @@ -409,7 +409,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -421,7 +421,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -433,7 +433,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -445,7 +445,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(paramMock.paramNumberMock); }) } @@ -454,17 +454,196 @@ export function mockOsAccount() { console.warn("AccountManager.queryOsAccountConstraintSourceTypes interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") var constraintSourceTypeInfoArrayMock = new Array(); - constraintSourceTypeInfoArrayMock.push(constraintSourceTypeInfoMock); + constraintSourceTypeInfoArrayMock.push(ConstraintSourceTypeInfoMock); const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { resolve(constraintSourceTypeInfoArrayMock); }) } }, }; + const UserAuthClass = class UserAuth { + constructor() { + console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.getVersion = function (..._args) { + console.warn("UserAuth.getVersion interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getAvailableStatus = function (..._args) { + console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getProperty = function (...args) { + console.warn("UserAuth.getProperty interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); + } else { + return new Promise((resolve, _reject) => { + resolve(ExecutorProperty); + }) + } + }; + this.setProperty = function (...args) { + console.warn("UserAuth.setProperty interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, _reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }; + this.auth = function (...args) { + console.warn("UserAuth.auth interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } + }; + this.anthUser = function (...args) { + console.warn("UserAuth.authUser interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } + }; + this.cancelAuth = function (..._args) { + console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + }; + }; + const PINAuthClass = class PINAuth { + constructor() { + console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.registerInputer = function (...args) { + console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.unregisterInputer = function (..._args) { + console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }; + }; + }; + const UserIdentityManagerClass = class UserIdentityManager { + constructor() { + console.warn("osAccount.getAccountManager constructor interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + this.openSession = function (...args) { + console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); + } else { + return new Promise((resolve, _reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }; + this.addCredential = function (...args) { + console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.updateCredential = function (...args) { + console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.closeSession = function (..._args) { + console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }; + this.cancel = function (..._args) { + console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.delUser = function (..._args) { + console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.delCred = function (..._args) { + console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); + } + }; + this.getAuthInfo = function (..._args) { + console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, new Array(EnrolledCredInfo)); + } else { + return new Promise((resolve, reject) => { + resolve(new Array(EnrolledCredInfo)) + }) + } + }; + }; + } + const IInputData = { + onSetData: function (..._args) { + console.warn("IInputData.onSetData interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IInputer = { + onSetData: function (..._args) { + console.warn("IInputer.onSetData interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IUserAuthCallback = { + onResult: function (..._args) { + console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + onAcquireInfo: function (..._args) { + console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; + const IIdmCallback = { + onResult: function (..._args) { + console.warn("IIdmCallback.onResult interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + onAcquireInfo: function (..._args) { + console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " + + "How this interface works on the Previewer may be different from that on a real device.") + }, + }; const ConstraintSourceType = { CONSTRAINT_NOT_EXIST: 0, CONSTRAINT_TYPE_BASE: 1, @@ -549,7 +728,7 @@ export function mockOsAccount() { NORMAL: "[PC Preview] unknown NORMAL", GUEST: "[PC Preview] unknown GUEST" }, - constraintSourceType, + ConstraintSourceType, } return osAccount } From 0b2fab459515936e32a5f01ce7ceea40a4bf22a5 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 21:21:06 +0800 Subject: [PATCH 078/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index a38a48aa..5a3f4148 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -81,7 +81,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -93,7 +93,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -105,7 +105,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -117,7 +117,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -129,7 +129,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -141,7 +141,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -153,7 +153,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -165,7 +165,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -177,7 +177,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -189,7 +189,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -201,7 +201,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -213,7 +213,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -225,7 +225,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -237,7 +237,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -249,7 +249,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -263,7 +263,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(osAccountInfoArrayMock); }) } @@ -277,7 +277,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(osAccountIdsArrayMock); }) } @@ -289,7 +289,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -301,7 +301,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -313,7 +313,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -325,7 +325,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountInfoMock); }) } @@ -337,7 +337,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(OsAccountTypeMock); }) } @@ -349,7 +349,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -361,7 +361,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); }) } @@ -373,7 +373,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -385,7 +385,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -397,7 +397,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(); }) } @@ -409,7 +409,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -421,7 +421,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -433,7 +433,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); }) } @@ -445,7 +445,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -459,7 +459,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(constraintSourceTypeInfoArrayMock); }) } @@ -486,7 +486,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(ExecutorProperty); }) } @@ -498,7 +498,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); }) } @@ -552,7 +552,7 @@ export function mockOsAccount() { if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } else { - return new Promise((resolve, _reject) => { + return new Promise((resolve, reject) => { resolve(paramMock.paramArrayMock); }) } From 54ad76d08f743ffd9a21ceeec69783e14889d4ec Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 22 Jul 2022 23:30:26 +0800 Subject: [PATCH 079/103] osAccount API Mock Signed-off-by: chen --- .../napi/ohos_account_osAccount.js | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 5a3f4148..d3ddfaae 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -49,7 +49,7 @@ export function mockOsAccount() { }; const ExecutorProperty = { result: "[PC Preview] unknown result", - authSubType: "[PC Preview] unknown authSubType", + authSubType: AuthSubType, remainTimes: "[PC Preview] unknown remainTimes", freezingTime: "[PC Preview] unknown freezingTime" }; @@ -468,20 +468,20 @@ export function mockOsAccount() { const UserAuthClass = class UserAuth { constructor() { console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - this.getVersion = function (..._args) { + "How this interface works on the Previewer may be different from that on a real device.") + this.getVersion = function (...args) { console.warn("UserAuth.getVersion interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; - this.getAvailableStatus = function (..._args) { + this.getAvailableStatus = function (...args) { console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; this.getProperty = function (...args) { console.warn("UserAuth.getProperty interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); @@ -493,7 +493,7 @@ export function mockOsAccount() { }; this.setProperty = function (...args) { console.warn("UserAuth.setProperty interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); @@ -505,7 +505,7 @@ export function mockOsAccount() { }; this.auth = function (...args) { console.warn("UserAuth.auth interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); @@ -513,16 +513,16 @@ export function mockOsAccount() { }; this.anthUser = function (...args) { console.warn("UserAuth.authUser interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); } }; - this.cancelAuth = function (..._args) { + this.cancelAuth = function (...args) { console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock; + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; }; }; }; @@ -530,15 +530,15 @@ export function mockOsAccount() { constructor() { console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - this.registerInputer = function (...args) { - console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + this.registerInputer = function (...args) { + console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; - }; - this.unregisterInputer = function (..._args) { - console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + }; + this.unregisterInputer = function (...args) { + console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - }; + }; }; }; const UserIdentityManagerClass = class UserIdentityManager { @@ -573,75 +573,75 @@ export function mockOsAccount() { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.closeSession = function (..._args) { + this.closeSession = function (...args) { console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }; - this.cancel = function (..._args) { + this.cancel = function (...args) { console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; - this.delUser = function (..._args) { + this.delUser = function (...args) { console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.delCred = function (..._args) { + this.delCred = function (...args) { console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); } }; - this.getAuthInfo = function (..._args) { + this.getAuthInfo = function (...args) { console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length + const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, new Array(EnrolledCredInfo)); } else { return new Promise((resolve, reject) => { - resolve(new Array(EnrolledCredInfo)) + resolve(new Array(EnrolledCredInfo)) }) } }; }; } const IInputData = { - onSetData: function (..._args) { + onSetData: function (...args) { console.warn("IInputData.onSetData interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IInputer = { - onSetData: function (..._args) { + onSetData: function (...args) { console.warn("IInputer.onSetData interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IUserAuthCallback = { - onResult: function (..._args) { + onResult: function (...args) { console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, - onAcquireInfo: function (..._args) { + onAcquireInfo: function (...args) { console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const IIdmCallback = { - onResult: function (..._args) { + onResult: function (...args) { console.warn("IIdmCallback.onResult interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, - onAcquireInfo: function (..._args) { + onAcquireInfo: function (...args) { console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " + - "How this interface works on the Previewer may be different from that on a real device.") + "How this interface works on the Previewer may be different from that on a real device.") }, }; const ConstraintSourceType = { From 6d9c9877a0cbef380a63334c600d5a8484d7b102 Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Sat, 23 Jul 2022 09:46:05 +0800 Subject: [PATCH 080/103] js api mock. Signed-off-by: dingxiaochen --- .../extend/systemplugin/napi/ohos_contact.js | 5 + .../systemplugin/napi/ohos_telephony_call.js | 131 +++++++++- .../systemplugin/napi/ohos_telephony_data.js | 2 + .../napi/ohos_telephony_observer.js | 2 + .../systemplugin/napi/ohos_telephony_radio.js | 145 ++++++++--- .../systemplugin/napi/ohos_telephony_sim.js | 76 +++++- .../systemplugin/napi/ohos_telephony_sms.js | 237 ++++++++++++++++++ 7 files changed, 559 insertions(+), 39 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_contact.js b/runtime/main/extend/systemplugin/napi/ohos_contact.js index 8b1706bd..443f6686 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_contact.js +++ b/runtime/main/extend/systemplugin/napi/ohos_contact.js @@ -39,6 +39,10 @@ export function mockContact() { this.organization = "[PC Preview] unknow organization"; } } + ContactClass.INVALID_CONTACT_ID = -1; + + const Attribute = "[PC Preview] unknow unkown Attribute"; + const ContactAttributesClass = class ContactAttributes { constructor() { console.warn('contact.ContactAttributes.constructor interface mocked in the Previewer. How this interface' + @@ -122,6 +126,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 { diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js index 64ef7ab0..f37cce69 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js @@ -18,6 +18,48 @@ import { paramMock } from "../utils" export function mockCall() { const CallWaitingStatus = "[PC Preview] unknow CallWaitingStatus"; const RestrictionStatus = "[PC Preview] unknow RestrictionStatus"; + const ImsCallMode = "[PC Preview] unknow ImsCallMode"; + const AudioDevice = "[PC Preview] unknow AudioDevice"; + const CallRestrictionType = "[PC Preview] unknow CallRestrictionType"; + const CallTransferType = "[PC Preview] unknow CallTransferType"; + const CallTransferSettingType = "[PC Preview] unknow CallTransferSettingType"; + const ConferenceState = "[PC Preview] unknow ConferenceState"; + const CallType = "[PC Preview] unknow CallType"; + const VideoStateType = "[PC Preview] unknow VideoStateType"; + const DetailedCallState = "[PC Preview] unknow DetailedCallState"; + const CallRestrictionMode = "[PC Preview] unknow CallRestrictionMode"; + const CallAbilityEventId = "[PC Preview] unknow CallAbilityEventId"; + const DialScene = "[PC Preview] unknow DialScene"; + const DialType = "[PC Preview] unknow DialType"; + const CallState = "[PC Preview] unknow CallState"; + const TransferStatus = "[PC Preview] unknow TransferStatus"; + const DisconnectedDetails = "[PC Preview] unknow DisconnectedDetails"; + const EmergencyNumberOptions = { + slotId: "[PC Preview] unknow slotId" + } + const CallTransferResult = { + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", + } + const CallTransferInfo = { + transferNum: "[PC Preview] unknow transferNum", + type: CallTransferType, + settingType: CallTransferSettingType, + } + const NumberFormatOptions = { + countryCode: "[PC Preview] unknow countryCode" + } + const CallRestrictionInfo = { + type: CallRestrictionType, + password: "[PC Preview] unknow password", + mode: CallRestrictionMode, + } + const CallEventOptions = { + eventId: CallAbilityEventId + } + const RejectMessageOptions = { + messageContent: "[PC Preview] unknow messageContent" + } const CallAttributeOptions = { accountNumber: "[PC Preview] unknow accountNumber", speakerphoneOn: "[PC Preview] unknow speakerphoneOn", @@ -30,9 +72,12 @@ export function mockCall() { callState: "[PC Preview] unknow callState", conferenceState: "[PC Preview] unknow conferenceState" } - const CallTransferResult = { - status: "[PC Preview] unknow status", - number: "[PC Preview] unknow number", + const DialOptions = { + extras: "[PC Preview] unknow extras", + accountId: "[PC Preview] unknow accountId", + videoState: VideoStateType, + dialScene: DialScene, + dialType: DialType, } const call = { dial: function (...args) { @@ -420,7 +465,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 +479,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 +641,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.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..1dd920aa 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js @@ -16,6 +16,8 @@ import { paramMock } from "../utils" export function mockData() { + const DataFlowType = "[PC Preview] unknow DataFlowType"; + const DataConnectState = "[PC Preview] unknow DataConnectState"; const data = { getDefaultCellularDataSlotId: function (...args) { console.warn("telephony.data.getDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" + diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js index bba534f2..ae3e51ac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js @@ -19,7 +19,9 @@ export function mockObserver() { const SimStateData = { type: "[PC Preview] unknow type", state: "[PC Preview] unknow state", + reason: LockReason, } + const LockReason = "[PC Preview] unknow LockReason"; const observer = { on: function (...args) { console.warn("telephony.observer.on interface mocked in the Previewer. How this interface works on the Previewer may " + diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js index 9922ed01..229c9b5a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js @@ -15,30 +15,96 @@ import { paramMock } from "../utils" -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", - isCaActive: "[PC Preview] unknow isCaActive", - isEmergency: "[PC Preview] unknow isEmergency", -} -const SignalInformation = { - signalType: "[PC Preview] unknow signalType", - signalLevel: "[PC Preview] unknow signalLevel" -} -const DataFlowType = "[PC Preview] unknow DataFlowType" -const DataConnectState = "[PC Preview] unknow DataConnectState" -const CellInformation = { - networkType: "[PC Preview] unknow networkType", - isCamped: "[PC Preview] unknow isCamped", - timeStamp: "[PC Preview] unknow timeStamp", - signalInformation: "[PC Preview] unknow signalInformation", - data: "[PC Preview] unknow unkown data" -} export function mockRadio() { + 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", + isCaActive: "[PC Preview] unknow isCaActive", + isEmergency: "[PC Preview] unknow isEmergency", + cfgTech: RadioTechnology, + } + const SignalInformation = { + signalType: "[PC Preview] unknow signalType", + signalLevel: "[PC Preview] unknow signalLevel" + } + const DataFlowType = "[PC Preview] unknow DataFlowType"; + const DataConnectState = "[PC Preview] unknow DataConnectState"; + const RadioTechnology = "[PC Preview] unknow RadioTechnology"; + const NetworkType = "[PC Preview] unknow NetworkType"; + const RegState = "[PC Preview] unknow RegState"; + const NsaState = "[PC Preview] unknow NsaState"; + const CellInformation = { + networkType: "[PC Preview] unknow networkType", + isCamped: "[PC Preview] unknow isCamped", + timeStamp: "[PC Preview] unknow timeStamp", + signalInformation: "[PC Preview] unknow signalInformation", + data: "[PC Preview] unknow data" + } + 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" + } + 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", + } + 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", + } + 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 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", + } + 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", + } + const NetworkSelectionModeOptions = { + slotId: "[PC Preview] unknow slotId", + selectMode: NetworkSelectionMode, + networkInformation: NetworkInformation, + resumeSelection: "[PC Preview] unknow resumeSelection", + } + const NetworkInformation = { + operatorName: "[PC Preview] unknow operatorName", + operatorNumeric: "[PC Preview] unknow operatorNumeric", + state: NetworkInformationState, + radioTech: "[PC Preview] unknow radioTech", + } const NetworkSearchResult = { isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", networkSearchResult: [{ @@ -48,9 +114,10 @@ export function mockRadio() { 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 PreferredNetworkMode = "[PC Preview] unknow PreferredNetworkMode"; + const NetworkInformationState = "[PC Preview] unknow NetworkInformationState"; + const NrOptionMode = "[PC Preview] unknow NrOptionMode"; + const NetworkSelectionMode = "[PC Preview] unknow unkown NetworkSelectionMode"; const radio = { getRadioTech: function (...args) { console.warn("telephony.radio.getRadioTech interface mocked in the Previewer. How this interface works on the Previewer may" + @@ -75,7 +142,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,12 +161,24 @@ 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.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, [CellInformation]); + args[len - 1].call(this, [CellInformation]); } else { return new Promise((resolve, reject) => { resolve([CellInformation]); @@ -111,7 +190,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, NetworkSelectionMode); + args[len - 1].call(this, NetworkSelectionMode); } else { return new Promise((resolve, reject) => { resolve(NetworkSelectionMode); @@ -135,7 +214,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, NetworkSearchResult); + args[len - 1].call(this, NetworkSearchResult); } else { return new Promise((resolve, reject) => { resolve(NetworkSearchResult); @@ -272,7 +351,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, paramMock.paramStringMock); + args[len - 1].call(this, paramMock.paramStringMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); @@ -296,7 +375,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, PreferredNetworkMode); + args[len - 1].call(this, PreferredNetworkMode); } else { return new Promise((resolve, reject) => { resolve(PreferredNetworkMode); @@ -308,7 +387,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, paramMock.paramStringMock); + args[len - 1].call(this, paramMock.paramStringMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js index 7325cee3..b5cf65bd 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js @@ -33,15 +33,29 @@ export function mockSim() { result: "[PC Preview] unknow result", remain: "[PC Preview] unknow remain" } + const LockInfo = { + lockType: LockType, + password: "[PC Preview] unknow password", + state: LockState, + } + const PersoLockInfo = { + lockType: PersoLockType, + password: "[PC Preview] unknow password", + } 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" + emails: "[PC Preview] unknow emails", + pin2: "[PC Preview] unknow pin2", } const CardType = "[PC Preview] unknow CardType"; + const LockType = "[PC Preview] unknow LockType"; const SimState = "[PC Preview] unknow SimState"; + const PersoLockType = "[PC Preview] unknow PersoLockType"; + const ContactType = "[PC Preview] unknow ContactType"; + const LockState = "[PC Preview] unknow LockState"; const sim = { isSimActive: function (...args) { console.warn("telephony.sim.isSimActive interface mocked in the Previewer. How this interface works on the Previewer may" + @@ -127,6 +141,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, 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 +338,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 +362,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 +386,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 +458,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..1aa84ba5 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js @@ -21,6 +21,12 @@ export function mockSMS() { simMessageStatus: "[PC Preview] unknow simMessageStatus", indexOnSim: "[PC Preview] unknow indexOnSim" } + const MmsInformation = { + messageType: MessageType, + mmsType: "[PC Preview] unknow mmsType", + attachment: [MmsAttachment] + } + const MessageType = "[PC Preview] unknow MessageType"; const ShortMessage = { visibleMessageBody: "[PC Preview] unknow visibleMessageBody", visibleRawAddress: "[PC Preview] unknow visibleRawAddress", @@ -38,6 +44,165 @@ export function mockSMS() { userRawData: ["[PC Preview] unknow userRawData"], isEmailMessage: "[PC Preview] unknow isEmailMessage", } + 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"], + } + const MmsAcknowledgeInd = { + transactionId: "[PC Preview] unknow transactionId", + version: MmsVersionType, + reportAllowed: ReportType, + } + const MmsDeliveryInd = { + transactionId: "[PC Preview] unknow transactionId", + date: "[PC Preview] unknow date", + to: [MmsAddress], + status: "[PC Preview] unknow status", + version: MmsVersionType, + } + const MmsReadRecInd = { + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", + to: [MmsAddress], + from: MmsAddress, + readStatus: "[PC Preview] unknow readStatus", + date: "[PC Preview] unknow date", + } + 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, + } + const MmsReadOrigInd = { + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", + to: [MmsAddress], + from: MmsAddress, + date: "[PC Preview] unknow date", + readStatus: "[PC Preview] unknow readStatus", + } + const MmsRespInd = { + transactionId: "[PC Preview] unknow transactionId", + status: "[PC Preview] unknow transactionId", + version: MmsVersionType, + reportAllowed: ReportType, + } + const CBConfigOptions = { + slotId: "[PC Preview] unknow slotId", + enable: "[PC Preview] unknow enable", + startMessageId: "[PC Preview] unknow startMessageId", + endMessageId: "[PC Preview] unknow endMessageId", + ranType: RanType + } + const SimMessageOptions = { + slotId: "[PC Preview] unknow slotId", + smsc: "[PC Preview] unknow smsc", + pdu: "[PC Preview] unknow pdu", + status: SimMessageStatus, + } + const UpdateSimMessageOptions = { + slotId: "[PC Preview] unknow slotId", + msgIndex: "[PC Preview] unknow msgIndex", + newStatus: SimMessageStatus, + pdu: "[PC Preview] unknow pdu", + smsc: "[PC Preview] unknow smsc", + } + 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, + } + const IDeliveryShortMessageCallback = { + pdu: "[PC Preview] unknow pdu", + } + const ISendShortMessageCallback = { + result: SendSmsResult, + url: "[PC Preview] unknow url", + isLastPart: "[PC Preview] unknow isLastPart", + } + const SendSmsResult = "[PC Preview] unknow SendSmsResult"; + const ShortMessageClass = "[PC Preview] unknow ShortMessageClass"; + const RanType = "[PC Preview] unknow RanType"; + const SimMessageStatus = "[PC Preview] unknow SimMessageStatus"; + const DispositionType = "[PC Preview] unknow DispositionType"; + const MmsCharSets = "[PC Preview] unknow MmsCharSets"; + const ReportType = "[PC Preview] unknow ReportType"; + 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", + } + const MmsAddress = { + address: "[PC Preview] unknow address", + charset: MmsCharSets, + } + const MmsVersionType = "[PC Preview] unknow MmsVersionType"; + const MmsPriorityType = "[PC Preview] unknow MmsPriorityType"; + const MmsSendReq = { + from: MmsAddress, + transactionId: "[PC Preview] unknow transactionId", + contentType: "[PC Preview] unknow contentType", + version: MmsVersionType, + to: "[PC Preview] unknow to", + date: "[PC Preview] unknow date", + cc: "[PC Preview] unknow cc", + bcc: "[PC Preview] unknow bcc", + 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", + } + const MmsSendConf = { + responseState: "[PC Preview] unknow responseState", + transactionId: "[PC Preview] unknow transactionId", + version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", + } + + const SmsSegmentsInfo = { + splitCount: "[PC Preview] unknow splitCount", + encodeCount: "[PC Preview] unknow encodeCount", + encodeCountRemaining: "[PC Preview] unknow encodeCountRemaining", + scheme: SmsEncodingScheme, + } + const SmsEncodingScheme = "[PC Preview] unknow SmsEncodingScheme"; const sms = { splitMessage: function (...args) { console.warn("telephony.sms.splitMessage interface mocked in the Previewer. How this interface works on the Previewer may" + @@ -63,6 +228,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.") From 42a3929dfddba26a0a2ba2c024384a1951f9366a Mon Sep 17 00:00:00 2001 From: zcdqs Date: Mon, 25 Jul 2022 08:39:37 +0800 Subject: [PATCH 081/103] add getInspector for toolbar Signed-off-by: zcdqs Change-Id: I9cc8e8cdf0afa9c349ee66726790f6170590fc0c --- runtime/preparation/init.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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' } ]; From 6df7c7da7591d4fca13722ebf0231148536aaf06 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 10:05:55 +0800 Subject: [PATCH 082/103] osAccount API Mock Signed-off-by: chen --- .../systemplugin/napi/ohos_account_osAccount.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index d3ddfaae..ed394b24 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -721,14 +721,27 @@ export function mockOsAccount() { getAccountManager: function (...args) { console.warn("osAccount.getAccountManager interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") - return accountManagerMock; + return AccountManagerMock; }, OsAccountType: { ADMIN: "[PC Preview] unknown ADMIN", NORMAL: "[PC Preview] unknown NORMAL", GUEST: "[PC Preview] unknown GUEST" }, + UserAuth: UserAuthClass, + PINAuth: PINAuthClass, + UserIdentityManager: UserIdentityManagerClass, ConstraintSourceType, + OsAccountType, + FingerprintTips, + FaceTipsCode, + ResultCode, + Module, + AuthTrustLevel, + AuthSubType, + GetPropertyType, + SetPropertyType, + AuthType, } return osAccount } From b315804f4f816e54d3ea2c94099756f6de87efe6 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 10:11:03 +0800 Subject: [PATCH 083/103] osAccount API Mock Signed-off-by: chen --- .../main/extend/systemplugin/napi/ohos_account_osAccount.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index ed394b24..67579cac 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -723,11 +723,6 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") return AccountManagerMock; }, - OsAccountType: { - ADMIN: "[PC Preview] unknown ADMIN", - NORMAL: "[PC Preview] unknown NORMAL", - GUEST: "[PC Preview] unknown GUEST" - }, UserAuth: UserAuthClass, PINAuth: PINAuthClass, UserIdentityManager: UserIdentityManagerClass, From 557057756c2d5264bb0c3ad72eaf9baa408c2ce7 Mon Sep 17 00:00:00 2001 From: weiyunxing Date: Mon, 25 Jul 2022 10:38:29 +0800 Subject: [PATCH 084/103] setting api mock Signed-off-by: weiyunxing --- .../extend/systemplugin/napi/ohos_settings.js | 170 +++++++++++++++++- 1 file changed, 165 insertions(+), 5 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_settings.js b/runtime/main/extend/systemplugin/napi/ohos_settings.js index 72d3a7b2..a20bf447 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_settings.js +++ b/runtime/main/extend/systemplugin/napi/ohos_settings.js @@ -16,21 +16,181 @@ import { paramMock } from "../utils" export function mockSettings() { + 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 settingsMock = { - getUri: function (...args) { - console.warn("settings.getUri interface mocked in the Previewer. How this interface works on the" + + 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; From 427f871ba89554625b23cf1093f1714fd35f87d6 Mon Sep 17 00:00:00 2001 From: jiawen Date: Mon, 25 Jul 2022 14:06:31 +0800 Subject: [PATCH 085/103] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E7=AE=A1=E7=90=86js?= =?UTF-8?q?=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiawen Change-Id: Ib6a8cd67315b9516c91f174724903ace61b62e23 --- .../systemplugin/napi/ohos_net_connection.js | 675 ++++++++---------- .../extend/systemplugin/napi/ohos_net_http.js | 165 +++-- .../systemplugin/napi/ohos_net_socket.js | 84 ++- 3 files changed, 436 insertions(+), 488 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_connection.js b/runtime/main/extend/systemplugin/napi/ohos_net_connection.js index a0ed0ba5..a478e905 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: '[PC preview] unknow NET_CAPABILITY_MMS', + NET_CAPABILITY_NOT_METERED: '[PC preview] unknow NET_CAPABILITY_NOT_METERED', + NET_CAPABILITY_INTERNET: '[PC preview] unknow NET_CAPABILITY_INTERNET', + NET_CAPABILITY_NOT_VPN: '[PC preview] unknow NET_CAPABILITY_NOT_VPN', + NET_CAPABILITY_VALIDATED: '[PC preview] unknow NET_CAPABILITY_VALIDATED' +} + +export const NetBearType = { + BEARER_CELLULAR: '[PC preview] unknow BEARER_CELLULAR', + BEARER_WIFI: '[PC preview] unknow BEARER_WIFI', + BEARER_ETHERNET: '[PC preview] unknow BEARER_ETHERNET' +} + +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..b343812c 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: "[PC Preview] unknow OPTIONS", + GET: "[PC Preview] unknow GET", + HEAD: "[PC Preview] unknow HEAD", + POST: "[PC Preview] unknow POST", + PUT: "[PC Preview] unknow PUT", + DELETE: "[PC Preview] unknow DELETE", + TRACE: "[PC Preview] unknow TRACE", + CONNECT: "[PC Preview] unknow CONNECT" +} + +export const ResponseCode = { + OK: "[PC Preview] unknow OK", + CREATED: "[PC Preview] unknow CREATED", + ACCEPTED: "[PC Preview] unknow ACCEPTED", + NOT_AUTHORITATIVE: "[PC Preview] unknow NOT_AUTHORITATIVE", + NO_CONTENT: "[PC Preview] unknow NO_CONTENT", + RESET: "[PC Preview] unknow RESET", + PARTIAL: "[PC Preview] unknow PARTIAL", + MULT_CHOICE: "[PC Preview] unknow MULT_CHOICE", + MOVED_PERM: "[PC Preview] unknow MOVED_PERM", + MOVED_TEMP: "[PC Preview] unknow MOVED_TEMP", + SEE_OTHER: "[PC Preview] unknow SEE_OTHER", + NOT_MODIFIED: "[PC Preview] unknow NOT_MODIFIED", + USE_PROXY: "[PC Preview] unknow USE_PROXY", + BAD_REQUEST: "[PC Preview] unknow BAD_REQUEST", + UNAUTHORIZED: "[PC Preview] unknow UNAUTHORIZED", + PAYMENT_REQUIRED: "[PC Preview] unknow PAYMENT_REQUIRED", + FORBIDDEN: "[PC Preview] unknow FORBIDDEN", + NOT_FOUND: "[PC Preview] unknow NOT_FOUND", + BAD_METHOD: "[PC Preview] unknow BAD_METHOD", + NOT_ACCEPTABLE: "[PC Preview] unknow NOT_ACCEPTABLE", + PROXY_AUTH: "[PC Preview] unknow PROXY_AUTH", + CLIENT_TIMEOUT: "[PC Preview] unknow CLIENT_TIMEOUT", + CONFLICT: "[PC Preview] unknow CONFLICT", + GONE: "[PC Preview] unknow GONE", + LENGTH_REQUIRED: "[PC Preview] unknow LENGTH_REQUIRED", + PRECON_FAILED: "[PC Preview] unknow PRECON_FAILED", + ENTITY_TOO_LARGE: "[PC Preview] unknow ENTITY_TOO_LARGE", + REQ_TOO_LONG: "[PC Preview] unknow REQ_TOO_LONG", + UNSUPPORTED_TYPE: "[PC Preview] unknow UNSUPPORTED_TYPE", + INTERNAL_ERROR: "[PC Preview] unknow INTERNAL_ERROR", + NOT_IMPLEMENTED: "[PC Preview] unknow NOT_IMPLEMENTED", + BAD_GATEWAY: "[PC Preview] unknow BAD_GATEWAY", + UNAVAILABLE: "[PC Preview] unknow UNAVAILABLE", + GATEWAY_TIMEOUT: "[PC Preview] unknow GATEWAY_TIMEOUT", + VERSION: "[PC Preview] unknow VERSION" +} + 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; +} From 5709a9aac624e773492076701c1c0a3fb23db16e Mon Sep 17 00:00:00 2001 From: anyueling Date: Mon, 25 Jul 2022 14:50:33 +0800 Subject: [PATCH 086/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- .../extend/systemplugin/napi/ohos_request.js | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index 6afa10cf..c6bd6927 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 @@ -17,28 +17,28 @@ import { paramMock } from "../utils" export function mockRequest() { const DownloadConfig = { - url: "[PC Preview]: unknow uri", - herder: "[PC Preview]: unknow herder", - 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", + url: "[PC Preview] unknow uri", + herder: "[PC Preview] unknow herder", + 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", + 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 = { @@ -48,13 +48,13 @@ export function mockRequest() { 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" + 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" + const err = "[PC Preview] unknow err" args[len - 1].call(this, err) } } @@ -66,8 +66,8 @@ export function mockRequest() { 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" + 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) @@ -145,21 +145,21 @@ export function mockRequest() { }; const File = { - filename: "[PC Preview]: unknow filename", - name: "[PC Preview]: unknow name", - uri: "[PC Preview]: unknow uri", - type: "[PC Preview]: unknow type", + 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", + name: "[PC Preview] unknow name", + value: "[PC Preview] unknow value", }; const UploadConfig = { - url: "[PC Preview]: unknow uri", - herder: "[PC Preview]: unknow herder", - method: "[PC Preview]: unknow method", + url: "[PC Preview] unknow uri", + herder: "[PC Preview] unknow herder", + method: "[PC Preview] unknow method", files: [File], data: [RequestData], }; @@ -171,11 +171,11 @@ export function mockRequest() { 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" + 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" + const header = "[PC Preview] unknow header" args[len - 1].call(this, header) } } @@ -187,11 +187,11 @@ export function mockRequest() { 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" + 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" + const header = "[PC Preview] unknow header" args[len - 1].call(this, header) } } From da0eb6bb97498f83a676e25e471db8e0ede28f00 Mon Sep 17 00:00:00 2001 From: weiyunxing Date: Mon, 25 Jul 2022 14:55:07 +0800 Subject: [PATCH 087/103] setting API mock Signed-off-by: weiyunxing --- runtime/main/extend/systemplugin/napi/ohos_settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_settings.js b/runtime/main/extend/systemplugin/napi/ohos_settings.js index a20bf447..f03e6ecf 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) 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 @@ -107,7 +107,7 @@ export function mockSettings() { WIFI_STATUS: "[PC Preview] unknow WIFI_STATUS", WIFI_WATCHDOG_STATUS: "[PC Preview] unknow WIFI_WATCHDOG_STATUS", }; - const settingsMock = { + const settings = { date, display, general, From 2785d6d2a6093a39df837ef839b2313c07d01ceb Mon Sep 17 00:00:00 2001 From: weiyunxing Date: Mon, 25 Jul 2022 14:59:30 +0800 Subject: [PATCH 088/103] setting API mock Signed-off-by: weiyunxing --- runtime/main/extend/systemplugin/napi/ohos_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_settings.js b/runtime/main/extend/systemplugin/napi/ohos_settings.js index f03e6ecf..c02c730f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_settings.js +++ b/runtime/main/extend/systemplugin/napi/ohos_settings.js @@ -193,5 +193,5 @@ export function mockSettings() { return paramMock.paramBooleanMock }, }; - return settingsMock; + return settings; } From 6b30ebac18d4c59dab8ffd4520f6a73c45c79c47 Mon Sep 17 00:00:00 2001 From: weiyunxing Date: Mon, 25 Jul 2022 15:11:43 +0800 Subject: [PATCH 089/103] setting API mock Signed-off-by: weiyunxing --- runtime/main/extend/systemplugin/napi/ohos_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_settings.js b/runtime/main/extend/systemplugin/napi/ohos_settings.js index c02c730f..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) 2022 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 From c04cc277c319878b09a08e513ce8e419033a2ecc Mon Sep 17 00:00:00 2001 From: mali Date: Mon, 25 Jul 2022 19:09:51 +0800 Subject: [PATCH 090/103] camera js mock Signed-off-by: mali --- .../napi/ohos_multimedia_camera.js | 181 +++++++++++++++++- 1 file changed, 172 insertions(+), 9 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js index 44a90354..4810c689 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' + @@ -213,6 +271,18 @@ export function mockMultimediaCamera() { }); } }, + setFocusPoint: function (...args) { + console.warn('CameraInput.setFocusPoint interface mocked 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(); + }); + } + }, getZoomRatioRange: function (...args) { console.warn('CameraInput.getZoomRatioRange interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); @@ -226,7 +296,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 +334,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 +412,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 +462,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 +490,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 +561,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 +621,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 From d965e034f2f8c1fef35613e02671acba7e30bcee Mon Sep 17 00:00:00 2001 From: mali Date: Mon, 25 Jul 2022 19:40:44 +0800 Subject: [PATCH 091/103] delete setFocusPoint Signed-off-by: mali --- .../systemplugin/napi/ohos_multimedia_camera.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js b/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js index 4810c689..1c906517 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimedia_camera.js @@ -271,18 +271,6 @@ export function mockMultimediaCamera() { }); } }, - setFocusPoint: function (...args) { - console.warn('CameraInput.setFocusPoint interface mocked 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(); - }); - } - }, getZoomRatioRange: function (...args) { console.warn('CameraInput.getZoomRatioRange interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); From a85ffae3856df941145930f805dab06caee7cd1f Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Mon, 25 Jul 2022 20:06:49 +0800 Subject: [PATCH 092/103] js api mock. Signed-off-by: dingxiaochen --- .../extend/systemplugin/napi/ohos_contact.js | 18 +- .../systemplugin/napi/ohos_telephony_call.js | 233 ++++++--- .../systemplugin/napi/ohos_telephony_data.js | 19 +- .../napi/ohos_telephony_observer.js | 19 +- .../systemplugin/napi/ohos_telephony_radio.js | 277 ++++++----- .../systemplugin/napi/ohos_telephony_sim.js | 118 +++-- .../systemplugin/napi/ohos_telephony_sms.js | 465 ++++++++++-------- 7 files changed, 726 insertions(+), 423 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_contact.js b/runtime/main/extend/systemplugin/napi/ohos_contact.js index 443f6686..ed8ca6d9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_contact.js +++ b/runtime/main/extend/systemplugin/napi/ohos_contact.js @@ -41,8 +41,6 @@ export function mockContact() { } ContactClass.INVALID_CONTACT_ID = -1; - const Attribute = "[PC Preview] unknow unkown Attribute"; - const ContactAttributesClass = class ContactAttributes { constructor() { console.warn('contact.ContactAttributes.constructor interface mocked in the Previewer. How this interface' + @@ -274,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_telephony_call.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js index f37cce69..0f7c281b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js @@ -14,72 +14,175 @@ */ 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 EmergencyNumberOptions = { + slotId: "[PC Preview] unknow slotId" +} +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 ImsCallMode = "[PC Preview] unknow ImsCallMode"; - const AudioDevice = "[PC Preview] unknow AudioDevice"; - const CallRestrictionType = "[PC Preview] unknow CallRestrictionType"; - const CallTransferType = "[PC Preview] unknow CallTransferType"; - const CallTransferSettingType = "[PC Preview] unknow CallTransferSettingType"; - const ConferenceState = "[PC Preview] unknow ConferenceState"; - const CallType = "[PC Preview] unknow CallType"; - const VideoStateType = "[PC Preview] unknow VideoStateType"; - const DetailedCallState = "[PC Preview] unknow DetailedCallState"; - const CallRestrictionMode = "[PC Preview] unknow CallRestrictionMode"; - const CallAbilityEventId = "[PC Preview] unknow CallAbilityEventId"; - const DialScene = "[PC Preview] unknow DialScene"; - const DialType = "[PC Preview] unknow DialType"; - const CallState = "[PC Preview] unknow CallState"; - const TransferStatus = "[PC Preview] unknow TransferStatus"; - const DisconnectedDetails = "[PC Preview] unknow DisconnectedDetails"; - const EmergencyNumberOptions = { - slotId: "[PC Preview] unknow slotId" - } - const CallTransferResult = { - status: "[PC Preview] unknow status", - number: "[PC Preview] unknow number", - } - const CallTransferInfo = { - transferNum: "[PC Preview] unknow transferNum", - type: CallTransferType, - settingType: CallTransferSettingType, - } - const NumberFormatOptions = { - countryCode: "[PC Preview] unknow countryCode" - } - const CallRestrictionInfo = { - type: CallRestrictionType, - password: "[PC Preview] unknow password", - mode: CallRestrictionMode, - } - const CallEventOptions = { - eventId: CallAbilityEventId - } - const RejectMessageOptions = { - messageContent: "[PC Preview] unknow messageContent" - } - 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 DialOptions = { - extras: "[PC Preview] unknow extras", - accountId: "[PC Preview] unknow accountId", - videoState: VideoStateType, - dialScene: DialScene, - dialType: DialType, - } const call = { + ImsCallMode, + AudioDevice, + CallRestrictionType, + TransferStatus, + CallTransferSettingType, + CallWaitingStatus, + CallTransferType, + ConferenceState, + DisconnectedDetails, + CallAbilityEventId, + CallType, + VideoStateType, + DetailedCallState, + CallState, + DialScene, + RestrictionStatus, + 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.") @@ -646,7 +749,7 @@ export function mockCall() { " 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); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramBooleanMock); diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js index 1dd920aa..1319640f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_data.js @@ -14,11 +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 DataFlowType = "[PC Preview] unknow DataFlowType"; - const DataConnectState = "[PC Preview] unknow DataConnectState"; 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 ae3e51ac..4c9c60af 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js @@ -14,15 +14,30 @@ */ import { paramMock } from "../utils" - +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 function mockObserver() { const SimStateData = { type: "[PC Preview] unknow type", state: "[PC Preview] unknow state", reason: LockReason, } - const LockReason = "[PC Preview] unknow LockReason"; const observer = { + LockReason, + SimStateData, 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 229c9b5a..2a12c5b5 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js @@ -14,111 +14,168 @@ */ import { paramMock } from "../utils" - +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 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", +} +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 function mockRadio() { - 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", - isCaActive: "[PC Preview] unknow isCaActive", - isEmergency: "[PC Preview] unknow isEmergency", - cfgTech: RadioTechnology, - } - const SignalInformation = { - signalType: "[PC Preview] unknow signalType", - signalLevel: "[PC Preview] unknow signalLevel" - } - const DataFlowType = "[PC Preview] unknow DataFlowType"; - const DataConnectState = "[PC Preview] unknow DataConnectState"; - const RadioTechnology = "[PC Preview] unknow RadioTechnology"; - const NetworkType = "[PC Preview] unknow NetworkType"; - const RegState = "[PC Preview] unknow RegState"; - const NsaState = "[PC Preview] unknow NsaState"; - const CellInformation = { - networkType: "[PC Preview] unknow networkType", - isCamped: "[PC Preview] unknow isCamped", - timeStamp: "[PC Preview] unknow timeStamp", - signalInformation: "[PC Preview] unknow signalInformation", - data: "[PC Preview] unknow data" - } - 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" - } - 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", - } - 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", - } - 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 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", - } - 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", - } - const NetworkSelectionModeOptions = { - slotId: "[PC Preview] unknow slotId", - selectMode: NetworkSelectionMode, - networkInformation: NetworkInformation, - resumeSelection: "[PC Preview] unknow resumeSelection", - } - const NetworkInformation = { - operatorName: "[PC Preview] unknow operatorName", - operatorNumeric: "[PC Preview] unknow operatorNumeric", - state: NetworkInformationState, - radioTech: "[PC Preview] unknow radioTech", - } - 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 NetworkInformationState = "[PC Preview] unknow NetworkInformationState"; - 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.") @@ -163,7 +220,7 @@ 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.") + " 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); @@ -178,7 +235,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, [CellInformation]); + args[len - 1].call(this, paramMock.businessErrorMock, [CellInformation]); } else { return new Promise((resolve, reject) => { resolve([CellInformation]); @@ -190,7 +247,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, NetworkSelectionMode); + args[len - 1].call(this, paramMock.businessErrorMock, NetworkSelectionMode); } else { return new Promise((resolve, reject) => { resolve(NetworkSelectionMode); @@ -214,7 +271,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, NetworkSearchResult); + args[len - 1].call(this, paramMock.businessErrorMock, NetworkSearchResult); } else { return new Promise((resolve, reject) => { resolve(NetworkSearchResult); @@ -351,7 +408,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.paramStringMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); @@ -375,7 +432,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, PreferredNetworkMode); + args[len - 1].call(this, paramMock.businessErrorMock, PreferredNetworkMode); } else { return new Promise((resolve, reject) => { resolve(PreferredNetworkMode); @@ -387,7 +444,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.paramStringMock); + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js index b5cf65bd..72171671 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js @@ -14,49 +14,73 @@ */ 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 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 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 LockInfo = { - lockType: LockType, - password: "[PC Preview] unknow password", - state: LockState, - } - const PersoLockInfo = { - lockType: PersoLockType, - password: "[PC Preview] unknow password", - } - 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", - pin2: "[PC Preview] unknow pin2", - } - const CardType = "[PC Preview] unknow CardType"; - const LockType = "[PC Preview] unknow LockType"; - const SimState = "[PC Preview] unknow SimState"; - const PersoLockType = "[PC Preview] unknow PersoLockType"; - const ContactType = "[PC Preview] unknow ContactType"; - const LockState = "[PC Preview] unknow LockState"; 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.") @@ -143,10 +167,10 @@ 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.") + " be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, LockState); + args[len - 1].call(this, paramMock.businessErrorMock, LockState); } else { return new Promise((resolve, reject) => { resolve(LockState); @@ -340,7 +364,7 @@ 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.") + " 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); @@ -364,7 +388,7 @@ 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.") + " 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); @@ -388,7 +412,7 @@ 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.") + " 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); @@ -460,7 +484,7 @@ 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.") + " 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); diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js index 1aa84ba5..a562634e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js @@ -14,196 +14,273 @@ */ 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, +} +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 MmsInformation = { - messageType: MessageType, - mmsType: "[PC Preview] unknow mmsType", - attachment: [MmsAttachment] - } - const MessageType = "[PC Preview] unknow MessageType"; - 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 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"], - } - const MmsAcknowledgeInd = { - transactionId: "[PC Preview] unknow transactionId", - version: MmsVersionType, - reportAllowed: ReportType, - } - const MmsDeliveryInd = { - transactionId: "[PC Preview] unknow transactionId", - date: "[PC Preview] unknow date", - to: [MmsAddress], - status: "[PC Preview] unknow status", - version: MmsVersionType, - } - const MmsReadRecInd = { - version: MmsVersionType, - messageId: "[PC Preview] unknow messageId", - to: [MmsAddress], - from: MmsAddress, - readStatus: "[PC Preview] unknow readStatus", - date: "[PC Preview] unknow date", - } - 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, - } - const MmsReadOrigInd = { - version: MmsVersionType, - messageId: "[PC Preview] unknow messageId", - to: [MmsAddress], - from: MmsAddress, - date: "[PC Preview] unknow date", - readStatus: "[PC Preview] unknow readStatus", - } - const MmsRespInd = { - transactionId: "[PC Preview] unknow transactionId", - status: "[PC Preview] unknow transactionId", - version: MmsVersionType, - reportAllowed: ReportType, - } - const CBConfigOptions = { - slotId: "[PC Preview] unknow slotId", - enable: "[PC Preview] unknow enable", - startMessageId: "[PC Preview] unknow startMessageId", - endMessageId: "[PC Preview] unknow endMessageId", - ranType: RanType - } - const SimMessageOptions = { - slotId: "[PC Preview] unknow slotId", - smsc: "[PC Preview] unknow smsc", - pdu: "[PC Preview] unknow pdu", - status: SimMessageStatus, - } - const UpdateSimMessageOptions = { - slotId: "[PC Preview] unknow slotId", - msgIndex: "[PC Preview] unknow msgIndex", - newStatus: SimMessageStatus, - pdu: "[PC Preview] unknow pdu", - smsc: "[PC Preview] unknow smsc", - } - 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, - } - const IDeliveryShortMessageCallback = { - pdu: "[PC Preview] unknow pdu", - } - const ISendShortMessageCallback = { - result: SendSmsResult, - url: "[PC Preview] unknow url", - isLastPart: "[PC Preview] unknow isLastPart", - } - const SendSmsResult = "[PC Preview] unknow SendSmsResult"; - const ShortMessageClass = "[PC Preview] unknow ShortMessageClass"; - const RanType = "[PC Preview] unknow RanType"; - const SimMessageStatus = "[PC Preview] unknow SimMessageStatus"; - const DispositionType = "[PC Preview] unknow DispositionType"; - const MmsCharSets = "[PC Preview] unknow MmsCharSets"; - const ReportType = "[PC Preview] unknow ReportType"; - 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", - } - const MmsAddress = { - address: "[PC Preview] unknow address", - charset: MmsCharSets, - } - const MmsVersionType = "[PC Preview] unknow MmsVersionType"; - const MmsPriorityType = "[PC Preview] unknow MmsPriorityType"; - const MmsSendReq = { - from: MmsAddress, - transactionId: "[PC Preview] unknow transactionId", - contentType: "[PC Preview] unknow contentType", - version: MmsVersionType, - to: "[PC Preview] unknow to", - date: "[PC Preview] unknow date", - cc: "[PC Preview] unknow cc", - bcc: "[PC Preview] unknow bcc", - 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", - } - const MmsSendConf = { - responseState: "[PC Preview] unknow responseState", - transactionId: "[PC Preview] unknow transactionId", - version: MmsVersionType, - messageId: "[PC Preview] unknow messageId", - } - - const SmsSegmentsInfo = { - splitCount: "[PC Preview] unknow splitCount", - encodeCount: "[PC Preview] unknow encodeCount", - encodeCountRemaining: "[PC Preview] unknow encodeCountRemaining", - scheme: SmsEncodingScheme, - } - const SmsEncodingScheme = "[PC Preview] unknow SmsEncodingScheme"; 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.") @@ -230,7 +307,7 @@ 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.") + " be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, SmsSegmentsInfo); @@ -242,7 +319,7 @@ export function mockSMS() { }, 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.") + " 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); @@ -254,7 +331,7 @@ export function mockSMS() { }, 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.") + " 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); @@ -266,7 +343,7 @@ export function mockSMS() { }, 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.") + " be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, MmsInformation); @@ -278,7 +355,7 @@ export function mockSMS() { }, 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.") + " 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); @@ -290,7 +367,7 @@ export function mockSMS() { }, 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.") + " 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); From db05de68a441062cf42bdcf25c8aaed3c2bbb176 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 25 Jul 2022 20:08:28 +0800 Subject: [PATCH 093/103] osAccount API Mock Signed-off-by: chen --- .../systemplugin/napi/ohos_account_osAccount.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js index 67579cac..95d6ec67 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js +++ b/runtime/main/extend/systemplugin/napi/ohos_account_osAccount.js @@ -475,7 +475,7 @@ export function mockOsAccount() { return paramMock.paramNumberMock; }; this.getAvailableStatus = function (...args) { - console.warn("UserAuth.getVAvailableStatus interface mocked in the Previewer. " + + console.warn("UserAuth.getAvailableStatus interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; @@ -512,7 +512,7 @@ export function mockOsAccount() { } }; this.anthUser = function (...args) { - console.warn("UserAuth.authUser interface mocked in the Previewer. " + + console.warn("UserAuth.anthUser interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -531,19 +531,19 @@ export function mockOsAccount() { console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") this.registerInputer = function (...args) { - console.warn("PINAuth.registerInputer constructor interface mocked in the Previewer. " + + console.warn("PINAuth.registerInputer interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramBooleanMock; }; this.unregisterInputer = function (...args) { - console.warn("PINAuth.unregisterInputer constructor interface mocked in the Previewer. " + + console.warn("PINAuth.unregisterInputer interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }; }; }; const UserIdentityManagerClass = class UserIdentityManager { constructor() { - console.warn("osAccount.getAccountManager constructor interface mocked in the Previewer. " + + console.warn("osAccount.getAccountManager.constructor interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") this.openSession = function (...args) { console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " + @@ -566,7 +566,7 @@ export function mockOsAccount() { } }; this.updateCredential = function (...args) { - console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + + console.warn("AUserIdentityManager.updateCredential interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") const len = args.length if (len > 0 && typeof args[len - 1] === 'function') { @@ -578,7 +578,7 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") }; this.cancel = function (...args) { - console.warn("AUserIdentityManager.console interface mocked in the Previewer. " + + console.warn("AUserIdentityManager.cancel interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") return paramMock.paramNumberMock; }; @@ -630,7 +630,7 @@ export function mockOsAccount() { "How this interface works on the Previewer may be different from that on a real device.") }, onAcquireInfo: function (...args) { - console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + + console.warn("IUserAuthCallback.onAcquireInfo interface mocked in the Previewer. " + "How this interface works on the Previewer may be different from that on a real device.") }, }; From 722657f0f2e21af43979d358f0f4daa21103648a Mon Sep 17 00:00:00 2001 From: lixingyang Date: Mon, 25 Jul 2022 20:21:58 +0800 Subject: [PATCH 094/103] Corrected the mock problem of the worker module of the language compilation subsystem Signed-off-by: lixingyang https://gitee.com/openharmony/third_party_jsframework/issues/I5ITQQ --- .../extend/systemplugin/napi/ohos_worker.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_worker.js b/runtime/main/extend/systemplugin/napi/ohos_worker.js index 4958d5fd..f4a06d4e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_worker.js +++ b/runtime/main/extend/systemplugin/napi/ohos_worker.js @@ -102,56 +102,56 @@ export function mockWorker() { 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."); From 1ab9d8b81d867ce7f0fc5ffc2282fad568cba15d Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Tue, 26 Jul 2022 08:00:11 +0800 Subject: [PATCH 095/103] aaaa Signed-off-by: liuyanzhi Change-Id: Ia169c40592db080ac9a74ea73d777a32e12c31cd --- .../napi/ability/dataAbilityHelper.js | 2 +- .../napi/application/AbilityContext.js | 250 +--------------- .../napi/application/AbilityStageContext.js | 4 +- .../AccessibilityExtensionContext.js | 2 +- .../napi/application/AppStateData.js | 8 +- .../napi/application/BaseContext.js | 11 +- .../systemplugin/napi/application/Context.js | 3 +- .../napi/application/ExtensionContext.js | 4 +- .../napi/application/FormExtensionContext.js | 8 +- .../napi/application/MissionInfo.js | 2 +- .../napi/application/ProcessData.js | 2 - .../napi/application/abilityDelegator.js | 2 +- .../main/extend/systemplugin/napi/index.js | 40 ++- .../napi/ohos_ability_errorCode.js | 3 + .../napi/ohos_ability_featureAbility.js | 278 +----------------- .../napi/ohos_ability_particleAbility.js | 4 +- .../napi/ohos_ability_wantConstant.js | 8 + .../napi/ohos_application_AbilityConstant.js | 9 + ...os_application_AbilityLifecycleCallback.js | 2 - .../napi/ohos_application_AbilityStage.js | 4 +- .../napi/ohos_application_Configuration.js | 3 + .../ohos_application_ConfigurationConstant.js | 8 + ...s_application_DataShareExtensionAbility.js | 3 +- .../ohos_application_EnvironmentCallback.js | 29 ++ .../napi/ohos_application_FormExtension.js | 42 +-- .../ohos_application_ServiceExtAbility.js | 224 -------------- ...hos_application_ServiceExtensionAbility.js | 185 +----------- .../napi/ohos_application_StartOptions.js | 3 + .../napi/ohos_application_Want.js | 5 +- ...os_application_abilityDelegatorRegistry.js | 15 +- .../napi/ohos_application_abilityManager.js | 52 +--- .../napi/ohos_application_appManager.js | 31 +- .../napi/ohos_application_context.js | 43 +++ .../napi/ohos_application_errorManager.js | 2 + .../napi/ohos_application_formBindingData.js | 1 + .../napi/ohos_application_formError.js | 6 + .../napi/ohos_application_formInfo.js | 12 + .../napi/ohos_application_missionManager.js | 46 +-- 38 files changed, 282 insertions(+), 1074 deletions(-) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_EnvironmentCallback.js delete mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_ServiceExtAbility.js create mode 100644 runtime/main/extend/systemplugin/napi/ohos_application_context.js diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js index 7899aa70..c89704b7 100755 --- a/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js @@ -101,7 +101,7 @@ const ResultSet = { } export const PacMap = {key:{}} -export const dataAbilityHelper = { +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.") 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/AbilityStageContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js index f66265e2..8199d32c 100755 --- a/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js @@ -14,8 +14,8 @@ */ import { ContextClass } from "./Context" -import { HapModuleInfo } from "../bundle/HapModuleInfo" -import { Configuration } from "../ohos.application.Configuration" +import { HapModuleInfo } from "../bundle/hapModuleInfo" +import { Configuration } from "../ohos_application_Configuration" export const AbilityStageContextClass = class AbilityStageContext extends ContextClass { constructor() { diff --git a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js index 1b527773..eee99234 100644 --- a/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/AccessibilityExtensionContext.js @@ -14,7 +14,7 @@ */ import { paramMock } from '../../utils' -import { ExtensionContextClass } from './AbilityContext' +import { ExtensionContextClass } from './ExtensionContext' const ElementAttributeNameMock = '[PC Preview] unknown element attribute name'; diff --git a/runtime/main/extend/systemplugin/napi/application/AppStateData.js b/runtime/main/extend/systemplugin/napi/application/AppStateData.js index b198254a..48465100 100755 --- a/runtime/main/extend/systemplugin/napi/application/AppStateData.js +++ b/runtime/main/extend/systemplugin/napi/application/AppStateData.js @@ -16,9 +16,9 @@ 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", + " 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/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 b2a6752e..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. " + diff --git a/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js index 0bfc644d..b2f4e883 100755 --- a/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js +++ b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js @@ -13,8 +13,8 @@ * limitations under the License. */ -import { HapModuleInfo } from "../bundle/HapModuleInfo"; -import { Configuration } from "../ohos.application.Configuration" +import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import { Configuration } from "../ohos_application_Configuration" import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo" import { ContextClass } from "./Context" 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 index bbf47676..b157bda2 100755 --- a/runtime/main/extend/systemplugin/napi/application/MissionInfo.js +++ b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { WantClass } from "../ohos.application.Want" +import { WantClass } from "../ohos_application_Want" export const MissionInfo = { missionId: '[PC preview] unknow missionId', diff --git a/runtime/main/extend/systemplugin/napi/application/ProcessData.js b/runtime/main/extend/systemplugin/napi/application/ProcessData.js index 4e651615..f27582f0 100755 --- a/runtime/main/extend/systemplugin/napi/application/ProcessData.js +++ b/runtime/main/extend/systemplugin/napi/application/ProcessData.js @@ -13,8 +13,6 @@ * limitations under the License. */ -import { paramMock } from "../../utils" - export const ProcessDataClass = class ProcessData { constructor() { console.warn("ProcessData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + 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/index.js b/runtime/main/extend/systemplugin/napi/index.js index 0b810a48..8cddadd8 100755 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -15,24 +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' @@ -280,26 +290,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": @@ -308,16 +330,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": 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 index 62e0e61d..f1e4ec1c 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { dataAbilityHelper } from "./ability/dataAbilityHelper" +import { DataAbilityHelper } from "./ability/dataAbilityHelper" export function mockParticleAbility() { const particleAbility = { @@ -45,7 +45,7 @@ export function mockParticleAbility() { 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; + return DataAbilityHelper; }, connectAbility: function (...args) { console.warn("ability.particleAbility.connectAbility interface mocked in the Previewer. How this interface works" + 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_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_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js index 1507e7cc..c368d86a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -21,3 +21,6 @@ export const Configuration = { 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 0d242ba3..85c6a5be 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -21,11 +21,14 @@ export const WantClass = class Want { 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.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 index ae82557b..b4ecd6ed 100755 --- 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 86461545..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,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, MissionSnapshotMock); + args[len - 1].call(this, paramMock.businessErrorMock, _MissionSnapshot); } else { return new Promise((resolve) => { - resolve(MissionSnapshotMock); + resolve(_MissionSnapshot); }); } }, @@ -97,10 +78,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, MissionSnapshotMock); + args[len - 1].call(this, paramMock.businessErrorMock, _MissionSnapshot); } else { return new Promise((resolve) => { - resolve(MissionSnapshotMock); + resolve(_MissionSnapshot); }); } }, @@ -163,7 +144,10 @@ export function mockMissionManager() { resolve(); }); } - } + }, + MissionInfo: _MissionInfo, + MissionListener: _MissionListener, + MissionSnapshot: _MissionSnapshot } return missionManager } \ No newline at end of file From 5778f880a5aec1d89cb7058ce9f9d44a0d9be771 Mon Sep 17 00:00:00 2001 From: h00514358 Date: Tue, 26 Jul 2022 14:24:44 +0800 Subject: [PATCH 096/103] Modify sensor js api Signed-off-by: h00514358 --- runtime/main/extend/systemplugin/napi/ohos_sensor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index fddc787f..85d9cc06 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_sensor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_sensor.js @@ -162,6 +162,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,6 +171,7 @@ 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 } From d01a86704a3887aef121ef94a716a283a82f21c3 Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Tue, 26 Jul 2022 14:53:50 +0800 Subject: [PATCH 097/103] js api code Signed-off-by: dingxiaochen --- .../systemplugin/napi/ohos_telephony_call.js | 19 ++++++++++++++ .../napi/ohos_telephony_observer.js | 12 ++++----- .../systemplugin/napi/ohos_telephony_radio.js | 26 +++++++++++++++++++ .../systemplugin/napi/ohos_telephony_sim.js | 17 ++++++++++++ .../systemplugin/napi/ohos_telephony_sms.js | 1 + 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js index 0f7c281b..e9f0a908 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js @@ -138,9 +138,27 @@ 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, @@ -181,6 +199,7 @@ export function mockCall() { CallState, DialScene, RestrictionStatus, + CallTransferResult, DialType, CallRestrictionMode, dial: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js index 4c9c60af..0f3ef44e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js @@ -14,6 +14,7 @@ */ 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", @@ -29,15 +30,14 @@ export const LockReason = { 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", - reason: LockReason, - } const observer = { LockReason, - SimStateData, 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 2a12c5b5..56de5d38 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js @@ -116,6 +116,17 @@ export const TdscdmaCellInformation = { 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: RegState, + cfgTech: RadioTechnology, + nsaState: NsaState, + isCaActive: "[PC Preview] unknow isCaActive", + isEmergency: "[PC Preview] unknow isEmergency", +} export const NrCellInformation = { nrArfcn: "[PC Preview] unknow nrArfcn", pci: "[PC Preview] unknow pci", @@ -166,6 +177,21 @@ export const NrOptionMode = { 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: 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 radio = { RegState, diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js index 72171671..1faba27d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js @@ -61,6 +61,15 @@ export const CardType = { 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", @@ -73,6 +82,14 @@ 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 sim = { ContactType, diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js index a562634e..b78411ea 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js @@ -119,6 +119,7 @@ export const MmsDeliveryInd = { to: [MmsAddress], status: "[PC Preview] unknow status", version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", } export const MmsReadRecInd = { version: MmsVersionType, From 61b5a2eb6518474f7295226e0196424328d7138e Mon Sep 17 00:00:00 2001 From: h00514358 Date: Wed, 27 Jul 2022 10:12:17 +0800 Subject: [PATCH 098/103] Modify sensor js api Signed-off-by: h00514358 --- .../extend/systemplugin/napi/ohos_sensor.js | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_sensor.js b/runtime/main/extend/systemplugin/napi/ohos_sensor.js index 85d9cc06..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', @@ -177,6 +199,7 @@ export function mockSensor() { } 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.') From b6027198327896399c86b8f654f0ce77dcbf6739 Mon Sep 17 00:00:00 2001 From: maosiping Date: Wed, 27 Jul 2022 11:15:12 +0800 Subject: [PATCH 099/103] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E7=AE=A1=E7=90=86API?= =?UTF-8?q?mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maosiping --- .../systemplugin/napi/ohos_net_connection.js | 20 ++--- .../extend/systemplugin/napi/ohos_net_http.js | 90 +++++++++---------- .../systemplugin/napi/ohos_net_webSocket.js | 7 ++ 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_connection.js b/runtime/main/extend/systemplugin/napi/ohos_net_connection.js index a478e905..14ae9d87 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_connection.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_connection.js @@ -16,18 +16,18 @@ import { paramMock } from "../utils" export const NetCap = { - NET_CAPABILITY_MMS: '[PC preview] unknow NET_CAPABILITY_MMS', - NET_CAPABILITY_NOT_METERED: '[PC preview] unknow NET_CAPABILITY_NOT_METERED', - NET_CAPABILITY_INTERNET: '[PC preview] unknow NET_CAPABILITY_INTERNET', - NET_CAPABILITY_NOT_VPN: '[PC preview] unknow NET_CAPABILITY_NOT_VPN', - NET_CAPABILITY_VALIDATED: '[PC preview] unknow NET_CAPABILITY_VALIDATED' -} + 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: '[PC preview] unknow BEARER_CELLULAR', - BEARER_WIFI: '[PC preview] unknow BEARER_WIFI', - BEARER_ETHERNET: '[PC preview] unknow BEARER_ETHERNET' -} + BEARER_CELLULAR: 0, + BEARER_WIFI: 1, + BEARER_ETHERNET: 3 +}; export function mockConnection() { const NetSpecifier = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_http.js b/runtime/main/extend/systemplugin/napi/ohos_net_http.js index b343812c..74c949c4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_http.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_http.js @@ -16,53 +16,53 @@ import { paramMock } from "../utils" export const RequestMethod = { - OPTIONS: "[PC Preview] unknow OPTIONS", - GET: "[PC Preview] unknow GET", - HEAD: "[PC Preview] unknow HEAD", - POST: "[PC Preview] unknow POST", - PUT: "[PC Preview] unknow PUT", - DELETE: "[PC Preview] unknow DELETE", - TRACE: "[PC Preview] unknow TRACE", - CONNECT: "[PC Preview] unknow CONNECT" -} + OPTIONS: "OPTIONS", + GET: "GET", + HEAD: "HEAD", + POST: "POST", + PUT: "PUT", + DELETE: "DELETE", + TRACE: "TRACE", + CONNECT: "CONNECT" +}; export const ResponseCode = { - OK: "[PC Preview] unknow OK", - CREATED: "[PC Preview] unknow CREATED", - ACCEPTED: "[PC Preview] unknow ACCEPTED", - NOT_AUTHORITATIVE: "[PC Preview] unknow NOT_AUTHORITATIVE", - NO_CONTENT: "[PC Preview] unknow NO_CONTENT", - RESET: "[PC Preview] unknow RESET", - PARTIAL: "[PC Preview] unknow PARTIAL", - MULT_CHOICE: "[PC Preview] unknow MULT_CHOICE", - MOVED_PERM: "[PC Preview] unknow MOVED_PERM", - MOVED_TEMP: "[PC Preview] unknow MOVED_TEMP", - SEE_OTHER: "[PC Preview] unknow SEE_OTHER", - NOT_MODIFIED: "[PC Preview] unknow NOT_MODIFIED", - USE_PROXY: "[PC Preview] unknow USE_PROXY", - BAD_REQUEST: "[PC Preview] unknow BAD_REQUEST", - UNAUTHORIZED: "[PC Preview] unknow UNAUTHORIZED", - PAYMENT_REQUIRED: "[PC Preview] unknow PAYMENT_REQUIRED", - FORBIDDEN: "[PC Preview] unknow FORBIDDEN", - NOT_FOUND: "[PC Preview] unknow NOT_FOUND", - BAD_METHOD: "[PC Preview] unknow BAD_METHOD", - NOT_ACCEPTABLE: "[PC Preview] unknow NOT_ACCEPTABLE", - PROXY_AUTH: "[PC Preview] unknow PROXY_AUTH", - CLIENT_TIMEOUT: "[PC Preview] unknow CLIENT_TIMEOUT", - CONFLICT: "[PC Preview] unknow CONFLICT", - GONE: "[PC Preview] unknow GONE", - LENGTH_REQUIRED: "[PC Preview] unknow LENGTH_REQUIRED", - PRECON_FAILED: "[PC Preview] unknow PRECON_FAILED", - ENTITY_TOO_LARGE: "[PC Preview] unknow ENTITY_TOO_LARGE", - REQ_TOO_LONG: "[PC Preview] unknow REQ_TOO_LONG", - UNSUPPORTED_TYPE: "[PC Preview] unknow UNSUPPORTED_TYPE", - INTERNAL_ERROR: "[PC Preview] unknow INTERNAL_ERROR", - NOT_IMPLEMENTED: "[PC Preview] unknow NOT_IMPLEMENTED", - BAD_GATEWAY: "[PC Preview] unknow BAD_GATEWAY", - UNAVAILABLE: "[PC Preview] unknow UNAVAILABLE", - GATEWAY_TIMEOUT: "[PC Preview] unknow GATEWAY_TIMEOUT", - VERSION: "[PC Preview] unknow VERSION" -} + 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 HttpResponse = { diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js b/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js index ec457c36..7a4515b7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js +++ b/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js @@ -17,6 +17,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" + From 8b36c0a98411b96a67d908c97d1ccca18cd7d5a7 Mon Sep 17 00:00:00 2001 From: maosiping Date: Wed, 27 Jul 2022 11:34:52 +0800 Subject: [PATCH 100/103] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E7=AE=A1=E7=90=86API?= =?UTF-8?q?mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maosiping --- runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js b/runtime/main/extend/systemplugin/napi/ohos_net_webSocket.js index 7a4515b7..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,6 @@ import { paramMock } from "../utils" export function mockWebSocket() { - global.systemplugin.net = {} const WebSocketRequestOptions = { header: "[PC Preview] unknow header" } @@ -108,4 +107,4 @@ export function mockWebSocket() { } } return webSocket -} \ No newline at end of file +} From 7fc9e75cba31ab6df7c0069438c66f5ff7e300c3 Mon Sep 17 00:00:00 2001 From: yanmengzhao1 Date: Mon, 25 Jul 2022 20:41:33 +0800 Subject: [PATCH 101/103] add faultlogger js interfaces API mock Signed-off-by: yanmengzhao1 --- .../main/extend/systemplugin/napi/index.js | 3 + .../systemplugin/napi/ohos_faultLogger.js | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_faultLogger.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index b2bf6cfa..2ebc1c1c 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -54,6 +54,7 @@ import { mockHiAppEvent } from './ohos_hiAppEvent' import { mockHilog } from './ohos_hilog' import { mockHiSysEvent } from './ohos_hiSysEvent' import { mockHiTraceChain } from './ohos_hiTraceChain' +import { mockFaultLogger } from './ohos_faultLogger' import { mockTv } from './tv' import { mockDtv } from './dtv' import { mockDistributedAccount } from './ohos_account_distributedAccount' @@ -361,6 +362,8 @@ export function mockRequireNapiFun() { return mockHiSysEvent(); case "hiTraceChain": return mockHiTraceChain(); + case "faultLogger": + return mockFaultLogger(); case "tv": return mockTv(); case "dtv": 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 From 9097c5d350d87253ade392686b0b06381fed26ec Mon Sep 17 00:00:00 2001 From: anyueling Date: Wed, 27 Jul 2022 16:01:00 +0800 Subject: [PATCH 102/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9MOCK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- runtime/main/extend/systemplugin/napi/ohos_request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index c6bd6927..658cadad 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_request.js +++ b/runtime/main/extend/systemplugin/napi/ohos_request.js @@ -18,7 +18,7 @@ import { paramMock } from "../utils" export function mockRequest() { const DownloadConfig = { url: "[PC Preview] unknow uri", - herder: "[PC Preview] unknow herder", + header: "[PC Preview] unknow herder", enableMetered: "[PC Preview] unknow enableMetered", enableRoaming: "[PC Preview] unknow enableRoaming", description: "[PC Preview] unknow description", @@ -158,7 +158,7 @@ export function mockRequest() { const UploadConfig = { url: "[PC Preview] unknow uri", - herder: "[PC Preview] unknow herder", + header: "[PC Preview] unknow herder", method: "[PC Preview] unknow method", files: [File], data: [RequestData], From 8d3ed5c318a87e941486c612c32caf2c4438292e Mon Sep 17 00:00:00 2001 From: anyueling Date: Wed, 27 Jul 2022 16:02:59 +0800 Subject: [PATCH 103/103] =?UTF-8?q?=E4=BF=AE=E6=94=B9MOCK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- runtime/main/extend/systemplugin/napi/ohos_request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_request.js b/runtime/main/extend/systemplugin/napi/ohos_request.js index 658cadad..32cfa49f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_request.js +++ b/runtime/main/extend/systemplugin/napi/ohos_request.js @@ -18,7 +18,7 @@ import { paramMock } from "../utils" export function mockRequest() { const DownloadConfig = { url: "[PC Preview] unknow uri", - header: "[PC Preview] unknow herder", + header: "[PC Preview] unknow header", enableMetered: "[PC Preview] unknow enableMetered", enableRoaming: "[PC Preview] unknow enableRoaming", description: "[PC Preview] unknow description", @@ -158,7 +158,7 @@ export function mockRequest() { const UploadConfig = { url: "[PC Preview] unknow uri", - header: "[PC Preview] unknow herder", + header: "[PC Preview] unknow header", method: "[PC Preview] unknow method", files: [File], data: [RequestData],