diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index 0557902c4d01798b03f5c69a0c6b7e8b3819c058..4945fc6bc97be2a66dbf825d9d0551e82d3a416e 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 a870129857cdb9d702652eed61a53df710d8a8f1..9928e18785595e39d36464cc3eadcc5e486cfa29 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 beb38afa388c24f9a61f82422e8905a374547823..5c1ea194ad617020f287dd9d345a8df94e061cd1 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); + }); + }); };