提交 097f5c1b 编写于 作者: Z zhangyushuai

add setCallingWindow test 002

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 5a2d74b1
......@@ -168,6 +168,10 @@ export class KeyboardDelegate {
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;
case 101:
console.debug(TAG + '====>inputMethodAbility_test_0101 event:' + data.event);
that.inputMethodAbility_test_101();
......@@ -968,7 +972,7 @@ export class KeyboardDelegate {
});
let t = setTimeout(() => {
if(count === 3){
if(count === 2){
commonEventPublishData = {
data: "SUCCESS"
};
......@@ -1067,6 +1071,25 @@ export class KeyboardDelegate {
},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);
});
}
private inputMethodAbility_test_101(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_101 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
......
......@@ -1817,6 +1817,68 @@ export default function inputMethodAbility() {
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);
});
it('inputMethodAbility_test_101', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_101 unSubscriberCallback start");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册