From c43a091db6eb7ab93925dbd4fb48ecdaf2741849 Mon Sep 17 00:00:00 2001 From: realice Date: Thu, 28 Jul 2022 11:45:15 +0800 Subject: [PATCH] =?UTF-8?q?Mock=EF=BC=9A=E6=88=AA=E5=B1=8F=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E3=80=81=E7=AA=97=E5=8F=A3=E6=88=AA=E5=9B=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: realice Change-Id: Ia366605c8c263fb9adae7ca5ad40ee3679ff7c7f --- .../main/extend/systemplugin/napi/ohos_window.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_window.js b/runtime/main/extend/systemplugin/napi/ohos_window.js index 58327ee4..f08f66d1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_window.js +++ b/runtime/main/extend/systemplugin/napi/ohos_window.js @@ -14,6 +14,7 @@ */ import { paramMock } from "../utils" +import { PixelMapMock } from "./ohos_multimedia_image" export const WindowType = { TYPE_APP: 0, @@ -533,6 +534,7 @@ export const Window = { if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + || args[0] === 'screenshot' ){ console.warn(`Window.on you has registered ${args[0]} event`) } else { @@ -549,6 +551,7 @@ export const Window = { if (typeof args[len - 1] === 'function') { if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' + || args[0] === 'screenshot' ){ console.warn(`Window.off you has registered ${args[0]} event`) } else { @@ -594,6 +597,18 @@ export const Window = { }) } }, + snapshot: function (...args) { + console.warn("Window.snapshot interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock) + } else { + return new Promise((resolve, reject) => { + resolve(PixelMapMock) + }) + } + }, } export const windowMock = Window