From 2afa5dc3c46289bc10f7900f332822895fe0ad0f Mon Sep 17 00:00:00 2001 From: lhb <443830197@qq.com> Date: Fri, 22 Jul 2022 10:04:11 +0800 Subject: [PATCH] add windowAnimationManager mock Signed-off-by: lhb <443830197@qq.com> Change-Id: I644c0184fa20861525cf5d0df1ff91076b3665c9 --- .../main/extend/systemplugin/napi/index.js | 3 + .../ohos_animation_windowAnimationManager.js | 79 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 8a16445e..56e6222e 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -174,6 +174,7 @@ import { mockTouchEvent } from './ohos_multimodalInput_touchEvent' import { mockUiAppearance } from './ohos_uiAppearance' import { mockContinationManager } from './ohos_continuation_continuationManager' import { mockUiTest } from './ohos_uitest' +import { mockWindowAnimationManager } from './ohos_animation_windowAnimationManager' export function mockRequireNapiFun() { global.requireNapi = function (...args) { switch (args[0]) { @@ -499,6 +500,8 @@ export function mockRequireNapiFun() { return mockContinationManager(); case "uitest": return mockUiTest(); + case "animation.windowAnimationManager": + return mockWindowAnimationManager(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js b/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js new file mode 100644 index 00000000..9839a613 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_animation_windowAnimationManager.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../utils" + +export function mockWindowAnimationManager() { + const RRect = { + left: '[PC preview] unknow left', + top: '[PC preview] unknow top', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + radius: '[PC preview] unknow radius', + } + const WindowAnimationTarget = { + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + windowBounds: RRect, + } + const WindowAnimationFinishedCallback = { + onAnimationFinish: function (...args) { + console.warn("WindowAnimationFinishedCallback.onAnimationFinish interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + } + const WindowAnimationController = { + onStartAppFromLauncher: function (...args) { + console.warn("WindowAnimationController.onStartAppFromLauncher interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onStartAppFromRecent: function (...args) { + console.warn("WindowAnimationController.onStartAppFromRecent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onStartAppFromOther: function (...args) { + console.warn("WindowAnimationController.onStartAppFromOther interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onAppTransition: function (...args) { + console.warn("WindowAnimationController.onAppTransition interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onMinimizeWindow: function (...args) { + console.warn("WindowAnimationController.onMinimizeWindow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onCloseWindow: function (...args) { + console.warn("WindowAnimationController.onCloseWindow interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + onScreenUnlock: function (...args) { + console.warn("WindowAnimationController.onScreenUnlock interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + } + + const windowAnimationManager = { + WindowAnimationController, + WindowAnimationFinishedCallback, + WindowAnimationTarget, + RRect, + setController: function (...args) { + console.warn("windowAnimationManager.setController interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } + } + return windowAnimationManager +} \ No newline at end of file