diff --git a/inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets b/inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets index f643cb857dfb8891a6941d5bb3ae2f8e7d22a06b..04c7c981da73d832bb4d7711e3168449bcde2919 100644 --- a/inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets +++ b/inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets @@ -201,6 +201,7 @@ export default function inputMethodAuthorityJSUnit() { name:inputM.packageName, id:inputM.methodId, label: "", + labelId: 123, icon: "", iconId: 124, extra:{} @@ -210,6 +211,7 @@ export default function inputMethodAuthorityJSUnit() { let inputMethodSubProperty : subtype = { id: inputMS.id, label: "", + labelId: 123, name: inputMS.name, mode: "lower", locale: "", @@ -253,6 +255,7 @@ export default function inputMethodAuthorityJSUnit() { name:inputM.packageName, id:inputM.methodId, label: "", + labelId: 123, icon: "", iconId: 124, extra:{} @@ -262,6 +265,7 @@ export default function inputMethodAuthorityJSUnit() { let inputMethodSubProperty : subtype = { id: inputMS.id, label: "", + labelId: 123, name: inputMS.name, mode: "lower", locale: "", @@ -302,6 +306,7 @@ export default function inputMethodAuthorityJSUnit() { let inputMethodSubProperty : subtype = { id: inputMS.id, label: "", + labelId: 123, name: inputMS.name, mode: "lower", locale: "", @@ -342,6 +347,7 @@ export default function inputMethodAuthorityJSUnit() { let inputMethodSubProperty : subtype = { id: inputMS.id, label: "", + labelId: 123, name: inputMS.name, mode: "lower", locale: "", diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts index 14d4f356d55496bd8f08af3046b32f2bd63fd14f..a126b26376a87d7f1b1daded37bc39a7acddd15c 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts @@ -25,5 +25,6 @@ export default class InputDemoService extends InputMethodExtensionAbility { onDestroy() { console.log("onDestroy inputStageService**"); + this.keyboardDelegate.onDestroy(); } } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts index dbed7ee64fd72e4a849559cc43c11409c6a79332..fe3f4c1348c477d215e0cadf13c0ccf95fe752b7 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts @@ -35,22 +35,21 @@ export class KeyboardDelegate { this.mContext = context; } + private onInputStop() { + try{ + this.mContext.destroy((err) => { + console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); + }) + }catch(err){ + console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err)); + } + } + public onCreate(): void { this.initWindow(); let that = this; - inputMethodAbility.on("inputStop", () => { - inputMethodAbility.off("inputStop", () => { - console.log('====>inputMethodEngine delete inputStop notification.'); - }); - try{ - that.mContext.destroy((err) => { - console.info(TAG + '====>inputMethodAbility destroy err:' + JSON.stringify(err)); - }) - }catch(err){ - console.info(TAG + '====>inputMethodAbility destroy catch err:' + JSON.stringify(err)); - console.info(TAG + '====>inputMethodAbility destroy catch err:' + err); - } - }) + this.onInputStop = this.onInputStop.bind(this) + inputMethodAbility.on('inputStop', this.onInputStop) function subscriberCallback(err, data) { console.debug(TAG + '====>receive event err:' + JSON.stringify(err)); @@ -172,6 +171,10 @@ export class KeyboardDelegate { console.debug(TAG + '====>inputMethodAbility_test_074 event:' + data.event); that.inputMethodAbility_test_074(); break; + case 91: + console.debug(TAG + '====>inputMethodAbility_test_091 event:' + data.event); + that.inputMethodAbility_test_091(); + break; case 101: console.debug(TAG + '====>inputMethodAbility_test_0101 event:' + data.event); that.inputMethodAbility_test_101(); @@ -255,16 +258,8 @@ export class KeyboardDelegate { public onDestroy(): void { console.debug(TAG + '====>onDestroy'); - globalThis.textInputClient.getTextIndexAtCursor().then((index) => { - console.debug(TAG + '====>getTextIndexAtCursor index:' + index); - promptAction.showToast({ message: 'getTextIndexAtCursor success' + index, duration: 200, bottom: 500 }); - var win = windowManager.findWindow(this.windowName); - win.destroyWindow(); - this.mContext.terminateSelf(); - return true; - }).catch((err) => { - promptAction.showToast({ message: 'getTextIndexAtCursor failed', duration: 200, bottom: 500 }); - }); + inputMethodAbility.off('inputStop', this.onInputStop) + } private publishCallback(err): void { @@ -275,6 +270,25 @@ export class KeyboardDelegate { } } + public async offInputStop_test() { + console.info(TAG + '====>inputMethodAbility_test_091.offInputStop_test callback'); + let commonEventPublishData = { + data: "FAILED" + }; + this.mContext.destroy((err) => { + console.info(TAG + '====>inputMethodAbility offInputStop_test destroy err: ' + JSON.stringify(err)); + commoneventmanager.publish("inputMethodAbility_test_091", commonEventPublishData,() => {}); + }) + } + + public inputMethodAbility_test_091(): void{ + console.info(TAG + '====>inputMethodAbility_test_091 start'); + this.offInputStop_test = this.offInputStop_test.bind(this); + inputMethodAbility.on("inputStop",this.offInputStop_test); + inputMethodAbility.off("inputStop",this.offInputStop_test); + console.info(TAG + '====>inputMethodAbility_test_091 end'); + } + private inputMethodAbility_test_getInputMethodAbility_001(): void { console.debug(TAG + '====>receive inputMethodAbility_test_getInputMethodAbility_001 data'); if (typeof(inputMethodAbility) === 'object') { diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index a935337c25f1c488d40ed3a24a1be1986eec2cbe..c735de848de932db700c4240f90532218a7b7131 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts @@ -294,18 +294,18 @@ export class KeyboardController { } private inputMethodEngine_test_029(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_029 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_029", commonEventPublishData, this.publishCallback); } else { - let editorAttribyte = await InputClient.getEditorAttribute(); + let editorAttribyte = await TextInputClient.getEditorAttribute(); console.debug(TAG + '====>inputMethodEngine_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte)); - let value = await InputClient.sendKeyFunction(editorAttribyte.enterKeyType); + let value = await TextInputClient.sendKeyFunction(editorAttribyte.inputPattern); console.debug(TAG + '====>inputMethodEngine_test_029 sendKeyFunction:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -323,16 +323,16 @@ export class KeyboardController { private inputMethodEngine_test_030(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_030 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_030", commonEventPublishData, this.publishCallback); } else { - InputClient.deleteForward(1, (err, value) => { + TextInputClient.deleteForward(1, (err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_030 deleteForward err:' + JSON.stringify(err)); commonEventPublishData = { @@ -357,16 +357,16 @@ export class KeyboardController { } private inputMethodEngine_test_031(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_031 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_031", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.deleteForward(1); + let value = await TextInputClient.deleteForward(1); console.debug(TAG + '====>inputMethodEngine_test_031 deleteForward:' + JSON.stringify(value)); if (typeof(value) === 'boolean'){ commonEventPublishData = { @@ -384,16 +384,16 @@ export class KeyboardController { private inputMethodEngine_test_032(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_032 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_032", commonEventPublishData, this.publishCallback); } else { - InputClient.deleteBackward(1, (err, value) => { + TextInputClient.deleteBackward(1, (err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_032 deleteBackward err:' + JSON.stringify(err)); commonEventPublishData = { @@ -418,16 +418,16 @@ export class KeyboardController { } private inputMethodEngine_test_033(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_033 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_033", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.deleteBackward(1); + let value = await TextInputClient.deleteBackward(1); console.debug(TAG + '====>inputMethodEngine_test_033 deleteBackward:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -445,16 +445,16 @@ export class KeyboardController { private inputMethodEngine_test_034(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_034 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_034", commonEventPublishData, this.publishCallback); } else { - InputClient.insertText('test', (err, value) => { + TextInputClient.insertText('test', (err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_034 insertText err:' + JSON.stringify(err)); commonEventPublishData = { @@ -479,16 +479,16 @@ export class KeyboardController { } private inputMethodEngine_test_035(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_035 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_035", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.insertText('test'); + let value = await TextInputClient.insertText('test'); console.debug(TAG + '====>inputMethodEngine_test_035 insertText:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -506,16 +506,16 @@ export class KeyboardController { private inputMethodEngine_test_036(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_036 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_036", commonEventPublishData, this.publishCallback); } else { - InputClient.getForward(1, (err, value) => { + TextInputClient.getForward(1, (err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_036 getForward err:' + JSON.stringify(err)); commonEventPublishData = { @@ -540,16 +540,16 @@ export class KeyboardController { } private inputMethodEngine_test_037(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_037 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_037", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.getForward(1); + let value = await TextInputClient.getForward(1); console.debug(TAG + '====>inputMethodEngine_test_037 getForward:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -567,16 +567,16 @@ export class KeyboardController { private inputMethodEngine_test_038(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_038 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_038", commonEventPublishData, this.publishCallback); } else { - InputClient.getEditorAttribute((err, value) => { + TextInputClient.getEditorAttribute((err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_038 getEditorAttribute err:' + JSON.stringify(err)); commonEventPublishData = { @@ -601,16 +601,16 @@ export class KeyboardController { } private inputMethodEngine_test_039(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_039 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_039", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.getEditorAttribute(); + let value = await TextInputClient.getEditorAttribute(); console.debug(TAG + '====>inputMethodEngine_test_039 getEditorAttribute:' + JSON.stringify(value)); if (value){ commonEventPublishData = { @@ -628,17 +628,17 @@ export class KeyboardController { private inputMethodEngine_test_040(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_040 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_040", commonEventPublishData, this.publishCallback); } else { try{ - KeyboardDelegate.hideKeyboard((err, value) => { + keyboardController.hideKeyboard((err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_040 hideKeyboard:' + JSON.stringify(err)); commonEventPublishData = { @@ -663,17 +663,17 @@ export class KeyboardController { } private inputMethodEngine_test_041(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_041 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_041", commonEventPublishData, this.publishCallback); } else { try{ - await KeyboardDelegate.hideKeyboard(); + await keyboardController.hideKeyboard(); console.debug(TAG + '====>inputMethodEngine_test_041 hideKeyboard success'); commonEventPublishData = { data: "SUCCESS" @@ -691,16 +691,16 @@ export class KeyboardController { private inputMethodEngine_test_042(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_042 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_042", commonEventPublishData, this.publishCallback); } else { - InputClient.getBackward(1, (err, value) => { + TextInputClient.getBackward(1, (err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_042 getBackward err:' + JSON.stringify(err)); commonEventPublishData = { @@ -719,16 +719,16 @@ export class KeyboardController { } private inputMethodEngine_test_043(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_043 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_043", commonEventPublishData, this.publishCallback); } else { - let value = await InputClient.getBackward(1); + let value = await TextInputClient.getBackward(1); console.debug(TAG + '====>inputMethodEngine_test_043 getBackward:' + JSON.stringify(value)); commonEventPublishData = { data: "SUCCESS" @@ -740,17 +740,17 @@ export class KeyboardController { private inputMethodEngine_test_049(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_049 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_049", commonEventPublishData, this.publishCallback); } else { try{ - KeyboardDelegate.hide((err, value) => { + keyboardController.hide((err, value) => { if (err){ console.debug(TAG + '====>inputMethodEngine_test_049 hide:' + JSON.stringify(err)); commonEventPublishData = { @@ -775,17 +775,17 @@ export class KeyboardController { } private inputMethodEngine_test_050(): void{ console.debug(TAG + '====>receive inputMethodEngine_test_050 data'); - inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{ + inputMethodEngine.on('inputStart', async(keyboardController, TextInputClient) =>{ inputMethodEngine.off('inputStart'); let commonEventPublishData; - if (InputClient == null) { + if (TextInputClient == null) { commonEventPublishData = { data: "FAILED" }; commoneventmanager.publish("inputMethodEngine_test_050", commonEventPublishData, this.publishCallback); } else { try{ - await KeyboardDelegate.hide(); + await keyboardController.hide(); console.debug(TAG + '====>inputMethodEngine_test_050 hideKeyboard success'); commonEventPublishData = { data: "SUCCESS" @@ -812,12 +812,12 @@ export class KeyboardController { inputMethodEngine.off("keyboardHide"); console.info(TAG + '====>inputMethodEngine.off("keyboardHide") count: ' + count); }); - inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => { + inputMethodEngine.on('inputStart', (keyboardController, TextInputClient) => { inputMethodEngine.off('inputStart'); console.info(TAG + '====>inputMethodEngine_test_071 inputMethodEngine.on("inputStart")'); let t = setInterval(async () => { - await KeyboardDelegate.hideKeyboard(); - console.info(TAG + '====>KeyboardDelegate.hideKeyboard count: ' + count); + await keyboardController.hideKeyboard(); + console.info(TAG + '====>keyboardController.hideKeyboard count: ' + count); if(count === 1){ clearInterval(t); } @@ -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; @@ -903,12 +905,12 @@ export class KeyboardController { count += 1; console.info(TAG + '====>inputMethodEngine_test_074 x,y,z: ' + x + "---" + y + "---" + h); }); - inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => { + inputMethodEngine.on('inputStart', (keyboardController, TextInputClient) => { inputMethodEngine.off('inputStart'); console.info(TAG + '====>inputMethodEngine_test_074 inputMethodEngine.on("inputStart")'); let t = setInterval(async () => { - await InputClient.insertText("ttt"); - console.info(TAG + '====>KeyboardDelegate.insertText count: ' + count); + await TextInputClient.insertText("ttt"); + console.info(TAG + '====>keyboardController.insertText count: ' + count); if(count === 2){ clearInterval(t); } @@ -959,12 +961,12 @@ export class KeyboardController { count += 1; console.info(TAG + '====>inputMethodEngine_test_077 text: ' + text); }); - inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => { + inputMethodEngine.on('inputStart', (keyboardController, TextInputClient) => { inputMethodEngine.off('inputStart'); console.info(TAG + '====>inputMethodEngine_test_077 inputMethodEngine.on("inputStart")'); let t = setInterval(async () => { - await InputClient.insertText("tttt"); - console.info(TAG + '====>KeyboardDelegate.insertText count: ' + count); + await TextInputClient.insertText("tttt"); + console.info(TAG + '====>keyboardController.insertText count: ' + count); if(count === 2){ clearInterval(t); } @@ -978,7 +980,7 @@ export class KeyboardController { } commoneventmanager.publish("inputMethodEngine_test_077", commonEventPublishData, this.publishCallback); clearTimeout(t); - },500); + },1000); } } \ No newline at end of file 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 42817b2264d397eea6c65c9b566d4a9ae40de4ab..06a57c6805f6fa2fc5261168912069ace66f498f 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets @@ -42,6 +42,7 @@ export default function inputMethodAbility() { let getFocusCmd = ''; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let inputMethodController = inputMethod.getController(); + let inputDemoService: subtype; async function runCmd(cmd){ console.debug('====>runCmd info:' + cmd); await abilityDelegator.executeShellCommand(cmd); @@ -279,6 +280,22 @@ export default function inputMethodAbility() { done(); }); + it('Sub_Misc_inputMethodEngine_ExtendAction_0100', 0, async function (done) { + let select_all = inputMethodEngine.ExtendAction.SELECT_ALL; + console.info("====>Sub_Misc_inputMethodEngine_ExtendAction_0100 select_all:" + select_all); + expect(select_all).assertEqual(0); + let cut = inputMethodEngine.ExtendAction.CUT; + console.info("====>Sub_Misc_inputMethodEngine_ExtendAction_0100 cut:" + cut); + expect(cut).assertEqual(3); + let copy = inputMethodEngine.ExtendAction.COPY; + console.info("====>Sub_Misc_inputMethodEngine_ExtendAction_0100 copy:" + copy); + expect(copy).assertEqual(4); + let paste = inputMethodEngine.ExtendAction.PASTE; + console.info("====>Sub_Misc_inputMethodEngine_ExtendAction_0100 paste:" + paste); + expect(paste).assertEqual(5); + done(); + }); + it('inputMethodAbility_test_getInputMethodAbility_001', 0, async function (done) { function unSubscriberCallback (err){ console.info("====>inputMethodAbility_test_getInputMethodAbility_001 unSubscriberCallback start"); @@ -2469,8 +2486,9 @@ export default function inputMethodAbility() { it('Sub_Misc_inputMethod_onImeChange_0150', 0, async function (done) { let inputMethodSetting = inputMethod.getSetting(); - inputMethodSetting.on("imeChange", (inputMethodProperty, inputMethodSubtype) => { + inputMethodSetting.on("imeChange", async (inputMethodProperty, inputMethodSubtype) => { inputMethodSetting.off("imeChange"); + await inputMethod.switchInputMethod(inputServerCopy); console.info("====>Sub_Misc_inputMethod_onImeChange_0150 inputMethodProperty:" + JSON.stringify(inputMethodProperty)); console.info("====>Sub_Misc_inputMethod_onImeChange_0150 inputMethodSubtype:" + JSON.stringify(inputMethodSubtype)); expect(typeof(inputMethodProperty) !== null).assertTrue(); @@ -2480,7 +2498,6 @@ export default function inputMethodAbility() { try { await inputMethod.switchInputMethod(inputServer); console.info("====>Sub_Misc_inputMethod_onImeChange_0150 switchInputMethod success" + JSON.stringify(inputServer)); - await inputMethod.switchInputMethod(inputServerCopy); } catch (err) { console.info("====>Sub_Misc_inputMethod_onImeChange_0150 switchInputMethod fail" + JSON.stringify(err)); } @@ -2518,5 +2535,60 @@ export default function inputMethodAbility() { },500); }); + it('inputMethodAbility_test_091', 0, async function (done) { + let flag = true; + function unSubscriberCallback (err){ + console.info("====>inputMethodAbility_test_091 unSubscriberCallback start"); + if (err){ + console.info("====>inputMethodAbility_test_091 unSubscriberCallback failed:" + + JSON.stringify(err)); + } else { + console.info("====>inputMethodAbility_test_091 unSubscriberCallback finish"); + } + } + + function subscriberCallback (err, data){ + console.info("====>inputMethodAbility_test_091 subscriberCallback data:" + JSON.stringify(data)); + commonEventManager.unsubscribe(subscriber, unSubscriberCallback); + flag = false; + } + + function publishCallback(err){ + console.info("====>inputMethodAbility_test_091 publishCallback start"); + if (err){ + console.info("====>inputMethodAbility_test_091 publishCallback failed:" + JSON.stringify(err)); + } else { + let t = setTimeout(async () => { + await inputMethod.switchInputMethod(inputServer); + console.info("====>inputMethodAbility_test_091 setTimeout first"); + let t1 = setTimeout(async () => { + done(); + console.info("====>inputMethodAbility_test_091 setTimeout second: " + flag); + expect(flag).assertTrue(); + clearTimeout(t1); + await inputMethod.switchCurrentInputMethodSubtype(inputDemoService); + },1000) + clearTimeout(t); + }, 1000) + } + } + + var commonEventSubscribeInfo = { + events: ["inputMethodAbility_test_091"] + } + var subscriber; + commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{ + subscriber = data; + console.info("====>inputMethodAbility_test_091 subscriber data:" + JSON.stringify(data)); + commonEventManager.subscribe(subscriber, subscriberCallback); + console.info("====>inputMethodAbility_test_091 subscriber finish"); + }) + + var commonEventPublishData = { + code: 91 + } + commonEventManager.publish('test', commonEventPublishData, publishCallback); + }); + }); }; diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.test.ets index 89536284064cb21adb21a1cb89d64bdf1dec26c2..10b1f054e77e2e4a558f74952f912e41a3ef91a6 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.test.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.test.ets @@ -425,5 +425,109 @@ export default function inputMethodStageJSUnit() { }) }); + it('Sub_Misc_inputMethod_TextInputType_0100', 0, async function (done) { + let none = inputMethod.TextInputType.NONE; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 none:" + none); + expect(none).assertEqual(-1); + let test = inputMethod.TextInputType.TEXT; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 test:" + test); + expect(test).assertEqual(0); + let nultiline = inputMethod.TextInputType.MULTILINE; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 nultiline:" + nultiline); + expect(nultiline).assertEqual(1); + let number = inputMethod.TextInputType.NUMBER; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 number:" + number); + expect(number).assertEqual(2); + let phone = inputMethod.TextInputType.PHONE; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 phone:" + phone); + expect(phone).assertEqual(3); + let datetime = inputMethod.TextInputType.DATETIME; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 datetime:" + datetime); + expect(datetime).assertEqual(4); + let email_addres = inputMethod.TextInputType.EMAIL_ADDRESS; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 email_addres:" + email_addres); + expect(email_addres).assertEqual(5); + let url = inputMethod.TextInputType.URL; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 url:" + url); + expect(url).assertEqual(6); + let visble_password = inputMethod.TextInputType.VISIBLE_PASSWORD; + console.info("====>Sub_Misc_inputMethod_TextInputType_0100 visble_password:" + visble_password); + expect(visble_password).assertEqual(7); + done(); + }); + + it('Sub_Misc_inputMethod_EnterKeyType_0100', 0, async function (done) { + let unspecified = inputMethod.EnterKeyType.UNSPECIFIED; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 unspecified:" + unspecified); + expect(unspecified).assertEqual(0); + let none = inputMethod.EnterKeyType.NONE; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 none:" + none); + expect(none).assertEqual(1); + let go = inputMethod.EnterKeyType.GO; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 go:" + go); + expect(go).assertEqual(2); + let search = inputMethod.EnterKeyType.SEARCH; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 search:" + search); + expect(search).assertEqual(3); + let send = inputMethod.EnterKeyType.SEND; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 send:" + send); + expect(send).assertEqual(4); + let next = inputMethod.EnterKeyType.NEXT; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 next:" + next); + expect(next).assertEqual(5); + let done_ = inputMethod.EnterKeyType.DONE; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 done_:" + done_); + expect(done_).assertEqual(6); + let previous = inputMethod.EnterKeyType.PREVIOUS; + console.info("====>Sub_Misc_inputMethod_EnterKeyType_0100 previous:" + previous); + expect(previous).assertEqual(7); + done(); + }); + + it('Sub_Misc_inputMethod_KeyboardStatus_0100', 0, async function (done) { + let none = inputMethod.KeyboardStatus.NONE; + console.info("====>Sub_Misc_inputMethod_KeyboardStatus_0100 none:" + none); + expect(none).assertEqual(0); + let hide = inputMethod.KeyboardStatus.HIDE; + console.info("====>Sub_Misc_inputMethod_KeyboardStatus_0100 hide:" + hide); + expect(hide).assertEqual(1); + let show = inputMethod.KeyboardStatus.SHOW; + console.info("====>Sub_Misc_inputMethod_KeyboardStatus_0100 show:" + show); + expect(show).assertEqual(2); + done(); + }); + + it('Sub_Misc_inputMethod_ExtendAction_0100', 0, async function (done) { + let select_all = inputMethod.ExtendAction.SELECT_ALL; + console.info("====>Sub_Misc_inputMethod_ExtendAction_0100 select_all:" + select_all); + expect(select_all).assertEqual(0); + let cut = inputMethod.ExtendAction.CUT; + console.info("====>Sub_Misc_inputMethod_ExtendAction_0100 cut:" + cut); + expect(cut).assertEqual(3); + let copy = inputMethod.ExtendAction.COPY; + console.info("====>Sub_Misc_inputMethod_ExtendAction_0100 copy:" + copy); + expect(copy).assertEqual(4); + let paste = inputMethod.ExtendAction.PASTE; + console.info("====>Sub_Misc_inputMethod_ExtendAction_0100 paste:" + paste); + expect(paste).assertEqual(5); + done(); + }); + + it('Sub_Misc_inputMethod_Direction_0100', 0, async function (done) { + let cursor_up = inputMethod.Direction.CURSOR_UP; + console.info("====>Sub_Misc_inputMethod_Direction_0100 cursor_up:" + cursor_up); + expect(cursor_up).assertEqual(1); + let cursor_down = inputMethod.Direction.CURSOR_DOWN; + console.info("====>Sub_Misc_inputMethod_Direction_0100 cursor_down:" + cursor_down); + expect(cursor_down).assertEqual(2); + let cursor_left = inputMethod.Direction.CURSOR_LEFT; + console.info("====>Sub_Misc_inputMethod_Direction_0100 cursor_left:" + cursor_left); + expect(cursor_left).assertEqual(3); + let cursor_right = inputMethod.Direction.CURSOR_RIGHT; + console.info("====>Sub_Misc_inputMethod_Direction_0100 cursor_right:" + cursor_right); + expect(cursor_right).assertEqual(4); + done(); + }); + }); }; diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.test.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.test.ets index d0757a4d1888dd0e47b74bc8516c2ee54dbc9eaf..cd25ae8cfc468d53aa978207aa749a6c1ac410ea 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.test.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.test.ets @@ -194,5 +194,54 @@ export default function inputMethodJSUnit() { } }); }); + + /* + * @tc.number inputmethod_test_getInputMethods_003 + * @tc.name param enable : + * if true, collect enabled input methods. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_getInputMethods_003', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethod_test_getInputMethods_003 result:" + JSON.stringify(inputMethodSetting)); + try { + let setting = await inputMethodSetting.getInputMethods(true); + console.info("inputmethod_test_getInputMethods_003 success because: " + setting); + expect(typeof(setting) === 'object').assertTrue(); + done(); + console.info("====>************* inputmethod_test_getInputMethods_003 Test end*************"); + done(); + } catch (err) { + console.info("inputmethod_test_getInputMethods_003 catch error: " + err); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.number inputmethod_test_getInputMethods_004 + * @tc.name param enable : + * if false, collect disabled input methods. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputmethod_test_getInputMethods_004', 0, async function (done) { + let inputMethodSetting = inputMethod.getInputMethodSetting(); + console.info("====>inputmethod_test_getInputMethods_004 result:" + JSON.stringify(inputMethodSetting)); + try { + let setting = await inputMethodSetting.getInputMethods(false); + console.info("inputmethod_test_getInputMethods_004 success because: " + setting); + expect(typeof(setting) === 'object').assertTrue(); + done(); + console.info("====>************* inputmethod_test_getInputMethods_004 Test end*************"); + done(); + } catch (err) { + console.info("inputmethod_test_getInputMethods_004 catch error: " + err); + expect().assertFail(); + done(); + } + }); + }); }; diff --git a/inputmethod/InputMethodWindManage/entry/src/main/ets/InputMethodWindManage/KeyboardController.ts b/inputmethod/InputMethodWindManage/entry/src/main/ets/InputMethodWindManage/KeyboardController.ts index f4c587c11c805acd776b0d5fbccd1c8317607715..30346864439575cbccce920651d8285403009906 100644 --- a/inputmethod/InputMethodWindManage/entry/src/main/ets/InputMethodWindManage/KeyboardController.ts +++ b/inputmethod/InputMethodWindManage/entry/src/main/ets/InputMethodWindManage/KeyboardController.ts @@ -140,6 +140,30 @@ export class KeyboardController { console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_onHide_0180 event:' + data.event); that.Sub_Misc_inputMethod_Panel_onHide_0180(); break; + case 190: + console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_offShow_0190 event:' + data.event); + that.Sub_Misc_inputMethod_Panel_offShow_0190(); + break; + case 200: + console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_offHide_0200 event:' + data.event); + that.Sub_Misc_inputMethod_Panel_offHide_0200(); + break; + case 201: + console.debug(TAG + '====>Sub_Misc_inputMethod_onImeShow_0201 event:' + data.event); + that.Sub_Misc_inputMethod_onImeShow_0201(); + break; + case 202: + console.debug(TAG + '====>Sub_Misc_inputMethod_onImeHide_0202 event:' + data.event); + that.Sub_Misc_inputMethod_onImeHide_0202(); + break; + case 203: + console.debug(TAG + '====>Sub_Misc_inputMethod_offImeShow_0203 event:' + data.event); + that.Sub_Misc_inputMethod_offImeShow_0203(); + break; + case 204: + console.debug(TAG + '====>Sub_Misc_inputMethod_offImeHide_0204 event:' + data.event); + that.Sub_Misc_inputMethod_offImeHide_0204(); + break; case 210: console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_changeFlag_0210 event:' + data.event); that.Sub_Misc_inputMethod_Panel_changeFlag_0210(); @@ -790,6 +814,191 @@ export class KeyboardController { } } + private Sub_Misc_inputMethod_Panel_offShow_0190(): void { + let commonEventPublishData = { + data: "FAILED" + }; + let count = 0; + let timeCount = 0; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offShow_0190 success'); + try{ + if (this.softKeyboardPanel !== null){ + this.softKeyboardPanel.on("show", async (err, data) => { + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offShow_0190 offShow if success: ' + JSON.stringify(err)); + this.softKeyboardPanel.off("show"); + count += 1; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offShow_0190 off Show count: ' + count); + }); + let t1 = setInterval(async () => { + await this.softKeyboardPanel.show(); + await this.softKeyboardPanel.hide(); + timeCount += 1; + console.info(TAG + '====>this.softKeyboardPanel.show setInterval timeCount: ' + timeCount); + if(timeCount === 2){ + clearInterval(t1); + } + },100); + + let t2 = setTimeout(() => { + console.info(TAG + '====>setTimeout count: ' + count); + if(count === 1){ + commonEventPublishData = { + data: "SUCCESS" + }; + } + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offShow_0190", commonEventPublishData, this.publishCallback); + clearTimeout(t2); + },500); + + }else{ + commonEventPublishData = { + data: "FAILED" + }; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offShow_0190 this.softKeyboardPanel is null'); + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offShow_0190", commonEventPublishData, this.publishCallback); + } + }catch(error){ + commonEventPublishData = { + data: "FAILED" + }; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offShow_0190 catch error: ' + JSON.stringify(error)); + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offShow_0190", commonEventPublishData, this.publishCallback); + } + } + + private Sub_Misc_inputMethod_Panel_offHide_0200(): void { + let commonEventPublishData = { + data: "FAILED" + }; + let count = 0; + let timeCount = 0; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offHide_0200 success'); + try{ + if (this.softKeyboardPanel !== null){ + this.softKeyboardPanel.on("hide", async (err, data) => { + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offHide_0200 offHide if success: ' + JSON.stringify(err)); + this.softKeyboardPanel.off("hide"); + count += 1; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offHide_0200 off hide count: ' + count); + }); + + let t1 = setInterval(async () => {; + await this.softKeyboardPanel.show(); + await this.softKeyboardPanel.hide(); + timeCount += 1; + console.info(TAG + '====>this.softKeyboardPanel.hide setInterval timeCount: ' + timeCount); + if(timeCount === 2){ + clearInterval(t1); + } + },100); + + let t2 = setTimeout(() => { + console.info(TAG + '====>setTimeout count: ' + count); + if(count === 1){ + commonEventPublishData = { + data: "SUCCESS" + }; + } + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offHide_0200", commonEventPublishData, this.publishCallback); + clearTimeout(t2); + },500); + + }else{ + commonEventPublishData = { + data: "FAILED" + }; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offHide_0200 this.softKeyboardPanel is null'); + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offHide_0200", commonEventPublishData, this.publishCallback); + } + }catch(error){ + commonEventPublishData = { + data: "FAILED" + }; + console.info(TAG + '====>receive Sub_Misc_inputMethod_Panel_offHide_0200 catch error: ' + JSON.stringify(error)); + commoneventmanager.publish("Sub_Misc_inputMethod_Panel_offHide_0200", commonEventPublishData, this.publishCallback); + } + } + + private async Sub_Misc_inputMethod_onImeShow_0201(): Promise { + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeShow_0201 success'); + try{ + if (this.softKeyboardPanel !== null){ + let fla_fixed = inputmethodengine.PanelFlag.FLG_FIXED; + let fla_floating = inputmethodengine.PanelFlag.FLG_FLOATING; + this.softKeyboardPanel.changeFlag(fla_fixed); + await this.softKeyboardPanel.hide(); + console.info('====>Sub_Misc_inputMethod_onImeShow_0201 show panel'); + await this.softKeyboardPanel.show(); + console.info('====>Sub_Misc_inputMethod_onImeShow_0201 hide panel'); + this.softKeyboardPanel.changeFlag(fla_floating); + }else{ + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeShow_0201 this.softKeyboardPanel is null'); + } + }catch(error){ + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeShow_0201 catch error: ' + JSON.stringify(error)); + } + } + + private async Sub_Misc_inputMethod_onImeHide_0202(): Promise { + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeHide_0202 success'); + try{ + if (this.softKeyboardPanel !== null){ + let fla_fixed = inputmethodengine.PanelFlag.FLG_FIXED; + let fla_floating = inputmethodengine.PanelFlag.FLG_FLOATING; + this.softKeyboardPanel.changeFlag(fla_fixed); + await this.softKeyboardPanel.show(); + console.info('====>Sub_Misc_inputMethod_onImeHide_0202 show panel'); + await this.softKeyboardPanel.hide(); + console.info('====>Sub_Misc_inputMethod_onImeHide_0202 hide panel'); + this.softKeyboardPanel.changeFlag(fla_floating); + }else{ + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeHide_0202 this.softKeyboardPanel is null'); + } + }catch(error){ + console.info(TAG + '====>receive Sub_Misc_inputMethod_onImeHide_0202 catch error: ' + JSON.stringify(error)); + } + } + + private async Sub_Misc_inputMethod_offImeShow_0203(): Promise { + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeShow_0203 success'); + try{ + if (this.softKeyboardPanel !== null){ + let fla_fixed = inputmethodengine.PanelFlag.FLG_FIXED; + let fla_floating = inputmethodengine.PanelFlag.FLG_FLOATING; + this.softKeyboardPanel.changeFlag(fla_fixed); + await this.softKeyboardPanel.hide(); + console.info('====>Sub_Misc_inputMethod_offImeShow_0203 show panel'); + await this.softKeyboardPanel.show(); + console.info('====>Sub_Misc_inputMethod_offImeShow_0203 hide panel'); + this.softKeyboardPanel.changeFlag(fla_floating); + }else{ + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeShow_0203 this.softKeyboardPanel is null'); + } + }catch(error){ + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeShow_0203 catch error: ' + JSON.stringify(error)); + } + } + + private async Sub_Misc_inputMethod_offImeHide_0204(): Promise { + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeHide_0204 success'); + try{ + if (this.softKeyboardPanel !== null){ + let fla_fixed = inputmethodengine.PanelFlag.FLG_FIXED; + let fla_floating = inputmethodengine.PanelFlag.FLG_FLOATING; + this.softKeyboardPanel.changeFlag(fla_fixed); + await this.softKeyboardPanel.show(); + console.info('====>Sub_Misc_inputMethod_offImeHide_0204 show panel'); + await this.softKeyboardPanel.hide(); + console.info('====>Sub_Misc_inputMethod_offImeHide_0204 hide panel'); + this.softKeyboardPanel.changeFlag(fla_floating); + }else{ + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeHide_0204 this.softKeyboardPanel is null'); + } + }catch(error){ + console.info(TAG + '====>receive Sub_Misc_inputMethod_offImeHide_0204 catch error: ' + JSON.stringify(error)); + } + } + private Sub_Misc_inputMethod_Panel_changeFlag_0210(): void { let commonEventPublishData = { data: "FAILED" diff --git a/inputmethod/InputMethodWindManage/entry/src/main/ets/test/InputMethodWindManage.test.ets b/inputmethod/InputMethodWindManage/entry/src/main/ets/test/InputMethodWindManage.test.ets index d4efc2d440494a5548ad4a4e4cea06af6a081b19..e1a728d8775250c78f559cf397d81bb54d06ac29 100644 --- a/inputmethod/InputMethodWindManage/entry/src/main/ets/test/InputMethodWindManage.test.ets +++ b/inputmethod/InputMethodWindManage/entry/src/main/ets/test/InputMethodWindManage.test.ets @@ -966,6 +966,266 @@ export default function inputMethodWindManageAbility() { commonEventManager.publish("test", commonEventPublishData, publishCallback); }); + it('Sub_Misc_inputMethod_Panel_offShow_0190', 0, async function (done) { + function unSubscriberCallback(err) { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 unSubscriberCallback start"); + if (err) { + console.error("====>Sub_Misc_inputMethod_Panel_offShow_0190 unSubscriberCallback failed: " + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 unSubscriberCallback finsh"); + } + } + + function subscriberCallback(err, data) { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 subscriberCallback data: " + JSON.stringify(data)); + commonEventManager.unsubscribe(subscriber, unSubscriberCallback); + let t = setTimeout(() => { + try { + expect(data.data).assertEqual("SUCCESS"); + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 end<===="); + clearTimeout(t); + done(); + } catch (err) { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 end<====" + JSON.stringify(err)); + clearTimeout(t) + done(); + } + }, 500) + } + + async function publishCallback(err) { + if (err) { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 end<====" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 success ====" ); + } + } + + var commonEventSubscribeInfo = { + events: ["Sub_Misc_inputMethod_Panel_offShow_0190"] + } + var subscriber; + commonEventManager.createSubscriber(commonEventSubscribeInfo).then(function (data) { + subscriber = data; + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 subscribe data: " + JSON.stringify(data)); + commonEventManager.subscribe(subscriber, subscriberCallback); + console.info("====>Sub_Misc_inputMethod_Panel_offShow_0190 subscribe finish===="); + }) + + var commonEventPublishData = { + code: 190 + } + commonEventManager.publish("test", commonEventPublishData, publishCallback); + }); + + it('Sub_Misc_inputMethod_Panel_offHide_0200', 0, async function (done) { + function unSubscriberCallback(err) { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 unSubscriberCallback start"); + if (err) { + console.error("====>Sub_Misc_inputMethod_Panel_offHide_0200 unSubscriberCallback failed: " + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 unSubscriberCallback finsh"); + } + } + + function subscriberCallback(err, data) { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 subscriberCallback data: " + JSON.stringify(data)); + commonEventManager.unsubscribe(subscriber, unSubscriberCallback); + let t = setTimeout(() => { + try { + expect(data.data).assertEqual("SUCCESS"); + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 end<===="); + clearTimeout(t); + done(); + } catch (err) { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 end<====" + JSON.stringify(err)); + clearTimeout(t) + done(); + } + }, 500) + } + + async function publishCallback(err) { + if (err) { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 end<====" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 success ====" ); + } + } + + var commonEventSubscribeInfo = { + events: ["Sub_Misc_inputMethod_Panel_offHide_0200"] + } + var subscriber; + commonEventManager.createSubscriber(commonEventSubscribeInfo).then(function (data) { + subscriber = data; + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 subscribe data: " + JSON.stringify(data)); + commonEventManager.subscribe(subscriber, subscriberCallback); + console.info("====>Sub_Misc_inputMethod_Panel_offHide_0200 subscribe finish===="); + }) + + var commonEventPublishData = { + code: 200 + } + commonEventManager.publish("test", commonEventPublishData, publishCallback); + }); + + it('Sub_Misc_inputMethod_onImeShow_0201', 0, async function (done) { + function publishCallback(err){ + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 publishCallback start"); + if (err){ + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 publishCallback failed:" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 publishCallback success:"); + } + } + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 imeShow start" ); + let inputMethodSetting = inputMethod.getSetting(); + inputMethodSetting.on("imeShow", (inputWindowInfo) => { + inputMethodSetting.off("imeShow"); + try { + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 imeShow inputWindowInfo:" + JSON.stringify(inputWindowInfo)); + expect(typeof(inputWindowInfo[0].name) === 'string').assertTrue(); + expect(typeof(inputWindowInfo[0].left) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].top) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].width) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].height) === 'number').assertTrue(); + done(); + } catch (err) { + console.info('====>Sub_Misc_inputMethod_onImeShow_0201 imeShow catch err: ' + JSON.stringify(err)); + done(); + } + }) + console.info("====>Sub_Misc_inputMethod_onImeShow_0201 imeShow end" ); + + var commonEventPublishData = { + code: 201 + } + commonEventManager.publish('test', commonEventPublishData, publishCallback); + }); + + it('Sub_Misc_inputMethod_onImeHide_0202', 0, async function (done) { + function publishCallback(err){ + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 publishCallback start"); + if (err){ + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 publishCallback failed:" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 publishCallback success:"); + } + } + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 imeHide start" ); + let inputMethodSetting = inputMethod.getSetting(); + inputMethodSetting.on("imeHide", (inputWindowInfo) => { + inputMethodSetting.off("imeHide"); + try { + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 imeHide inputWindowInfo:" + JSON.stringify(inputWindowInfo)); + expect(typeof(inputWindowInfo[0].name) === 'string').assertTrue(); + expect(typeof(inputWindowInfo[0].left) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].top) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].width) === 'number').assertTrue(); + expect(typeof(inputWindowInfo[0].height) === 'number').assertTrue(); + done(); + } catch (err) { + console.info('====>Sub_Misc_inputMethod_onImeHide_0202 imeHide catch err: ' + JSON.stringify(err)); + done(); + } + }) + console.info("====>Sub_Misc_inputMethod_onImeHide_0202 imeHide end" ); + + var commonEventPublishData = { + code: 202 + } + commonEventManager.publish('test', commonEventPublishData, publishCallback); + }); + + it('Sub_Misc_inputMethod_offImeShow_0203', 0, async function (done) { + function publishCallback(err){ + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 publishCallback start"); + if (err){ + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 publishCallback failed:" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 publishCallback success:"); + } + } + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow start" ); + let flat = true; + let inputMethodSetting = inputMethod.getSetting(); + let inputwind = (inputWindowInfo) => { + flat = false; + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow inputWindowInfo:" + JSON.stringify(inputWindowInfo)); + } + inputMethodSetting.on("imeShow", inputwind) + inputMethodSetting.off("imeShow", inputwind); + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow end" ); + + var commonEventPublishData = { + code: 203 + } + commonEventManager.publish('test', commonEventPublishData, publishCallback); + + let t = setTimeout(() => { + if(flat){ + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow off success" ); + expect(true).assertTrue(); + done(); + }else{ + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow off fail" ); + try{ + expect().assertFail(); + done(); + }catch(err){ + console.info("====>Sub_Misc_inputMethod_offImeShow_0203 imeShow off catch err: " + JSON.stringify(err)); + done(); + } + } + clearTimeout(t); + }, 1000); + }); + + it('Sub_Misc_inputMethod_offImeHide_0204', 0, async function (done) { + function publishCallback(err){ + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 publishCallback start"); + if (err){ + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 publishCallback failed:" + JSON.stringify(err)); + } else { + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 publishCallback success:"); + } + } + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide start" ); + let flat = true; + let inputMethodSetting = inputMethod.getSetting(); + let inputwind = (inputWindowInfo) => { + flat = false; + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide inputWindowInfo:" + JSON.stringify(inputWindowInfo)); + } + inputMethodSetting.on("imeHide", inputwind) + inputMethodSetting.off("imeHide", inputwind); + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide end" ); + + var commonEventPublishData = { + code: 203 + } + commonEventManager.publish('test', commonEventPublishData, publishCallback); + + let t = setTimeout(() => { + if(flat){ + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide off success" ); + expect(true).assertTrue(); + done(); + }else{ + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide off fail" ); + try{ + expect().assertFail(); + done(); + }catch(err){ + console.info("====>Sub_Misc_inputMethod_offImeHide_0204 imeHide off catch err: " + JSON.stringify(err)); + done(); + } + } + clearTimeout(t); + }, 1000); + }); + it('Sub_Misc_inputMethod_Panel_changeFlag_0210', 0, async function (done) { function unSubscriberCallback(err) { console.info("====>Sub_Misc_inputMethod_Panel_changeFlag_0210 unSubscriberCallback start");