提交 201ddbe1 编写于 作者: Z zhangyushuai

add inputmethodWindManage testcases 002

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 4fdca903
......@@ -19,5 +19,6 @@ group("inputmethod") {
"InputMethodEngine:ActsInputMethodEngineTest",
"InputMethodTest_Stage:ActsImeAbilityTest",
"InputMethodTest_ets:ActsInputMethodEtsTest",
"InputMethodWindManage:ActsInputMethodWindManageTest",
]
}
......@@ -2,7 +2,7 @@
"string":[
{
"name":"app_name",
"value":"ohosProject"
"value":"ActsInputMethodEngineTest"
}
]
}
\ No newline at end of file
......@@ -196,6 +196,22 @@ export class KeyboardDelegate {
console.debug(TAG + '====>inputMethodAbility_test_0106 event:' + data.event);
that.inputMethodAbility_test_106();
break;
case 110:
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 event:' + data.event);
that.Sub_Misc_inputMethod_onSelectByRange_0110();
break;
case 120:
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 event:' + data.event);
that.Sub_Misc_inputMethod_onSelectByMovement_0120();
break;
case 130:
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 event:' + data.event);
that.Sub_Misc_inputMethod_offSelectByRange_0130();
break;
case 140:
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 event:' + data.event);
that.Sub_Misc_inputMethod_offSelectByMovement_0140();
break;
}
}
......@@ -1299,4 +1315,178 @@ export class KeyboardDelegate {
}
});
}
private Sub_Misc_inputMethod_onSelectByRange_0110(): void {
let commonEventPublishData;
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 success');
try{
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 success inputStart');
let commonEventPublishData;
let range = { start: 0, end: 10 };
inputMethodAbility.off('inputStart');
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback);
} else {
commonEventPublishData = {
data: "SUCCESS"
};
try {
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange success');
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback);
await InputClient.selectByRange(range);
} catch (err) {
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange catch err:' + JSON.stringify(err));
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback);
}
}
});
}catch(error){
commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 catch error: ' + JSON.stringify(error));
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback);
}
}
private Sub_Misc_inputMethod_onSelectByMovement_0120(): void {
let commonEventPublishData;
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 success');
try{
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 success inputStart');
let commonEventPublishData;
let movement = { direction: inputMethodEngine.CURSOR_DOWN };
inputMethodAbility.off('inputStart');
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback);
} else {
commonEventPublishData = {
data: "SUCCESS"
};
try {
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement success');
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback);
await InputClient.selectByMovement(movement);
} catch (err) {
console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement catch err:' + JSON.stringify(err));
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback);
}
}
});
}catch(error){
commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 catch error: ' + JSON.stringify(error));
commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback);
}
}
private Sub_Misc_inputMethod_offSelectByRange_0130(): void {
let commonEventPublishData;
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 success');
try{
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 success inputStart');
let commonEventPublishData;
let timeCount = 0;
let range = { start: 0, end: 10 };
inputMethodAbility.off('inputStart');
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback);
} else {
commonEventPublishData = {
data: "SUCCESS"
};
try {
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange in');
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback);
let t1 = setInterval(async () => {;
await InputClient.selectByRange(range);
timeCount += 1;
console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 this.softKeyboardPanel.hide setInterval timeCount: ' + timeCount);
if(timeCount === 2){
clearInterval(t1);
}
},100);
} catch (err) {
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange catch err:' + JSON.stringify(err));
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback);
}
}
});
}catch(error){
commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 catch error: ' + JSON.stringify(error));
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback);
}
}
private Sub_Misc_inputMethod_offSelectByMovement_0140(): void {
let commonEventPublishData;
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 success');
try{
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 success inputStart');
let commonEventPublishData;
let timeCount = 0;
let movement = { direction: inputMethodEngine.CURSOR_DOWN };
inputMethodAbility.off('inputStart');
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback);
} else {
commonEventPublishData = {
data: "SUCCESS"
};
try {
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement in');
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback);
let t1 = setInterval(async () => {;
await InputClient.selectByMovement(movement);
timeCount += 1;
console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 this.softKeyboardPanel.hide setInterval timeCount: ' + timeCount);
if(timeCount === 2){
clearInterval(t1);
}
},100);
} catch (err) {
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement catch err:' + JSON.stringify(err));
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback);
}
}
});
}catch(error){
commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 catch error: ' + JSON.stringify(error));
commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback);
}
}
}
\ No newline at end of file
......@@ -30,9 +30,18 @@ export default function inputMethodAbility() {
extra:{}
}
var inputServerCopy = {
packageName: '',
methodId: '',
name:'',
id:'',
extra:{}
}
let display_info;
let getFocusCmd = '';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let inputMethodController = inputMethod.getController();
async function runCmd(cmd){
console.debug('====>runCmd info:' + cmd);
await abilityDelegator.executeShellCommand(cmd);
......@@ -67,6 +76,12 @@ export default function inputMethodAbility() {
}catch(err){
console.debug("====>beforeAll inputMethodStageJSUnit switchCurrentInputMethodSubtype failed");
}
let inputCurrent = inputMethod.getCurrentInputMethod();
inputServerCopy.packageName = inputCurrent.packageName;
inputServerCopy.methodId = inputCurrent.methodId;
inputServerCopy.name = inputCurrent.packageName;
inputServerCopy.id = inputCurrent.methodId;
console.info("====>Sub_Misc_inputMethod_onImeChange_0010 restore to: " + JSON.stringify(inputServerCopy));
})
afterAll(async (done) => {
......@@ -2208,5 +2223,300 @@ export default function inputMethodAbility() {
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_onSelectByRange_0110', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_onSelectByRange_0110"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_onSelectByRange_0110 subscriber finish")
})
inputMethodController.on("selectByRange", async (range) => {
console.info('====>Sub_Misc_inputMethod_onSelectByRange_0110 onSelectByRange start');
inputMethodController.off("selectByRange");
try {
expect(range.start).assertEqual(0);
expect(range.end).assertEqual(10);
console.info('====>Sub_Misc_inputMethod_onSelectByRange_0110 Succeed onSelectByRange: ' + JSON.stringify(range));
done();
} catch (err) {
console.info('====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange success');
done();
}
});
var commonEventPublishData = {
code:110
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_onSelectByMovement_0120', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_onSelectByMovement_0120"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_onSelectByMovement_0120 subscriber finish")
})
inputMethodController.on("selectByMovement", async (movement) => {
console.info('====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement start');
inputMethodController.off("selectByMovement");
try {
expect(movement.direction).assertEqual(2);
console.info('====>Sub_Misc_inputMethod_onSelectByMovement_0120 Succeed onSelectByMovement: ' + JSON.stringify(movement));
done();
} catch (err) {
console.info('====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement catch err: ' + JSON.stringify(err));
done();
}
});
var commonEventPublishData = {
code:120
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_offSelectByRange_0130', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_offSelectByRange_0130"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_offSelectByRange_0130 subscriber finish")
})
let count = 0;
inputMethodController.on("selectByRange", async (movement) => {
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange start');
inputMethodController.off("selectByRange");
count += 1;
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 Succeed offSelectByRange: ' + JSON.stringify(movement));
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 count: ' + count);
});
let t = setTimeout(() => {
try {
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 setTimeout count: ' + count);
expect(count).assertEqual(1);
clearTimeout(t);
done();
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 Succeed offSelectByRange ');
} catch (err) {
console.info('====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange err: ' + JSON.stringify(err));
done();
}
},500);
var commonEventPublishData = {
code:130
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_offSelectByMovement_0140', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_offSelectByMovement_0140"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_offSelectByMovement_0140 subscriber finish")
})
let count = 0;
inputMethodController.on("selectByMovement", async (movement) => {
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement start');
inputMethodController.off("selectByMovement");
count += 1;
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 Succeed offSelectByMovement: ' + JSON.stringify(movement));
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 count: ' + count);
});
let t = setTimeout(() => {
try {
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 setTimeout count: ' + count);
expect(count).assertEqual(1);
clearTimeout(t);
done();
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 Succeed offSelectByMovement ');
} catch (err) {
console.info('====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement err: ' + JSON.stringify(err));
done();
}
},500);
var commonEventPublishData = {
code:140
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_onImeChange_0150', 0, async function (done) {
let inputMethodSetting = inputMethod.getSetting();
inputMethodSetting.on("imeChange", (inputMethodProperty, inputMethodSubtype) => {
inputMethodSetting.off("imeChange");
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();
expect(typeof(inputMethodSubtype) !== null).assertTrue();
done();
})
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));
}
});
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 {
await inputMethod.switchInputMethod(inputServer);
console.info('====>Sub_Misc_inputMethod_offImeChange_0160 switchInputMethod');
let t = setTimeout(async () => {
clearTimeout(t);
await inputMethod.switchInputMethod(inputServerCopy);
},100);
} 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();
},500);
});
});
};
{
"app":{
"bundleName":"com.acts.inputmethodwidmanage.test",
"vendor":"hw",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ActsInputMethodWindManageTest"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsInputMethodWindManageTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":IMExtAbility_ets_assets",
":IMExtAbility_resources",
]
ets2abc = true
certificate_profile = "signature/ActsInputMethodWindManageTest.p7b"
hap_name = "ActsInputMethodWindManageTest"
subsystem_name = "inputmethod"
part_name = "imf"
}
ohos_app_scope("IMExtAbility_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("IMExtAbility_ets_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("IMExtAbility_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":IMExtAbility_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.inputmethodwidmanage.test",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 15000
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602",
"uinput -T -m 300 720 300 360 200",
"uinput -T -m 650 2760 650 1380 200"
]
},
{
"test-file-name": [
"ActsInputMethodWindManageTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage";
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate");
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
import { KeyboardController } from './KeyboardController';
export default class inputMethodWindService extends InputMethodExtensionAbility {
private keyboardController: KeyboardController;
onCreate(want) {
console.log("====>onCreate inputMethodWindService");
this.keyboardController = new KeyboardController(this.context);
this.keyboardController.onCreate(); // 初始化窗口
}
onDestroy() {
console.log("onDestroy inputMethodEngine**");
this.context.destroy();
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility';
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.info("ImExtAbility onCreate");
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.info("ImExtAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info("ImExtAbility onWindowStageCreate");
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/index/index", null);
console.info("ImExtAbility onWindowStageCreate finish");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info("ImExtAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.info("ImExtAbility onForeground");
}
onBackground() {
// Ability has back to background
console.info("ImExtAbility onBackground");
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
var abilityDelegator = undefined;
var abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ");
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
var cmd = 'aa start -d 0 -a com.acts.inputmethodwidmanage.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters["-D"];
if (debug === 'true')
{
cmd += ' -D';
}
console.info('cmd : '+cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
});
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
@State inputValue: string = 'inputMethodEngine1inputMethodEngine2inputMethodEngine3inputMethodEngine' +
'inputMethodEngine4inputMethodEngine5inputMethodEngine6inputMethodEngine7inputMethodEngine8inputMethodEn' +
'gine9inputMethodEngine10inputMethodEngine11inputMethodEngine12inputMethodEngine13inputMethodEngine14inputMet' +
'hodEngine15inputMethodEngine16inputMethodEngine17inputMethodEngine18inputMethodEngine19inputMethodEngine20inputMethodEngine21';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.defaultFocus(true)
TextArea({ text: this.inputValue })
.onChange((value: string) => {
this.inputValue = value;
})
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
})
}
.width('100%')
}
.height('100%')
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import InputMethodWindManage from './InputMethodWindManage.test'
export default function testsuite() {
InputMethodWindManage();
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.inputmethodwidmanage.test.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"description": "inputPanelTest",
"icon": "$media:icon",
"name": "inputMethodWindService",
"srcEntrance": "./ets/InputMethodWindManage/InputMethodWindService.ts",
"type": "inputMethod",
"visible":true
}
],
"requestPermissions": [
{
"name": "ohos.permission.CONNECT_IME_ABILITY"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsInputMethodWindManageTest"
},
{
"name": "ime_description",
"value": "input method extension ability."
},
{
"name": "ime_label",
"value": "inputMethod extension ability services."
},
{
"name": "ime_label_1",
"value": "inputMethod extension ability services_1."
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册