未验证 提交 0981a30a 编写于 作者: O openharmony_ci 提交者: Gitee

!8976 【杂散】【输入法框架】输入法 91用例优化,覆盖部分属性接口

Merge pull request !8976 from 张育帅/master
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
import { KeyboardDelegate } from './KeyboardDelegate';
export default class InputMethodControlService extends InputMethodExtensionAbility {
private keyboardDelegate: KeyboardDelegate;
onCreate(want) {
this.keyboardDelegate = new KeyboardDelegate(this.context);
this.keyboardDelegate.onCreate(); // 初始化窗口
}
onDestroy() {
console.log("onDestroy inputStageService**");
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import inputMethodEngine from '@ohos.inputMethodEngine';
import display from '@ohos.display';
import windowManager from '@ohos.window';
import promptAction from '@ohos.promptAction';
import commoneventmanager from '@ohos.commonEventManager';
let inputMethodAbility = inputMethodEngine.getInputMethodAbility();
let inputKeyboardDelegate = inputMethodEngine.getKeyboardDelegate();
const TAG = 'KeyboardDelegate';
export class KeyboardDelegate {
mContext;
WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105;
windowName = 'inputApp';
private windowHeight: number = 0;
private windowWidth: number = 0;
private nonBarPosition: number = 0;
constructor(context) {
this.mContext = context;
}
private sleep(timeout): Promise<void> {
return new Promise(resolve => {
let t = setTimeout(() => {
clearTimeout(t);
resolve(null);
}, timeout);
});
};
public onCreate(): void {
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));
});
}catch(err){
console.info(TAG + '====>inputMethodAbility destroy catch err:' + JSON.stringify(err));
console.info(TAG + '====>inputMethodAbility destroy catch err:' + err);
}
})
function subscriberCallback(err, data) {
console.debug(TAG + '====>receive event err:' + JSON.stringify(err));
console.debug(TAG + '====>receive event data:' + JSON.stringify(data));
switch (data.code) {
case 10:
console.debug(TAG + '====>SUB_Misc_inputMethod_onHandleExtendAction_0010 event:' + data.event);
that.SUB_Misc_inputMethod_onHandleExtendAction_0010();
break;
case 20:
console.debug(TAG + '====>SUB_Misc_inputMethod_offHandleExtendAction_0020 event:' + data.event);
that.SUB_Misc_inputMethod_offHandleExtendAction_0020();
break;
case 30:
console.debug(TAG + '====>SUB_Misc_inputMethod_onSendFunctionKey_0030 event:' + data.event);
that.SUB_Misc_inputMethod_onSendFunctionKey_0030();
break;
case 40:
console.debug(TAG + '====>SUB_Misc_inputMethod_offSendFunctionKey_0040 event:' + data.event);
that.SUB_Misc_inputMethod_offSendFunctionKey_0040();
break;
}
}
var commonEventSubscribeInfo = {
events: ["test"]
};
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) {
subscriber = data;
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug(TAG + '====>scene subscribe finish====');
});
}
public initWindow(): void {
let dis = display.getDefaultDisplaySync();
var dWidth = dis.width;
var dHeight = dis.height;
var keyHeightRate = 0.47;
var keyHeight = dHeight * keyHeightRate;
this.windowWidth = dWidth;
this.windowHeight = keyHeight;
this.nonBarPosition = dHeight - keyHeight;
var config = {
name: this.windowName,
windowType: this.WINDOW_TYPE_INPUT_METHOD_FLOAT,
cts: this.mContext
};
windowManager.createWindow(config).then((win) => {
win.resize(dWidth, keyHeight).then(() => {
win.moveWindowTo(0, this.nonBarPosition).then(() => {
win.setUIContent('page/service/index').then(() => {
});
});
});
});
}
public onDestroy(): void {
console.debug(TAG + '====>onDestroy');
globalThis.textInputClient.getTextIndexAtCursor().then((index) => {
console.debug(TAG + '====>getTextIndexAtCursor index:' + index);
promptAction.showToast({ message: 'getTextIndexAtCursor success' + index, duration: 200, bottom: 500 });
var win = windowManager.findWindow(this.windowName);
win.destroyWindow();
this.mContext.terminateSelf();
return true;
}).catch((err) => {
promptAction.showToast({ message: 'getTextIndexAtCursor failed', duration: 200, bottom: 500 });
});
}
private publishCallback(err): void {
if (err) {
console.error(TAG + '====>publish failed:' + JSON.stringify(err));
} else {
console.debug(TAG + '====>publish');
}
}
private SUB_Misc_inputMethod_onHandleExtendAction_0010(): void {
console.info(TAG + '====>SUB_Misc_inputMethod_onHandleExtendAction_0010 start');
inputMethodAbility.on("inputStart", async (KeyboardDelegate, InputClient) => {
let t = setTimeout(async () => {
clearTimeout(t);
console.info(TAG + '====>SUB_Misc_inputMethod_onHandleExtendAction_0010 sendExtendAction start');
await InputClient.sendExtendAction(0);
console.info(TAG + '====>SUB_Misc_inputMethod_onHandleExtendAction_0010 sendExtendAction end');
}, 500);
});
}
private SUB_Misc_inputMethod_offHandleExtendAction_0020(): void {
console.info(TAG + '====>SUB_Misc_inputMethod_offHandleExtendAction_0020 start');
inputMethodAbility.on("inputStart", async (KeyboardDelegate, InputClient) => {
let t = setTimeout(async () => {
clearTimeout(t);
console.info(TAG + '====>SUB_Misc_inputMethod_offHandleExtendAction_0020 sendExtendAction start');
await InputClient.sendExtendAction(0);
await this.sleep(100);
await InputClient.sendExtendAction(0);
console.info(TAG + '====>SUB_Misc_inputMethod_offHandleExtendAction_0020 sendExtendAction end');
}, 500);
});
}
private SUB_Misc_inputMethod_onSendFunctionKey_0030(): void {
console.info(TAG + '====>SUB_Misc_inputMethod_onSendFunctionKey_0030 start');
inputMethodAbility.on("inputStart", async (KeyboardDelegate, InputClient) => {
let t = setTimeout(async () => {
clearTimeout(t);
console.info(TAG + '====>SUB_Misc_inputMethod_onSendFunctionKey_0030 sendExtendAction start');
await InputClient.sendKeyFunction(0);
console.info(TAG + '====>SUB_Misc_inputMethod_onSendFunctionKey_0030 sendExtendAction end');
}, 500);
});
}
private SUB_Misc_inputMethod_offSendFunctionKey_0040(): void {
console.info(TAG + '====>SUB_Misc_inputMethod_offSendFunctionKey_0040 start');
inputMethodAbility.on("inputStart", async (KeyboardDelegate, InputClient) => {
let t = setTimeout(async () => {
clearTimeout(t);
console.info(TAG + '====>SUB_Misc_inputMethod_offSendFunctionKey_0040 sendExtendAction start');
await InputClient.sendKeyFunction(0);
await this.sleep(100);
await InputClient.sendKeyFunction(0);
console.info(TAG + '====>SUB_Misc_inputMethod_offSendFunctionKey_0040 sendExtendAction end');
}, 500);
});
}
}
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import inputMethodDrawnControl from './inputMethod_drawnControl.test'
import inputMethod_attach from './inputMethod_attach.test' import inputMethod_attach from './inputMethod_attach.test'
import inputMethod_showTextInput_hideTextInput_detach from './inputMethod_showTextInput_hideTextInput_detach.test' import inputMethod_showTextInput_hideTextInput_detach from './inputMethod_showTextInput_hideTextInput_detach.test'
import inputMethod_updateAttribute from './inputMethod_updateAttribute.test' import inputMethod_updateAttribute from './inputMethod_updateAttribute.test'
...@@ -20,6 +21,7 @@ import inputMethod_updateCursor from './inputMethod_updateCursor.test' ...@@ -20,6 +21,7 @@ import inputMethod_updateCursor from './inputMethod_updateCursor.test'
import inputMethod_setCallingWindow from './inputMethod_setCallingWindow.test' import inputMethod_setCallingWindow from './inputMethod_setCallingWindow.test'
export default function testsuite() { export default function testsuite() {
inputMethodDrawnControl();
inputMethod_attach(); inputMethod_attach();
inputMethod_showTextInput_hideTextInput_detach(); inputMethod_showTextInput_hideTextInput_detach();
inputMethod_updateAttribute(); inputMethod_updateAttribute();
......
/**
* 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 commoneventmanager from '@ohos.commonEventManager';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import subtype from '@ohos.InputMethodSubtype';
import inputMethod from '@ohos.inputMethod';
import display from '@ohos.display';
export default function inputMethodDrawnControlJSUnit() {
describe('inputMethodDrawnControlTest', function () {
var inputSever = {
packageName: '',
methodId: '',
name: '',
id: '',
extra: {}
}
/**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeAll(async (done) => {
let inputM = inputMethod.getCurrentInputMethod();
console.info("====>beforeAll: getCurrentInputMethod inputMethodEngineJSUnit to: " + JSON.stringify(inputM));
inputSever.packageName = inputM.packageName;
inputSever.methodId = inputM.methodId;
inputSever.name = inputM.packageName;
inputSever.id = inputM.methodId;
let inputDemoService: subtype = {
id: "inputMethodWindService",
label: "",
name: "com.acts.inputmethoddrawncontrol.test",
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}
try {
console.info("====>beforeAll: inputMethodEngineJSUnit switchCurrentInputMethodSubtype success" + JSON.stringify(inputDemoService));
await inputMethod.switchCurrentInputMethodSubtype(inputDemoService);
setTimeout(() => {
console.info("====>beforeAll: inputMethodEngineJSUnit switchCurrentInputMethodSubtype success");
done();
}, 2000)
} catch (err) {
console.info("====>beforeAll: inputMethodEngineJSUnit fail" + JSON.stringify(err));
}
})
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterAll(async (done) => {
try {
await inputMethod.switchInputMethod(inputSever);
setTimeout(() => {
console.info("====>afterAll: inputMethodEngineJSUnit switchInputMethod success");
done();
}, 2000)
} catch (err) {
console.info("====>afterAll: inputMethodEngineJSUnit fail" + JSON.stringify(err));
}
})
it('SUB_Misc_inputMethod_onHandleExtendAction_0010',0, async function (done) {
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
async function publishCallback(err){
console.info("====>SUB_Misc_inputMethod_onHandleExtendAction_0010 publishCallback start");
if (err){
console.info("====>SUB_Misc_inputMethod_onHandleExtendAction_0010 publishCallback failed:" + JSON.stringify(err));
} else {
try {
await inputMethod.getController().attach(true, ATTRIBUTE);
console.info("====>SUB_Misc_inputMethod_onHandleExtendAction_0010 onHandleExtendAction start");
inputMethod.getController().on("handleExtendAction",async (action) => {
console.info("====>SUB_Misc_inputMethod_onHandleExtendAction_0010 onHandleExtendAction success: " + action);
inputMethod.getController().off("handleExtendAction");
await inputMethod.getController().detach();
expect(action).assertEqual(0);
done();
});
} catch (err) {
console.info("====>SUB_Misc_inputMethod_onHandleExtendAction_0010 onHandleExtendAction catch err: " + JSON.stringify(err));
}
}
}
var commonEventPublishData = {
code:10
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
});
it('SUB_Misc_inputMethod_offHandleExtendAction_0020',0, async function (done) {
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let flag = true;
async function publishCallback(err){
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 publishCallback start");
if (err){
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 publishCallback failed:" + JSON.stringify(err));
} else {
try {
await inputMethod.getController().attach(true, ATTRIBUTE);
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 offHandleExtendAction start");
inputMethod.getController().on("handleExtendAction",async (action) => {
flag = false;
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 flag: " + flag);
});
inputMethod.getController().off("handleExtendAction");
let t = setTimeout(async () => {
try {
clearTimeout(t);
await inputMethod.getController().detach();
if (flag){
expect(true).assertEqual(true);
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 offHandleExtendAction success");
}else{
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 offHandleExtendAction fail");
expect().assertFail();
}
} catch (err) {
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 offHandleExtendAction catch err: " + JSON.stringify(err));
}
done();
}, 1000)
} catch (err) {
console.info("====>SUB_Misc_inputMethod_offHandleExtendAction_0020 offHandleExtendAction catch err: " + JSON.stringify(err));
}
}
}
var commonEventPublishData = {
code:20
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
});
it('SUB_Misc_inputMethod_onSendFunctionKey_0030',0, async function (done) {
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
async function publishCallback(err){
console.info("====>SUB_Misc_inputMethod_onSendFunctionKey_0030 publishCallback start");
if (err){
console.info("====>SUB_Misc_inputMethod_onSendFunctionKey_0030 publishCallback failed:" + JSON.stringify(err));
} else {
try {
await inputMethod.getController().attach(true, ATTRIBUTE);
console.info("====>SUB_Misc_inputMethod_onSendFunctionKey_0030 onSendFunctionKey start");
inputMethod.getController().on("sendFunctionKey",async (FunctionKey) => {
console.info("====>SUB_Misc_inputMethod_onSendFunctionKey_0030 onSendFunctionKey success: " + FunctionKey.enterKeyType);
inputMethod.getController().off("sendFunctionKey");
await inputMethod.getController().detach();
expect(FunctionKey.enterKeyType).assertEqual(0);
done();
});
} catch (err) {
console.info("====>SUB_Misc_inputMethod_onSendFunctionKey_0030 onSendFunctionKey catch err: " + JSON.stringify(err));
}
}
}
var commonEventPublishData = {
code:30
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
});
it('SUB_Misc_inputMethod_offSendFunctionKey_0040',0, async function (done) {
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let flag = true;
async function publishCallback(err){
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 publishCallback start");
if (err){
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 publishCallback failed:" + JSON.stringify(err));
} else {
try {
await inputMethod.getController().attach(true, ATTRIBUTE);
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 offSendFunctionKey start");
inputMethod.getController().on("sendFunctionKey",async (FunctionKey) => {
flag = false;
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 flag: " + flag);
});
inputMethod.getController().off("sendFunctionKey");
let t = setTimeout(async () => {
try {
clearTimeout(t);
await inputMethod.getController().detach();
if (flag){
expect(true).assertEqual(true);
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 offSendFunctionKey success");
}else{
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 offSendFunctionKey fail");
expect().assertFail();
}
} catch (err) {
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 offSendFunctionKey catch err: " + JSON.stringify(err));
}
done();
}, 1000)
} catch (err) {
console.info("====>SUB_Misc_inputMethod_offSendFunctionKey_0040 offSendFunctionKey catch err: " + JSON.stringify(err));
}
}
}
var commonEventPublishData = {
code:40
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
});
})
}
\ No newline at end of file
...@@ -35,6 +35,16 @@ ...@@ -35,6 +35,16 @@
} }
] ]
} }
],
"extensionAbilities": [
{
"description": "inputPanelTest",
"icon": "$media:icon",
"name": "inputMethodWindService",
"srcEntrance": "./ets/InputMethodDrawnControl/InputMethodControlService.ts",
"type": "inputMethod",
"visible":true
}
], ],
"requestPermissions": [ "requestPermissions": [
{ {
......
...@@ -215,6 +215,14 @@ export class KeyboardDelegate { ...@@ -215,6 +215,14 @@ export class KeyboardDelegate {
console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 event:' + data.event); console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 event:' + data.event);
that.Sub_Misc_inputMethod_offSelectByMovement_0140(); that.Sub_Misc_inputMethod_offSelectByMovement_0140();
break; break;
case 170:
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 event:' + data.event);
that.Sub_Misc_inputMethod_sendExtendAction_0170();
break;
case 180:
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 event:' + data.event);
that.Sub_Misc_inputMethod_sendExtendAction_0180();
break;
} }
} }
...@@ -1502,5 +1510,70 @@ export class KeyboardDelegate { ...@@ -1502,5 +1510,70 @@ export class KeyboardDelegate {
} }
} }
private Sub_Misc_inputMethod_sendExtendAction_0170(): void{
console.debug(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0170 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback);
} else {
try {
InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err,) => {
if (err) {
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction success' );
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback);
});
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 getTextIndexAtCursor throw_err:');
commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback);
}
}
});
}
private Sub_Misc_inputMethod_sendExtendAction_0180(): void{
console.debug(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0180 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0180", commonEventPublishData, this.publishCallback);
} else {
try {
await InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY);
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction success:');
commonEventPublishData = {
data: "SUCCESS"
};
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction catch err:');
}
commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0180", commonEventPublishData, this.publishCallback);
}
});
}
} }
\ No newline at end of file
...@@ -57,7 +57,7 @@ export default function inputMethodAbility() { ...@@ -57,7 +57,7 @@ export default function inputMethodAbility() {
inputServer.name = inputM.packageName; inputServer.name = inputM.packageName;
inputServer.id = inputM.methodId; inputServer.id = inputM.methodId;
console.info("====>beforeAll inputMethodStageJSUnit start"); console.info("====>beforeAll inputMethodStageJSUnit start");
let inputDemoService: subtype ={ inputDemoService = {
id: 'inputStageService', id: 'inputStageService',
label: '', label: '',
name: 'com.acts.inputmethodengine.test', name: 'com.acts.inputmethodengine.test',
...@@ -2560,13 +2560,17 @@ export default function inputMethodAbility() { ...@@ -2560,13 +2560,17 @@ export default function inputMethodAbility() {
} else { } else {
let t = setTimeout(async () => { let t = setTimeout(async () => {
await inputMethod.switchInputMethod(inputServer); await inputMethod.switchInputMethod(inputServer);
console.info("====>inputMethodAbility_test_091 setTimeout first"); console.info("====>inputMethodAbility_test_091 setTimeout first: " + JSON.stringify(inputServer));
let t1 = setTimeout(async () => { let t1 = setTimeout(async () => {
done();
console.info("====>inputMethodAbility_test_091 setTimeout second: " + flag); console.info("====>inputMethodAbility_test_091 setTimeout second: " + flag);
expect(flag).assertTrue(); expect(flag).assertTrue();
clearTimeout(t1); clearTimeout(t1);
await inputMethod.switchCurrentInputMethodSubtype(inputDemoService); await inputMethod.switchCurrentInputMethodSubtype(inputDemoService);
console.info("====>inputMethodAbility_test_091 switchInputMethod second" + JSON.stringify(inputDemoService));
let t2 = setTimeout(() => {
clearTimeout(t2)
done();
}, 500)
},1000) },1000)
clearTimeout(t); clearTimeout(t);
}, 1000) }, 1000)
...@@ -2590,5 +2594,115 @@ export default function inputMethodAbility() { ...@@ -2590,5 +2594,115 @@ export default function inputMethodAbility() {
commonEventManager.publish('test', commonEventPublishData, publishCallback); commonEventManager.publish('test', commonEventPublishData, publishCallback);
}); });
it('Sub_Misc_inputMethod_sendExtendAction_0170', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_sendExtendAction_0170"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0170 subscriber finish");
})
var commonEventPublishData = {
code: 170
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('Sub_Misc_inputMethod_sendExtendAction_0180', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 unSubscriberCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 publishCallback start");
if (err){
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["Sub_Misc_inputMethod_sendExtendAction_0180"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>Sub_Misc_inputMethod_sendExtendAction_0180 subscriber finish");
})
var commonEventPublishData = {
code: 180
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
}); });
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册