From 85fbdd11fd449bade7f764c8f7857e4503f01397 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Sat, 16 Jul 2022 18:57:41 +0800 Subject: [PATCH 1/3] Signed-off-by: ma-shaoyin Changes to be committed: --- .../napi/ohos_inputmethodengine.js | 70 +++++++++---------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index a228bda6..f7d6c51a 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021 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 @@ -15,36 +15,6 @@ import { paramMock } from "../utils" -const NOTIFY = "[PC Preview] unknow" -const Properties = [ - 'ENTER_KEY_TYPE_NEXT', - 'ENTER_KEY_TYPE_PREVIOUS', - 'ENTER_KEY_TYPE_UNSPECIFIED', - 'ENTER_KEY_TYPE_SEARCH', - 'ENTER_KEY_TYPE_GO', - 'ENTER_KEY_TYPE_SEND', - 'ENTER_KEY_TYPE_DONE', - 'DISPLAY_MODE_PART', - 'DISPLAY_MODE_FULL', - 'OPTION_AUTO_CAP_CHARACTERS', - 'OPTION_AUTO_CAP_WORDS', - 'OPTION_AUTO_CAP_SENTENCES', - 'OPTION_NO_FULLSCREEN', - 'OPTION_ASCII', - 'OPTION_NONE', - 'OPTION_MULTI_LINE', - 'FLAG_SINGLE_LINE', - 'FLAG_SELECTING', - 'PATTERN_TEXT', - 'PATTERN_NUMBER', - 'PATTERN_NULL', - 'PATTERN_PHONE', - 'PATTERN_DATETIME', - 'PATTERN_URI', - 'PATTERN_EMAIL', - 'PATTERN_PASSWORD' -] - export function mockInputMethodEngine() { const EditingText = { textContent: "[PC Preview] unknow textContent", @@ -65,6 +35,10 @@ export function mockInputMethodEngine() { enterKeyType: 2, inputOption: 3 } + const KeyEvent = { + keyCode: 1, + keyAction: 2, + } const RichContent = { contentURI: "[PC Preview] unknow contentURI", linkURI: "[PC Preview] unknow linkURI", @@ -376,7 +350,7 @@ export function mockInputMethodEngine() { const len = args.length if (typeof args[len - 1] === 'function') { if (args[0] == 'keyDown' || args[0] == 'keyUp') { - args[len - 1].call(this, paramMock.paramObjectMock); + args[len - 1].call(this, KeyEvent); } else if (args[0] == 'selectionChange') { args[len - 1].call(this, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock, paramMock.paramNumberMock); } else if (args[0] == 'cursorContextChange') { @@ -413,11 +387,33 @@ export function mockInputMethodEngine() { console.warn("inputMethodEngine.createKeyboardDelegate interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return KeyboardDelegateMock; - } - } - - for (let Property of Properties) { - inputMethodEngine[Property] = NOTIFY + " " + Property + }, + ENTER_KEY_TYPE_UNSPECIFIED: "[PC Preview] unknow ENTER_KEY_TYPE_UNSPECIFIED", + ENTER_KEY_TYPE_GO: "[PC Preview] unknow ENTER_KEY_TYPE_GO", + ENTER_KEY_TYPE_SEARCH: "[PC Preview] unknow ENTER_KEY_TYPE_SEARCH", + ENTER_KEY_TYPE_SEND: "[PC Preview] unknow ENTER_KEY_TYPE_SEND", + ENTER_KEY_TYPE_NEXT: "[PC Preview] unknow ENTER_KEY_TYPE_NEXT", + ENTER_KEY_TYPE_DONE: "[PC Preview] unknow ENTER_KEY_TYPE_DONE", + ENTER_KEY_TYPE_PREVIOUS: "[PC Preview] unknow ENTER_KEY_TYPE_PREVIOUS", + PATTERN_NULL: "[PC Preview] unknow PATTERN_NULL", + PATTERN_TEXT: "[PC Preview] unknow PATTERN_TEXT", + PATTERN_NUMBER: "[PC Preview] unknow PATTERN_NUMBER", + PATTERN_PHONE: "[PC Preview] unknow PATTERN_PHONE", + PATTERN_DATETIME: "[PC Preview] unknow PATTERN_DATETIME", + PATTERN_EMAIL: "[PC Preview] unknow PATTERN_EMAIL", + PATTERN_URI: "[PC Preview] unknow PATTERN_URI", + PATTERN_PASSWORD: "[PC Preview] unknow PATTERN_PASSWORD", + FLAG_SELECTING: "[PC Preview] unknow FLAG_SELECTING", + FLAG_SINGLE_LINE: "[PC Preview] unknow FLAG_SINGLE_LINE", + DISPLAY_MODE_PART: "[PC Preview] unknow DISPLAY_MODE_PART", + DISPLAY_MODE_FULL: "[PC Preview] unknow DISPLAY_MODE_FULL", + OPTION_ASCII: "[PC Preview] unknow OPTION_ASCII", + OPTION_NONE: "[PC Preview] unknow OPTION_NONE", + OPTION_AUTO_CAP_CHARACTERS: "[PC Preview] unknow OPTION_AUTO_CAP_CHARACTERS", + OPTION_AUTO_CAP_SENTENCES: "[PC Preview] unknow OPTION_AUTO_CAP_SENTENCES", + OPTION_AUTO_WORDS: "[PC Preview] unknow OPTION_AUTO_WORDS", + OPTION_MULTI_LINE: "[PC Preview] unknow OPTION_MULTI_LINE", + OPTION_NO_FULLSCREEN: "[PC Preview] unknow OPTION_NO_FULLSCREEN" } return inputMethodEngine } \ No newline at end of file From 0fedb57c65b1559979be566e16ea4ac08c348251 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Mon, 18 Jul 2022 15:57:56 +0800 Subject: [PATCH 2/3] Signed-off-by: ma-shaoyin Changes to be committed: --- .../main/extend/systemplugin/napi/ohos_inputmethodengine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js index f7d6c51a..d7722b82 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethodengine.js @@ -36,8 +36,8 @@ export function mockInputMethodEngine() { inputOption: 3 } const KeyEvent = { - keyCode: 1, - keyAction: 2, + keyCode: "[PC Preview] unknow keyCode", + keyAction: "[PC Preview] unknow keyAction" } const RichContent = { contentURI: "[PC Preview] unknow contentURI", From 9bf9e82f8357c07596ab7a1d71f30fbc79fb1525 Mon Sep 17 00:00:00 2001 From: ma-shaoyin Date: Tue, 19 Jul 2022 09:02:42 +0800 Subject: [PATCH 3/3] Signed-off-by: ma-shaoyin Changes to be committed: --- .../systemplugin/napi/ohos_inputmethod.js | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js index dfb840e4..4596334c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js +++ b/runtime/main/extend/systemplugin/napi/ohos_inputmethod.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021 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 @@ -39,14 +39,8 @@ export function mockInputMethod() { } ] const InputMethodProperty = { - methodId: "[PC Preview] unknow method id", - bundleName: "[PC Preview] unknow bundle name", - abilityName: "[PC Preview] unknow ability name", - configurationPage: "[PC Preview] unknow configuration page", - isSystemIme: true, - typeCount: 1, - defaultImeId: 2, - keyboardTypes: KeyboardTypeArry + packageName :"[PC Preview] unknow packageName", + methodId: "[PC Preview] unknow method id" } const InputMethodPropertyArry = [ { @@ -137,7 +131,7 @@ export function mockInputMethod() { }, } const inputMethod = { - MAX_TYPE_MUN: 128, + MAX_TYPE_NUM: 128, getInputMethodController: function () { console.warn("inputmethod.getInputMethodController interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") @@ -147,7 +141,24 @@ export function mockInputMethod() { console.warn("inputmethod.getInputMethodSetting interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") return InputMethodSettingMock; - } + }, + getCurrentInputMethod: function () { + console.warn("inputmethod.getCurrentInputMethod interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return InputMethodProperty; + }, + switchInputMethod: function (...args) { + console.warn("inputMethod.switchInputMethod 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, } return inputMethod } \ No newline at end of file