From 8aea518b9264c7a83e872fb0b4b8a0f4bf639a4f Mon Sep 17 00:00:00 2001 From: zhangyushuai Date: Tue, 6 Jun 2023 08:31:10 +0000 Subject: [PATCH] =?UTF-8?q?=E8=A6=86=E7=9B=96input=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=92=8C=E6=8E=A5=E5=8F=A3=20=20001?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangyushuai --- .../InputMethodEngine/KeyboardController.ts | 8 +- .../main/ets/test/inputMethodAbility.test.ets | 1 + .../main/ets/test/inputMethodStageJSUnit.ets | 83 +++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index 0557902c4..4945fc6bc 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts @@ -305,7 +305,7 @@ export class KeyboardController { } else { let editorAttribyte = await InputClient.getEditorAttribute(); console.debug(TAG + '====>inputMethodEngine_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte)); - let value = await InputClient.sendKeyFunction(editorAttribyte.enterKeyType); + let value = await InputClient.sendKeyFunction(editorAttribyte.inputPattern); console.debug(TAG + '====>inputMethodEngine_test_029 sendKeyFunction:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -867,7 +867,8 @@ export class KeyboardController { inputKeyboardDelegate.on('keyDown', (keyEvent) => { inputKeyboardDelegate.off('keyDown'); console.info(TAG + "====>inputKeyboardDelegate.on('keyDown') count: " + count); - if (keyEvent.keyCode === 2000){ + console.info(TAG + "====>inputKeyboardDelegate.keyEvent.keyAction " + keyEvent.keyAction); + if (keyEvent.keyCode === 2000 && keyEvent.keyAction === 2){ count += 1; } return true; @@ -875,7 +876,8 @@ export class KeyboardController { inputKeyboardDelegate.on('keyUp', (keyEvent) => { inputKeyboardDelegate.off('keyUp'); console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count); - if (keyEvent.keyCode === 2000){ + console.info(TAG + "====>inputKeyboardDelegate.keyEvent.keyAction " + keyEvent.keyAction); + if (keyEvent.keyCode === 2000 && keyEvent.keyAction === 3){ count += 1; } return true; diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets index a87012985..9928e1878 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets @@ -1878,5 +1878,6 @@ export default function inputMethodAbility() { } commonEventManager.publish('test', commonEventPublishData, publishCallback); }); + }); }; diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets index beb38afa3..5c1ea194a 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets @@ -19,6 +19,31 @@ import subtype from '@ohos.InputMethodSubtype'; export default function inputMethodStageJSUnit() { describe('inputMethodTest', function () { console.info("====>************* settings Test start*************"); + var inputServer = { + packageName: '', + methodId: '', + name:'', + id:'', + extra:{} + } + + var inputServerCopy = { + packageName : "com.acts.imeability.test", + methodId : "com.acts.imeability.test.ImExtAbility", + name:"com.acts.imeability.test", + id:"com.acts.imeability.test.ImExtAbility", + extra:{} + } + + beforeAll(async (done)=>{ + let inputM = inputMethod.getCurrentInputMethod() + console.info("====>beforeAll: switchInputMethod to: " + JSON.stringify(inputM)); + inputServer.packageName = inputM.packageName; + inputServer.methodId = inputM.methodId; + inputServer.name = inputM.packageName; + inputServer.id = inputM.methodId; + }) + /* * @tc.number inputMethod_test_getController_001 * @tc.name get inputMethod controller @@ -608,5 +633,63 @@ export default function inputMethodStageJSUnit() { }) }); + it('Sub_Misc_inputMethod_onImeChange_0150', 0, async function (done) { + let inputMethodSetting = inputMethod.getSetting(); + inputMethodSetting.on("imeChange", async (inputMethodProperty, inputMethodSubtype) => { + inputMethodSetting.off("imeChange"); + let t = setTimeout(async () => { + clearTimeout(t); + await inputMethod.switchInputMethod(inputServer); + console.info("====>Sub_Misc_inputMethod_onImeChange_0150 inputMethodProperty:" + JSON.stringify(inputServerCopy)); + console.info("====>Sub_Misc_inputMethod_onImeChange_0150 inputMethodSubtype:" + JSON.stringify(inputMethodSubtype)); + expect(typeof(inputMethodProperty) !== null).assertTrue(); + expect(typeof(inputMethodSubtype) !== null).assertTrue(); + done(); + },200); + }) + try { + await inputMethod.switchInputMethod(inputServerCopy); + console.info("====>Sub_Misc_inputMethod_onImeChange_0150 switchInputMethod success" + JSON.stringify(inputServer)); + } catch (err) { + console.info("====>Sub_Misc_inputMethod_onImeChange_0150 switchInputMethod fail" + JSON.stringify(err)); + } + }); + + it('Sub_Misc_inputMethod_offImeChange_0160', 0, async function (done) { + let count = 0; + let inputMethodSetting = inputMethod.getSetting(); + inputMethodSetting.on("imeChange", (inputMethodProperty, inputMethodSubtype) => { + inputMethodSetting.off("imeChange"); + count += 1; + console.info("====>Sub_Misc_inputMethod_offImeChange_0160 count:" + count); + }) + + try { + console.info('====>Sub_Misc_inputMethod_offImeChange_0160 switchInputMethod 001'); + let t = setTimeout(async () => { + clearTimeout(t); + await inputMethod.switchInputMethod(inputServerCopy); + },200); + console.info('====>Sub_Misc_inputMethod_offImeChange_0160 switchInputMethod 002'); + let t1 = setTimeout(async () => { + clearTimeout(t1); + await inputMethod.switchInputMethod(inputServer); + },200); + } catch (err) { + console.info("====>Sub_Misc_inputMethod_offImeChange_0160 switchInputMethod fail" + JSON.stringify(err)); + } + + let t = setTimeout(() => { + clearTimeout(t); + try { + console.info('====>Sub_Misc_inputMethod_offImeChange_0160 setTimeout count: ' + count); + expect(count === 1).assertTrue(); + } catch (err) { + console.info("====>Sub_Misc_inputMethod_offImeChange_0160 switchInputMethod fail" + JSON.stringify(err)); + } + done(); + },1000); + }); + }); }; -- GitLab