提交 8622d971 编写于 作者: Z zhangyushuai

add intputmethodEngine 挑单 004

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 4eb164f7
......@@ -15,6 +15,7 @@ import("//build/ohos_var.gni")
group("inputmethod") {
testonly = true
deps = [
"InputMethodEngine:ActsInputMethodEngineTest",
"InputMethodTest_Stage:ActsImeAbilityTest",
"InputMethodTest_ets:ActsInputMethodEtsTest",
]
......
{
"app":{
"bundleName":"com.acts.inputmethodengine.test",
"vendor":"hw",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsInputMethodEngineTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":IMExtAbility_ets_assets",
":IMExtAbility_resources",
]
ets2abc = true
certificate_profile = "signature/ActsInputMethodEngineTest.p7b"
hap_name = "ActsInputMethodEngineTest"
subsystem_name = "inputmethod"
part_name = "imf"
}
ohos_app_scope("IMExtAbility_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("IMExtAbility_ets_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("IMExtAbility_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":IMExtAbility_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.inputmethodengine.test",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 15000
},
"kits": [{
"test-file-name": [
"ActsInputMethodEngineTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
/*
* 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 AbilityStage from "@ohos.app.ability.AbilityStage";
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate");
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* 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 InputDemoService extends InputMethodExtensionAbility {
private keyboardDelegate: KeyboardDelegate;
onCreate(want) {
this.keyboardDelegate = new KeyboardDelegate(this.context);
this.keyboardDelegate.onCreate(); // 初始化窗口
}
onDestroy() {
console.log("onDestroy inputStageService**");
this.context.destroy();
}
}
\ 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;
}
public onCreate(): void {
this.initWindow();
let that = this;
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 1:
console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 event:' + data.event);
that.inputMethodAbility_test_getInputMethodAbility_001();
break;
case 2:
console.debug(TAG + '====>inputMethodAbility_test_getInputMethodDelegate_001 event:' + data.event);
that.inputMethodAbility_test_getKeyboardDelegate_001();
break;
case 28:
console.debug(TAG + '====>inputMethodAbility_test_028 event:' + data.event);
that.inputMethodAbility_test_028();
break;
case 29:
console.debug(TAG + '====>inputMethodAbility_test_029 event:' + data.event);
that.inputMethodAbility_test_029();
break;
case 30:
console.debug(TAG + '====>inputMethodAbility_test_030 event:' + data.event);
that.inputMethodAbility_test_030();
break;
case 31:
console.debug(TAG + '====>inputMethodAbility_test_031 event:' + data.event);
that.inputMethodAbility_test_031();
break;
case 32:
console.debug(TAG + '====>inputMethodAbility_test_032 event:' + data.event);
that.inputMethodAbility_test_032();
break;
case 33:
console.debug(TAG + '====>inputMethodAbility_test_033 event:' + data.event);
that.inputMethodAbility_test_033();
break;
case 34:
console.debug(TAG + '====>inputMethodAbility_test_034 event:' + data.event);
that.inputMethodAbility_test_034();
break;
case 35:
console.debug(TAG + '====>inputMethodAbility_test_035 event:' + data.event);
that.inputMethodAbility_test_035();
break;
case 36:
console.debug(TAG + '====>inputMethodAbility_test_036 event:' + data.event);
that.inputMethodAbility_test_036();
break;
case 37:
console.debug(TAG + '====>inputMethodAbility_test_037 event:' + data.event);
that.inputMethodAbility_test_037();
break;
case 38:
console.debug(TAG + '====>inputMethodAbility_test_038 event:' + data.event);
that.inputMethodAbility_test_038();
break;
case 39:
console.debug(TAG + '====>inputMethodAbility_test_039 event:' + data.event);
that.inputMethodAbility_test_039();
break;
case 40:
console.debug(TAG + '====>inputMethodAbility_test_040 event:' + data.event);
that.inputMethodAbility_test_040();
break;
case 41:
console.debug(TAG + '====>inputMethodAbility_test_041 event:' + data.event);
that.inputMethodAbility_test_041();
break;
case 42:
console.debug(TAG + '====>inputMethodAbility_test_042 event:' + data.event);
that.inputMethodAbility_test_042();
break;
case 43:
console.debug(TAG + '====>inputMethodAbility_test_043 event:' + data.event);
that.inputMethodAbility_test_043();
break;
case 45:
console.debug(TAG + '====>inputMethodAbility_test_045 event:' + data.event);
that.inputMethodAbility_test_045();
break;
case 46:
console.debug(TAG + '====>inputMethodAbility_test_046 event:' + data.event);
that.inputMethodAbility_test_046();
break;
case 47:
console.debug(TAG + '====>inputMethodAbility_test_047 event:' + data.event);
that.inputMethodAbility_test_047();
break;
case 48:
console.debug(TAG + '====>inputMethodAbility_test_048 event:' + data.event);
that.inputMethodAbility_test_048();
break;
case 49:
console.debug(TAG + '====>inputMethodAbility_test_049 event:' + data.event);
that.inputMethodAbility_test_049();
break;
case 50:
console.debug(TAG + '====>inputMethodAbility_test_050 event:' + data.event);
that.inputMethodAbility_test_050();
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 inputMethodAbility_test_getInputMethodAbility_001(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_getInputMethodAbility_001 data');
if (typeof(inputMethodAbility) === 'object') {
console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 success');
var commonEventPublishData = {
data: "SUCCESS"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 failed');
var commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_getInputMethodAbility_001", commonEventPublishData, this.publishCallback);
}
private inputMethodAbility_test_getKeyboardDelegate_001(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_getKeyboardDelegate_001 data');
if (typeof (inputKeyboardDelegate) === 'object') {
console.debug(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 success');
var commonEventPublishData = {
data: "SUCCESS"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 failed');
var commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_getKeyboardDelegate_001", commonEventPublishData, this.publishCallback);
}
private inputMethodAbility_test_028(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_028 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_028", commonEventPublishData, this.publishCallback);
} else {
let editorAttribyte = await InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodAbility_test_028 editorAttribyte:' + JSON.stringify(editorAttribyte));
InputClient.sendKeyFunction(editorAttribyte.enterKeyType, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_028 sendKeyFunction err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_028 sendKeyFunction value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_028", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_029(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_029 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_029", commonEventPublishData, this.publishCallback);
} else {
let editorAttribyte = await InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodAbility_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte));
let value = InputClient.sendKeyFunction(editorAttribyte.enterKeyType);
console.debug(TAG + '====>inputMethodAbility_test_029 sendKeyFunction value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_029", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_030(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_030 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_030", commonEventPublishData, this.publishCallback);
} else {
InputClient.deleteForward(1, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_030 deleteForward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_030 deleteForward value:' + JSON.stringify(value));
if (typeof value === 'boolean') {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_030", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_031(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_031 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_031", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.deleteForward(1);
console.debug(TAG + '====>inputMethodAbility_test_031 deleteForward value:' + value);
if (typeof value === 'boolean') {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_031", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_032(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_032 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_032", commonEventPublishData, this.publishCallback);
} else {
InputClient.deleteBackward(1, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_032 deleteBackward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_032 deleteBackward value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_032", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_033(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_033 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_033", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.deleteBackward(1);
console.debug(TAG + '====>inputMethodAbility_test_033 deleteBackward value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_033", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_034(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_034 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_034", commonEventPublishData, this.publishCallback);
} else {
InputClient.insertText('test', (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_034 insertText err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_034 insertText value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_034", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_035(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_035 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.insertText('test');
console.debug(TAG + '====>inputMethodAbility_test_035 insertText value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_036(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_036 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_036", commonEventPublishData, this.publishCallback);
} else {
InputClient.getForward(1, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_036 getForward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_036 getForward value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_036", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_037(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_037 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getForward(1);
console.debug(TAG + '====>inputMethodAbility_test_037 getForward value' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_038(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_038 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_038", commonEventPublishData, this.publishCallback);
} else {
InputClient.getEditorAttribute((err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_038 getEditorAttribute err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_038 getEditorAttribute value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodAbility_test_038", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_039(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_039 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodAbility_test_039 getEditorAttribute value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_040(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_040 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback);
} else {
try {
KeyboardDelegate.hideKeyboard((err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_040 hideKeyboard err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback);
});
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodAbility_test_040 hideKeyboard throw_err:');
commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback);
}
}
});
}
private inputMethodAbility_test_041(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_041 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_041", commonEventPublishData, this.publishCallback);
} else {
try {
await KeyboardDelegate.hideKeyboard();
console.debug(TAG + '====>inputMethodAbility_test_041 hideKeyboard success');
commonEventPublishData = {
data: "SUCCESS"
};
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodAbility_test_041 hideKeyboard catch err:' + JSON.stringify(err));
}
commoneventmanager.publish("inputMethodAbility_test_041", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_042(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_042 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_042", commonEventPublishData, this.publishCallback);
} else {
InputClient.getBackward(1, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_042 getBackward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_042 getBackward value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_042", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_043(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_043 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getBackward(1);
console.debug(TAG + '====>inputMethodAbility_test_043 getBackward value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_045(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_045 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
setTimeout(()=>{
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback);
} else {
InputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_045 CURSOR_UP err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_045 CURSOR_UP value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback);
});
}
},1000);
});
}
private inputMethodAbility_test_046(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_046 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_046", commonEventPublishData, this.publishCallback);
} else {
InputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_046", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodAbility_test_047(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_047 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_047", commonEventPublishData, this.publishCallback);
} else {
await InputClient.moveCursor(inputMethodEngine.CURSOR_LEFT);
console.debug(TAG + '====>inputMethodAbility_test_047 CURSOR_LEFT success');
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("inputMethodAbility_test_047", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_048(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_048 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_048", commonEventPublishData, this.publishCallback);
} else {
await InputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT);
console.debug(TAG + '====>inputMethodAbility_test_048 CURSOR_RIGHT success');
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("inputMethodAbility_test_048", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodAbility_test_049(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_049 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_049", commonEventPublishData, this.publishCallback);
} else {
try {
KeyboardDelegate.hide((err, value) => {
if (err) {
console.debug(TAG + '====>inputMethodAbility_test_049 hide err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodAbility_test_049", commonEventPublishData, this.publishCallback);
});
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodAbility_test_049 hide throw_err:');
commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback);
}
}
});
}
private inputMethodAbility_test_050(): void {
console.debug(TAG + '====>receive inputMethodAbility_test_050 data');
inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => {
inputMethodAbility.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodAbility_test_050", commonEventPublishData, this.publishCallback);
} else {
try {
await KeyboardDelegate.hide();
console.debug(TAG + '====>inputMethodAbility_test_050 hideKeyboard success');
commonEventPublishData = {
data: "SUCCESS"
};
} catch (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodAbility_test_050 hideKeyboard catch err:' + JSON.stringify(err));
}
commoneventmanager.publish("inputMethodAbility_test_050", commonEventPublishData, this.publishCallback);
}
});
}
}
\ 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 InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
import { KeyboardController } from './KeyboardController';
export default class InputDemoService extends InputMethodExtensionAbility {
private keyboardController: KeyboardController;
onCreate(want) {
this.keyboardController = new KeyboardController(this.context);
this.keyboardController.onCreate(); // 初始化窗口
}
onDestroy() {
console.log("onDestroy inputMethodEngine**");
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 inputMethodEngine = inputmethodengine.getInputMethodEngine();
let inputKeyboardDelegate = inputmethodengine.createKeyboardDelegate();
const TAG = "keyboardController";
export class KeyboardController {
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;
}
public onCreate(): void {
this.initWindow();
let that = this;
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 1:
console.debug(TAG + '====>inputMethodEngine_test_getInputMethodEngine_001 event:' + data.event);
that.inputMethodEngine_test_getInputMethodEngine_001();
break;
case 2:
console.debug(TAG + '====>inputMethodEngine_test_getKeyboardDelegate_001 event:' + data.event);
that.inputMethodEngine_test_getKeyboardDelegate_001();
break;
case 28:
console.debug(TAG + '====>inputMethodEngine_test_028 event:' + data.event);
that.inputMethodEngine_test_028();
break;
case 29:
console.debug(TAG + '====>inputMethodEngine_test_029 event:' + data.event);
that.inputMethodEngine_test_029();
break;
case 30:
console.debug(TAG + '====>inputMethodEngine_test_030 event:' + data.event);
that.inputMethodEngine_test_030();
break;
case 31:
console.debug(TAG + '====>inputMethodEngine_test_031 event:' + data.event);
that.inputMethodEngine_test_031();
break;
case 32:
console.debug(TAG + '====>inputMethodEngine_test_032 event:' + data.event);
that.inputMethodEngine_test_032();
break;
case 33:
console.debug(TAG + '====>inputMethodEngine_test_033 event:' + data.event);
that.inputMethodEngine_test_033();
break;
case 34:
console.debug(TAG + '====>inputMethodEngine_test_034 event:' + data.event);
that.inputMethodEngine_test_034();
break;
case 35:
console.debug(TAG + '====>inputMethodEngine_test_035 event:' + data.event);
that.inputMethodEngine_test_035();
break;
case 36:
console.debug(TAG + '====>inputMethodEngine_test_036 event:' + data.event);
that.inputMethodEngine_test_036();
break;
case 37:
console.debug(TAG + '====>inputMethodEngine_test_037 event:' + data.event);
that.inputMethodEngine_test_037();
break;
case 38:
console.debug(TAG + '====>inputMethodEngine_test_038 event:' + data.event);
that.inputMethodEngine_test_038();
break;
case 39:
console.debug(TAG + '====>inputMethodEngine_test_039 event:' + data.event);
that.inputMethodEngine_test_039();
break;
case 40:
console.debug(TAG + '====>inputMethodEngine_test_040 event:' + data.event);
that.inputMethodEngine_test_040();
break;
case 41:
console.debug(TAG + '====>inputMethodEngine_test_041 event:' + data.event);
that.inputMethodEngine_test_041();
break;
case 42:
console.debug(TAG + '====>inputMethodEngine_test_042 event:' + data.event);
that.inputMethodEngine_test_042();
break;
case 43:
console.debug(TAG + '====>inputMethodEngine_test_043 event:' + data.event);
that.inputMethodEngine_test_043();
break;
case 49:
console.debug(TAG + '====>inputMethodEngine_test_049 event:' + data.event);
that.inputMethodEngine_test_049();
break;
case 50:
console.debug(TAG + '====>inputMethodEngine_test_050 event:' + data.event);
that.inputMethodEngine_test_050();
break;
}
}
var commonEventSubscribeInfo = {
events: ["test1"]
};
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) {
subscriber = data;
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug(TAG + '====>scene subscribe finish====');
});
}
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 initWindow(): void {
display.getDefaultDisplay().then(dis => {
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,
ctx: this.mContext
};
windowManager.createWindow(config).then((win) => {
win.resize(dWidth, keyHeight).then(() => {
win.moveWindowTo(0, this.nonBarPosition).then(() => {
win.setUIContent('pages/service/index').then(() => {
});
});
});
});
});
}
private publishCallback(err): void {
if (err) {
console.error(TAG + '====>publish failed: ' + JSON.stringify(err));
} else {
console.log(TAG + '====>publish');
}
}
private inputMethodEngine_test_getInputMethodEngine_001(): void {
console.debug(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 data');
if (typeof(inputMethodEngine) === "object") {
console.info(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 object');
var commonEventPublishData = {
data: "SUCCESS"
};
} else {
console.info(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 failed');
var commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_getInputMethodEngine_001", commonEventPublishData, this.publishCallback);
}
private inputMethodEngine_test_getKeyboardDelegate_001(): void {
console.debug(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 data');
if (typeof(inputKeyboardDelegate) === "object") {
console.info(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 object');
var commonEventPublishData = {
data: "SUCCESS"
};
} else {
console.info(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 failed');
var commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_getKeyboardDelegate_001", commonEventPublishData, this.publishCallback);
}
private inputMethodEngine_test_028(): void {
console.debug(TAG + '====>receive inputMethodEngine_test_028 data');
inputMethodEngine.on('inputStart', async (keyboardController, TextInputClient) => {
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (TextInputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_028", commonEventPublishData, this.publishCallback);
} else {
let editorAttribyte = await TextInputClient.getEditorAttribute();
console.debug(TAG + '====>receive inputMethodEngine_test_028 editorAttribyte: ' + JSON.stringify(editorAttribyte));
TextInputClient.sendKeyFunction(editorAttribyte.enterKeyType, (err, value) => {
if (err) {
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodEngine_test_028 TextInputClient sendKeyFunction err: ' + JSON.stringify(err));
} else {
console.debug(TAG + '====>inputMethodEngine_test_028 TextInputClient sendKeyFunction value: ' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_028", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_029(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_029 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_029", commonEventPublishData, this.publishCallback);
} else {
let editorAttribyte = await InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodEngine_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte));
let value = await InputClient.sendKeyFunction(editorAttribyte.enterKeyType);
console.debug(TAG + '====>inputMethodEngine_test_029 sendKeyFunction:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_029", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_030(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_030 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_030", commonEventPublishData, this.publishCallback);
} else {
InputClient.deleteForward(1, (err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_030 deleteForward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_030 deleteForward value:' + JSON.stringify(value));
if (typeof(value) === 'boolean'){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_030", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_031(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_031 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_031", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.deleteForward(1);
console.debug(TAG + '====>inputMethodEngine_test_031 deleteForward:' + JSON.stringify(value));
if (typeof(value) === 'boolean'){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_031", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_032(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_032 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_032", commonEventPublishData, this.publishCallback);
} else {
InputClient.deleteBackward(1, (err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_032 deleteBackward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_032 deleteBackward value:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_032", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_033(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_033 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_033", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.deleteBackward(1);
console.debug(TAG + '====>inputMethodEngine_test_033 deleteBackward:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_033", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_034(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_034 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_034", commonEventPublishData, this.publishCallback);
} else {
InputClient.insertText('test', (err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_034 insertText err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_034 insertText value:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_034", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_035(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_035 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_035", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.insertText('test');
console.debug(TAG + '====>inputMethodEngine_test_035 insertText:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_035", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_036(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_036 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_036", commonEventPublishData, this.publishCallback);
} else {
InputClient.getForward(1, (err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_036 getForward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_036 getForward value:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_036", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_037(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_037 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_037", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.getForward(1);
console.debug(TAG + '====>inputMethodEngine_test_037 getForward:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_037", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_038(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_038 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_038", commonEventPublishData, this.publishCallback);
} else {
InputClient.getEditorAttribute((err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_038 getEditorAttribute err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_038 getEditorAttribute value:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
}
commoneventmanager.publish("inputMethodEngine_test_038", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_039(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_039 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_039", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodEngine_test_039 getEditorAttribute:' + JSON.stringify(value));
if (value){
commonEventPublishData = {
data: "SUCCESS"
};
} else {
commonEventPublishData = {
data: "FAILED"
};
}
commoneventmanager.publish("inputMethodEngine_test_039", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_040(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_040 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_040", commonEventPublishData, this.publishCallback);
} else {
try{
KeyboardDelegate.hideKeyboard((err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_040 hideKeyboard:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_040", commonEventPublishData, this.publishCallback);
});
}catch(err){
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodEngine_test_040 hideKeyboard throw_err:');
commoneventmanager.publish("inputMethodEngine_test_040", commonEventPublishData, this.publishCallback);
}
}
});
}
private inputMethodEngine_test_041(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_041 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_041", commonEventPublishData, this.publishCallback);
} else {
try{
await KeyboardDelegate.hideKeyboard();
console.debug(TAG + '====>inputMethodEngine_test_041 hideKeyboard success');
commonEventPublishData = {
data: "SUCCESS"
};
}catch(err){
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodEngine_test_041 hideKeyboard catch err:');
}
commoneventmanager.publish("inputMethodEngine_test_041", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_042(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_042 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_042", commonEventPublishData, this.publishCallback);
} else {
InputClient.getBackward(1, (err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_042 getBackward err:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
console.debug(TAG + '====>inputMethodEngine_test_042 getBackward value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_042", commonEventPublishData, this.publishCallback);
});
}
});
}
private inputMethodEngine_test_043(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_043 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_043", commonEventPublishData, this.publishCallback);
} else {
let value = await InputClient.getBackward(1);
console.debug(TAG + '====>inputMethodEngine_test_043 getBackward:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
};
commoneventmanager.publish("inputMethodEngine_test_043", commonEventPublishData, this.publishCallback);
}
});
}
private inputMethodEngine_test_049(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_049 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_049", commonEventPublishData, this.publishCallback);
} else {
try{
KeyboardDelegate.hide((err, value) => {
if (err){
console.debug(TAG + '====>inputMethodEngine_test_049 hide:' + JSON.stringify(err));
commonEventPublishData = {
data: "FAILED"
};
} else {
commonEventPublishData = {
data: "SUCCESS"
};
}
commoneventmanager.publish("inputMethodEngine_test_049", commonEventPublishData, this.publishCallback);
});
}catch(err){
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodEngine_test_049 hide throw_err:');
commoneventmanager.publish("inputMethodEngine_test_040", commonEventPublishData, this.publishCallback);
}
}
});
}
private inputMethodEngine_test_050(): void{
console.debug(TAG + '====>receive inputMethodEngine_test_050 data');
inputMethodEngine.on('inputStart', async(KeyboardDelegate, InputClient) =>{
inputMethodEngine.off('inputStart');
let commonEventPublishData;
if (InputClient == null) {
commonEventPublishData = {
data: "FAILED"
};
commoneventmanager.publish("inputMethodEngine_test_050", commonEventPublishData, this.publishCallback);
} else {
try{
await KeyboardDelegate.hide();
console.debug(TAG + '====>inputMethodEngine_test_050 hideKeyboard success');
commonEventPublishData = {
data: "SUCCESS"
};
}catch(err){
commonEventPublishData = {
data: "FAILED"
};
console.debug(TAG + '====>inputMethodEngine_test_050 hideKeyboard catch err:');
}
commoneventmanager.publish("inputMethodEngine_test_050", commonEventPublishData, this.publishCallback);
}
});
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility';
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.info("ImExtAbility onCreate");
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.info("ImExtAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info("ImExtAbility onWindowStageCreate");
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/index/index", null);
console.info("ImExtAbility onWindowStageCreate finish");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info("ImExtAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.info("ImExtAbility onForeground");
}
onBackground() {
// Ability has back to background
console.info("ImExtAbility onBackground");
}
};
\ 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 TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
var abilityDelegator = undefined;
var abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ");
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
var cmd = 'aa start -d 0 -a com.acts.inputmethodengine.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters["-D"];
if (debug === 'true')
{
cmd += ' -D';
}
console.info('cmd : '+cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
});
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
@State inputValue: string = 'inputMethodEngineinputMethodEngineinputMethodEngineinputMethodEngine' +
'inputMethodEngineinputMethodEngineinputMethodEngineinputMethodEngineinputMethodEngine';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.defaultFocus(true)
TextArea({ text: this.inputValue })
.height(50)
.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%')
}
.height('100%')
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ 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 './inputMethodEngine.test'
import inputMethodAbility from './inputMethodAbility.test'
export default function testsuite() {
inputMethodEngine();
inputMethodAbility()
}
\ 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 inputMethod from '@ohos.inputMethod';
import inputMethodEngine from '@ohos.inputMethodEngine';
import subtype from '@ohos.InputMethodSubtype';
import commonEventManager from '@ohos.commonEventManager';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'
import display from '@ohos.display';
export default function inputMethodAbility() {
describe('inputMethodAbility', function () {
var inputServer = {
packageName: '',
methodId: '',
name:'',
id:'',
extra:{}
}
let display_info;
let getFocusCmd = '';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
async function runCmd(cmd){
console.debug('====>runCmd info:' + cmd);
await abilityDelegator.executeShellCommand(cmd);
}
beforeAll(async (done)=>{
display_info = display.getDefaultDisplaySync()
getFocusCmd = `uinput -T -c ${display_info.width*0.5} ${display_info.height*0.5}`
let inputM = inputMethod.getCurrentInputMethod()
console.info("====>beforeAll: switchInputMethod to: " + JSON.stringify(inputM));
inputServer.packageName = inputM.packageName;
inputServer.methodId = inputM.methodId;
inputServer.name = inputM.packageName;
inputServer.id = inputM.methodId;
console.info("====>beforeAll inputMethodStageJSUnit start");
let inputDemoService: subtype ={
id: 'com.acts.inputmethodengine.test',
label: 'inputStageService',
name: '',
mode: 'lower',
locale: '',
language: '',
icon: '',
iconId: 0,
extra: {},
}
try{
await inputMethod.switchCurrentInputMethodSubtype(inputDemoService);
setTimeout(()=>{
console.debug("====>beforeAll inputMethodStageJSUnit switchCurrentInputMethodSubtype success");
done();
},2000)
}catch(err){
console.debug("====>beforeAll inputMethodStageJSUnit switchCurrentInputMethodSubtype failed");
}
})
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('inputMethodAbility_test_getInputMethodAbility_001', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 publishCallback failed:" +
JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_getInputMethodAbility_001"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_getInputMethodAbility_001 subscriber finish");
})
var commonEventPublishData = {
code: 1
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_getKeyboardDelegate_001', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 publishCallback failed:" +
JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_getKeyboardDelegate_001"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_getKeyboardDelegate_001 subscriber finish");
})
var commonEventPublishData = {
code: 2
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_028', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_028 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_028 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_028 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_028 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_028 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_028 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_028 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_028 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_028"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_028 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_028 subscriber finish");
})
var commonEventPublishData = {
code: 28
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_029', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_029 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_029 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_029 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_029 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_029 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_029 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_029 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_029 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_029"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_029 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_029 subscriber finish");
})
var commonEventPublishData = {
code: 29
}
commonEventManager.publish('test', commonEventPublishData, publishCallback)
});
it('inputMethodAbility_test_030', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_030 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_030 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_030 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_030 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_030 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_030 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_030 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_030 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_030"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_030 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_030 subscriber finish");
})
var commonEventPublishData = {
code: 30
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_031', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_031 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_031 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_031 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_031 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_031 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_031 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_031 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_031 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_031"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_031 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_031 subscriber finish");
})
var commonEventPublishData = {
code: 31
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_032', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_032 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_032 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_032 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_032 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_032 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_032 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_032 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_032 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_032"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_032 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_032 subscriber finish");
})
var commonEventPublishData = {
code: 32
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_033', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_033 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_033 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_033 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_033 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_033 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_033 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_033 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_033 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_033"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_033 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_033 subscriber finish");
})
var commonEventPublishData = {
code: 33
}
commonEventManager.publish('test', commonEventPublishData, publishCallback)
});
it('inputMethodAbility_test_034', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_034 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_034 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_034 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_034 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_034 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_034 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_034 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_034 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_034"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_034 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_034 subscriber finish");
})
var commonEventPublishData = {
code: 34
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_035', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_035 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_035 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_035 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_035 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_035 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_035 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_035 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_035 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_035"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_035 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_035 subscriber finish");
})
var commonEventPublishData = {
code: 35
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_036', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_036 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_036 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_036 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_036 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_036 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_036 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_036 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_036 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_036"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_036 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_036 subscriber finish");
})
var commonEventPublishData = {
code: 36
};
commonEventManager.publish('test', commonEventPublishData, publishCallback);;
});
it('inputMethodAbility_test_037', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_037 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_037 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_037 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_037 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_037 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_037 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_037 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_037 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_037"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_037 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_037 subscriber finish");
})
var commonEventPublishData = {
code: 37
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_038', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_038 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_038 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_038 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_038 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_038 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_038 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_038 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_038 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_038"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_038 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_038 subscriber finish");
})
var commonEventPublishData = {
code: 38
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_039', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_039 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_039 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_039 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_039 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_039 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_039 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_039 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_039 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_039"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_039 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_039 subscriber finish");
})
var commonEventPublishData = {
code: 39
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_040', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_040 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_040 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_040 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_040 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_040 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_040 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_040 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_040 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_040"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_040 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_040 subscriber finish");
})
var commonEventPublishData = {
code: 40
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_041', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_041 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_041 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_041 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_041 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_041 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_041 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_041 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_041 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_041"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_041 subscriber data:" + JSON.stringify(data))
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_041 subscriber finish");
})
var commonEventPublishData = {
code: 41
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_042', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_042 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_042 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_042 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_042 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_042 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_042 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_042 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_042 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_042"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_042 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_042 subscriber finish");
})
var commonEventPublishData = {
code: 42
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_043', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_043 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_043 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_043 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_043 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_043 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_043 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_043 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_043 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_043"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_043 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_043 subscriber finish");
})
var commonEventPublishData = {
code: 43
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_044', 0, async function (done) {
let keyType = inputMethodEngine.WINDOW_TYPE_INPUT_METHOD_FLOAT;
console.info("====>inputMethodEngine_test_044 result:" + keyType);
expect(keyType).assertEqual(2105);
done();
});
it('inputMethodAbility_test_045', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_045 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_045 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_045 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_045 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_045 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_045 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_045 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_045 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_045"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_045 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_045 subscriber finish");
})
var commonEventPublishData = {
code: 45
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_046', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_046 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_046 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_046 unSubscriberCallback finish")
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_046 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_046 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_046 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_046 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_046 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_046"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_046 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_046 subscriber finish");
})
var commonEventPublishData = {
code: 46
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_047', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_047 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_047 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_047 unSubscriberCallback finish")
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_047 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_047 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_047 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_047 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_047 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_047"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_047 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_047 subscriber finish");
})
var commonEventPublishData = {
code: 47
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_048', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_048 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_048 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_048 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_048 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_048 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_048 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_048 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_048 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_048"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_048 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_048 subscriber finish");
})
var commonEventPublishData = {
code: 48
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_049', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_049 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_049 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_049 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_049 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_049 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_049 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_049 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_049 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_049"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_049 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_049 subscriber finish");
})
var commonEventPublishData = {
code: 49
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
it('inputMethodAbility_test_050', 0, async function (done) {
function unSubscriberCallback (err){
console.info("====>inputMethodAbility_test_050 unSubscriberCallback start");
if (err){
console.info("====>inputMethodAbility_test_050 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.info("====>inputMethodAbility_test_050 unSubscriberCallback finish");
}
}
function subscriberCallback (err, data){
console.info("====>inputMethodAbility_test_050 subscriberCallback data:"
+ JSON.stringify(data));
commonEventManager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try{
expect(data.data).assertEqual("SUCCESS");
console.info("====>inputMethodAbility_test_050 end");
clearTimeout(t);
done();
}catch(err){
console.info("====>inputMethodAbility_test_050 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err){
console.info("====>inputMethodAbility_test_050 publishCallback start");
if (err){
console.info("====>inputMethodAbility_test_050 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodAbility_test_050"]
}
var subscriber;
commonEventManager.createSubscriber(commonEventSubscribeInfo).then((data)=>{
subscriber = data;
console.info("====>inputMethodAbility_test_050 subscriber data:" + JSON.stringify(data));
commonEventManager.subscribe(subscriber, subscriberCallback);
console.info("====>inputMethodAbility_test_050 subscriber finish")
})
var commonEventPublishData = {
code: 50
}
commonEventManager.publish('test', commonEventPublishData, publishCallback);
});
});
};
/**
* 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 inputMethodEngineJSUnit() {
describe('inputMethodEngine', 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: "com.acts.inputmethodengine.test",
label: "InputDemoService",
name: "",
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}
try {
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));
}
})
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('inputMethodEngine_test_getInputMethodEngine_001', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_getInputMethodEngine_001 unSubscriberCallback start");
if (err) {
console.error("====>inputMethodEngine_test_getInputMethodEngine_001 unSubscriberCallback failed: " + JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_getInputMethodEngine_001 unSubscriberCallback finsh");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 subscriberCallback data: " + JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 end<====");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 end<====" + JSON.stringify(err));
clearTimeout(t)
done();
}
}, 500)
}
async function publishCallback(err) {
if (err) {
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 end<====" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_getInputMethodEngine_001"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) {
subscriber = data;
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 subscribe data: " + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_getInputMethodEngine_001 subscribe finish====");
})
var commonEventPublishData = {
code: 1
}
commoneventmanager.publish("test1", commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) {
function unSubscriberCallback(err) {
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 unSubscriberCallback start");
if (err) {
console.error("====>inputMethodEngine_test_getKeyboardDelegate_001 unSubscriberCallback failed: " + JSON.stringify(err));
} else {
console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 unSubscriberCallback finsh");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 subscriberCallback data: " + JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 end<====");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 end<====" + JSON.stringify(err));
clearTimeout(t)
done();
}
}, 500)
}
async function publishCallback(err) {
if (err) {
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 end<====" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_getKeyboardDelegate_001"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) {
subscriber = data;
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 subscribe data: " + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_getKeyboardDelegate_001 subscribe finish====");
})
var commonEventPublishData = {
code: 2
}
commoneventmanager.publish("test1", commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_028', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_028 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_028 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_028 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_028 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_028 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_028 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_028 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_028 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_028"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_028 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_028 subscriber finish");
})
var commonEventPublishData = {
code: 28
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_029', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_029 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_029 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_029 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_029 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_029 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_029 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_029 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_029 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_029"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_029 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_029 subscriber finish");
})
var commonEventPublishData = {
code: 29
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_030', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_030 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_030 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_030 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_030 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_030 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_030 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_030 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_030 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_030"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_030 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_030 subscriber finish");
})
var commonEventPublishData = {
code: 30
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_031', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_031 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_031 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_031 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_031 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_031 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_031 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 10000)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_031 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_031 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_031"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_031 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_031 subscriber finish");
})
var commonEventPublishData = {
code: 31
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_032', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_032 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_032 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_032 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_032 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_032 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_032 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_032 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_032 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_032"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_032 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_032 subscriber finish");
})
var commonEventPublishData = {
code: 32
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_033', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_033 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_033 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_033 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_033 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_033 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_033 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_033 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_033 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_033"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_033 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_033 subscriber finish")
})
var commonEventPublishData = {
code: 33
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback)
});
it('inputMethodEngine_test_034', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_034 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_034 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_034 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_034 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_034 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_034 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_034 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_034 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_034"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_034 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_034 subscriber finish");
})
var commonEventPublishData = {
code: 34
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_035', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_035 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_035 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_035 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_035 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_035 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_035 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_035 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_035 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_035"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_035 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_035 subscriber finish");
})
var commonEventPublishData = {
code: 35
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_036', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_036 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_036 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_036 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_036 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_036 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_036 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_036 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_036 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_036"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_036 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_036 subscriber finish");
})
var commonEventPublishData = {
code: 36
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_037', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_037 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_037 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_037 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_037 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_037 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_037 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_037 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_037 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_037"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_037 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_037 subscriber finish");
})
var commonEventPublishData = {
code: 37
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_038', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_038 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_038 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_038 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_038 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_038 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_038 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_038 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_038 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_038"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_038 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_038 subscriber finish");
})
var commonEventPublishData = {
code: 38
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_039', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_039 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_039 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_039 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_039 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_039 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_039 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_039 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_039 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_039"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_039 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_039 subscriber finish");
})
var commonEventPublishData = {
code: 39
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_040', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_040 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_040 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_040 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_040 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_040 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_040 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_040 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_040 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_040"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_040 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_040 subscriber finish");
})
var commonEventPublishData = {
code: 40
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_041', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_041 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_041 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_041 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_041 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_041 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_041 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_041 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_041 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_041"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_041 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_041 subscriber finish");
})
var commonEventPublishData = {
code: 41
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_042', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_042 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_042 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_042 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_042 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_042 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_042 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_042 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_042 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_042"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_042 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_042 subscriber finish");
})
var commonEventPublishData = {
code: 42
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_043', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_043 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_043 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_043 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_043 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_043 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_043 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_043 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_043 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_043"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_043 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_043 subscriber finish");
})
var commonEventPublishData = {
code: 43
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_049', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_049 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_049 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_049 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_049 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_049 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_049 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_049 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_049 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_049"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_049 subscriber data:" + JSON.stringify(data))
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_049 subscriber finish")
})
var commonEventPublishData = {
code: 49
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
it('inputMethodEngine_test_050', 0, async function (done) {
function unSubscriberCallback(err) {
console.debug("====>inputMethodEngine_test_050 unSubscriberCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_050 unSubscriberCallback failed:" +
JSON.stringify(err));
} else {
console.debug("====>inputMethodEngine_test_050 unSubscriberCallback finish");
}
}
function subscriberCallback(err, data) {
console.debug("====>inputMethodEngine_test_050 subscriberCallback data:"
+ JSON.stringify(data));
commoneventmanager.unsubscribe(subscriber, unSubscriberCallback);
let t = setTimeout(() => {
try {
expect(data.data).assertEqual("SUCCESS");
console.debug("====>inputMethodEngine_test_050 end");
clearTimeout(t);
done();
} catch (err) {
console.debug("====>inputMethodEngine_test_050 err:" + JSON.stringify(err));
clearTimeout(t);
done();
}
}, 500)
}
function publishCallback(err) {
console.debug("====>inputMethodEngine_test_050 publishCallback start");
if (err) {
console.debug("====>inputMethodEngine_test_050 publishCallback failed:" + JSON.stringify(err));
} else {
runCmd(getFocusCmd);
}
}
var commonEventSubscribeInfo = {
events: ["inputMethodEngine_test_050"]
}
var subscriber;
commoneventmanager.createSubscriber(commonEventSubscribeInfo).then((data) => {
subscriber = data;
console.debug("====>inputMethodEngine_test_050 subscriber data:" + JSON.stringify(data));
commoneventmanager.subscribe(subscriber, subscriberCallback);
console.debug("====>inputMethodEngine_test_050 subscriber finish");
})
var commonEventPublishData = {
code: 50
}
commoneventmanager.publish('test1', commonEventPublishData, publishCallback);
});
})
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "false"
}
],
"abilities": [
{
"name": "com.acts.inputmethodengine.test.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"description": "输入法demoStage",
"icon": "$media:icon",
"name": "inputStageService",
"srcEntrance": "./ets/InputMethodAbility/InputStageService.ts",
"type": "inputMethod",
"visible":true
},
{
"description": "输入法Demo",
"icon": "$media:icon",
"name": "InputDemoService",
"srcEntrance": "./ets/InputMethodEngine/InputDemoService.ts",
"type": "inputMethod",
"visible":true
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CONNECT_IME_ABILITY"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsImeAbilityTest"
},
{
"name": "ime_description",
"value": "input method extension ability."
},
{
"name": "ime_label",
"value": "inputMethod extension ability services."
},
{
"name": "ime_label_1",
"value": "inputMethod extension ability services_1."
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册