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 +}