From 277f372d921a1ac2bcc4126b26166933649d67d1 Mon Sep 17 00:00:00 2001 From: binny1024 Date: Tue, 12 Jul 2022 09:39:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyaoying Change-Id: If8a2ff8ff635f196e4e48f00df00d692b0f9b858 --- .../extend/systemplugin/napi/ohos_display.js | 202 ++- .../extend/systemplugin/napi/ohos_screen.js | 435 ++--- .../extend/systemplugin/napi/ohos_window.js | 1452 ++++++++--------- 3 files changed, 1053 insertions(+), 1036 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_display.js b/runtime/main/extend/systemplugin/napi/ohos_display.js index 9ef6e171..b3123826 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_display.js +++ b/runtime/main/extend/systemplugin/napi/ohos_display.js @@ -1,88 +1,116 @@ -/* - * 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 mockDisplay() { - const displayMock = { - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - } - const allDisplayMock = [{ - densityDPI: '[PC preview] unknow densityDPI', - densityPixels: '[PC preview] unknow densityPixels', - scaledDensity: '[PC preview] unknow scaledDensity', - xDPI: '[PC preview] unknow xDPI', - yDPI: '[PC preview] unknow yDPI', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height', - alive: '[PC preview] unknow alive', - refreshRate: '[PC preview] unknow refreshRate', - id: '[PC preview] unknow id', - state: '[PC preview] unknow state', - rotation: '[PC preview] unknow rotation', - name: '[PC preview] unknow name' - }] - const display = { - getDefaultDisplay: function (...args) { - console.warn("display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, displayMock) - } else { - return new Promise((resolve, reject) => { - resolve(displayMock) - }) - } - }, - getAllDisplay: function (...args) { - console.warn("display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, allDisplayMock) - } else { - return new Promise((resolve, reject) => { - resolve(allDisplayMock) - }) - } - }, - on: function (...args) { - console.warn("display.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, paramMock.paramNumberMock) - }, - off: function (...args) { - console.warn("display.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, paramMock.businessErrorMock, paramMock.paramNumberMock) - }, - } - return display +/* + * 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" + +const DisplayState = { + STATE_UNKNOWN: 0, + STATE_OFF: 1, + STATE_ON: 2, + STATE_DOZE: 3, + STATE_DOZE_SUSPEND: 4, + STATE_VR: 5, + STATE_ON_SUSPEND: 6 +} +const DisplayType = { + add: 'add', + remove: 'remove', + change: 'change' +} + +export const Display = { + id: '[PC preview] unknow id', + name: '[PC preview] unknow name', + alive: '[PC preview] unknow alive', + state: '[PC preview] unknow state', + refreshRate: '[PC preview] unknow refreshRate', + rotation: '[PC preview] unknow rotation', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + densityDPI: '[PC preview] unknow densityDPI', + densityPixels: '[PC preview] unknow densityPixels', + scaledDensity: '[PC preview] unknow scaledDensity', + xDPI: '[PC preview] unknow xDPI', + yDPI: '[PC preview] unknow yDPI' +} + +export function mockDisplay() { + + const display = { + getDefaultDisplay: function (...args) { + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Display) + } else { + return new Promise((resolve, reject) => { + resolve(Display) + }) + } + }, + getAllDisplay: function (...args) { + console.warn("Display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [Display]) + } else { + return new Promise((resolve, reject) => { + resolve([Display]) + }) + } + }, + on: function (...args) { + console.warn("Display.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!==2){ + console.warn("Display.on:please check params !") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.on: you has registered ${args[0]} event.`) + } else { + console.warn("Display.on:please check first param!") + } + } else { + console.warn("Display.on:please check params, the second parma must be a function!") + } + }, + off: function (...args) { + console.warn("Display.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!==2){ + console.warn("Display.off:please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === DisplayType.add|| args[0] === DisplayType.remove || args[0] === DisplayType.change){ + console.warn(`Display.off: you has registered ${args[0]} event`) + } else { + console.warn("Display.off:please check first param!") + } + } else { + console.warn("Display.off:please check params, the second parma must be a function!") + } + }, + DisplayState: DisplayState, + Type: DisplayType + } + return display } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_screen.js b/runtime/main/extend/systemplugin/napi/ohos_screen.js index 7f1f597f..577a1225 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screen.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screen.js @@ -1,211 +1,224 @@ -/* - * 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 OrientationMock = { - UNSPECIFIED: 0, - VERTICAL: 1, - HORIZONTAL: 2, - REVERSE_VERTICAL: 3, - REVERSE_HORIZONTAL: 4, - SENSOR: 5, - SENSOR_VERTICAL: 6, - SENSOR_HORIZONTAL: 7 -}; - -export const screenMock = { - id: 'PC preview] unknown id', - parent: '[PC preview] unknown parent', - supportedModeInfo: supportedModeInfoMock, - activeModeIndex: '[PC preview] unknown activeModeIndex', - orientation: OrientationMock, - setOrientation: function(...args) { - console.warn('Screen.setOrientation interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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(); - }); - } - }, - setScreenActiveMode: function(...args) { - console.warn('Screen.setScreenActiveMode interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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(); - }); - } - }, - setDensityDpi: function(...args) { - console.warn('Screen.setDensityDpi interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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(); - }); - } - } -}; - -export const allScreenMock = [ - screenMock -]; - -export const ExpandOptionMock = { - screenId: '[PC preview] unknown screenId', - startX: '[PC preview] unknown startX', - startY: '[PC preview] unknown startY' -}; - -export const VirtualScreenOptionMock = { - name: '[PC preview] unknown name', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - density: '[PC preview] unknown density', - surfaceId: '[PC preview] unknown surfaceId' -}; - -export const screenModeInfoMock = { - id: '[PC preview] unknown id', - width: '[PC preview] unknown width', - height: '[PC preview] unknown height', - refreshRate: '[PC preview] unknown refreshRate' -}; - -export const supportedModeInfoMock = [ - screenModeInfoMock -] - -export function mockScreen() { - const screen = { - ExpandOption: ExpandOptionMock, - VirtualScreenOption: VirtualScreenOptionMock, - Orientation: OrientationMock, - ScreenModeInfo: screenModeInfoMock, - getAllScreens: function(...args) { - console.warn('Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); - } else { - return new Promise((resolve) => { - resolve(allScreenMock); - }); - } - }, - on: function(...args) { - console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on: please check param!') - } - }, - off: function(...args) { - console.warn('Screen.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] === 'connect' || args[0] === 'disconnect' || args[0] === 'change') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off: please check first param!') - } - } else { - console.warn('off: please check param!') - } - }, - makeExpand: function(...args) { - console.warn('Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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); - }); - } - }, - makeMirror: function(...args) { - console.warn('Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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); - }); - } - }, - createVirtualScreen: function(...args) { - console.warn('Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); - const len = args.length; - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, screenMock); - } else { - return new Promise((resolve) => { - resolve(screenMock); - }); - } - }, - destroyVirtualScreen: function(...args) { - console.warn('Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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(); - }); - } - }, - setVirtualScreenSurface: function(...args) { - console.warn('Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be 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 screen -} - +/* + * 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 Orientation = { + UNSPECIFIED: 0, + VERTICAL: 1, + HORIZONTAL: 2, + REVERSE_VERTICAL: 3, + REVERSE_HORIZONTAL: 4, + SENSOR: 5, + SENSOR_VERTICAL: 6, + SENSOR_HORIZONTAL: 7 +}; + +export const Screen = { + id: 'PC preview] unknown id', + parent: '[PC preview] unknown parent', + supportedModeInfo: supportedModeInfoArray, + activeModeIndex: '[PC preview] unknown activeModeIndex', + orientation: Orientation, + setOrientation: function(...args) { + console.warn('Screen.setOrientation interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be 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(); + }); + } + }, + setScreenActiveMode: function(...args) { + console.warn('Screen.setScreenActiveMode interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be 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(); + }); + } + }, + setDensityDpi: function(...args) { + console.warn('Screen.setDensityDpi interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be 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(); + }); + } + } +}; + +export const allScreenMock = [ + Screen +]; + +export const ExpandOption = { + screenId: '[PC preview] unknown screenId', + startX: '[PC preview] unknown startX', + startY: '[PC preview] unknown startY' +}; + +export const VirtualScreenOption = { + name: '[PC preview] unknown name', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + density: '[PC preview] unknown density', + surfaceId: '[PC preview] unknown surfaceId' +}; + +export const ScreenModeInfo = { + id: '[PC preview] unknown id', + width: '[PC preview] unknown width', + height: '[PC preview] unknown height', + refreshRate: '[PC preview] unknown refreshRate' +}; + +export const supportedModeInfoArray = [ + ScreenModeInfo +] +const EventTypeMock = { + connect: 'connect', + disconnect: 'disconnect', + change: 'change' +} +export function mockScreen() { + const screen = { + ExpandOption: ExpandOption, + VirtualScreenOption: VirtualScreenOption, + Orientation: Orientation, + ScreenModeInfo: ScreenModeInfo, + EventType: EventTypeMock, + getAllScreens: function(...args) { + console.warn( + 'Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); + } else { + return new Promise((resolve) => { + resolve(allScreenMock); + }); + } + }, + on: function(...args) { + console.warn( + 'Screen.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!==2){ + console.warn("Screen.on please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.on you has registered ${args[0]} event`) + } else { + console.warn('Screen.on please check first param!') + } + } else { + console.warn('Screen.on please check param!') + } + }, + off: function(...args) { + console.warn( + 'Screen.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!==2){ + console.warn("Screen.off please check params!") + return + } + if (typeof args[len - 1] === 'function') { + if (args[0] === EventTypeMock.connect || args[0] === EventTypeMock.disconnect || args[0] === EventTypeMock.change) { + console.warn(`Screen.off you has registered ${args[0]} event`) + } else { + console.warn('Screen.off please check first param!') + } + } else { + console.warn('Screen.off please check param!') + } + }, + makeExpand: function(...args) { + console.warn( + 'Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + ' Previewer may be 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); + }); + } + }, + makeMirror: function(...args) { + console.warn( + 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + ' Previewer may be 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); + }); + } + }, + createVirtualScreen: function(...args) { + console.warn( + 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + const len = args.length; + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Screen); + } else { + return new Promise((resolve) => { + resolve(Screen); + }); + } + }, + destroyVirtualScreen: function(...args) { + console.warn( + 'Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be 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(); + }); + } + }, + setVirtualScreenSurface: function(...args) { + console.warn( + 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + ' Previewer may be 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 screen +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index f06438a1..2e3279f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -1,738 +1,714 @@ -/* - * 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 windowPropertiesMock = { - windowRect: '[PC preview] unknow windowRect', - type: '[PC preview] unknow type', - brightness: '[PC preview] unknow brightness', - isTransparent: '[PC preview] unknow isTransparent', - isFullScreen: '[PC preview] unknow isFullScreen', - isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', - dimBehindValue: '[PC preview] unknow dimBehindValue', - isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', - focusable: '[PC preview] unknow focusable', - touchable: '[PC preview] unknow touchable', - isPrivacyMode: '[PC preview] unknow isPrivacyMode', - isRoundCorner: '[PC preview] unknow isRoundCorner' -} -export const RectMock = { - left: '[PC preview] unknow Rect.left', - top: '[PC preview] unknow Rect.top', - width: '[PC preview] unknow Rect.width', - height: '[PC preview] unknow Rect.height' -} -export const AvoidAreaMock = { - visible: '[PC preview] unknow visible', - leftRect: RectMock, - topRect: RectMock, - rightRect: RectMock, - bottomRect: RectMock -} -export const WindowTypeMock = { - TYPE_APP: 0, - TYPE_SYSTEM_ALERT: 1, - TYPE_INPUT_METHOD: 2, - TYPE_STATUS_BAR: 3, - TYPE_PANEL: 4, - TYPE_KEYGUARD: 5, - TYPE_VOLUME_OVERLAY: 6, - TYPE_NAVIGATION_BAR: 7 -} -export const SystemBarRegionTintMock={ - type: WindowTypeMock, - isEnable: '[PC preview] unknow isEnable', - region: RectMock, - backgroundColor: '[PC preview] unknow backgroundColor', - contentColor: '[PC preview] unknow contentColor' -} -export const SystemBarTintStateMock= { - displayId: '[PC preview] unknow brightness', - regionTint:[SystemBarRegionTintMock] -} -export const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' -} -export const WindowStageEventTypeMock = { - FOREGROUND: 1, - ACTIVE: 2, - INACTIVE: 3, - BACKGROUND: 4 -} - -export const WindowStageMock= { - getMainWindow: function (...args) { - console.warn("windowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - createSubWindow: function (...args) { - console.warn("windowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getSubWindow: function (...args) { - console.warn("windowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,[windowMock]) - } else { - return new Promise((resolve, reject) => { - resolve([windowMock]) - }) - } - }, - loadContent: function (...args) { - console.warn("windowStage.loadContent interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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("windowStage.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]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("windowStage.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]==='windowStageEvent'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - disableWindowDecor: function (){ - console.warn("windowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setShowOnLockScreen: function (){ - console.warn("windowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } -} - -export const windowMock = { - setBrightness: function (...args) { - console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setBackgroundColor: function (...args) { - console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setTransparent: function (...args) { - console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setFullScreen: function (...args) { - console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setKeepScreenOn: function (...args) { - console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setDimBehind: function (...args) { - console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setLayoutFullScreen: function (...args) { - console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setFocusable: function (...args) { - console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setTouchable: function (...args) { - console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setPrivacyMode: function (...args) { - console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setSystemBarEnable: function (...args) { - console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setSystemBarProperties: function (...args) { - console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setForbidSplitMove: function (...args) { - console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - getProperties: function (...args) { - console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowPropertiesMock) - } else { - return new Promise((resolve) => { - resolve(windowPropertiesMock) - }) - } - }, - getAvoidArea: function (...args) { - console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, AvoidAreaMock) - } else { - return new Promise((resolve) => { - resolve(AvoidAreaMock) - }) - } - }, - moveTo: function (...args) { - console.warn("Window.moveTo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - resetSize: function (...args) { - console.warn("Window.resetSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - setWindowType: function (...args) { - console.warn("Window.setWindowType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - loadContent: function (...args) { - console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - hide: function (...args) { - console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - show: function (...args) { - console.warn("Window.show interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - isShowing: function (...args) { - console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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) - }) - } - }, - destroy: function (...args) { - console.warn("Window.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) => { - resolve() - }) - } - }, - setOutsideTouchable: function (...args) { - console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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() - }) - } - }, - on: function (...args) { - console.warn('Window.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] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('on: please check first param!') - } - } else { - console.warn('on:please check param!') - } - }, - off: function (...args) { - console.warn('Window.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] === 'keyboardHeightChange' || args[0] === 'systemAvoidAreaChange' - || args[0] === 'avoidAreaChange' || args[0] === 'windowSizeChange' || args[0] === 'touchOutside') { - console.warn(`you has registered ${args[0]} event`) - } else { - console.warn('off:please check first param!') - } - } else { - console.warn('off:please check param!') - } - }, - setColorSpace: function (...args) { - console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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() - }) - } - }, - getColorSpace: function (...args) { - console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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) - }) - } - }, - isSupportWideGamut: function (...args) { - console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + - " Previewer may be 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) - }) - } - }, -} - -export function mockWindow() { - const SizeMock = { - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - } - const getSplitScreenBoundsMock = { - splitMode: '[PC preview] unknow splitMode', - primaryBounds: RectMock, - secondaryBounds: RectMock, - } - const window = { - getTopWindow: function (...args) { - console.warn("window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - create: function (...args) { - console.warn("Window.create interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - find: function (...args) { - console.warn("Window.find interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) - } else { - return new Promise((resolve, reject) => { - resolve(windowMock) - }) - } - }, - getAbilityWindowMode: function (...args) { - console.warn("Window.getAbilityWindowMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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) - }) - } - }, - getSplitScreenBounds: function (...args) { - console.warn("window.getSplitScreenBounds interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, getSplitScreenBoundsMock) - } else { - return new Promise((resolve, reject) => { - resolve(getSplitScreenBoundsMock) - }) - } - }, - isFloatingAbilityWindowVisible: function (...args) { - console.warn("window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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) - }) - } - }, - setSplitBarVisibility: function (...args) { - console.warn("window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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() - }) - } - }, - minimizeAll: function (...args) { - console.warn("window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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() - }) - } - }, - toggleShownStateForAllAppWindows: function (...args) { - console.warn("window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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() - }) - } - }, - setWindowLayoutMode: function (...args) { - console.warn("window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + - " may be 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("window.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]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("on:please check first param!") - } - }else { - console.warn("on:please check param!") - } - }, - off: function (...args) { - console.warn("window.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]==='systemBarTintChange'){ - console.warn(`you has registered ${args[0]} event`) - }else { - console.warn("off:please check first param!") - } - }else { - console.warn("off:please check param!") - } - }, - WindowType: WindowTypeMock, - AvoidAreaType: { - TYPE_SYSTEM: 0, - TYPE_CUTOUT: 1, - TYPE_SYSTEM_GESTURE: 2, - TYPE_KEYBOARD: 3 - }, - WindowMode: { - UNDEFINED: 1, - FULLSCREEN: 2, - PRIMARY: 3, - SECONDARY: 4, - FLOATING: 5 - }, - WindowLayoutMode: { - WINDOW_LAYOUT_MODE_CASCADE: 0, - WINDOW_LAYOUT_MODE_TILE: 1 - }, - SystemBarProperties: { - statusBarColor: '[PC preview] unknow statusBarColor', - isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', - statusBarContentColor: '[PC preview] unknow statusBarContentColor', - navigationBarColor: '[PC preview] unknow navigationBarColor', - isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', - navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' - }, - SystemBarRegionTint: SystemBarRegionTintMock, - SystemBarTintState: SystemBarTintStateMock, - Rect: { - left: '[PC preview] unknow left', - top: '[PC preview] unknow top', - width: '[PC preview] unknow width', - height: '[PC preview] unknow height' - }, - AvoidArea:AvoidAreaMock, - Size: SizeMock, - WindowProperties: { - windowRect: RectMock, - type: WindowTypeMock, - isFullScreen: '[PC preview] unknow isFullScreen', - isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', - focusable: '[PC preview] unknow focusable', - touchable: '[PC preview] unknow touchable', - brightness: '[PC preview] unknow brightness', - dimBehindValue: '[PC preview] unknow dimBehindValue', - isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', - isPrivacyMode: '[PC preview] unknow isPrivacyMode', - isRoundCorner: '[PC preview] unknow isRoundCorner', - isTransparent: '[PC preview] unknow isTransparent' - }, - ColorSpace: { - DEFAULT: 0, - WIDE_GAMUT: 1 - }, - WindowStageEventType: WindowStageEventTypeMock, - WindowStage: WindowStageMock - } - return window -} +/* + * 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 WindowType = { + TYPE_APP: 0, + TYPE_SYSTEM_ALERT: 1, + TYPE_INPUT_METHOD: 2, + TYPE_STATUS_BAR: 3, + TYPE_PANEL: 4, + TYPE_KEYGUARD: 5, + TYPE_VOLUME_OVERLAY: 6, + TYPE_NAVIGATION_BAR: 7, + TYPE_FLOAT: 8, + TYPE_WALLPAPER: 9, + TYPE_DESKTOP: 10, + TYPE_LAUNCHER_RECENT: 11, + TYPE_LAUNCHER_DOCK: 12, + TYPE_VOICE_INTERACTION: 13, + TYPE_POINTER: 14 +} + +export const AvoidAreaType= { + TYPE_SYSTEM: 0, + TYPE_CUTOUT: 1, + TYPE_SYSTEM_GESTURE: 2, + TYPE_KEYBOARD: 3 +} + +export const WindowMode= { + UNDEFINED: 1, + FULLSCREEN: 2, + PRIMARY: 3, + SECONDARY: 4, + FLOATING: 5 +} + +export const WindowLayoutMode= { + WINDOW_LAYOUT_MODE_CASCADE: 0, + WINDOW_LAYOUT_MODE_TILE: 1 +} + +export const SystemBarProperties= { + statusBarColor: '[PC preview] unknow statusBarColor', + isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', + statusBarContentColor: '[PC preview] unknow statusBarContentColor', + navigationBarColor: '[PC preview] unknow navigationBarColor', + isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', + navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' +} + +export const Rect = { + left: '[PC preview] unknow Rect.left', + top: '[PC preview] unknow Rect.top', + width: '[PC preview] unknow Rect.width', + height: '[PC preview] unknow Rect.height' +} + +export const SystemBarRegionTint = { + type: WindowType, + isEnable: '[PC preview] unknow isEnable', + region: Rect, + backgroundColor: '[PC preview] unknow backgroundColor', + contentColor: '[PC preview] unknow contentColor' +} + +export const SystemBarTintState = { + displayId: '[PC preview] unknow brightness', + regionTint:[SystemBarRegionTint] +} + +export const AvoidArea = { + visible: '[PC preview] unknow AvoidArea.visible', + leftRect: Rect, + topRect: Rect, + rightRect: Rect, + bottomRect: Rect +} +export const Size = { + width: '[PC preview] unknow width', + height: '[PC preview] unknow height' +} + +export const WindowProperties = { + windowRect: '[PC preview] unknow windowRect', + type: '[PC preview] unknow type', + brightness: '[PC preview] unknow brightness', + isTransparent: '[PC preview] unknow isTransparent', + isFullScreen: '[PC preview] unknow isFullScreen', + isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', + dimBehindValue: '[PC preview] unknow dimBehindValue', + isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', + focusable: '[PC preview] unknow focusable', + touchable: '[PC preview] unknow touchable', + isPrivacyMode: '[PC preview] unknow isPrivacyMode', + isRoundCorner: '[PC preview] unknow isRoundCorner' +} + +export const ColorSpace = { + DEFAULT: 0, + WIDE_GAMUT: 1 +} + +export const WindowStageEventType = { + FOREGROUND: 1, + ACTIVE: 2, + INACTIVE: 3, + BACKGROUND: 4 +} + +export const WindowStage = { + getMainWindow: function(...args) { + console.warn("WindowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + createSubWindow: function(...args) { + console.warn("WindowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + getSubWindow: function(...args) { + console.warn("WindowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [Window]) + } else { + return new Promise((resolve) => { + resolve([Window]) + }) + } + }, + loadContent: function(...args) { + console.warn("WindowStage.loadContent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be 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() + }) + } + }, + on: function(...args) { + console.warn("WindowStage.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] === 'windowStageEvent') { + console.warn(`WindowStage.on you has registered ${args[0]} event`) + } else { + console.warn("WindowStage.on:please check first param!") + } + } else { + console.warn("WindowStage.on:please check param!") + } + }, + off: function(...args) { + console.warn("WindowStage.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] === 'windowStageEvent') { + console.warn(`you has registered ${args[0]} event`) + }else { + console.warn("WindowStage.off:please check first param!") + } + }else { + console.warn("WindowStage.off:please check param!") + } + }, + disableWindowDecor: function() { + console.warn("WindowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, + setShowOnLockScreen: function() { + console.warn("WindowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the" + + " Previewer" + + " may be different from that on a real device.") + } +} + +export const Window = { + setBrightness: function(...args) { + console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setBackgroundColor: function(...args) { + console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setTransparent: function(...args) { + console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setFullScreen: function(...args) { + console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setKeepScreenOn: function(...args) { + console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setDimBehind: function(...args) { + console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setLayoutFullScreen: function(...args) { + console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setFocusable: function(...args) { + console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setTouchable: function(...args) { + console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setPrivacyMode: function(...args) { + console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setSystemBarEnable: function(...args) { + console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setSystemBarProperties: function(...args) { + console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setForbidSplitMove: function(...args) { + console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + getProperties: function(...args) { + console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, WindowProperties) + } else { + return new Promise((resolve) => { + resolve(WindowProperties) + }) + } + }, + getAvoidArea: function(...args) { + console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, AvoidArea) + } else { + return new Promise((resolve) => { + resolve(AvoidArea) + }) + } + }, + moveTo: function(...args) { + console.warn("Window.moveTo interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + resetSize: function(...args) { + console.warn("Window.resetSize interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + setWindowType: function(...args) { + console.warn("Window.setWindowType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + loadContent: function(...args) { + console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + hide: function(...args) { + console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + show: function(...args) { + console.warn("Window.show interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + isShowing: function(...args) { + console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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) + }) + } + }, + destroy: function(...args) { + console.warn("Window.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) => { + resolve() + }) + } + }, + setOutsideTouchable: function(...args) { + console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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() + }) + } + }, + on: function(...args) { + console.warn("Window.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] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("on:please check first param!") + } + } else { + console.warn("on:please check param!") + } + }, + off: function(...args) { + console.warn("Window.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] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' + || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + ){ + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("off:please check first param!") + } + } else { + console.warn("off:please check param!") + } + }, + setColorSpace: function(...args) { + console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be 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() + }) + } + }, + getColorSpace: function(...args) { + console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be 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) + }) + } + }, + isSupportWideGamut: function(...args) { + console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + + " Previewer may be 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) + }) + } + }, +} + +export function mockWindow() { + + const window = { + getTopWindow: function(...args) { + console.warn( + "Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + create: function(...args) { + console.warn( + "Window.create interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + find: function(...args) { + console.warn( + "Window.find interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, Window) + } else { + return new Promise((resolve) => { + resolve(Window) + }) + } + }, + isFloatingAbilityWindowVisible: function(...args) { + console.warn( + "Window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface works on the Previewer" + " may be 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) + }) + } + }, + setSplitBarVisibility: function(...args) { + console.warn( + "Window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + " may be 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() + }) + } + }, + minimizeAll: function(...args) { + console.warn( + "Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + " may be 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() + }) + } + }, + toggleShownStateForAllAppWindows: function(...args) { + console.warn( + "Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + " may be 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() + }) + } + }, + setWindowLayoutMode: function(...args) { + console.warn( + "Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + " may be 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() + }) + } + }, + on: function(...args) { + console.warn( + "Window.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] === 'systemBarTintChange') { + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("on:please check first param!") + } + } else { + console.warn("on:please check param!") + } + }, + off: function(...args) { + console.warn( + "Window.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] === 'systemBarTintChange') { + console.warn(`you has registered ${args[0]} event`) + } else { + console.warn("off:please check first param!") + } + } else { + console.warn("off:please check param!") + } + }, + WindowType: WindowType, + AvoidAreaType: AvoidAreaType, + WindowMode: WindowMode, + WindowLayoutMode: WindowLayoutMode, + SystemBarProperties: SystemBarProperties, + SystemBarRegionTint: SystemBarRegionTint, + SystemBarTintState: SystemBarTintState, + Rect: Rect, + AvoidArea: AvoidArea, + Size: Size, + WindowProperties: WindowProperties, + ColorSpace: ColorSpace, + WindowStageEventType: WindowStageEventType, + WindowStage: WindowStage + } + return window +} From 360d1af1331214485e8f4d991fe0128ee6e9fb3c Mon Sep 17 00:00:00 2001 From: binny1024 Date: Tue, 12 Jul 2022 11:08:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=85=BC=E5=AE=B9=E5=A4=96=E9=83=A8=E5=BC=95?= =?UTF-8?q?=E7=94=A8,=E6=95=B4=E6=94=B9=E6=A0=BC=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyaoying Change-Id: I13d2fdcc56fa2b07e36afaaf3c0076b0f33d8aaf --- runtime/main/extend/systemplugin/ability.js | 6 +- .../extend/systemplugin/napi/ohos_display.js | 24 ++- .../extend/systemplugin/napi/ohos_screen.js | 69 ++++-- .../extend/systemplugin/napi/ohos_window.js | 196 ++++++++++-------- 4 files changed, 175 insertions(+), 120 deletions(-) diff --git a/runtime/main/extend/systemplugin/ability.js b/runtime/main/extend/systemplugin/ability.js index 64ecc6d8..d22765e4 100644 --- a/runtime/main/extend/systemplugin/ability.js +++ b/runtime/main/extend/systemplugin/ability.js @@ -14,7 +14,7 @@ */ import { paramMock } from "./utils" -import { windowMock } from "./napi/ohos_window" +import { Window } from "./napi/ohos_window" const DataAbilityResultMock = { uri: "[PC Preview] unknow uri", @@ -839,10 +839,10 @@ export function mockAbilityFeatureAbility() { " on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, windowMock) + args[len - 1].call(this, paramMock.businessErrorMock, Window) } else { return new Promise((resolve) => { - resolve(windowMock) + resolve(Window) }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_display.js b/runtime/main/extend/systemplugin/napi/ohos_display.js index b3123826..0fadf06a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_display.js +++ b/runtime/main/extend/systemplugin/napi/ohos_display.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + et 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 @@ -34,7 +34,7 @@ export const Display = { id: '[PC preview] unknow id', name: '[PC preview] unknow name', alive: '[PC preview] unknow alive', - state: '[PC preview] unknow state', + state: DisplayState, refreshRate: '[PC preview] unknow refreshRate', rotation: '[PC preview] unknow rotation', width: '[PC preview] unknow width', @@ -50,8 +50,8 @@ export function mockDisplay() { const display = { getDefaultDisplay: function (...args) { - console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Display) @@ -61,9 +61,14 @@ export function mockDisplay() { }) } }, + getDefaultDisplaySync: function (...args) { + console.warn("Display.getDefaultDisplay interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return Display; + }, getAllDisplay: function (...args) { console.warn("Display.getAllDisplay interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, [Display]) @@ -75,7 +80,7 @@ export function mockDisplay() { }, on: function (...args) { console.warn("Display.on interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length if (len!==2){ console.warn("Display.on:please check params !") @@ -93,7 +98,7 @@ export function mockDisplay() { }, off: function (...args) { console.warn("Display.off interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length if (len!==2){ console.warn("Display.off:please check params!") @@ -109,8 +114,7 @@ export function mockDisplay() { console.warn("Display.off:please check params, the second parma must be a function!") } }, - DisplayState: DisplayState, - Type: DisplayType + DisplayState } return display -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_screen.js b/runtime/main/extend/systemplugin/napi/ohos_screen.js index 577a1225..3740235b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screen.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screen.js @@ -46,7 +46,7 @@ export const Screen = { }, setScreenActiveMode: function(...args) { console.warn('Screen.setScreenActiveMode interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -58,7 +58,7 @@ export const Screen = { }, setDensityDpi: function(...args) { console.warn('Screen.setDensityDpi interface mocked in the Previewer. How this interface works on the' + - ' Previewer may be different from that on a real device.'); + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -105,14 +105,13 @@ const EventTypeMock = { } export function mockScreen() { const screen = { - ExpandOption: ExpandOption, - VirtualScreenOption: VirtualScreenOption, - Orientation: Orientation, - ScreenModeInfo: ScreenModeInfo, - EventType: EventTypeMock, + ExpandOption, + VirtualScreenOption, + Orientation, + ScreenModeInfo, getAllScreens: function(...args) { - console.warn( - 'Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.getAllScreens interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, allScreenMock); @@ -123,8 +122,8 @@ export function mockScreen() { } }, on: function(...args) { - console.warn( - 'Screen.on interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + console.warn('Screen.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!==2){ console.warn("Screen.on please check params!") @@ -141,8 +140,8 @@ export function mockScreen() { } }, off: function(...args) { - console.warn( - 'Screen.off interface mocked in the Previewer. How this interface works on the Previewer may be' + ' different from that on a real device.'); + console.warn('Screen.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!==2){ console.warn("Screen.off please check params!") @@ -159,8 +158,8 @@ export function mockScreen() { } }, makeExpand: function(...args) { - console.warn( - 'Screen.makeExpand interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.makeExpand interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be 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); @@ -171,8 +170,8 @@ export function mockScreen() { } }, makeMirror: function(...args) { - console.warn( - 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.makeMirror interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be 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); @@ -183,8 +182,8 @@ export function mockScreen() { } }, createVirtualScreen: function(...args) { - console.warn( - 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.createVirtualScreen interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Screen); @@ -195,8 +194,8 @@ export function mockScreen() { } }, destroyVirtualScreen: function(...args) { - console.warn( - 'Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn('Screen.destroyVirtualScreen interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); const len = args.length; if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock); @@ -207,8 +206,8 @@ export function mockScreen() { } }, setVirtualScreenSurface: function(...args) { - console.warn( - 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be 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,6 +216,30 @@ export function mockScreen() { resolve(); }); } + }, + isScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be 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); + }); + } + }, + setScreenRotationLocked: function(...args) { + console.warn( 'Screen.setVirtualScreenSurface interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be 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 screen diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index 2e3279f9..cd4c9ff7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -40,6 +40,22 @@ export const AvoidAreaType= { TYPE_KEYBOARD: 3 } +export const Orientation = { + UNSPECIFIED: 0, + PORTRAIT: 1, + LANDSCAPE: 2, + PORTRAIT_INVERTED: 3, + LANDSCAPE_INVERTED: 4, + AUTO_ROTATION: 5, + AUTO_ROTATION_PORTRAIT: 6, + AUTO_ROTATION_LANDSCAPE: 7, + AUTO_ROTATION_RESTRICTED: 8, + AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, + AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, + LOCKED: 11 +} + + export const WindowMode= { UNDEFINED: 1, FULLSCREEN: 2, @@ -89,6 +105,7 @@ export const AvoidArea = { rightRect: Rect, bottomRect: Rect } + export const Size = { width: '[PC preview] unknow width', height: '[PC preview] unknow height' @@ -124,7 +141,7 @@ export const WindowStageEventType = { export const WindowStage = { getMainWindow: function(...args) { console.warn("WindowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -136,7 +153,7 @@ export const WindowStage = { }, createSubWindow: function(...args) { console.warn("WindowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -148,7 +165,7 @@ export const WindowStage = { }, getSubWindow: function(...args) { console.warn("WindowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, [Window]) @@ -160,7 +177,7 @@ export const WindowStage = { }, loadContent: function(...args) { console.warn("WindowStage.loadContent interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -172,7 +189,7 @@ export const WindowStage = { }, on: function(...args) { console.warn("WindowStage.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'windowStageEvent') { @@ -186,7 +203,7 @@ export const WindowStage = { }, off: function(...args) { console.warn("WindowStage.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] === 'windowStageEvent') { @@ -200,19 +217,18 @@ export const WindowStage = { }, disableWindowDecor: function() { console.warn("WindowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + "may be different from that on a real device.") }, setShowOnLockScreen: function() { console.warn("WindowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the" + - " Previewer" + - " may be different from that on a real device.") + " Previewer may be different from that on a real device.") } } export const Window = { setBrightness: function(...args) { console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -224,7 +240,7 @@ export const Window = { }, setBackgroundColor: function(...args) { console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -236,7 +252,7 @@ export const Window = { }, setTransparent: function(...args) { console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -248,7 +264,7 @@ export const Window = { }, setFullScreen: function(...args) { console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -260,7 +276,7 @@ export const Window = { }, setKeepScreenOn: function(...args) { console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -272,7 +288,7 @@ export const Window = { }, setDimBehind: function(...args) { console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -284,7 +300,7 @@ export const Window = { }, setLayoutFullScreen: function(...args) { console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -296,7 +312,7 @@ export const Window = { }, setFocusable: function(...args) { console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -308,7 +324,7 @@ export const Window = { }, setTouchable: function(...args) { console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -320,7 +336,7 @@ export const Window = { }, setPrivacyMode: function(...args) { console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -332,7 +348,7 @@ export const Window = { }, setSystemBarEnable: function(...args) { console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -344,7 +360,7 @@ export const Window = { }, setSystemBarProperties: function(...args) { console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -354,9 +370,21 @@ export const Window = { }) } }, + setPreferredOrientation: function(...args) { + console.warn("Window.setPreferredOrientation interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,Orientation) + } else { + return new Promise((resolve) => { + resolve(Orientation) + }) + } + }, setForbidSplitMove: function(...args) { console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -368,7 +396,7 @@ export const Window = { }, getProperties: function(...args) { console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, WindowProperties) @@ -380,7 +408,7 @@ export const Window = { }, getAvoidArea: function(...args) { console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, AvoidArea) @@ -392,7 +420,7 @@ export const Window = { }, moveTo: function(...args) { console.warn("Window.moveTo interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -404,7 +432,7 @@ export const Window = { }, resetSize: function(...args) { console.warn("Window.resetSize interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -416,7 +444,7 @@ export const Window = { }, setWindowType: function(...args) { console.warn("Window.setWindowType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -428,7 +456,7 @@ export const Window = { }, loadContent: function(...args) { console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -440,7 +468,7 @@ export const Window = { }, hide: function(...args) { console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -452,7 +480,7 @@ export const Window = { }, show: function(...args) { console.warn("Window.show interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -464,7 +492,7 @@ export const Window = { }, isShowing: function(...args) { console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) @@ -476,7 +504,7 @@ export const Window = { }, destroy: function(...args) { console.warn("Window.destroy interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -488,7 +516,7 @@ export const Window = { }, setOutsideTouchable: function(...args) { console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -500,39 +528,39 @@ export const Window = { }, on: function(...args) { console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' ){ - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.on you has registered ${args[0]} event`) } else { - console.warn("on:please check first param!") + console.warn("Window.on please check first param!") } } else { - console.warn("on:please check param!") + console.warn("Window.on please check param!") } }, off: function(...args) { console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + - " different from that on a real device.") + " different from that on a real device.") const len = args.length; if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' ){ - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.off you has registered ${args[0]} event`) } else { - console.warn("off:please check first param!") + console.warn("Window.off please check first param!") } } else { - console.warn("off:please check param!") + console.warn("Window.off please check param!") } }, setColorSpace: function(...args) { console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -544,7 +572,7 @@ export const Window = { }, getColorSpace: function(...args) { console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + " may be 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) @@ -556,7 +584,7 @@ export const Window = { }, isSupportWideGamut: function(...args) { console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) @@ -572,8 +600,8 @@ export function mockWindow() { const window = { getTopWindow: function(...args) { - console.warn( - "Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -584,8 +612,8 @@ export function mockWindow() { } }, create: function(...args) { - console.warn( - "Window.create interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + console.warn("Window.create interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -596,8 +624,8 @@ export function mockWindow() { } }, find: function(...args) { - console.warn( - "Window.find interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") + console.warn("Window.find interface mocked in the Previewer. How this interface works on the Previewer may be" + + " different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, Window) @@ -608,8 +636,8 @@ export function mockWindow() { } }, isFloatingAbilityWindowVisible: function(...args) { - console.warn( - "Window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface" + + " works on the Previewer may be 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) @@ -620,8 +648,8 @@ export function mockWindow() { } }, setSplitBarVisibility: function(...args) { - console.warn( - "Window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -632,8 +660,8 @@ export function mockWindow() { } }, minimizeAll: function(...args) { - console.warn( - "Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -644,8 +672,8 @@ export function mockWindow() { } }, toggleShownStateForAllAppWindows: function(...args) { - console.warn( - "Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface" + + " works on the Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -656,8 +684,8 @@ export function mockWindow() { } }, setWindowLayoutMode: function(...args) { - console.warn( - "Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock) @@ -668,47 +696,47 @@ export function mockWindow() { } }, on: function(...args) { - console.warn( - "Window.on interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.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] === 'systemBarTintChange') { - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.on you has registered ${args[0]} event`) } else { - console.warn("on:please check first param!") + console.warn("Window.on please check first param!") } } else { - console.warn("on:please check param!") + console.warn("Window.on please check param!") } }, off: function(...args) { - console.warn( - "Window.off interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") + console.warn("Window.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] === 'systemBarTintChange') { - console.warn(`you has registered ${args[0]} event`) + console.warn(`Window.off you has registered ${args[0]} event`) } else { - console.warn("off:please check first param!") + console.warn("Window.off please check first param!") } } else { - console.warn("off:please check param!") + console.warn("Window.off please check param!") } }, - WindowType: WindowType, - AvoidAreaType: AvoidAreaType, - WindowMode: WindowMode, - WindowLayoutMode: WindowLayoutMode, - SystemBarProperties: SystemBarProperties, - SystemBarRegionTint: SystemBarRegionTint, - SystemBarTintState: SystemBarTintState, - Rect: Rect, - AvoidArea: AvoidArea, - Size: Size, - WindowProperties: WindowProperties, - ColorSpace: ColorSpace, - WindowStageEventType: WindowStageEventType, - WindowStage: WindowStage + WindowType, + AvoidAreaType, + WindowMode, + WindowLayoutMode, + SystemBarProperties, + SystemBarRegionTint, + SystemBarTintState, + Rect, + AvoidArea, + Size, + WindowProperties, + ColorSpace, + WindowStageEventType, + WindowStage } return window }