From 682e04774830dc124deca7913faac52a606e78d0 Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Thu, 7 Jul 2022 17:55:52 +0800 Subject: [PATCH] =?UTF-8?q?=C3=A4Fill=20in=20the=20missing=20mocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hungry_feiwei Change-Id: Ie2a97c7f09577622a3613ea4c91322e87d8112c8 --- .../napi/ohos_multimodalInput_inputMonitor.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js index 4534dfb1..d808db3b 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js @@ -82,8 +82,26 @@ export function mockInputMonitor() { off: function (...args) { console.warn('multimodalInput.inputMonitor.off interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); - clearInterval(this.offInputMonitor); - delete this.offInputMonitor; + const len = args.length; + if (len < 1 || len > 2) { + console.warn("a maximum of two parameters"); + return; + } + if (typeof args[0] !== 'string') { + console.warn("the first parameter type must be string"); + return; + } + if (len === 1) { + if (args[0] !== 'touch' && args[0] !== 'mouse') { + console.warn("the first param should be touch or mouse"); + return; + } + } else { + if (typeof args[1] !== 'function') { + console.warn("the second parameter type must be function"); + return; + } + } } } return inputMonitor