diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts index 1a421a95cd149350206800d8bb4a07215d1f74d8..c44fcf4fae0687ea203e74581b59f5f792f8c5a7 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts @@ -39,6 +39,9 @@ export class KeyboardDelegate { this.initWindow(); let that = this; inputMethodAbility.on("inputStop", () => { + inputMethodAbility.off("inputStop", () => { + console.log('====>inputMethodEngine delete inputStop notification.'); + }); try{ that.mContext.destroy((err) => { console.info(TAG + '====>inputMethodAbility destroy err:' + JSON.stringify(err)); @@ -149,6 +152,22 @@ export class KeyboardDelegate { console.debug(TAG + '====>inputMethodAbility_test_050 event:' + data.event); that.inputMethodAbility_test_050(); 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 101: console.debug(TAG + '====>inputMethodAbility_test_0101 event:' + data.event); that.inputMethodAbility_test_101(); @@ -762,7 +781,7 @@ export class KeyboardDelegate { console.debug(TAG + '====>receive inputMethodAbility_test_045 data'); inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { inputMethodAbility.off('inputStart'); - setTimeout(()=>{ + let t = setTimeout(()=>{ let commonEventPublishData; if (InputClient == null) { commonEventPublishData = { @@ -785,6 +804,7 @@ export class KeyboardDelegate { commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback); }); } + clearTimeout(t); },1000); }); @@ -925,6 +945,128 @@ 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_101(): void { console.debug(TAG + '====>receive inputMethodAbility_test_101 data'); inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index ee3b5fe1077719ba0232a8b56bea4d511ebb1a26..a935337c25f1c488d40ed3a24a1be1986eec2cbe 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts @@ -40,6 +40,9 @@ export class KeyboardController { this.initWindow(); let that = this; inputMethodAbility.on("inputStop", () => { + inputMethodAbility.off("inputStop", () => { + console.log('====>inputMethodEngine delete inputStop notification.'); + }); try{ that.mContext.destroy((err) => { console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); @@ -133,6 +136,30 @@ export class KeyboardController { console.debug(TAG + '====>inputMethodEngine_test_050 event:' + data.event); that.inputMethodEngine_test_050(); 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,184 @@ 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(() => { + if(count === 2){ + commonEventPublishData = { + data: "SUCCESS" + }; + } + commoneventmanager.publish("inputMethodEngine_test_074", commonEventPublishData, this.publishCallback); + clearTimeout(t); + },500); + } + + 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(() => { + if(count === 2){ + commonEventPublishData = { + data: "SUCCESS" + }; + } + commoneventmanager.publish("inputMethodEngine_test_077", commonEventPublishData, this.publishCallback); + clearTimeout(t); + },500); + } } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets index 74a427771b2f03b03a9f842e426f5ea9786d72f9..92bdaabfe73948ae046e089e76f891aba27f880f 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets @@ -1593,6 +1593,230 @@ export default function inputMethodAbility() { 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_101', 0, async function (done) { function unSubscriberCallback (err){ console.info("====>inputMethodAbility_test_101 unSubscriberCallback start"); diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodEngine.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodEngine.test.ets index 3ceb226b93babc0dc5ae3643e37c6e8521ab4bec..35832eb7cb363c434a2f0a1e754c70825f834faa 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodEngine.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodEngine.test.ets @@ -1198,6 +1198,339 @@ export default function inputMethodEngineJSUnit() { 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 diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/config.json b/inputmethod/InputMethodTest_ets/entry/src/main/config.json index e398b7f7b9bb15ed7b84dc929c043a9aa3d6fb92..5a6150fde3325eec8ceff192d95e115f1a4a8a42 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/config.json +++ b/inputmethod/InputMethodTest_ets/entry/src/main/config.json @@ -73,8 +73,7 @@ "type": "pageAbility" }, "pages": [ - "pages/index", - "pages/input" + "pages/index" ], "name": ".MainAbility", "window": { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets index 1a788d8fa2c4672e18e4efb60d7080a900892e9c..de06a2c00c66bdb12c44fc4108c990bb0404fdf7 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/index.ets @@ -1,5 +1,4 @@ -// @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. @@ -13,24 +12,48 @@ * 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 MyComponent { - aboutToAppear() { - } +struct Index { + @State message: string = 'Hello World'; + @State inputValue: string = 'inputMethodEngine1inputMethodEngine2inputMethodEngine3inputMethodEngine' + + 'inputMethodEngine4inputMethodEngine5inputMethodEngine6inputMethodEngine7inputMethodEngine8inputMethodEn' + + 'gine9inputMethodEngine10inputMethodEngine11inputMethodEngine12inputMethodEngine13inputMethodEngine14inputMet' + + 'hodEngine15inputMethodEngine16inputMethodEngine17inputMethodEngine18inputMethodEngine19inputMethodEngine20inputMethodEngine21'; build() { - Flex({ - direction: FlexDirection.Column, - alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center - }) { - Text('ACE ETS TEST') - .fontSize(50) - .fontWeight(FontWeight.Bold) + 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%') } - .width('100%') .height('100%') } -} +} diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets deleted file mode 100644 index 309eb39d48f7758be858a6c6b5a23da41b9579e1..0000000000000000000000000000000000000000 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/pages/input.ets +++ /dev/null @@ -1,45 +0,0 @@ -// @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) - } - } -} - diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets index 62c4d749fcc70d0a8af94734082bbf9f15d3b59f..6b78af64c9754d7aad1df92fa865e4c34aebfe8a 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets @@ -13,11 +13,9 @@ * limitations under the License. */ import inputMethodJSUnit from './inputMethodJSUnit'; -import inputMethodEngineJSUnit from './inputMethodEngineJSUnit'; import inputMethodNormalJSUnit from './inputMethodNormalJSUnit'; export default function testsuite() { inputMethodJSUnit(); - inputMethodEngineJSUnit(); inputMethodNormalJSUnit(); } \ No newline at end of file diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets deleted file mode 100644 index 4d27274069336154724453066b05559e3bbb3ea1..0000000000000000000000000000000000000000 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets +++ /dev/null @@ -1,118 +0,0 @@ -// @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) - } -} - - - - diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets deleted file mode 100644 index 7322bb92ac27d21d086b3acf89706e63abb6a9bf..0000000000000000000000000000000000000000 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets +++ /dev/null @@ -1,717 +0,0 @@ -/** - * 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(); - }); - - }) -} diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets index 20d6d1f522dbc30f60ac03e686f9fb29e5dd9972..3239e294ac3d97a3c427c1ad4db5a23b9a10cac1 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets @@ -14,11 +14,23 @@ */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; import inputMethod from '@ohos.inputMethod'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry' +import display from '@ohos.display'; export default function inputMethodNormalJSUnit() { describe('inputMethodNormalJSUnit', function () { console.info("====>************* inputMethodNormalJSUnit settings Test start*************"); + beforeAll(async (done)=>{ + let display_info; + let getFocusCmd = ''; + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + display_info = display.getDefaultDisplaySync(); + getFocusCmd = `uinput -T -c ${display_info.width*0.5} ${display_info.height*0.5}`; + console.debug('====>runCmd info:' + getFocusCmd); + await abilityDelegator.executeShellCommand(getFocusCmd); + }) + /* * @tc.number inputmethodNomal_test_switchInputMethod_001 * @tc.name Test Indicates the input method which will replace the current one.