From f7dbac216e4f2a6424bf46cd3db8f983dec198e5 Mon Sep 17 00:00:00 2001 From: xiaojianfeng Date: Tue, 15 Mar 2022 22:34:53 +0800 Subject: [PATCH] add window interface mock Signed-off-by: xiaojianfeng Change-Id: I53d514d0d2eb51d9678b1b72f107b5e380629bf0 --- runtime/main/extend/systemplugin/window.js | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/window.js b/runtime/main/extend/systemplugin/window.js index ffdfad8e..fb8ebedc 100644 --- a/runtime/main/extend/systemplugin/window.js +++ b/runtime/main/extend/systemplugin/window.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -334,6 +334,42 @@ export const windowMock = { args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } }, + 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 = { @@ -445,5 +481,9 @@ export function mockWindow() { TYPE_VOLUME_OVERLAY: 6, TYPE_NAVIGATION_BAR: 7 }, + ColorSpace: { + DEFAULT: 0, + WIDE_GAMUT: 1 + }, } }