From 252ee0dd9b0109bfe1a86b0f1a52278967e136f3 Mon Sep 17 00:00:00 2001 From: zhangyushuai Date: Tue, 4 Apr 2023 14:08:01 +0000 Subject: [PATCH] input test optrine 001 Signed-off-by: zhangyushuai --- .../ets/InputMethodAbility/InputStageService.ts | 1 - .../main/ets/InputMethodAbility/KeyboardDelegate.ts | 10 ++++++++++ .../main/ets/InputMethodEngine/InputDemoService.ts | 1 - .../ets/InputMethodEngine/KeyboardController.ts | 10 ++++++++++ .../entry/src/main/ets/test/List.test.ets | 3 ++- .../src/main/ets/test/inputMethodAbility.test.ets | 13 +++++++++++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts index 9d029f26f..14d4f356d 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 b14ebf777..7c8df874d 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 b309c8521..c88bfb09d 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 2529cf2ca..ee3b5fe10 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 3b1e0268f..740d9382f 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 1b1e4765b..85463bddc 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); -- GitLab