提交 d20afb00 编写于 作者: Z zhangyushuai

input物理按键输入用例覆盖 001

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 d7635faf
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
import { KeyboardController } from './KeyboardController';
export default class InputKeyService extends InputMethodExtensionAbility {
private keyboardController: KeyboardController;
onCreate(want) {
console.log("====>onCreate onCreate onCreate onCreate onCreate onCreate InputKeyService************************");
this.keyboardController = new KeyboardController(this.context);
this.keyboardController.onCreate();
}
onDestroy() {
console.log("onDestroy InputKeyService**");
this.context.destroy();
}
}
\ No newline at end of file
import prompt from '@ohos.prompt';
/*
* 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 commoneventmanager from '@ohos.commonEventManager';
let inputKeyboardDelegate = inputmethodengine.getKeyboardDelegate();
let inputMethodAbility = inputmethodengine.getInputMethodAbility();
const TAG = "keyboardController";
export class KeyboardController {
mContext;
WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105;
windowName = 'inputApp';
constructor(context) {
this.mContext = context;
}
public onCreate(): void {
let that = this;
inputMethodAbility.on("inputStop", () => {
this.mContext.destroy((err, data) => {
console.info(TAG + '====>inputMethodEngine destorey err:' + JSON.stringify(err));
console.info(TAG + '====>inputMethodEngine destorey data:' + JSON.stringify(data));
});
});
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_Manage_Physical_Buttons_0010 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0010();
break;
case 20:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0020();
break;
case 30:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0030();
break;
case 40:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0040();
break;
case 50:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0050();
break;
case 60:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0060();
break;
case 70:
console.debug(TAG + '====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 event:' + data.event);
that.SUB_Misc_InputMethod_Manage_Physical_Buttons_0070();
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====');
});
}
private publishCallback(err): void {
if (err) {
console.error(TAG + '====>publish failed: ' + JSON.stringify(err));
} else {
console.log(TAG + '====>publish');
}
}
public onDestroy(): void {
console.log('imsakitjsapp onDestroy');
globalThis.textInputClient.getTextIndexAtCursor().then((index) => {
console.log('imsakitjsapp getTextIndexAtCursor: index = ' + index);
prompt.showToast({ message: 'getTextIndexAtCursor success' + index, duration: 200, bottom: 500 });
var win = windowManager.findWindow(this.windowName);
win.destroyWindow();
this.mContext.terminateSelf();
return true;
}).catch((err) => {
prompt.showToast({ message: 'getTextIndexAtCursor failed', duration: 200, bottom: 500 });
});
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0010(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 keyEvent: " + KeyEvents.key.code);
if (KeyEvents.key.code === 2045){
commonEventPublishData = {
data: "SUCCESS"
};
}
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0010", commonEventPublishData, this.publishCallback);
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0020(): void{
let commonEventPublishData = {
data: "FAILED"
};
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 keyEvent: " + KeyEvents.key.code);
if (KeyEvents.key.code === 2017 && KeyEvents.action === 1){
commonEventPublishData = {
data: "SUCCESS"
};
}else{
commonEventPublishData = {
data: "FAILED"
};
}
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0020", commonEventPublishData, this.publishCallback);
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0030(): void{
let commonEventPublishData = {
data: "FAILED"
};
let arr = new Array();
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 keyEvent: " + KeyEvents.key.code);
arr.push(KeyEvents.action);
arr.push(KeyEvents.key.code);
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 arr: " + JSON.stringify(arr));
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 arr: " + arr.join());
if (arr.join() === '1,2045,1,2049,2,2049,2,2045'){
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0030", commonEventPublishData, this.publishCallback);
}else{
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0030", commonEventPublishData, this.publishCallback);
}
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0040(): void{
let commonEventPublishData = {
data: "FAILED"
};
let arr = new Array();
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 keyEvent: " + KeyEvents.key.code);
arr.push(KeyEvents.action);
arr.push(KeyEvents.key.code);
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 arr: " + JSON.stringify(arr));
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 arr: " + arr.join());
if (arr.join() === '1,2017,1,2047,2,2017,2,2047'){
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0040", commonEventPublishData, this.publishCallback);
}else {
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0040", commonEventPublishData, this.publishCallback);
}
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0050(): void{
let commonEventPublishData = {
data: "FAILED"
};
let arr = new Array();
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 keyEvent: " + KeyEvents.key.code);
arr.push(KeyEvents.action);
arr.push(KeyEvents.key.code);
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 arr: " + JSON.stringify(arr));
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 arr: " + arr.join());
if (arr.join() === '1,2047,1,2017,2,2017,2,2047'){
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0050", commonEventPublishData, this.publishCallback);
}else {
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0050", commonEventPublishData, this.publishCallback);
}
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0060(): void{
let commonEventPublishData = {
data: "FAILED"
};
let arr = new Array();
console.info(TAG + '====>receive SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 keyEvent: " + KeyEvents.key.code);
arr.push(KeyEvents.action);
arr.push(KeyEvents.key.code);
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 arr: " + JSON.stringify(arr));
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 arr: " + arr.join());
if (arr.join() === '1,2072,1,2045,1,2055,2,2055,2,2045,2,2072'){
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0060", commonEventPublishData, this.publishCallback);
}else {
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0060", commonEventPublishData, this.publishCallback);
}
}, 500);
}
private SUB_Misc_InputMethod_Manage_Physical_Buttons_0070(): void{
let commonEventPublishData = {
data: "FAILED"
};
let arr = new Array();
console.info(TAG + '====>receive r success');
inputKeyboardDelegate.on('keyEvent', (KeyEvents) => {
console.info(TAG + "====>inputKeyboardDelegate.on('keyEvent')");
try{
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 keyEvent: " + KeyEvents.action);
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 keyEvent: " + KeyEvents.key.code);
arr.push(KeyEvents.action);
arr.push(KeyEvents.key.code);
}catch(err){
console.error("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 keyDown throw_error: " + err);
}
return true;
});
let t = setTimeout(() => {
clearTimeout(t);
inputKeyboardDelegate.off("keyEvent");
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 arr: " + JSON.stringify(arr));
console.info(TAG + "====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 arr: " + arr.join());
if (arr.join() === '1,2072,1,2045,1,2017,2,2017,2,2045,2,2072'){
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0070", commonEventPublishData, this.publishCallback);
}else {
commoneventmanager.publish("SUB_Misc_InputMethod_Manage_Physical_Buttons_0070", commonEventPublishData, this.publishCallback);
}
}, 500);
}
}
\ No newline at end of file
......@@ -12,10 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import inputMethodEngine from './inputMethodEngine.test'
import inputMethodAbility from './inputMethodAbility.test'
import inputMethodEngine from './inputMethodEngine.test';
import inputMethodAbility from './inputMethodAbility.test';
import inputMethodEngineKey from './inputMethodEngineKey.test';
export default function testsuite() {
inputMethodEngine();
inputMethodAbility();
inputMethodEngineKey();
}
\ 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 { 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 inputMethodEngineKeyJSUnit() {
describe('inputMethodEngineKeyEvent', 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 InputKeyService: subtype = {
id: "InputKeyService",
label: "",
name: "com.acts.inputmethodengine.test",
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}
try {
await inputMethod.switchCurrentInputMethodSubtype(InputKeyService);
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));
}
})
let dis = display.getDefaultDisplaySync();
let w = dis.width / 2;
let h = dis.height /2;
let getFocusCmd = `uinput -T -c ${w} ${h}`
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
async function runCmd(cmd) {
console.info("====>runCmdInfo: " + cmd);
await abilityDelegator.executeShellCommand(cmd);
}
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0010', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2045 -u 2045';
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0010"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0010 subscriber finish");
var commonEventPublishData = {
code: 10
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0020', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500);
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2017 -u 2017'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0020"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0020 subscriber finish");
var commonEventPublishData = {
code: 20
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0030', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500);
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2045 -d 2049 -u 2049 -u 2045'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0030"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0030 subscriber finish");
var commonEventPublishData = {
code: 30
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0040', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2017 -d 2047 -u 2017 -u 2047'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0040"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0040 subscriber finish");
var commonEventPublishData = {
code: 40
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0050', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2047 -d 2017 -u 2017 -u 2047'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0050"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0050 subscriber finish");
var commonEventPublishData = {
code: 50
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0060', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2072 -d 2045 -d 2055 -u 2055 -u 2045 -u 2072'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0060"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0060 subscriber finish");
var commonEventPublishData = {
code: 60
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
it('SUB_Misc_InputMethod_Manage_Physical_Buttons_0070', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 unSubscriberCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
async function publishCallback(err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 publishCallback start");
if (err){
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 publishCallback failed:" + JSON.stringify(err));
} else {
let cmd = 'uinput -K -d 2072 -d 2045 -d 2017 -u 2017 -u 2045 -u 2072'
await abilityDelegator.executeShellCommand(cmd);
console.info("====>runCmdInfo success: " + cmd);
}
}
var commonEventSubscribeInfo = {
events: ["SUB_Misc_InputMethod_Manage_Physical_Buttons_0070"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.info("====>SUB_Misc_InputMethod_Manage_Physical_Buttons_0070 subscriber finish");
var commonEventPublishData = {
code: 70
}
commoneventmanager.publish('test', commonEventPublishData, publishCallback);
})
});
})
}
\ No newline at end of file
......@@ -53,6 +53,14 @@
"srcEntrance": "./ets/InputMethodEngine/InputDemoService.ts",
"type": "inputMethod",
"visible": true
},
{
"description": "keyEventDemo",
"icon": "$media:icon",
"name": "InputKeyService",
"srcEntrance": "./ets/InputMethodEngineKey/InputKeyService.ts",
"type": "inputMethod",
"visible":true
}
],
"requestPermissions": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册