diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts index 9d029f26f0ba0a3c2583de24a910ef0fb79819bb..14d4f356d55496bd8f08af3046b32f2bd63fd14f 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts @@ -25,6 +25,5 @@ export default class InputDemoService extends InputMethodExtensionAbility { onDestroy() { console.log("onDestroy inputStageService**"); - this.context.destroy(); } } \ 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 b14ebf777f7443276a3ecf8ed66fe0ad4c3d2977..7c8df874d08e7911053c9b97042a48ccf5febd08 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts @@ -38,6 +38,16 @@ export class KeyboardDelegate { public onCreate(): void { this.initWindow(); let that = this; + inputMethodAbility.on("inputStop", () => { + 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); + } + }) function subscriberCallback(err, data) { console.debug(TAG + '====>receive event err:' + JSON.stringify(err)); diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts index b309c8521245d41d0fcaf0e03429b3c7b8cab436..c88bfb09d56038f578380fd65ba79d9385676d08 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts @@ -25,6 +25,5 @@ export default class InputDemoService extends InputMethodExtensionAbility { onDestroy() { console.log("onDestroy inputMethodEngine**"); - this.context.destroy(); } } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index 2529cf2ca4adc950abc6d8f52e023060097371a4..ee3b5fe1077719ba0232a8b56bea4d511ebb1a26 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts @@ -21,6 +21,7 @@ import commoneventmanager from '@ohos.commonEventManager'; let inputMethodEngine = inputmethodengine.getInputMethodEngine(); let inputKeyboardDelegate = inputmethodengine.createKeyboardDelegate(); +let inputMethodAbility = inputmethodengine.getInputMethodAbility(); const TAG = "keyboardController"; export class KeyboardController { @@ -38,6 +39,15 @@ export class KeyboardController { public onCreate(): void { this.initWindow(); let that = this; + inputMethodAbility.on("inputStop", () => { + try{ + that.mContext.destroy((err) => { + console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); + }) + }catch(err){ + console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err)); + } + }) function subscriberCallback(err, data) { console.debug(TAG + '====>receive event err: ' + JSON.stringify(err)); diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets index 3b1e0268fd24288686623f99503832c8721b2e5a..740d9382fe995e808ea17339cdd151283352e19e 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets @@ -15,7 +15,8 @@ import inputMethodEngine from './inputMethodEngine.test' import inputMethodAbility from './inputMethodAbility.test' + export default function testsuite() { inputMethodEngine(); - inputMethodAbility() + inputMethodAbility(); } \ 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 1b1e4765b42e4a13745a70778fc831d709abeb72..85463bddc44f589d017a00e5f59e8727ae697854 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets @@ -69,6 +69,19 @@ export default function inputMethodAbility() { } }) + afterAll(async (done) => { + try { + await inputMethod.switchInputMethod(inputServer); + console.info("====>afterAll: inputMethodStageJSUnit switchInputMethod success" + JSON.stringify(inputServer)); + setTimeout(() => { + console.info("====>afterAll: inputMethodStageJSUnit switchInputMethod success"); + done(); + }, 2000) + } catch (err) { + console.info("====>afterAll: inputMethodStageJSUnit fail" + JSON.stringify(err)); + } + }) + it('inputMethodEngine_test_001', 0, async function (done) { let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED; console.info("====>inputMethodEngine_test_001 result:" + keyType);