mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
@@ -157,6 +157,9 @@ import { mockEnterpriseDeviceManager } from './ohos_enterpriseDeviceManager'
|
||||
import { mockKeyCode } from './ohos_multimodalInput_keyCode'
|
||||
import { mockInputEventClient } from './ohos_multimodalInput_inputEventClient'
|
||||
import { mockDefaultAppManager } from './ohos_bundle_defaultAppManager'
|
||||
import { mockKeyEvent } from './ohos_multimodalInput_keyEvent'
|
||||
import { mockMouseEvent } from './ohos_multimodalInput_mouseEvent'
|
||||
import { mockTouchEvent } from './ohos_multimodalInput_touchEvent'
|
||||
export function mockRequireNapiFun() {
|
||||
global.requireNapi = function (...args) {
|
||||
switch (args[0]) {
|
||||
@@ -448,6 +451,12 @@ export function mockRequireNapiFun() {
|
||||
return mockKeyCode();
|
||||
case "multimodalInput.inputEventClient":
|
||||
return mockInputEventClient();
|
||||
case "multimodalInput.keyEvent":
|
||||
return mockKeyEvent();
|
||||
case "multimodalInput.mouseEvent":
|
||||
return mockMouseEvent();
|
||||
case "multimodalInput.touchEvent":
|
||||
return mockTouchEvent();
|
||||
default:
|
||||
return global.requireNapiPreview(...args);
|
||||
}
|
||||
|
||||
Executable → Regular
Executable → Regular
+9
@@ -28,11 +28,20 @@ export function mockInputDevice() {
|
||||
sources: ['[PC preview] unknow sources'],
|
||||
axisRanges: [AxisRange]
|
||||
}
|
||||
const KeyboardType = {
|
||||
NONE: 0,
|
||||
UNKNOWN: 1,
|
||||
ALPHABETIC_KEYBOARD: 2,
|
||||
DIGITAL_KEYBOARD: 3,
|
||||
HANDWRITING_PEN: 4,
|
||||
REMOTE_CONTROL: 5,
|
||||
}
|
||||
|
||||
const EventType = ['change']
|
||||
const DeviceIds = [0, 1, 2, 3, 4]
|
||||
const GetKeyboardType = 3
|
||||
const inputDevice = {
|
||||
KeyboardType,
|
||||
on: function (...args) {
|
||||
console.warn("inputDevice.on interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 const Action = {
|
||||
CANCEL: 0,
|
||||
DOWN: 1,
|
||||
UP: 2,
|
||||
}
|
||||
|
||||
export function mockKeyEvent() {
|
||||
const keyEvent = {
|
||||
Action,
|
||||
}
|
||||
return keyEvent;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 const Action = {
|
||||
CANCEL: 0,
|
||||
MOVE: 1,
|
||||
BUTTON_DOWN: 2,
|
||||
BUTTON_UP: 3,
|
||||
AXIS_BEGIN: 4,
|
||||
AXIS_UPDATE: 5,
|
||||
AXIS_END: 6,
|
||||
}
|
||||
|
||||
export const Button = {
|
||||
LEFT: 0,
|
||||
MIDDLE: 1,
|
||||
RIGHT: 2,
|
||||
SIDE: 3,
|
||||
EXTRA: 4,
|
||||
FORWARD: 5,
|
||||
BACK: 6,
|
||||
TASK: 7,
|
||||
}
|
||||
|
||||
export const Axis = {
|
||||
SCROLL_VERTICAL: 0,
|
||||
SCROLL_HORIZONTAL: 1,
|
||||
PINCH: 2,
|
||||
}
|
||||
|
||||
export function mockMouseEvent() {
|
||||
const mouseEvent = {
|
||||
Action,
|
||||
Button,
|
||||
Axis,
|
||||
}
|
||||
return mouseEvent;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 const Action = {
|
||||
CANCEL: 0,
|
||||
DOWN: 1,
|
||||
MOVE: 2,
|
||||
UP: 3,
|
||||
}
|
||||
|
||||
export const ToolType = {
|
||||
FINGER: 0,
|
||||
PEN: 1,
|
||||
RUBBER: 2,
|
||||
BRUSH: 3,
|
||||
PENCIL: 4,
|
||||
AIRBRUSH: 5,
|
||||
MOUSE: 6,
|
||||
LENS: 7,
|
||||
}
|
||||
|
||||
export const SourceType = {
|
||||
TOUCH_SCREEN: 0,
|
||||
PEN: 1,
|
||||
TOUCH_PAD: 2,
|
||||
}
|
||||
|
||||
export function mockTouchEvent() {
|
||||
const touchEvent = {
|
||||
Action,
|
||||
ToolType,
|
||||
SourceType,
|
||||
}
|
||||
return touchEvent;
|
||||
}
|
||||
Reference in New Issue
Block a user