From e85fa6966d4574fe9101ac370a1cd3091a71ec6a Mon Sep 17 00:00:00 2001 From: zwx1016320 Date: Wed, 26 Oct 2022 03:11:09 +0000 Subject: [PATCH] reduce inputmethod API 3 Signed-off-by: zwx1016320 --- .../main/ets/ImExtAbility/ImExtAbility.ets | 63 ++++++------------- .../src/main/ets/test/imeAbilityTest.test.ets | 11 +++- .../main/ets/test/inputMethodStageJSUnit.ets | 16 +++-- .../src/main/ets/test/inputMethodJSUnit.ets | 14 +++-- theme/wallpaper_ets/Test.json | 2 +- .../entry/src/main/ets/test/wallpaperTest.ets | 4 +- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets index 396025b21..16bf442e3 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets @@ -26,51 +26,26 @@ export default class ImExtAbility extends inputMethodExtensionAbility { console.info("inputMethodExtensionAbility want.abilityName is: " + want.abilityName); console.info("---------------------------1-----------------------------"); - this.context.startAbility(want, (data)=>{ - console.info("startAbility001 inputMethodExtensionAbility start successfully." + JSON.stringify(data)); - }) - - this.context.terminateSelf((err) => { - console.info('startAbility001 terminateSelf success' + JSON.stringify(err)); - }); - - - console.info("---------------------------2-----------------------------"); - this.context.startAbility(want,options,(data) => { - console.info("startAbility002 inputMethodExtensionAbility start successfully." + JSON.stringify(data)); - }) - - this.context.terminateSelf().then((data) => { - console.info("startAbility002 terminateSelf success:." + JSON.stringify(data)); - }).catch((err) => { - console.info('startAbility002 terminateSelf fail: ' + JSON.stringify(err)); - }) - - console.info("---------------------------3-----------------------------"); - this.context.startAbility(want).then((data) => { - console.info("startAbility003 inputMethodExtensionAbility start successfully." + JSON.stringify(data)); - }).catch((err) => { - console.info('startAbility003 failed:' + JSON.stringify(err)); - }) - - this.context.terminateSelf().then((data) => { - console.info("startAbility003 terminateSelf success:." + JSON.stringify(data)); - }).catch((err) => { - console.info('startAbility003 terminateSelf fail: ' + JSON.stringify(err)); - }) - - console.info("---------------------------4-----------------------------"); - this.context.startAbility(want, options).then((data) => { - console.info("startAbility004 inputMethodExtensionAbility start successfully." + JSON.stringify(data)); - }).catch((err) => { - console.info('startAbility004 failed:' + JSON.stringify(err)); - }) + try{ + this.context.destroy((err, data)=>{ + if(err){ + console.info('destroy001 destroy fail: ' + JSON.stringify(err)); + } + console.info("destroy001 inputMethodExtensionAbility destroy successfully." + JSON.stringify(data)); + }) + }catch(error){ + console.info('destroy001 destroy catch error: ' + JSON.stringify(error)); + } - this.context.terminateSelf().then((data) => { - console.info("startAbility004 terminateSelf success:." + JSON.stringify(data)); - }).catch((err) => { - console.info('startAbility004 terminateSelf fail: ' + JSON.stringify(err)); - }) + try{ + this.context.destroy().then((data) => { + console.info("destroy002 terminateSelf success:." + JSON.stringify(data)); + }).catch((err) => { + console.info('destroy002 terminateSelf fail: ' + JSON.stringify(err)); + }) + }catch(error){ + console.info('destroy002 destroy catch error: ' + JSON.stringify(error)); + } } onDestroy() { diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets index f1afcc58d..99afcb795 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets @@ -32,7 +32,10 @@ export default function imeAbilityTest(abilityContext) { console.info('beforeEach: switchInputMethod to kikakeyboard.'); let serviceAbilityProperty = { packageName: "com.example.kikakeyboard", - methodId: "ServiceExtAbility" + methodId: "ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + extra:{} } inputMethod.switchInputMethod(serviceAbilityProperty).then((data)=>{ @@ -61,6 +64,9 @@ export default function imeAbilityTest(abilityContext) { let imExtAbilityProperty = { packageName : "com.acts.imeability.test", methodId : "com.acts.imeability.test.ImExtAbility", + name:"com.acts.imeability.test", + id:"com.acts.imeability.test.ImExtAbility", + extra:{} } inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ @@ -86,6 +92,9 @@ export default function imeAbilityTest(abilityContext) { let imExtAbilityProperty = { packageName : "com.acts.imeability.test", methodId : "com.acts.imeability.test.ImExtAbility", + name:"com.acts.imeability.test", + id:"com.acts.imeability.test.ImExtAbility", + extra:{} } inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ 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 10921dc61..9962f7974 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets @@ -314,8 +314,11 @@ export default function inputMethodStageJSUnit() { it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) { console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************"); let inputMethodProperty = { - packageName:"com.example.kikakeyboard", - methodId:"ServiceExtAbility" + packageName: "com.example.kikakeyboard", + methodId: "ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + extra:{} } let inputMethodSubProperty : subtype = { id: "com.example.kikakeyboard", @@ -356,8 +359,11 @@ export default function inputMethodStageJSUnit() { it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) { console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************"); let inputMethodProperty = { - packageName:"com.example.kikakeyboard", - methodId:"ServiceExtAbility" + packageName: "com.example.kikakeyboard", + methodId: "ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + extra:{} } let inputMethodSubProperty : subtype = { id: "com.example.kikakeyboard", @@ -505,7 +511,7 @@ export default function inputMethodStageJSUnit() { try { console.info("inputMethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); inputMethodSetting.showOptionalInputMethods().then((data) => { - console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(data)); + console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods success data is: " + JSON.stringify(data)); expect(true).assertTrue(); done(); }).catch(err => { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets index bc0f30e89..8660b7290 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets @@ -114,8 +114,11 @@ export default function inputMethodJSUnit() { it('inputmethod_test_switchInputMethod_001', 0, async function (done) { console.info("************* inputmethod_test_switchInputMethod_001 Test start*************"); let inputMethodProperty = { - packageName:"com.example.kikakeyboard", - methodId:"ServiceExtAbility" + packageName: "com.example.kikakeyboard", + methodId: "ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + extra:{} } inputMethod.switchInputMethod(inputMethodProperty).then(data => { console.info("inputmethod_test_switchInputMethod_001 data:" + data) @@ -137,8 +140,11 @@ export default function inputMethodJSUnit() { it('inputmethod_test_switchInputMethod_002', 0, async function (done) { console.info("************* inputmethod_test_switchInputMethod_002 Test start*************"); let inputMethodProperty = { - packageName:"com.example.kikakeyboard", - methodId:"ServiceExtAbility" + packageName: "com.example.kikakeyboard", + methodId: "ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + extra:{} } inputMethod.switchInputMethod(inputMethodProperty, (err, data)=>{ if(err){ diff --git a/theme/wallpaper_ets/Test.json b/theme/wallpaper_ets/Test.json index 5b084a8ac..87fa69645 100755 --- a/theme/wallpaper_ets/Test.json +++ b/theme/wallpaper_ets/Test.json @@ -22,7 +22,7 @@ "mkdir -p /data/app/el2/100/base/com.acts.theme.wallpapertest/haps" ], "push": [ - "./resource./wallpaper/wp.png ->/data/app/el2/100/base/com.acts.theme.wallpapertest/haps/wp.png" + "./resource/wallpaper/wp.png ->/data/app/el2/100/base/com.acts.theme.wallpapertest/haps/wp.png" ] } ] diff --git a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets index 9777b2e2c..2faafd313 100755 --- a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets +++ b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets @@ -14,7 +14,7 @@ */ import wallpaper from '@ohos.wallpaper'; import image from '@ohos.multimedia.image'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; const WALLPAPER_SYSTEM = 0; const WALLPAPER_LOCKSCREEN = 1; @@ -913,7 +913,7 @@ export default function wallpaperJSUnit() { console.info('------------------testGetMinWidthSync101 start----------------------'); let number = null; try{ - number = wallpaper.getMinHeightSync() + number = wallpaper.getMinWidthSync() console.info('wallpaperXTS ===> testGetMinWidthSync101 data : ' + JSON.stringify(number)); if (typeof number == "number") { expect(true).assertTrue(); -- GitLab