From b42a86bb73ca373bf3aeeccc694e80c735c68f98 Mon Sep 17 00:00:00 2001 From: hungry_feiwei Date: Thu, 7 Jul 2022 16:47:33 +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: Ieb3c3338c4a4c536646d4095963ec47c3baa0f84 --- .../ohos_multimodalInput_inputConsumer.js | 6 +++++ .../napi/ohos_multimodalInput_inputDevice.js | 17 ++++++++++-- .../napi/ohos_multimodalInput_inputEvent.js | 24 +++++++++++++++++ .../napi/ohos_multimodalInput_inputMonitor.js | 3 +++ .../napi/ohos_multimodalInput_keyCode.js | 2 ++ .../napi/ohos_multimodalInput_keyEvent.js | 19 ++++++++++++++ .../napi/ohos_multimodalInput_mouseEvent.js | 25 ++++++++++++++++++ .../napi/ohos_multimodalInput_touchEvent.js | 26 +++++++++++++++++++ 8 files changed, 120 insertions(+), 2 deletions(-) create mode 100755 runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js index c251ab58..5bab4542 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputConsumer.js @@ -16,6 +16,12 @@ import { paramMock } from "../utils" export function mockInputConsumer() { + const KeyOptions = { + preKeys: ["[PC preview] unknown preKeys"], + finalKey: "[PC preview] unknown finalKey", + isFinalKeyDown: "[PC preview] unknown isFinalKeyDown", + finalKeyDownDuration: "[PC preview] unknown finalKeyDownDuration", + } const EventType = ['key'] const inputConsumer = { on: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js index 874f1756..2edabfd6 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js @@ -16,17 +16,30 @@ import { paramMock } from "../utils" export function mockInputDevice() { + const DeviceListener = { + type: '[PC preview] unknow type', + deviceId: '[PC preview] unknow deviceId', + } const AxisRange = { source: '[PC preview] unknow source', axis: '[PC preview] unknow axis', max: '[PC preview] unknow max', - min: '[PC preview] unknow min' + min: '[PC preview] unknow min', + fuzz: '[PC preview] unknow fuzz', + flat: '[PC preview] unknow flat', + resolution: '[PC preview] unknow resolution', } const InputDeviceData = { id: '[PC preview] unknow id', name: '[PC preview] unknow name', sources: ['[PC preview] unknow sources'], - axisRanges: [AxisRange] + axisRanges: [AxisRange], + bus: '[PC preview] unknow bus', + product: '[PC preview] unknow product', + vendor: '[PC preview] unknow vendor', + version: '[PC preview] unknow version', + phys: '[PC preview] unknow phys', + uniq: '[PC preview] unknow uniq', } const KeyboardType = { NONE: 0, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js new file mode 100755 index 00000000..afcd6edd --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputEvent.js @@ -0,0 +1,24 @@ +/* + * 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. + */ + +export function mockInputEvent() { + const InputEvent = { + id: '[PC preview] unknow id', + deviceId: '[PC preview] unknow deviceId', + actionTime: '[PC preview] unknow actionTime', + screenId: '[PC preview] unknow screenId', + windowId: '[PC preview] unknow windowId', + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js index ff969d42..4534dfb1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputMonitor.js @@ -14,6 +14,9 @@ */ export function mockInputMonitor() { + const TouchEventReceiver = { + "touchEvent": '[PC preview] unknow boolean' + } const touches = [{ force: 1.67, globalX: 122, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js index 3a9e8180..63a34cfc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyCode.js @@ -16,6 +16,8 @@ export const KeyCode = { KEYCODE_FN: 0, KEYCODE_UNKNOWN: -1, + KEYCODE_HOME: 1, + KEYCODE_BACK: 2, KEYCODE_MEDIA_PLAY_PAUSE: 10, KEYCODE_MEDIA_STOP: 11, KEYCODE_MEDIA_NEXT: 12, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js index 93d84695..888f6432 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_keyEvent.js @@ -20,6 +20,25 @@ export const Action = { } export function mockKeyEvent() { + const Key = { + code: '[PC preview] unknow code', + pressedTime: '[PC preview] unknow pressedTime', + deviceId: '[PC preview] unknow deviceId', + } + const KeyEvent = { + action: '[PC preview] unknow action', + key: Key, + unicodeChar: '[PC preview] unknow unicodeChar', + keys: ['[PC preview] unknow Key'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const keyEvent = { Action, } diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js index f0f65236..7d7fd3bb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_mouseEvent.js @@ -41,6 +41,31 @@ export const Axis = { } export function mockMouseEvent() { + const AxisValue = { + axis: '[PC preview] unknow axis', + value: '[PC preview] unknow value', + } + const MouseEvent = { + action: '[PC preview] unknow action', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + rawDeltaX: '[PC preview] unknow rawDeltaX', + rawDeltaY: '[PC preview] unknow rawDeltaY', + button: '[PC preview] unknow button', + pressedButtons: ['[PC preview] unknow pressedButtons'], + axes: ['[PC preview] unknow axes'], + pressedKeys: ['[PC preview] unknow pressedKeys'], + ctrlKey: '[PC preview] unknow ctrlKey', + altKey: '[PC preview] unknow altKey', + shiftKey: '[PC preview] unknow shiftKey', + logoKey: '[PC preview] unknow logoKey', + fnKey: '[PC preview] unknow fnKey', + capsLock: '[PC preview] unknow capsLock', + numLock: '[PC preview] unknow numLock', + scrollLock: '[PC preview] unknow scrollLock', + } const mouseEvent = { Action, Button, diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js index 58b53f7a..76655570 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_touchEvent.js @@ -38,6 +38,32 @@ export const SourceType = { } export function mockTouchEvent() { + const Touch = { + id: '[PC preview] unknow id', + pressedTime: '[PC preview] unknow pressedTime', + screenX: '[PC preview] unknow screenX', + screenY: '[PC preview] unknow screenY', + windowX: '[PC preview] unknow windowX', + windowY: '[PC preview] unknow windowY', + pressure: '[PC preview] unknow pressure', + width: '[PC preview] unknow width', + height: '[PC preview] unknow height', + tiltX: '[PC preview] unknow tiltX', + tiltY: '[PC preview] unknow tiltY', + toolX: '[PC preview] unknow toolX', + toolY: '[PC preview] unknow toolY', + toolWidth: '[PC preview] unknow toolWidth', + toolHeight: '[PC preview] unknow toolHeight', + rawX: '[PC preview] unknow rawX', + rawY: '[PC preview] unknow rawY', + toolType: '[PC preview] unknow toolType', + } + const TouchEvent = { + action: '[PC preview] unknow action', + touch: '[PC preview] unknow Touch', + touches: ['[PC preview] unknow Touch'], + sourceType: '[PC preview] unknow SourceType', + } const touchEvent = { Action, ToolType,