未验证 提交 761e0f16 编写于 作者: O openharmony_ci 提交者: Gitee

!8479 【杂散】【输入法框架】优化input的监听接口

Merge pull request !8479 from 张育帅/release
...@@ -39,6 +39,9 @@ export class KeyboardDelegate { ...@@ -39,6 +39,9 @@ export class KeyboardDelegate {
this.initWindow(); this.initWindow();
let that = this; let that = this;
inputMethodAbility.on("inputStop", () => { inputMethodAbility.on("inputStop", () => {
inputMethodAbility.off("inputStop", () => {
console.log('====>inputMethodEngine delete inputStop notification.');
});
try{ try{
that.mContext.destroy((err) => { that.mContext.destroy((err) => {
console.info(TAG + '====>inputMethodAbility destroy err:' + JSON.stringify(err)); console.info(TAG + '====>inputMethodAbility destroy err:' + JSON.stringify(err));
...@@ -149,6 +152,26 @@ export class KeyboardDelegate { ...@@ -149,6 +152,26 @@ export class KeyboardDelegate {
console.debug(TAG + '====>inputMethodAbility_test_050 event:' + data.event); console.debug(TAG + '====>inputMethodAbility_test_050 event:' + data.event);
that.inputMethodAbility_test_050(); that.inputMethodAbility_test_050();
break; break;
case 70:
console.debug(TAG + '====>inputMethodAbility_test_070 event:' + data.event);
that.inputMethodAbility_test_070();
break;
case 71:
console.debug(TAG + '====>inputMethodAbility_test_071 event:' + data.event);
that.inputMethodAbility_test_071();
break;
case 72:
console.debug(TAG + '====>inputMethodAbility_test_072 event:' + data.event);
that.inputMethodAbility_test_072();
break;
case 73:
console.debug(TAG + '====>inputMethodAbility_test_073 event:' + data.event);
that.inputMethodAbility_test_073();
break;
case 74:
console.debug(TAG + '====>inputMethodAbility_test_074 event:' + data.event);
that.inputMethodAbility_test_074();
break;
} }
} }
...@@ -738,7 +761,7 @@ export class KeyboardDelegate { ...@@ -738,7 +761,7 @@ export class KeyboardDelegate {
console.debug(TAG + '====>receive inputMethodAbility_test_045 data'); console.debug(TAG + '====>receive inputMethodAbility_test_045 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart'); inputMethodAbility.off('inputStart');
setTimeout(()=>{ let t = setTimeout(()=>{
let commonEventPublishData; let commonEventPublishData;
if (InputClient == null) { if (InputClient == null) {
commonEventPublishData = { commonEventPublishData = {
...@@ -761,6 +784,7 @@ export class KeyboardDelegate { ...@@ -761,6 +784,7 @@ export class KeyboardDelegate {
commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback); commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback);
}); });
} }
clearTimeout(t);
},1000); },1000);
}); });
...@@ -901,4 +925,144 @@ export class KeyboardDelegate { ...@@ -901,4 +925,144 @@ export class KeyboardDelegate {
}); });
} }
private inputMethodAbility_test_070(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodAbility_test_070 success');
let count = 0;
inputMethodAbility.on('inputStart', (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
console.info(TAG + '====>inputMethodAbility.on("inputStart") count: ' + count);
count += 1;
});
inputMethodAbility.on('keyboardShow', () => {
inputMethodAbility.off('keyboardShow');
console.info(TAG + '====>inputMethodAbility.on("keyboardShow") count: ' + count);
count += 1;
});
inputMethodAbility.on('setSubtype', () => {
inputMethodAbility.off('setSubtype');
console.info(TAG + '====>inputMethodAbility.on("setSubtype") count: ' + count);
count += 1;
});
let t = setTimeout(() => {
if(count === 3){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_070", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
private inputMethodAbility_test_071(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodAbility_test_071 success');
let count = 0;
inputMethodAbility.on('keyboardHide', () => {
count += 1;
inputMethodAbility.off("keyboardHide");
console.info(TAG + '====>inputMethodAbility.off("keyboardHide") count: ' + count);
});
inputMethodAbility.on('inputStart', (KeyboardDelegate, InputClient) => {
console.info(TAG + '====>inputMethodAbility_test_071 inputMethodAbility.on("inputStart")');
let t = setInterval(async () => {
await KeyboardDelegate.hideKeyboard();
console.info(TAG + '====>KeyboardDelegate.hideKeyboard count: ' + count);
if(count === 1){
clearInterval(t);
}
},100);
});
let t = setTimeout(() => {
if(count === 1){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_071", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
private inputMethodAbility_test_072(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodAbility_test_072 success');
let count = 0;
inputMethodAbility.on('keyboardShow', () => {
count += 1;
inputMethodAbility.off("keyboardShow");
console.info(TAG + '====>inputMethodAbility.off("keyboardShow") count: ' + count);
});
let t = setTimeout(() => {
if(count === 1){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_072", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},300);
}
private inputMethodAbility_test_073(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodAbility_test_073 success');
let count = 0;
inputKeyboardDelegate.on('keyDown', (keyEvent) => {
inputKeyboardDelegate.off('keyDown');
console.info(TAG + "====>inputKeyboardDelegate.on('keyDown') count: " + count);
if (keyEvent.keyCode === 2000){
count += 1;
}
return true;
});
inputKeyboardDelegate.on('keyUp', (keyEvent) => {
inputKeyboardDelegate.off('keyUp');
console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count);
if (keyEvent.keyCode === 2000){
count += 1;
}
console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count);
return true;
});
let t = setTimeout(() => {
if(count === 2){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_073", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
private inputMethodAbility_test_074(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodAbility_test_074 success');
inputMethodAbility.on('setCallingWindow', (wid) => {
console.info(TAG + "====>inputKeyboardDelegate.on('setCallingWindow')" + wid);
inputMethodAbility.off('setCallingWindow', () => {
console.log('inputMethodAbility off setCallingWindow' );
});
if (typeof(wid) === "number"){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_074", commonEventPublishData, this.publishCallback);
});
}
} }
\ No newline at end of file
...@@ -40,6 +40,9 @@ export class KeyboardController { ...@@ -40,6 +40,9 @@ export class KeyboardController {
this.initWindow(); this.initWindow();
let that = this; let that = this;
inputMethodAbility.on("inputStop", () => { inputMethodAbility.on("inputStop", () => {
inputMethodAbility.off("inputStop", () => {
console.log('====>inputMethodEngine delete inputStop notification.');
});
try{ try{
that.mContext.destroy((err) => { that.mContext.destroy((err) => {
console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err));
...@@ -133,6 +136,30 @@ export class KeyboardController { ...@@ -133,6 +136,30 @@ export class KeyboardController {
console.debug(TAG + '====>inputMethodEngine_test_050 event:' + data.event); console.debug(TAG + '====>inputMethodEngine_test_050 event:' + data.event);
that.inputMethodEngine_test_050(); that.inputMethodEngine_test_050();
break; break;
case 71:
console.debug(TAG + '====>inputMethodEngine_test_071 event:' + data.event);
that.inputMethodEngine_test_071();
break;
case 72:
console.debug(TAG + '====>inputMethodEngine_test_072 event:' + data.event);
that.inputMethodEngine_test_072();
break;
case 73:
console.debug(TAG + '====>inputMethodEngine_test_073 event:' + data.event);
that.inputMethodEngine_test_073();
break;
case 74:
console.debug(TAG + '====>inputMethodEngine_test_074 event:' + data.event);
that.inputMethodEngine_test_074();
break;
case 76:
console.debug(TAG + '====>inputMethodEngine_test_076 event:' + data.event);
that.inputMethodEngine_test_076();
break;
case 77:
console.debug(TAG + '====>inputMethodEngine_test_077 event:' + data.event);
that.inputMethodEngine_test_077();
break;
} }
} }
...@@ -774,7 +801,186 @@ export class KeyboardController { ...@@ -774,7 +801,186 @@ export class KeyboardController {
}); });
} }
private inputMethodEngine_test_071(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_071 success');
let count = 0;
inputMethodEngine.on('keyboardHide', () => {
count += 1;
inputMethodEngine.off("keyboardHide");
console.info(TAG + '====>inputMethodEngine.off("keyboardHide") count: ' + count);
});
inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => {
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);
if(count === 1){
clearInterval(t);
}
},100);
});
let t = setTimeout(() => {
if(count === 1){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_071", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
private inputMethodEngine_test_072(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_072 success');
let count = 0;
inputMethodEngine.on('keyboardShow', () => {
count += 1;
inputMethodEngine.off("keyboardShow");
console.info(TAG + '====>inputMethodEngine.off("keyboardShow") count: ' + count);
});
let t = setTimeout(() => {
if(count === 1){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_072", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
private inputMethodEngine_test_073(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_073 success');
let count = 0;
inputKeyboardDelegate.on('keyDown', (keyEvent) => {
inputKeyboardDelegate.off('keyDown');
console.info(TAG + "====>inputKeyboardDelegate.on('keyDown') count: " + count);
if (keyEvent.keyCode === 2000){
count += 1;
}
return true;
});
inputKeyboardDelegate.on('keyUp', (keyEvent) => {
inputKeyboardDelegate.off('keyUp');
console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count);
if (keyEvent.keyCode === 2000){
count += 1;
}
return true;
});
let t = setTimeout(() => {
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("inputMethodEngine_test_073", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},300);
}
private inputMethodEngine_test_074(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_074 success');
let count = 0;
inputKeyboardDelegate.on('cursorContextChange', (x, y, h) => {
console.info(TAG + "====>inputKeyboardDelegate.on('cursorContextChange') count: " + count);
if (count === 1){
inputKeyboardDelegate.off('cursorContextChange');
}
count += 1;
console.info(TAG + '====>inputMethodEngine_test_074 x,y,z: ' + x + "---" + y + "---" + h);
});
inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => {
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);
if(count === 2){
clearInterval(t);
}
},100);
});
let t = setTimeout(() => {
console.info(TAG + '====>inputMethodEngine_test_074 setTimeout: ' + count);
if(count === 2){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_074", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},1000);
}
private inputMethodEngine_test_076(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_076 success');
inputKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info(TAG + "====>inputKeyboardDelegate.on('selectionChange')");
inputKeyboardDelegate.off('selectionChange');
commonEventPublishData = {
data: "SUCCESS"
};
console.info(TAG + '====>inputMethodEngine_test_076 oldBegin,oldEnd,newBegin,newEnd: ' + oldBegin + "---" + oldEnd + "---" + newBegin + "---" + newEnd);
});
let t = setTimeout(() => {
commoneventmanager.publish("inputMethodEngine_test_076", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},2000);
}
private inputMethodEngine_test_077(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive inputMethodEngine_test_077 success');
let count = 0;
inputKeyboardDelegate.on('textChange', (text) => {
console.info(TAG + "====>inputKeyboardDelegate.on('textChange') count:" + count);
if (count === 1){
inputKeyboardDelegate.off('textChange');
}
count += 1;
console.info(TAG + '====>inputMethodEngine_test_077 text: ' + text);
});
inputMethodEngine.on('inputStart', (KeyboardDelegate, InputClient) => {
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);
if(count === 2){
clearInterval(t);
}
},100);
});
let t = setTimeout(() => {
console.info(TAG + '====>inputMethodEngine_test_077 setTimeout: ' + count);
if(count === 2){
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_077", commonEventPublishData, this.publishCallback);
clearTimeout(t);
},500);
}
} }
\ No newline at end of file
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
import inputMethodEngine from './inputMethodEngine.test' import inputMethodEngine from './inputMethodEngine.test'
import inputMethodAbility from './inputMethodAbility.test' import inputMethodAbility from './inputMethodAbility.test'
export default function testsuite() { export default function testsuite() {
inputMethodEngine(); inputMethodEngine();
inputMethodAbility(); inputMethodAbility();
......
...@@ -1592,5 +1592,291 @@ export default function inputMethodAbility() { ...@@ -1592,5 +1592,291 @@ export default function inputMethodAbility() {
} }
commonEventManager.publish('test', commonEventPublishData, publishCallback); commonEventManager.publish('test', commonEventPublishData, publishCallback);
}); });
it('inputMethodAbility_test_070', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_070 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_070 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_070 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_070 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_070 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_070 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_070 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_070 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_070"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_070 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_070 subscriber finish")
})
var commonEventPublishData = {
code: 70
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_071', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_071 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_071 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_071 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_071 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_071 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_071 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_071 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_071 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_071"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_071 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_071 subscriber finish")
})
var commonEventPublishData = {
code: 71
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_072', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_072 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_072 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_072 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_072 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_072 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_072 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_072 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_072 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_072"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_072 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_072 subscriber finish")
})
var commonEventPublishData = {
code: 72
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_073', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_073 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_073 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_073 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_073 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_073 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_073 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_073 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_073 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
let t = setTimeout(() => {
runCmd("uinput -K -d 2000 -u 2000");
clearTimeout(t);
},200);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_073"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_073 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_073 subscriber finish")
})
var commonEventPublishData = {
code: 73
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_074', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_074 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_074 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_074 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_074 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_074 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_074 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500);
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_074 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_074 publishCallback failed:" + JSON.stringify(err));
} else {
let count = 0;
let t = setInterval(() => {
count += 1;
runCmd(getFocusCmd);
if (count === 2){
clearInterval(t);
}
}, 500);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_074"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_074 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_074 subscriber finish");
})
var commonEventPublishData = {
code: 74
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
}); });
}; };
...@@ -1198,6 +1198,339 @@ export default function inputMethodEngineJSUnit() { ...@@ -1198,6 +1198,339 @@ export default function inputMethodEngineJSUnit() {
commoneventmanager.publish('test1', commonEventPublishData, publishCallback); commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
}); });
it('inputMethodEngine_test_071', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_071 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_071 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_071 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_071 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_071 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_071 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_071 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_071 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_071"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_071 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_071 subscriber finish")
})
var commonEventPublishData = {
code: 71
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_072', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_072 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_072 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_072 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_072 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_072 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_072 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_072 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_072 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_072"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_072 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_072 subscriber finish")
})
var commonEventPublishData = {
code: 72
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_073', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_073 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_073 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_073 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_073 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_073 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_073 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_073 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_073 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
let t = setTimeout(() => {
runCmd("uinput -K -d 2000 -u 2000");
clearTimeout(t);
},200)
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_073"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_073 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_073 subscriber finish")
})
var commonEventPublishData = {
code: 73
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_074', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_074 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_074 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_074 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_074 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_074 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_074 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_074 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_074 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_074"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_074 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_074 subscriber finish")
})
var commonEventPublishData = {
code: 74
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_076', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_076 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_076 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_076 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_076 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_076 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_076 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_076 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_076 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_076"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_076 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_076 subscriber finish")
})
var commonEventPublishData = {
code: 76
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_077', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_077 unSubscriberCallback start");
if (err) {
console.info("====>inputMethodEngine_test_077 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_077 unSubscriberCallback finish")
}
}
function subscriberCallback(err, data) {
console.info("====>inputMethodEngine_test_077 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodEngine_test_077 end");
clearTimeout(t);
done();
} catch (err) {
console.info("====>inputMethodEngine_test_077 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.info("====>inputMethodEngine_test_077 publishCallback start");
if (err) {
console.info("====>inputMethodEngine_test_077 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_077"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.info("====>inputMethodEngine_test_077 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodEngine_test_077 subscriber finish")
})
var commonEventPublishData = {
code: 77
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
}) })
} }
\ No newline at end of file
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
"mainAbility": "com.acts.inputmethodtest.MainAbility", "mainAbility": "com.acts.inputmethodtest.MainAbility",
"deviceType": [ "deviceType": [
"tablet", "tablet",
"default", "default"
"phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
...@@ -78,8 +77,7 @@ ...@@ -78,8 +77,7 @@
"type": "pageAbility" "type": "pageAbility"
}, },
"pages": [ "pages": [
"pages/index", "pages/index"
"pages/input"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
// @ts-nocheck
/**
* 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.
*/
@Entry
@Component
struct TextInputTest {
@State text: string = '';
build() {
Column() {
TextInput({ placeholder: 'input your word' })
.type(InputType.Normal)
.key('TextInput')
.placeholderColor(Color.Blue)
.placeholderFont({ size: 40, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal })
.enterKeyType(EnterKeyType.Search)
.caretColor(Color.Green)
.height(60)
.fontSize(30)
.fontWeight(FontWeight.Bold)
.fontFamily("cursive")
.fontStyle(FontStyle.Italic)
.fontColor(Color.Red)
.maxLength(20)
.onChange((value: string) => {
this.text = value
})
Text(this.text)
}
}
}
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import inputMethodJSUnit from './inputMethodJSUnit'; import inputMethodJSUnit from './inputMethodJSUnit';
import inputMethodEngineJSUnit from './inputMethodEngineJSUnit';
export default function testsuite() { export default function testsuite() {
inputMethodJSUnit(); inputMethodJSUnit();
inputMethodEngineJSUnit();
} }
\ No newline at end of file
// @ts-nocheck
/**
* 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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("====>[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("====>[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('====>start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('====>start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
let xStep;
let yStep;
let swipeSteps;
let ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('====>move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
let downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('====>down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('====>start to move')
if (drag) {
await this.sleep(500)
}
for (let i = 1;i <= swipeSteps; i++) {
let movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('====>move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('====>start to up')
if (drag) {
await this.sleep(100)
}
let upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('====>up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import inputMethodEngine from '@ohos.inputMethodEngine';
import Utils from './Utils';
import router from '@system.router';
import events_emitter from '@ohos.events.emitter';
export default function inputMethodEngineJSUnit() {
describe('appInfoTest_input_1', function () {
let mKeyboardDelegate = null;
let inputMethodEngineObject = inputMethodEngine.getInputMethodEngine();
let textInputClient = null;
let kbController = null;
let KeyboardDelegate = null;
console.info("====>************* inputMethodEngine Test start*************");
beforeEach(async function (done) {
let options = {
uri: 'pages/input',
}
try {
router.clear();
let pages = router.getState();
if (!("input" == pages.name)) {
let result = await router.push(options);
await Utils.sleep(1000);
}
done();
} catch (err) {
console.error("push input page error: " + err);
done();
}
});
afterEach(async function () {
console.info("====>inputMethodEngine afterEach start:" + inputMethodEngineObject);
await Utils.sleep(1000);
});
it('inputMethodEngine_testOff_000', 0 , async function (done) {
inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => {
console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
});
inputMethodEngineObject.off('keyboardShow', () => {
console.info("====>inputMethodEngine beforeEach keyboardShow:");
});
inputMethodEngineObject.off('keyboardHide', () => {
console.info("====>inputMethodEngine beforeEach keyboardHide:");
});
KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
KeyboardDelegate.off('keyDown', (keyEvent) => {
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('1');
});
KeyboardDelegate.off('keyUp', (keyEvent) => {
console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('0');
});
KeyboardDelegate.off('cursorContextChange', (x, y, height) => {
console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x);
console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y);
console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height);
});
KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
});
KeyboardDelegate.off('textChange', (text) => {
console.info("====>inputMethodEngine beforeEach textChange:" + text);
});
done();
});
it('inputMethodEngine_test_000', 0, async function (done) {
inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => {
console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
textInputClient = textInputClient;
kbController = kbController;
});
inputMethodEngineObject.on('keyboardShow', () => {
console.info("====>inputMethodEngine beforeEach keyboardShow:");
});
inputMethodEngineObject.on('keyboardHide', () => {
console.info("====>inputMethodEngine beforeEach keyboardHide:");
});
mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
mKeyboardDelegate.on('keyDown', (keyEvent) => {
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('1');
});
mKeyboardDelegate.on('keyUp', (keyEvent) => {
console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('0');
});
mKeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x);
console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y);
console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height);
});
mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
});
mKeyboardDelegate.on('textChange', (text) => {
console.info("====>inputMethodEngine beforeEach textChange:" + text);
});
done();
});
it('inputMethodEngine_test_001', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED;
console.info("====>inputMethodEngine_test_001 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_002', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO;
console.info("====>inputMethodEngine_test_002 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_003', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH;
console.info("====>inputMethodEngine_test_003 result:" + keyType);
expect(keyType).assertEqual(3);
done();
});
it('inputMethodEngine_test_004', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND;
console.info("====>inputMethodEngine_test_004 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_005', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT;
console.info("====>inputMethodEngine_test_005 result:" + keyType);
expect(keyType).assertEqual(5);
done();
});
it('inputMethodEngine_test_006', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE;
console.info("====>inputMethodEngine_test_006 result:" + keyType);
expect(keyType).assertEqual(6);
done();
});
it('inputMethodEngine_test_007', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS;
console.info("====>inputMethodEngine_test_007 result:" + keyType);
expect(keyType).assertEqual(7);
done();
});
it('inputMethodEngine_test_008', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NULL;
console.info("====>inputMethodEngine_test_008 result:" + keyType);
expect(keyType).assertEqual(-1);
done();
});
it('inputMethodEngine_test_009', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_TEXT;
console.info("====>inputMethodEngine_test_009 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_010', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NUMBER;
console.info("====>inputMethodEngine_test_010 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_011', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PHONE;
console.info("====>inputMethodEngine_test_011 result:" + keyType);
expect(keyType).assertEqual(3);
done();
});
it('inputMethodEngine_test_012', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_DATETIME;
console.info("====>inputMethodEngine_test_012 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_013', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_EMAIL;
console.info("====>inputMethodEngine_test_013 result:" + keyType);
expect(keyType).assertEqual(5);
done();
});
it('inputMethodEngine_test_014', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_URI;
console.info("====>inputMethodEngine_test_014 result:" + keyType);
expect(keyType).assertEqual(6);
done();
});
it('inputMethodEngine_test_015', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PASSWORD;
console.info("====>inputMethodEngine_test_015 result:" + keyType);
expect(keyType).assertEqual(7);
done();
});
it('inputMethodEngine_test_016', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SELECTING;
console.info("====>inputMethodEngine_test_016 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_017', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SINGLE_LINE;
console.info("====>inputMethodEngine_test_017 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_018', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_PART;
console.info("====>inputMethodEngine_test_018 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_019', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_FULL;
console.info("====>inputMethodEngine_test_019 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_020', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_ASCII;
console.info("====>inputMethodEngine_test_020 result:" + keyType);
expect(keyType).assertEqual(20);
done();
});
it('inputMethodEngine_test_021', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NONE;
console.info("====>inputMethodEngine_test_021 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_022', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS;
console.info("====>inputMethodEngine_test_022 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_023', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES;
console.info("====>inputMethodEngine_test_023 result:" + keyType);
expect(keyType).assertEqual(8);
done();
});
it('inputMethodEngine_test_024', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_WORDS;
console.info("====>inputMethodEngine_test_024 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_025', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_MULTI_LINE;
console.info("====>inputMethodEngine_test_025 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_026', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN;
console.info("====>inputMethodEngine_test_026 result:" + keyType);
expect(keyType).assertEqual(10);
done();
});
it('inputMethodEngine_test_027', 0, async function (done) {
let rect = await Utils.getComponentRect('TextInput')
console.info("====>[inputMethodEngine_test_027] rectInfo is " + rect);
console.info("====>[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect));
let x_value = rect.left + (rect.right - rect.left) / 10
let y_value = rect.top + (rect.bottom - rect.top) / 10
console.info("====>[inputMethodEngine_test_027] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value);
let point: TouchObject = {
id: 1,
x: x_value,
y: y_value,
type: TouchType.Move,
screenX: rect.left + (rect.right - rect.left) / 10,
screenY: rect.left + (rect.right - rect.left) / 10,
}
console.info('====>[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point));
await Utils.sleep(1000)
console.info('====>[inputMethodEngine_test_027] END');
done();
});
it('inputMethodEngine_test_028', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.sendKeyFunction(0, (value) => {
console.info("====>inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_029', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.sendKeyFunction(0);
promise.then(res => {
console.info("====>inputMethodEngine_test_029 listInputMethod promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_029 listInputMethod promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_030', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.deleteForward(1, (value) => {
console.info("====>inputMethodEngine_test_030 deleteForward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_031', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.deleteForward(1);
promise.then(res => {
console.info("====>inputMethodEngine_test_031 deleteForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_031 deleteForward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_032', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.deleteBackward(1, (value) => {
console.info("====>inputMethodEngine_test_032 deleteBackward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_033', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.deleteBackward(1);
promise.then(res => {
console.info("====>inputMethodEngine_test_033 deleteBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_033 deleteBackward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_034', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.InsertText('test', (value) => {
console.info("====>inputMethodEngine_test_034 InsertText:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_035', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.InsertText('test');
promise.then(res => {
console.info("====>inputMethodEngine_test_035 InsertText promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_035 InsertText promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_036', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getForward(1, (value) => {
console.info("====>inputMethodEngine_test_036 getForward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_037', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getForward(1);
promise.then(res => {
console.info("====>inputMethodEngine_test_037 getForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_037 getForward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_038', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getEditorAttribute(1, (editorAttribute) => {
console.info("====>inputMethodEngine_test_038 getEditorAttribute:" + editorAttribute);
expect(editorAttribute.inputPattern).assertEqual(1);
expect(editorAttribute.enterKeyType).assertEqual(1);
});
}
done();
});
it('inputMethodEngine_test_039', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getEditorAttribute();
promise.then(res => {
console.info("====>inputMethodEngine_test_039 getEditorAttribute promise result-----" + JSON.stringify(res));
expect(res.inputPattern).assertEqual(1);
expect(res.enterKeyType).assertEqual(1);
}).catch(err => {
console.info("====>inputMethodEngine_test_039 getEditorAttribute promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_040', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
kbController.hideKeyboard(() => {
console.info("====>inputMethodEngine_test_040 hideKeyboard");
expect(1 == 1).assertTrue();
});
}
done();
});
it('inputMethodEngine_test_041', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
let promise = kbController.hideKeyboard();
promise.then(res => {
console.info("====>inputMethodEngine_test_041 hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue();
}).catch(err => {
console.info("====>inputMethodEngine_test_041 hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_042', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getBackward(1, (value) => {
console.info("====>inputMethodEngine_test_042 getBackward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_043', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getBackward(1);
promise.then(res => {
console.info("====>inputMethodEngine_test_043 getBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_043 getBackward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_044', 0, async function (done) {
let keyType = inputMethodEngine.WINDOW_TYPE_INPUT_METHOD_FLOAT;
console.error("inputMethodEngine_test_044 result:" + keyType);
expect(keyType == 2105).assertTrue();
done();
});
it('inputMethodEngine_test_045', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_UP, (value) => {
console.info("====>inputMethodEngine_test_045 moveCursor:" + value);
expect(value == null).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_046', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (value) => {
console.info("====>inputMethodEngine_test_046 moveCursor:" + value);
expect(value == null).assertEqual(true);
});
}
done();
})
it('inputMethodEngine_test_047', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_LEFT).then(res => {
console.info("====>inputMethodEngine_test_047 moveCursor promise result-----" + JSON.stringify(res));
expect(res == null).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_047 moveCursor promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
})
it('inputMethodEngine_test_048', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT).then(res => {
console.info("====>inputMethodEngine_test_048 moveCursor promise result-----" + JSON.stringify(res));
expect(res == null).assertEqual(true);
}).catch(err => {
console.info("====>inputMethodEngine_test_048 moveCursor promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
})
it('inputMethodEngine_test_049', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
kbController.hide(() => {
console.info("====>inputMethodEngine_test_049 hideKeyboard:");
expect(1 == 1).assertTrue();
});
}
done();
});
it('inputMethodEngine_test_050', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
let promise = kbController.hide();
promise.then(res => {
console.info("====>inputMethodEngine_test_050 hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue();
}).catch(err => {
console.info("====>inputMethodEngine_test_050 hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
/*
* @tc.number inputMethodEngine_test_getInputMethodAbility_001
* @tc.name InputMethodAbility object of the current input method.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) {
console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------");
try{
let inputMethodAbility = inputMethodEngine.getInputMethodAbility();
console.info("====>inputMethodEngine_test_getInputMethodAbility_001 result:" + typeof inputMethodAbility);
if(typeof inputMethodAbility == "object" ){
console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success");
expect(true).assertTrue();
}else{
console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed");
expect().assertFail();
};
}catch(error){
console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype error" + JSON.stringify(error));
expect().assertFail();
}
console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------");
done();
});
/*
* @tc.number inputMethodEngine_test_getKeyboardDelegate_001
* @tc.name KeyboardDelegate object of the current input method.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) {
console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------");
try{
let inputMethodAbility = inputMethodEngine.getKeyboardDelegate();
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 result:" + typeof inputMethodAbility);
if(typeof inputMethodAbility == "object" ){
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success");
expect(true).assertTrue();
}else{
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed");
expect().assertFail();
};
}catch(error){
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype error" + JSON.stringify(error));
expect().assertFail();
}
console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------");
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册