• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import prompt from '@ohos.prompt';
2/*
3 * Copyright (c) 2024 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import inputmethodengine from '@ohos.inputMethodEngine';
17import display from '@ohos.display';
18import windowManager from '@ohos.window';
19import commoneventmanager from '@ohos.commonEventManager';
20import inputMethod from '@ohos.inputMethod';
21import { resourceManager } from '@kit.LocalizationKit';
22
23
24let inputMethodEngine = inputmethodengine.getInputMethodEngine();
25let inputKeyboardDelegate = inputmethodengine.createKeyboardDelegate();
26let inputMethodAbility = inputmethodengine.getInputMethodAbility();
27const TAG = 'keyboardController';
28
29export class KeyboardController {
30  mContext;
31  WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105;
32  windowName = 'inputApp';
33  private windowHeight: number = 0;
34  private windowWidth: number = 0;
35  private nonBarPosition: number = 0;
36  private keyboardController: inputmethodengine.KeyboardController;
37  private TextInputClient: inputmethodengine.TextInputClient;
38  private InputClient: inputmethodengine.InputClient;
39  private capitalizeMode: inputmethodengine.CapitalizeMode;
40  private placeholder: string;
41  private abilityName: string;
42
43  constructor(context) {
44    this.mContext = context;
45  }
46
47  public onCreate(): void {
48    this.initWindow();
49    let that = this;
50    inputMethodAbility.on('inputStop', () => {
51      inputMethodAbility.off('inputStop', () => {
52        console.log('====>inputMethodEngine delete inputStop notification.');
53      });
54      inputMethodEngine.off('inputStart', () => { })
55      inputMethodAbility.off('inputStart', () => { })
56      inputMethodAbility.off('inputStart')
57      try {
58        that.mContext.destroy((err) => {
59          console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err));
60        })
61      } catch (err) {
62        console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err));
63      }
64    })
65
66    inputMethodEngine.on('inputStart', async (keyboardController, TextInputClient) => {
67      this.keyboardController = keyboardController;
68      this.TextInputClient = TextInputClient
69      console.info(TAG + '====>inputMethodEngine inputStart into');
70    })
71    inputMethodAbility.on('inputStart', async (keyboardController, InputClient) => {
72      this.InputClient = InputClient
73      console.info(TAG + '====>inputMethodAbility inputStart into');
74    })
75
76    function subscriberCallback(err, data) {
77      console.info(TAG + '====>receive event err: ' + JSON.stringify(err));
78      console.info(TAG + '====>receive event data ' + JSON.stringify(data));
79      switch (data.code) {
80        case 1:
81          console.info(TAG + '====>inputMethodEngine_test_getInputMethodEngine_001 event:' + data.event);
82          that.inputMethodEngine_test_getInputMethodEngine_001();
83          break;
84        case 2:
85          console.info(TAG + '====>inputMethodEngine_test_getKeyboardDelegate_001 event:' + data.event);
86          that.inputMethodEngine_test_getKeyboardDelegate_001();
87          break;
88        case 28:
89          console.info(TAG + '====>inputMethodEngine_test_028 event:' + data.event);
90          that.inputMethodEngine_test_028();
91          break;
92        case 29:
93          console.info(TAG + '====>inputMethodEngine_test_029 event:' + data.event);
94          that.inputMethodEngine_test_029();
95          break;
96        case 30:
97          console.info(TAG + '====>inputMethodEngine_test_030 event:' + data.event);
98          that.inputMethodEngine_test_030();
99          break;
100        case 31:
101          console.info(TAG + '====>inputMethodEngine_test_031 event:' + data.event);
102          that.inputMethodEngine_test_031();
103          break;
104        case 32:
105          console.info(TAG + '====>inputMethodEngine_test_032 event:' + data.event);
106          that.inputMethodEngine_test_032();
107          break;
108        case 33:
109          console.info(TAG + '====>inputMethodEngine_test_033 event:' + data.event);
110          that.inputMethodEngine_test_033();
111          break;
112        case 34:
113          console.info(TAG + '====>inputMethodEngine_test_034 event:' + data.event);
114          that.inputMethodEngine_test_034();
115          break;
116        case 35:
117          console.info(TAG + '====>inputMethodEngine_test_035 event:' + data.event);
118          that.inputMethodEngine_test_035();
119          break;
120        case 36:
121          console.info(TAG + '====>inputMethodEngine_test_036 event:' + data.event);
122          that.inputMethodEngine_test_036();
123          break;
124        case 37:
125          console.info(TAG + '====>inputMethodEngine_test_037 event:' + data.event);
126          that.inputMethodEngine_test_037();
127          break;
128        case 38:
129          console.info(TAG + '====>inputMethodEngine_test_038 event:' + data.event);
130          that.inputMethodEngine_test_038();
131          break;
132        case 39:
133          console.info(TAG + '====>inputMethodEngine_test_039 event:' + data.event);
134          that.inputMethodEngine_test_039();
135          break;
136        case 40:
137          console.info(TAG + '====>inputMethodEngine_test_040 event:' + data.event);
138          that.inputMethodEngine_test_040();
139          break;
140        case 41:
141          console.info(TAG + '====>inputMethodEngine_test_041 event:' + data.event);
142          that.inputMethodEngine_test_041();
143          break;
144        case 42:
145          console.info(TAG + '====>inputMethodEngine_test_042 event:' + data.event);
146          that.inputMethodEngine_test_042();
147          break;
148        case 43:
149          console.info(TAG + '====>inputMethodEngine_test_043 event:' + data.event);
150          that.inputMethodEngine_test_043();
151          break;
152        case 49:
153          console.info(TAG + '====>inputMethodEngine_test_049 event:' + data.event);
154          that.inputMethodEngine_test_049();
155          break;
156        case 50:
157          console.info(TAG + '====>inputMethodEngine_test_050 event:' + data.event);
158          that.inputMethodEngine_test_050();
159          break;
160        case 71:
161          console.info(TAG + '====>inputMethodEngine_test_071 event:' + data.event);
162          that.inputMethodEngine_test_071();
163          break;
164        case 72:
165          console.info(TAG + '====>inputMethodEngine_test_072 event:' + data.event);
166          that.inputMethodEngine_test_072();
167          break;
168        case 73:
169          console.info(TAG + '====>inputMethodEngine_test_073 event:' + data.event);
170          that.inputMethodEngine_test_073();
171          break;
172        case 74:
173          console.info(TAG + '====>inputMethodEngine_test_074 event:' + data.event);
174          that.inputMethodEngine_test_074();
175          break;
176        case 76:
177          console.info(TAG + '====>inputMethodEngine_test_076 event:' + data.event);
178          that.inputMethodEngine_test_076();
179          break;
180        case 77:
181          console.info(TAG + '====>inputMethodEngine_test_077 event:' + data.event);
182          that.inputMethodEngine_test_077();
183          break;
184        case 78:
185          console.debug(TAG + '====>Sub_InputMethod_IME_VisualInput_0500 event:' + data.event);
186          that.Sub_InputMethod_IME_VisualInput_0500();
187          break;
188        case 79:
189          console.debug(TAG + '====>Sub_InputMethod_IME_VisualInput_0600 event:' + data.event);
190          that.Sub_InputMethod_IME_VisualInput_0600();
191          break;
192        case 80:
193          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100 event:' + data.event);
194          that.Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100();
195          break;
196        case 81:
197          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200 event:' + data.event);
198          that.Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200();
199          break;
200        case 82:
201          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100 event:' + data.event);
202          that.Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100();
203          break;
204        case 83:
205          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200 event:' + data.event);
206          that.Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200();
207          break;
208        case 84:
209          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0100 event:' + data.event);
210          that.Sub_Misc_inputMethodEngine_InputClient_insertText_0100();
211          break;
212        case 85:
213          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0200 event:' + data.event);
214          that.Sub_Misc_inputMethodEngine_InputClient_insertText_0200();
215          break;
216        case 86:
217          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0100 event:' + data.event);
218          that.Sub_Misc_inputMethodEngine_InputClient_getForward_0100();
219          break;
220        case 87:
221          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0200 event:' + data.event);
222          that.Sub_Misc_inputMethodEngine_InputClient_getForward_0200();
223          break;
224        case 88:
225          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0100 event:' + data.event);
226          that.Sub_Misc_inputMethodEngine_InputClient_getBackward_0100();
227          break;
228        case 89:
229          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0200 event:' + data.event);
230          that.Sub_Misc_inputMethodEngine_InputClient_getBackward_0200();
231          break;
232        case 90:
233          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100 event:' + data.event);
234          that.Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100();
235          break;
236        case 91:
237          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200 event:' + data.event);
238          that.Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200();
239          break;
240        case 92:
241          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100 event:' + data.event);
242          that.Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100();
243          break;
244        case 93:
245          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200 event:' + data.event);
246          that.Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200();
247          break;
248        case 94:
249          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100 event:' + data.event);
250          that.Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100();
251          break;
252        case 95:
253          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200 event:' + data.event);
254          that.Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200();
255          break;
256        case 96:
257          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100 event:' + data.event);
258          that.Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100();
259          break;
260        case 97:
261          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200 event:' + data.event);
262          that.Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200();
263          break;
264        case 98:
265          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200 event:' + data.event);
266          that.Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200();
267          break;
268        case 99:
269          console.debug(TAG + '====>Sub_InputMethod_IMF_SecurityKeyboard_0601 event:' + data.event);
270          that.Sub_InputMethod_IMF_SecurityKeyboard_0601();
271          break;
272        case 100:
273          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100 event:' + data.event);
274          that.Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100();
275          break;
276        case 101:
277          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200 event:' + data.event);
278          that.Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200();
279          break;
280        case 102:
281          console.debug(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1101 event:' + data.event);
282          that.SUB_InputMethod_IME_PrivateDateTransferred_1101();
283          break;
284        case 103:
285          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0100 event:' + data.event);
286          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0100();
287          break;
288        case 104:
289          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0200 event:' + data.event);
290          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0200();
291          break;
292        case 105:
293          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0300 event:' + data.event);
294          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0300();
295          break;
296        case 106:
297          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0400 event:' + data.event);
298          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0400();
299          break;
300        case 107:
301          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100 event:' + data.event);
302          that.Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100();
303          break;
304        case 108:
305          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 event:' + data.event);
306          that.Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200();
307          break;
308        case 109:
309          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100 event:' + data.event);
310          that.Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100();
311          break;
312        case 110:
313          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200 event:' + data.event);
314          that.Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200();
315          break;
316        case 111:
317          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0500 event:' + data.event);
318          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0500();
319          break;
320        case 112:
321          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0600 event:' + data.event);
322          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0600();
323          break;
324        case 113:
325          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0700 event:' + data.event);
326          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0700();
327          break;
328        case 114:
329          console.debug(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0800 event:' + data.event);
330          that.Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0800();
331          break;
332        case 115:
333          console.debug(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0100 event:' + data.event);
334          that.Sub_InputMethod_IMF_CapitalizeMode_0100();
335          break;
336        case 116:
337          console.debug(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0200 event:' + data.event);
338          that.Sub_InputMethod_IMF_CapitalizeMode_0200();
339          break;
340        case 117:
341          console.debug(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0300 event:' + data.event);
342          that.Sub_InputMethod_IMF_CapitalizeMode_0300();
343          break;
344        case 118:
345          console.debug(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0400 event:' + data.event);
346          that.Sub_InputMethod_IMF_CapitalizeMode_0400();
347          break;
348        case 119:
349          console.debug(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0500 event:' + data.event);
350          that.Sub_InputMethod_IMF_CapitalizeMode_0500();
351          break;
352        case 120:
353          console.debug(TAG + '====>Sub_InputMethod_IMF_Placeholder_0100 event:' + data.event);
354          that.Sub_InputMethod_IMF_Placeholder_0100();
355          break;
356        case 121:
357          console.debug(TAG + '====>Sub_InputMethod_IMF_Placeholder_0200 event:' + data.event);
358          that.Sub_InputMethod_IMF_Placeholder_0200();
359          break;
360        case 122:
361          console.debug(TAG + '====>Sub_InputMethod_IMF_Placeholder_0300 event:' + data.event);
362          that.Sub_InputMethod_IMF_Placeholder_0300();
363          break;
364        case 123:
365          console.debug(TAG + '====>Sub_InputMethod_IMF_Placeholder_0400 event:' + data.event);
366          that.Sub_InputMethod_IMF_Placeholder_0400();
367          break;
368        case 124:
369          console.debug(TAG + '====>Sub_InputMethod_IMF_Placeholder_0600 event:' + data.event);
370          that.Sub_InputMethod_IMF_Placeholder_0600();
371          break;
372        case 125:
373          console.debug(TAG + '====>Sub_InputMethod_IMF_DiscardTypingText_0100 event:' + data.event);
374          that.Sub_InputMethod_IMF_DiscardTypingText_0100();
375          break;
376        case 126:
377          console.debug(TAG + '====>Sub_InputMethod_IMF_DiscardTypingText_1000 event:' + data.event);
378          that.Sub_InputMethod_IMF_DiscardTypingText_1000();
379          break;
380      }
381    }
382
383    var commonEventSubscribeInfo = {
384      events: ['inputMethodEngineTest']
385    };
386
387    var subscriber;
388    commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) {
389      subscriber = data;
390      commoneventmanager.subscribe(subscriber, subscriberCallback);
391      console.info(TAG + '====>scene subscribe finish====');
392    });
393  }
394
395  public onDestroy(): void {
396    console.log('imsakitjsapp onDestroy');
397    globalThis.textInputClient.getTextIndexAtCursor().then((index) => {
398      console.log('imsakitjsapp getTextIndexAtCursor:  index = ' + index);
399      prompt.showToast({ message: 'getTextIndexAtCursor success' + index, duration: 200, bottom: 500 });
400      var win = windowManager.findWindow(this.windowName);
401      win.destroyWindow();
402      this.mContext.terminateSelf();
403      return true;
404    }).catch((err) => {
405      prompt.showToast({ message: 'getTextIndexAtCursor failed', duration: 200, bottom: 500 });
406    });
407  }
408
409  private initWindow(): void {
410    display.getDefaultDisplay().then(dis => {
411      var dWidth = dis.width;
412      var dHeight = dis.height;
413      var keyHeightRate = 0.47;
414      var keyHeight = dHeight * keyHeightRate;
415      this.windowWidth = dWidth;
416      this.windowHeight = keyHeight;
417      this.nonBarPosition = dHeight - keyHeight;
418
419      var config = {
420        name: this.windowName,
421        windowType: windowManager.WindowType.TYPE_INPUT_METHOD,
422        ctx: this.mContext
423      };
424      windowManager.createWindow(config).then((win) => {
425        win.resize(dWidth, keyHeight).then(() => {
426          win.moveWindowTo(0, this.nonBarPosition).then(() => {
427            win.setUIContent('pages/service/index').then(() => {
428            });
429          });
430        });
431      });
432    });
433  }
434
435  private publishCallback(err): void {
436    if (err) {
437      console.error(TAG + '====>publish failed: ' + JSON.stringify(err));
438    } else {
439      console.log(TAG + '====>publish');
440    }
441  }
442
443  private inputMethodEngine_test_getInputMethodEngine_001(): void {
444    console.info(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 data');
445    if (typeof (inputMethodEngine) === 'object') {
446      console.info(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 object');
447      var commonEventPublishData = {
448        data: 'SUCCESS'
449      };
450    } else {
451      console.info(TAG + '====>receive inputMethodEngine_test_getInputMethodEngine_001 failed');
452      var commonEventPublishData = {
453        data: 'FAILED'
454      };
455    };
456    commoneventmanager.publish('inputMethodEngine_test_getInputMethodEngine_001', commonEventPublishData,
457      this.publishCallback);
458  }
459
460  private inputMethodEngine_test_getKeyboardDelegate_001(): void {
461    console.info(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 data');
462    if (typeof (inputKeyboardDelegate) === 'object') {
463      console.info(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 object');
464      var commonEventPublishData = {
465        data: 'SUCCESS'
466      };
467    } else {
468      console.info(TAG + '====>receive inputMethodEngine_test_getKeyboardDelegate_001 failed');
469      var commonEventPublishData = {
470        data: 'FAILED'
471      };
472    };
473    commoneventmanager.publish('inputMethodEngine_test_getKeyboardDelegate_001', commonEventPublishData,
474      this.publishCallback);
475  }
476
477  async inputMethodEngine_test_028(): Promise<void> {
478    console.info(TAG + '====>receive inputMethodEngine_test_028 data');
479    let commonEventPublishData;
480    let editorAttribyte = await this.TextInputClient.getEditorAttribute();
481    console.info(TAG + '====>receive inputMethodEngine_test_028 editorAttribyte: ' + JSON.stringify(editorAttribyte));
482    this.TextInputClient.sendKeyFunction(editorAttribyte.enterKeyType, (err, value) => {
483      if (err) {
484        commonEventPublishData = {
485          data: 'FAILED'
486        };
487        console.info(TAG + '====>inputMethodEngine_test_028 TextInputClient sendKeyFunction err: ' +
488          JSON.stringify(err));
489      } else {
490        console.info(TAG + '====>inputMethodEngine_test_028 TextInputClient sendKeyFunction value: ' +
491          JSON.stringify(value));
492        if (value) {
493          commonEventPublishData = {
494            data: 'SUCCESS'
495          };
496        } else {
497          commonEventPublishData = {
498            data: 'FAILED'
499          };
500        }
501
502      }
503      commoneventmanager.publish('inputMethodEngine_test_028', commonEventPublishData, this.publishCallback);
504    })
505  }
506
507  async inputMethodEngine_test_029(): Promise<void> {
508    console.info(TAG + '====>receive inputMethodEngine_test_029 data');
509    let commonEventPublishData;
510    let editorAttribyte = await this.TextInputClient.getEditorAttribute();
511    console.info(TAG + '====>inputMethodEngine_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte));
512    let value = await this.TextInputClient.sendKeyFunction(editorAttribyte.inputPattern);
513    console.info(TAG + '====>inputMethodEngine_test_029 sendKeyFunction:' + JSON.stringify(value));
514    if (value) {
515      commonEventPublishData = {
516        data: 'SUCCESS'
517      };
518    } else {
519      commonEventPublishData = {
520        data: 'FAILED'
521      };
522    }
523    commoneventmanager.publish('inputMethodEngine_test_029', commonEventPublishData, this.publishCallback);
524  }
525
526  async inputMethodEngine_test_030(): Promise<void> {
527    console.info(TAG + '====>receive inputMethodEngine_test_030 data');
528    let commonEventPublishData;
529    this.TextInputClient.deleteForward(1, (err, value) => {
530      if (err) {
531        console.info(TAG + '====>inputMethodEngine_test_030 deleteForward err:' + JSON.stringify(err));
532        commonEventPublishData = {
533          data: 'FAILED'
534        };
535      } else {
536        console.info(TAG + '====>inputMethodEngine_test_030 deleteForward value:' + JSON.stringify(value));
537        if (typeof (value) === 'boolean') {
538          commonEventPublishData = {
539            data: 'SUCCESS'
540          };
541        } else {
542          commonEventPublishData = {
543            data: 'FAILED'
544          };
545        }
546      }
547      commoneventmanager.publish('inputMethodEngine_test_030', commonEventPublishData, this.publishCallback);
548    });
549  }
550
551  async inputMethodEngine_test_031(): Promise<void> {
552    console.info(TAG + '====>receive inputMethodEngine_test_031 data');
553    let commonEventPublishData;
554    let value = await this.TextInputClient.deleteForward(1);
555    console.info(TAG + '====>inputMethodEngine_test_031 deleteForward:' + JSON.stringify(value));
556    if (typeof (value) === 'boolean') {
557      commonEventPublishData = {
558        data: 'SUCCESS'
559      };
560    } else {
561      commonEventPublishData = {
562        data: 'FAILED'
563      };
564    }
565    commoneventmanager.publish('inputMethodEngine_test_031', commonEventPublishData, this.publishCallback);
566  }
567
568  async inputMethodEngine_test_032(): Promise<void> {
569    console.info(TAG + '====>receive inputMethodEngine_test_032 data');
570    let commonEventPublishData;
571    this.TextInputClient.deleteBackward(1, (err, value) => {
572      if (err) {
573        console.info(TAG + '====>inputMethodEngine_test_032 deleteBackward err:' + JSON.stringify(err));
574        commonEventPublishData = {
575          data: 'FAILED'
576        };
577      } else {
578        console.info(TAG + '====>inputMethodEngine_test_032 deleteBackward value:' + JSON.stringify(value));
579        if (value) {
580          commonEventPublishData = {
581            data: 'SUCCESS'
582          };
583        } else {
584          commonEventPublishData = {
585            data: 'FAILED'
586          };
587        }
588      }
589      commoneventmanager.publish('inputMethodEngine_test_032', commonEventPublishData, this.publishCallback);
590    });
591  }
592
593  async inputMethodEngine_test_033(): Promise<void> {
594    console.info(TAG + '====>receive inputMethodEngine_test_033 data');
595    let commonEventPublishData;
596    let value = await this.TextInputClient.deleteBackward(1);
597    console.info(TAG + '====>inputMethodEngine_test_033 deleteBackward:' + JSON.stringify(value));
598    if (value) {
599      commonEventPublishData = {
600        data: 'SUCCESS'
601      };
602    } else {
603      commonEventPublishData = {
604        data: 'FAILED'
605      };
606    }
607    commoneventmanager.publish('inputMethodEngine_test_033', commonEventPublishData, this.publishCallback);
608  }
609
610  async inputMethodEngine_test_034(): Promise<void> {
611    console.info(TAG + '====>receive inputMethodEngine_test_034 data');
612    let commonEventPublishData;
613    this.TextInputClient.insertText('test', (err, value) => {
614      if (err) {
615        console.info(TAG + '====>inputMethodEngine_test_034 insertText err:' + JSON.stringify(err));
616        commonEventPublishData = {
617          data: 'FAILED'
618        };
619      } else {
620        console.info(TAG + '====>inputMethodEngine_test_034 insertText value:' + JSON.stringify(value));
621        if (value) {
622          commonEventPublishData = {
623            data: 'SUCCESS'
624          };
625        } else {
626          commonEventPublishData = {
627            data: 'FAILED'
628          };
629        }
630      }
631      commoneventmanager.publish('inputMethodEngine_test_034', commonEventPublishData, this.publishCallback);
632    });
633  }
634
635  async inputMethodEngine_test_035(): Promise<void> {
636    console.info(TAG + '====>receive inputMethodEngine_test_035 data');
637    let commonEventPublishData;
638    let value = await this.TextInputClient.insertText('test');
639    console.info(TAG + '====>inputMethodEngine_test_035 insertText:' + JSON.stringify(value));
640    if (value) {
641      commonEventPublishData = {
642        data: 'SUCCESS'
643      };
644    } else {
645      commonEventPublishData = {
646        data: 'FAILED'
647      };
648    }
649    commoneventmanager.publish('inputMethodEngine_test_035', commonEventPublishData, this.publishCallback);
650  }
651
652  async inputMethodEngine_test_036(): Promise<void> {
653    console.info(TAG + '====>receive inputMethodEngine_test_036 data');
654    let commonEventPublishData;
655    this.TextInputClient.getForward(1, (err, value) => {
656      if (err) {
657        console.info(TAG + '====>inputMethodEngine_test_036 getForward err:' + JSON.stringify(err));
658        commonEventPublishData = {
659          data: 'FAILED'
660        };
661      } else {
662        console.info(TAG + '====>inputMethodEngine_test_036 getForward value:' + JSON.stringify(value));
663        if (typeof (value) !== null) {
664          commonEventPublishData = {
665            data: 'SUCCESS'
666          };
667        } else {
668          commonEventPublishData = {
669            data: 'FAILED'
670          };
671        }
672      }
673      commoneventmanager.publish('inputMethodEngine_test_036', commonEventPublishData, this.publishCallback);
674    });
675  }
676
677  async inputMethodEngine_test_037(): Promise<void> {
678    console.info(TAG + '====>receive inputMethodEngine_test_037 data');
679    let commonEventPublishData;
680    let value = await this.TextInputClient.getForward(1);
681    console.info(TAG + '====>inputMethodEngine_test_037 getForward:' + JSON.stringify(value));
682    if (typeof (value) !== null) {
683      commonEventPublishData = {
684        data: 'SUCCESS'
685      };
686    } else {
687      commonEventPublishData = {
688        data: 'FAILED'
689      };
690    }
691    commoneventmanager.publish('inputMethodEngine_test_037', commonEventPublishData, this.publishCallback);
692  }
693
694  async inputMethodEngine_test_038(): Promise<void> {
695    console.info(TAG + '====>receive inputMethodEngine_test_038 data');
696    let commonEventPublishData;
697    this.TextInputClient.getEditorAttribute((err, value) => {
698      if (err) {
699        console.info(TAG + '====>inputMethodEngine_test_038 getEditorAttribute err:' + JSON.stringify(err));
700        commonEventPublishData = {
701          data: 'FAILED'
702        };
703      } else {
704        console.info(TAG + '====>inputMethodEngine_test_038 getEditorAttribute value:' + JSON.stringify(value));
705        if (value) {
706          commonEventPublishData = {
707            data: 'SUCCESS'
708          };
709        } else {
710          commonEventPublishData = {
711            data: 'FAILED'
712          };
713        }
714      }
715      commoneventmanager.publish('inputMethodEngine_test_038', commonEventPublishData, this.publishCallback);
716    });
717  }
718
719  async inputMethodEngine_test_039(): Promise<void> {
720    console.info(TAG + '====>receive inputMethodEngine_test_039 data');
721    let commonEventPublishData;
722    let value = await this.TextInputClient.getEditorAttribute();
723    console.info(TAG + '====>inputMethodEngine_test_039 getEditorAttribute:' + JSON.stringify(value));
724    if (value) {
725      commonEventPublishData = {
726        data: 'SUCCESS'
727      };
728    } else {
729      commonEventPublishData = {
730        data: 'FAILED'
731      };
732    }
733    commoneventmanager.publish('inputMethodEngine_test_039', commonEventPublishData, this.publishCallback);
734  }
735
736  async inputMethodEngine_test_040(): Promise<void> {
737    console.info(TAG + '====>receive inputMethodEngine_test_040 data');
738    let commonEventPublishData;
739    try {
740      this.keyboardController.hideKeyboard((err, value) => {
741        if (err) {
742          console.info(TAG + '====>inputMethodEngine_test_040 hideKeyboard:' + JSON.stringify(err));
743          commonEventPublishData = {
744            data: 'FAILED'
745          };
746        } else {
747          commonEventPublishData = {
748            data: 'SUCCESS'
749          };
750        }
751        commoneventmanager.publish('inputMethodEngine_test_040', commonEventPublishData, this.publishCallback);
752      });
753    } catch (err) {
754      commonEventPublishData = {
755        data: 'FAILED'
756      };
757      console.info(TAG + '====>inputMethodEngine_test_040 hideKeyboard throw_err:');
758      commoneventmanager.publish('inputMethodEngine_test_040', commonEventPublishData, this.publishCallback);
759    }
760  }
761
762  async inputMethodEngine_test_041(): Promise<void> {
763    console.info(TAG + '====>receive inputMethodEngine_test_041 data');
764    let commonEventPublishData;
765    try {
766      await this.keyboardController.hideKeyboard();
767      console.info(TAG + '====>inputMethodEngine_test_041 hideKeyboard success');
768      commonEventPublishData = {
769        data: 'SUCCESS'
770      };
771    } catch (err) {
772      commonEventPublishData = {
773        data: 'FAILED'
774      };
775      console.info(TAG + '====>inputMethodEngine_test_041 hideKeyboard catch err:');
776    }
777    commoneventmanager.publish('inputMethodEngine_test_041', commonEventPublishData, this.publishCallback);
778  }
779
780  async inputMethodEngine_test_042(): Promise<void> {
781    console.info(TAG + '====>receive inputMethodEngine_test_042 data');
782    let commonEventPublishData;
783    this.TextInputClient.getBackward(1, (err, value) => {
784      if (err) {
785        console.info(TAG + '====>inputMethodEngine_test_042 getBackward err:' + JSON.stringify(err));
786        commonEventPublishData = {
787          data: 'FAILED'
788        };
789      } else {
790        console.info(TAG + '====>inputMethodEngine_test_042 getBackward value:' + JSON.stringify(value));
791        commonEventPublishData = {
792          data: 'SUCCESS'
793        };
794      }
795      commoneventmanager.publish('inputMethodEngine_test_042', commonEventPublishData, this.publishCallback);
796    });
797  }
798
799  async inputMethodEngine_test_043(): Promise<void> {
800    console.info(TAG + '====>receive inputMethodEngine_test_043 data');
801    let commonEventPublishData;
802    let value = await this.TextInputClient.getBackward(1);
803    console.info(TAG + '====>inputMethodEngine_test_043 getBackward:' + JSON.stringify(value));
804    commonEventPublishData = {
805      data: 'SUCCESS'
806    };
807    commoneventmanager.publish('inputMethodEngine_test_043', commonEventPublishData, this.publishCallback);
808  }
809
810  async inputMethodEngine_test_049(): Promise<void> {
811    console.info(TAG + '====>receive inputMethodEngine_test_049 data');
812    let commonEventPublishData;
813    try {
814      this.keyboardController.hide((err, value) => {
815        if (err) {
816          console.info(TAG + '====>inputMethodEngine_test_049 hide:' + JSON.stringify(err));
817          commonEventPublishData = {
818            data: 'FAILED'
819          };
820        } else {
821          commonEventPublishData = {
822            data: 'SUCCESS'
823          };
824        }
825        commoneventmanager.publish('inputMethodEngine_test_049', commonEventPublishData, this.publishCallback);
826      });
827    } catch (err) {
828      commonEventPublishData = {
829        data: 'FAILED'
830      };
831      console.info(TAG + '====>inputMethodEngine_test_049 hide throw_err:');
832      commoneventmanager.publish('inputMethodEngine_test_040', commonEventPublishData, this.publishCallback);
833    }
834  }
835
836  async inputMethodEngine_test_050(): Promise<void> {
837    console.info(TAG + '====>receive inputMethodEngine_test_050 data');
838    let commonEventPublishData;
839    try {
840      await this.keyboardController.hide();
841      console.info(TAG + '====>inputMethodEngine_test_050 hideKeyboard success');
842      commonEventPublishData = {
843        data: 'SUCCESS'
844      };
845    } catch (err) {
846      commonEventPublishData = {
847        data: 'FAILED'
848      };
849      console.info(TAG + '====>inputMethodEngine_test_050 hideKeyboard catch err:');
850    }
851    commoneventmanager.publish('inputMethodEngine_test_050', commonEventPublishData, this.publishCallback);
852  }
853
854  async inputMethodEngine_test_071(): Promise<void> {
855    let commonEventPublishData = {
856      data: 'FAILED'
857    };
858    console.info(TAG + '====>receive inputMethodEngine_test_071 success');
859    let count = 0;
860    inputMethodEngine.on('keyboardHide', () => {
861      count += 1;
862      inputMethodEngine.off('keyboardHide');
863      console.info(TAG + '====>inputMethodEngine.off("keyboardHide") count: ' + count);
864    });
865
866    let t = setTimeout(async () => {
867      clearTimeout(t);
868      await this.keyboardController.hideKeyboard();
869      console.info(TAG + '====>inputMethodEngine_test_071 hideKeyboard success');
870    }, 100);
871
872    let t1 = setTimeout(() => {
873      if (count === 1) {
874        commonEventPublishData = {
875          data: 'SUCCESS'
876        };
877      }
878      commoneventmanager.publish('inputMethodEngine_test_071', commonEventPublishData, this.publishCallback);
879      clearTimeout(t1);
880    }, 1000);
881  }
882
883  async inputMethodEngine_test_072(): Promise<void> {
884    let commonEventPublishData = {
885      data: 'FAILED'
886    };
887    console.info(TAG + '====>receive inputMethodEngine_test_072 success');
888    let count = 0;
889    inputMethodEngine.on('keyboardShow', () => {
890      count += 1;
891      inputMethodEngine.off('keyboardShow');
892      console.info(TAG + '====>inputMethodEngine.off("keyboardShow") count: ' + count);
893    });
894
895    let t1 = setTimeout(() => {
896      if (count === 1) {
897        commonEventPublishData = {
898          data: 'SUCCESS'
899        };
900      }
901      commoneventmanager.publish('inputMethodEngine_test_072', commonEventPublishData, this.publishCallback);
902      clearTimeout(t1);
903    }, 1500);
904  }
905
906  async inputMethodEngine_test_073(): Promise<void> {
907    let commonEventPublishData = {
908      data: 'FAILED'
909    };
910    console.info(TAG + '====>receive inputMethodEngine_test_073 success');
911    let count = 0;
912    inputKeyboardDelegate.on('keyDown', (keyEvent) => {
913      inputKeyboardDelegate.off('keyDown');
914      console.info(TAG + '====>inputKeyboardDelegate.on("keyDown") count: ' + count);
915      console.info(TAG + '====>inputKeyboardDelegate.keyEvent.keyAction ' + keyEvent.keyAction);
916      if (keyEvent.keyCode === 2000 && keyEvent.keyAction === 2) {
917        count += 1;
918      }
919      return true;
920    });
921    inputKeyboardDelegate.on('keyUp', (keyEvent) => {
922      inputKeyboardDelegate.off('keyUp');
923      console.info(TAG + '====>inputKeyboardDelegate.on("keyUp") count: ' + count);
924      console.info(TAG + '====>inputKeyboardDelegate.keyEvent.keyAction ' + keyEvent.keyAction);
925      if (keyEvent.keyCode === 2000 && keyEvent.keyAction === 3) {
926        count += 1;
927      }
928      return true;
929    });
930    let t = setTimeout(() => {
931      commonEventPublishData = {
932        data: 'SUCCESS'
933      };
934      commoneventmanager.publish('inputMethodEngine_test_073', commonEventPublishData, this.publishCallback);
935      clearTimeout(t);
936    }, 1000);
937  }
938
939  async inputMethodEngine_test_074(): Promise<void> {
940    let commonEventPublishData = {
941      data: 'FAILED'
942    };
943    console.info(TAG + '====>receive inputMethodEngine_test_074 success');
944    let count = 0;
945
946    let t = setTimeout(async () => {
947      clearTimeout(t);
948      inputKeyboardDelegate.on('cursorContextChange', (x, y, h) => {
949        console.info(TAG + '====>inputKeyboardDelegate.on("cursorContextChange") count: ' + count);
950        if (count === 1) {
951          inputKeyboardDelegate.off('cursorContextChange');
952          console.info(TAG + '====>inputMethodEngine_test_074 inputKeyboardDelegate.off');
953        }
954        count += 1;
955        console.info(TAG + '====>inputMethodEngine_test_074 x,y,z: ' + x + '---' + y + '---' + h);
956      });
957
958      let loop = 0;
959      let t1 = setInterval(async () => {
960        await this.TextInputClient.insertText('ttt');
961        console.info(TAG + '====>keyboardController.insertText count: ' + count);
962        console.info(TAG + '====>keyboardController.insertText loop: ' + loop);
963        loop += 1;
964        if (loop === 3) {
965          clearInterval(t1);
966        }
967      }, 500);
968    }, 1000);
969
970    let t1 = setTimeout(() => {
971      if (count === 2) {
972        commonEventPublishData = {
973          data: 'SUCCESS'
974        };
975      }
976      commoneventmanager.publish('inputMethodEngine_test_074', commonEventPublishData, this.publishCallback);
977      clearTimeout(t1);
978    }, 4000);
979  }
980
981  async inputMethodEngine_test_076(): Promise<void> {
982    let commonEventPublishData = {
983      data: 'FAILED'
984    };
985    await this.InputClient.moveCursor(inputmethodengine.CURSOR_LEFT);
986    console.info(TAG + '====>receive inputMethodEngine_test_076 success');
987    inputKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
988      console.info(TAG + '====>inputKeyboardDelegate.on("selectionChange")');
989      inputKeyboardDelegate.off('selectionChange');
990      commonEventPublishData = {
991        data: 'SUCCESS'
992      };
993      console.info(TAG + '====>inputMethodEngine_test_076 oldBegin,oldEnd,newBegin,newEnd: ' + oldBegin + '---' +
994        oldEnd + '---' + newBegin + '---' + newEnd);
995    });
996
997    let t = setTimeout(() => {
998      commoneventmanager.publish('inputMethodEngine_test_076', commonEventPublishData, this.publishCallback);
999      clearTimeout(t);
1000    }, 2000);
1001  }
1002
1003  async inputMethodEngine_test_077(): Promise<void> {
1004    let commonEventPublishData = {
1005      data: 'FAILED'
1006    };
1007    console.info(TAG + '====>receive inputMethodEngine_test_077 success');
1008    let count = 0;
1009    inputKeyboardDelegate.on('textChange', (text) => {
1010      console.info(TAG + '====>inputKeyboardDelegate.on("textChange") count:' + count);
1011      if (count === 1) {
1012        inputKeyboardDelegate.off('textChange');
1013      }
1014      count += 1;
1015      console.info(TAG + '====>inputMethodEngine_test_077 text: ' + text);
1016    });
1017
1018    let loopCount = 0;
1019    let t = setInterval(async () => {
1020      await this.TextInputClient.insertText('tttt');
1021      console.info(TAG + '====>keyboardController.insertText count: ' + count);
1022      if (loopCount === 2) {
1023        clearInterval(t);
1024      }
1025      loopCount += 1;
1026    }, 300);
1027
1028    let t1 = setTimeout(() => {
1029      if (count === 2) {
1030        commonEventPublishData = {
1031          data: 'SUCCESS'
1032        };
1033      }
1034      commoneventmanager.publish('inputMethodEngine_test_077', commonEventPublishData, this.publishCallback);
1035      clearTimeout(t1);
1036    }, 2000);
1037  }
1038
1039  async Sub_InputMethod_IME_VisualInput_0500(): Promise<void> {
1040    console.info(TAG + '====>receive Sub_InputMethod_IME_VisualInput_0500 data');
1041    let commonEventPublishData = {
1042      data: 'FAILED'
1043    };
1044    try {
1045      console.info(TAG + '====>Sub_InputMethod_IME_VisualInput_0500 exitCurrentInputType start');
1046      await this.keyboardController.exitCurrentInputType();
1047      console.info(TAG + '====>Sub_InputMethod_IME_VisualInput_0500 exitCurrentInputType success');
1048      commonEventPublishData = {
1049        data: 'FAILED'
1050      };
1051    } catch (err) {
1052      console.info(TAG + '====>Sub_InputMethod_IME_VisualInput_0500 exitCurrentInputType catch err:' +
1053        JSON.stringify(err));
1054      if (err.code === 12800010) {
1055        commonEventPublishData = {
1056          data: 'SUCCESS'
1057        };
1058      }
1059    }
1060    commoneventmanager.publish('Sub_InputMethod_IME_VisualInput_0500', commonEventPublishData, this.publishCallback);
1061  }
1062
1063  async Sub_InputMethod_IME_VisualInput_0600(): Promise<void> {
1064    console.info(TAG + '====>receive Sub_InputMethod_IME_VisualInput_0600 data');
1065    let commonEventPublishData = {
1066      data: 'FAILED'
1067    };
1068    this.keyboardController.exitCurrentInputType((err) => {
1069      console.info(TAG + '====>Sub_InputMethod_IME_VisualInput_0600 exitCurrentInputType failed: ' +
1070        JSON.stringify(err));
1071      if (err.code === 12800010) {
1072        commonEventPublishData = {
1073          data: 'SUCCESS'
1074        };
1075      } else {
1076        console.info(TAG + '====>Sub_InputMethod_IME_VisualInput_0600 exitCurrentInputType not throw 12800010');
1077      }
1078      commoneventmanager.publish('Sub_InputMethod_IME_VisualInput_0600', commonEventPublishData, this.publishCallback);
1079    });
1080  }
1081
1082  async Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100(): Promise<void> {
1083    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100 data');
1084    let commonEventPublishData = {
1085      data: 'FAILED'
1086    };
1087    try {
1088      this.InputClient.sendKeyFunction(undefined, (err, value) => {
1089        if (err) {
1090          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100 sendKeyFunction err:' + JSON.stringify(err));
1091          commonEventPublishData = {
1092            data: 'SUCCESS'
1093          };
1094        }
1095        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100 sendKeyFunction success');
1096      });
1097    } catch (err) {
1098      if (err.code === 401) {
1099        commonEventPublishData = {
1100          data: 'SUCCESS'
1101        };
1102      }
1103      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100 catch err: ' + JSON.stringify(err));
1104    }
1105    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0100', commonEventPublishData, this.publishCallback);
1106  }
1107
1108  async Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200(): Promise<void> {
1109    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200 data');
1110    let commonEventPublishData = {
1111      data: 'FAILED'
1112    };
1113    try {
1114      this.InputClient.sendKeyFunction(undefined).then((data) => {
1115        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200 Succeed in sendKeyFunction.' + JSON.stringify(data));
1116        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200', commonEventPublishData, this.publishCallback);
1117      }).catch((err) => {
1118        commonEventPublishData = {
1119          data: 'SUCCESS'
1120        };
1121        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200 sendKeyFunction error: ' + JSON.stringify(err));
1122        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200', commonEventPublishData, this.publishCallback);
1123      });
1124    } catch (err) {
1125      if (err.code === 401) {
1126        commonEventPublishData = {
1127          data: 'SUCCESS'
1128        };
1129      }
1130      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200 err: ' + JSON.stringify(err));
1131      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendKeyFunction_0200', commonEventPublishData, this.publishCallback);
1132    }
1133  }
1134
1135  async Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100(): Promise<void> {
1136    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100 data');
1137    let commonEventPublishData = {
1138      data: 'FAILED'
1139    };
1140    try {
1141      this.InputClient.deleteForward(undefined, (err, result) => {
1142        if (err) {
1143          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100 sendKeyFunction err:' + JSON.stringify(err));
1144          commonEventPublishData = {
1145            data: 'SUCCESS'
1146          };
1147        }
1148        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100 sendKeyFunction success');
1149      });
1150    } catch (err) {
1151      if (err.code === 401) {
1152        commonEventPublishData = {
1153          data: 'SUCCESS'
1154        };
1155      }
1156      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100 catch err: ' + JSON.stringify(err));
1157    }
1158    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteForward_0100', commonEventPublishData, this.publishCallback);
1159  }
1160
1161  async Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200(): Promise<void> {
1162    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200 data');
1163    let commonEventPublishData = {
1164      data: 'FAILED'
1165    };
1166    try {
1167      this.InputClient.deleteForward(undefined).then((result) => {
1168        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200 Succeed in sendKeyFunction.' + JSON.stringify(result));
1169        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200', commonEventPublishData, this.publishCallback);
1170      }).catch((err) => {
1171        commonEventPublishData = {
1172          data: 'SUCCESS'
1173        };
1174        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200 sendKeyFunction error: ' + JSON.stringify(err));
1175        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200', commonEventPublishData, this.publishCallback);
1176      });
1177    } catch (err) {
1178      if (err.code === 401) {
1179        commonEventPublishData = {
1180          data: 'SUCCESS'
1181        };
1182      }
1183      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200 err: ' + JSON.stringify(err));
1184      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteForward_0200', commonEventPublishData, this.publishCallback);
1185    }
1186  }
1187
1188  async Sub_Misc_inputMethodEngine_InputClient_insertText_0100(): Promise<void> {
1189    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_insertText_0100 data');
1190    let commonEventPublishData = {
1191      data: 'FAILED'
1192    };
1193    try {
1194      this.InputClient.insertText(undefined, (err, result) => {
1195        if (err) {
1196          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0100 sendKeyFunction err:' + JSON.stringify(err));
1197          commonEventPublishData = {
1198            data: 'SUCCESS'
1199          };
1200        }
1201        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0100 sendKeyFunction success');
1202      });
1203    } catch (err) {
1204      if (err.code === 401) {
1205        commonEventPublishData = {
1206          data: 'SUCCESS'
1207        };
1208      }
1209      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0100 catch err: ' + JSON.stringify(err));
1210    }
1211    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_insertText_0100', commonEventPublishData, this.publishCallback);
1212  }
1213
1214  async Sub_Misc_inputMethodEngine_InputClient_insertText_0200(): Promise<void> {
1215    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_insertText_0200 data');
1216    let commonEventPublishData = {
1217      data: 'FAILED'
1218    };
1219    try {
1220      this.InputClient.insertText(undefined).then((result) => {
1221        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0200 Succeed in sendKeyFunction.' + JSON.stringify(result));
1222        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_insertText_0200', commonEventPublishData, this.publishCallback);
1223      }).catch((err) => {
1224        commonEventPublishData = {
1225          data: 'SUCCESS'
1226        };
1227        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_insertText_0200 sendKeyFunction error: ' + JSON.stringify(err));
1228        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_insertText_0200', commonEventPublishData, this.publishCallback);
1229      });
1230    } catch (err) {
1231      if (err.code === 401) {
1232        commonEventPublishData = {
1233          data: 'SUCCESS'
1234        };
1235      }
1236      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_insertText_0200 err: ' + JSON.stringify(err));
1237      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_insertText_0200', commonEventPublishData, this.publishCallback);
1238    }
1239  }
1240
1241  async Sub_Misc_inputMethodEngine_InputClient_getForward_0100(): Promise<void> {
1242    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getForward_0100 data');
1243    let commonEventPublishData = {
1244      data: 'FAILED'
1245    };
1246    try {
1247      this.InputClient.getForward(undefined, (err, result) => {
1248        if (err) {
1249          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0100 sendKeyFunction err:' + JSON.stringify(err));
1250          commonEventPublishData = {
1251            data: 'SUCCESS'
1252          };
1253        }
1254        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0100 sendKeyFunction success');
1255      });
1256    } catch (err) {
1257      if (err.code === 401) {
1258        commonEventPublishData = {
1259          data: 'SUCCESS'
1260        };
1261      }
1262      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0100 catch err: ' + JSON.stringify(err));
1263    }
1264    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getForward_0100', commonEventPublishData, this.publishCallback);
1265  }
1266
1267  async Sub_Misc_inputMethodEngine_InputClient_getForward_0200(): Promise<void> {
1268    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getForward_0200 data');
1269    let commonEventPublishData = {
1270      data: 'FAILED'
1271    };
1272    try {
1273      this.InputClient.getForward(undefined).then((result) => {
1274        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0200 Succeed in sendKeyFunction.' + JSON.stringify(result));
1275        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getForward_0200', commonEventPublishData, this.publishCallback);
1276      }).catch((err) => {
1277        commonEventPublishData = {
1278          data: 'SUCCESS'
1279        };
1280        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getForward_0200 sendKeyFunction error: ' + JSON.stringify(err));
1281        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getForward_0200', commonEventPublishData, this.publishCallback);
1282      });
1283    } catch (err) {
1284      if (err.code === 401) {
1285        commonEventPublishData = {
1286          data: 'SUCCESS'
1287        };
1288      }
1289      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getForward_0200 err: ' + JSON.stringify(err));
1290      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getForward_0200', commonEventPublishData, this.publishCallback);
1291    }
1292  }
1293
1294  async Sub_Misc_inputMethodEngine_InputClient_getBackward_0100(): Promise<void> {
1295    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getBackward_0100 data');
1296    let commonEventPublishData = {
1297      data: 'FAILED'
1298    };
1299    try {
1300      this.InputClient.getBackward(undefined, (err, result) => {
1301        if (err) {
1302          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0100 sendKeyFunction err:' + JSON.stringify(err));
1303          commonEventPublishData = {
1304            data: 'SUCCESS'
1305          };
1306        }
1307        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0100 sendKeyFunction success');
1308      });
1309    } catch (err) {
1310      if (err.code === 401) {
1311        commonEventPublishData = {
1312          data: 'SUCCESS'
1313        };
1314      }
1315      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0100 catch err: ' + JSON.stringify(err));
1316    }
1317    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getBackward_0100', commonEventPublishData, this.publishCallback);
1318  }
1319
1320  async Sub_Misc_inputMethodEngine_InputClient_getBackward_0200(): Promise<void> {
1321    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getBackward_0200 data');
1322    let commonEventPublishData = {
1323      data: 'FAILED'
1324    };
1325    try {
1326      this.InputClient.getBackward(undefined).then((result) => {
1327        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0200 Succeed in sendKeyFunction.' + JSON.stringify(result));
1328        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getBackward_0200', commonEventPublishData, this.publishCallback);
1329      }).catch((err) => {
1330        commonEventPublishData = {
1331          data: 'SUCCESS'
1332        };
1333        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_getBackward_0200 sendKeyFunction error: ' + JSON.stringify(err));
1334        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getBackward_0200', commonEventPublishData, this.publishCallback);
1335      });
1336    } catch (err) {
1337      if (err.code === 401) {
1338        commonEventPublishData = {
1339          data: 'SUCCESS'
1340        };
1341      }
1342      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getBackward_0200 err: ' + JSON.stringify(err));
1343      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_getBackward_0200', commonEventPublishData, this.publishCallback);
1344    }
1345  }
1346
1347  async Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100(): Promise<void> {
1348    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100 data');
1349    let commonEventPublishData = {
1350      data: 'FAILED'
1351    };
1352    try {
1353      this.InputClient.moveCursor(undefined, (err) => {
1354        if (err) {
1355          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100 sendKeyFunction err:' + JSON.stringify(err));
1356          commonEventPublishData = {
1357            data: 'SUCCESS'
1358          };
1359        }
1360        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100 sendKeyFunction success');
1361      });
1362    } catch (err) {
1363      if (err.code === 401) {
1364        commonEventPublishData = {
1365          data: 'SUCCESS'
1366        };
1367      }
1368      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100 catch err: ' + JSON.stringify(err));
1369    }
1370    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_moveCursor_0100', commonEventPublishData, this.publishCallback);
1371  }
1372
1373  async Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200(): Promise<void> {
1374    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200 data');
1375    let commonEventPublishData = {
1376      data: 'FAILED'
1377    };
1378    try {
1379      this.InputClient.moveCursor(undefined).then(() => {
1380        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200 Succeed in sendKeyFunction.');
1381        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200', commonEventPublishData, this.publishCallback);
1382      }).catch((err) => {
1383        commonEventPublishData = {
1384          data: 'SUCCESS'
1385        };
1386        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200 sendKeyFunction error: ' + JSON.stringify(err));
1387        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200', commonEventPublishData, this.publishCallback);
1388      });
1389    } catch (err) {
1390      if (err.code === 401) {
1391        commonEventPublishData = {
1392          data: 'SUCCESS'
1393        };
1394      }
1395      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200 err: ' + JSON.stringify(err));
1396      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_moveCursor_0200', commonEventPublishData, this.publishCallback);
1397    }
1398  }
1399
1400  async Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100(): Promise<void> {
1401    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100 data');
1402    let commonEventPublishData = {
1403      data: 'FAILED'
1404    };
1405    try {
1406      this.InputClient.selectByRange(undefined, (err) => {
1407        if (err) {
1408          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100 sendKeyFunction err:' + JSON.stringify(err));
1409          commonEventPublishData = {
1410            data: 'SUCCESS'
1411          };
1412        }
1413        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100 sendKeyFunction success');
1414      });
1415    } catch (err) {
1416      if (err.code === 401) {
1417        commonEventPublishData = {
1418          data: 'SUCCESS'
1419        };
1420      }
1421      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100 catch err: ' + JSON.stringify(err));
1422    }
1423    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByRange_0100', commonEventPublishData, this.publishCallback);
1424  }
1425
1426  async Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200(): Promise<void> {
1427    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200 data');
1428    let commonEventPublishData = {
1429      data: 'FAILED'
1430    };
1431    try {
1432      this.InputClient.selectByRange(undefined).then(() => {
1433        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200 Succeed in sendKeyFunction.');
1434        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200', commonEventPublishData, this.publishCallback);
1435      }).catch((err) => {
1436        commonEventPublishData = {
1437          data: 'SUCCESS'
1438        };
1439        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200 sendKeyFunction error: ' + JSON.stringify(err));
1440        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200', commonEventPublishData, this.publishCallback);
1441      });
1442    } catch (err) {
1443      if (err.code === 401) {
1444        commonEventPublishData = {
1445          data: 'SUCCESS'
1446        };
1447      }
1448      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200 err: ' + JSON.stringify(err));
1449      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByRange_0200', commonEventPublishData, this.publishCallback);
1450    }
1451  }
1452
1453  async Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100(): Promise<void> {
1454    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100 data');
1455    let commonEventPublishData = {
1456      data: 'FAILED'
1457    };
1458    try {
1459      this.InputClient.selectByMovement(undefined, (err) => {
1460        if (err) {
1461          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100 sendKeyFunction err:' + JSON.stringify(err));
1462          commonEventPublishData = {
1463            data: 'SUCCESS'
1464          };
1465        }
1466        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100 sendKeyFunction success');
1467      });
1468    } catch (err) {
1469      if (err.code === 401) {
1470        commonEventPublishData = {
1471          data: 'SUCCESS'
1472        };
1473      }
1474      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100 catch err: ' + JSON.stringify(err));
1475    }
1476    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0100', commonEventPublishData, this.publishCallback);
1477  }
1478
1479  async Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200(): Promise<void> {
1480    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200 data');
1481    let commonEventPublishData = {
1482      data: 'FAILED'
1483    };
1484    try {
1485      this.InputClient.selectByMovement(undefined).then(() => {
1486        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200 Succeed in sendKeyFunction.');
1487        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200', commonEventPublishData, this.publishCallback);
1488      }).catch((err) => {
1489        commonEventPublishData = {
1490          data: 'SUCCESS'
1491        };
1492        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200 sendKeyFunction error: ' + JSON.stringify(err));
1493        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200', commonEventPublishData, this.publishCallback);
1494      });
1495    } catch (err) {
1496      if (err.code === 401) {
1497        commonEventPublishData = {
1498          data: 'SUCCESS'
1499        };
1500      }
1501      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200 err: ' + JSON.stringify(err));
1502      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_selectByMovement_0200', commonEventPublishData, this.publishCallback);
1503    }
1504  }
1505
1506  async Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100(): Promise<void> {
1507    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100 data');
1508    let commonEventPublishData = {
1509      data: 'FAILED'
1510    };
1511    try {
1512      this.InputClient.sendExtendAction(undefined, (err) => {
1513        if (err) {
1514          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100 sendKeyFunction err:' + JSON.stringify(err));
1515          commonEventPublishData = {
1516            data: 'SUCCESS'
1517          };
1518        }
1519        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100 sendKeyFunction success');
1520      });
1521    } catch (err) {
1522      if (err.code === 401) {
1523        commonEventPublishData = {
1524          data: 'SUCCESS'
1525        };
1526      }
1527      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100 catch err: ' + JSON.stringify(err));
1528    }
1529    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0100', commonEventPublishData, this.publishCallback);
1530  }
1531
1532  async Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200(): Promise<void> {
1533    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200 data');
1534    let commonEventPublishData = {
1535      data: 'FAILED'
1536    };
1537    try {
1538      this.InputClient.sendExtendAction(undefined).then(() => {
1539        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200 Succeed in sendKeyFunction.');
1540        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200', commonEventPublishData, this.publishCallback);
1541      }).catch((err) => {
1542        commonEventPublishData = {
1543          data: 'SUCCESS'
1544        };
1545        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200 sendKeyFunction error: ' + JSON.stringify(err));
1546        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200', commonEventPublishData, this.publishCallback);
1547      });
1548    } catch (err) {
1549      if (err.code === 401) {
1550        commonEventPublishData = {
1551          data: 'SUCCESS'
1552        };
1553      }
1554      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200 err: ' + JSON.stringify(err));
1555      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendExtendAction_0200', commonEventPublishData, this.publishCallback);
1556    }
1557  }
1558
1559  async Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200(): Promise<void> {
1560    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200 data');
1561    let commonEventPublishData = {
1562      data: 'FAILED'
1563    };
1564    try {
1565      let record: Record<string, inputmethodengine.CommandDataType> = {
1566        'valueString1': 'abcdefg',
1567        'valueString2': true,
1568        'valueString3': 500,
1569        'valueString4': 400,
1570        'valueString5': 300,
1571        'valueString6': 200,
1572      };
1573      this.InputClient.sendPrivateCommand(record).then(() => {
1574        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200 Succeed in sendKeyFunction.');
1575        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200', commonEventPublishData, this.publishCallback);
1576      }).catch((err) => {
1577        commonEventPublishData = {
1578          data: 'SUCCESS'
1579        };
1580        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200 sendKeyFunction error: ' + JSON.stringify(err));
1581        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200', commonEventPublishData, this.publishCallback);
1582      });
1583    } catch (err) {
1584      if (err.code === 401) {
1585        commonEventPublishData = {
1586          data: 'SUCCESS'
1587        };
1588      };
1589      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200 err: ' + JSON.stringify(err));
1590      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_sendPrivateCommand_0200', commonEventPublishData, this.publishCallback);
1591    }
1592  }
1593
1594  private async Sub_InputMethod_IMF_SecurityKeyboard_0601(): Promise<void> {
1595    let commonEventPublishData = {
1596      data: 'FAILED'
1597    };
1598    console.info(TAG + '====>Sub_InputMethod_IMF_SecurityKeyboard_0601 success');
1599    let panelInfo1 = {
1600      type: 0,
1601      flag: 1
1602    };
1603    let inputPanel = await inputMethodAbility.createPanel(this.mContext, panelInfo1);
1604    try {
1605      let isPrivacyMode: boolean = true;
1606      inputPanel.setPrivacyMode(isPrivacyMode);
1607      console.info(TAG + '====>Sub_InputMethod_IMF_SecurityKeyboard_0601 setPrivacyMode success');
1608      commoneventmanager.publish('Sub_InputMethod_IMF_SecurityKeyboard_0601', commonEventPublishData, this.publishCallback);
1609    } catch (error) {
1610      if (error.code === 201) {
1611        commonEventPublishData = {
1612          data: 'SUCCESS'
1613        };
1614      };
1615      await inputMethodAbility.destroyPanel(inputPanel);
1616      console.info(TAG + '====>Sub_InputMethod_IMF_SecurityKeyboard_0601 catch error: ' + JSON.stringify(error));
1617      commoneventmanager.publish('Sub_InputMethod_IMF_SecurityKeyboard_0601', commonEventPublishData, this.publishCallback);
1618    }
1619  }
1620
1621  async Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100(): Promise<void> {
1622    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100 data');
1623    let commonEventPublishData = {
1624      data: 'FAILED'
1625    };
1626    try {
1627      this.InputClient.deleteBackward(undefined, (err, result) => {
1628        if (err) {
1629          console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100 sendKeyFunction err:' + JSON.stringify(err));
1630          commonEventPublishData = {
1631            data: 'SUCCESS'
1632          };
1633        }
1634        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100 sendKeyFunction success');
1635      });
1636    } catch (err) {
1637      if (err.code === 401) {
1638        commonEventPublishData = {
1639          data: 'SUCCESS'
1640        };
1641      }
1642      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100 catch err: ' + JSON.stringify(err));
1643    }
1644    commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0100', commonEventPublishData, this.publishCallback);
1645  }
1646
1647  async Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200(): Promise<void> {
1648    console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200 data');
1649    let commonEventPublishData = {
1650      data: 'FAILED'
1651    };
1652    try {
1653      this.InputClient.deleteBackward(undefined).then((result) => {
1654        console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200 Succeed in sendKeyFunction.' + JSON.stringify(result));
1655        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200', commonEventPublishData, this.publishCallback);
1656      }).catch((err) => {
1657        commonEventPublishData = {
1658          data: 'SUCCESS'
1659        };
1660        console.info(TAG + '====>receive Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200 sendKeyFunction error: ' + JSON.stringify(err));
1661        commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200', commonEventPublishData, this.publishCallback);
1662      });
1663    } catch (err) {
1664      if (err.code === 401) {
1665        commonEventPublishData = {
1666          data: 'SUCCESS'
1667        };
1668      }
1669      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200 err: ' + JSON.stringify(err));
1670      commoneventmanager.publish('Sub_Misc_inputMethodEngine_InputClient_deleteBackward_0200', commonEventPublishData, this.publishCallback);
1671    }
1672  }
1673
1674  async SUB_InputMethod_IME_PrivateDateTransferred_1101(): Promise<void> {
1675    console.info(TAG + '====>receive SUB_InputMethod_IME_PrivateDateTransferred_1101 data');
1676    let commonEventPublishData = {
1677      data: 'FAILED'
1678    };
1679    try {
1680      await this.mContext.startAbility(undefined);
1681      console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1101 startAbility success');
1682    } catch (err) {
1683      console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1101 err: ' + JSON.stringify(err));
1684      if (err.code === 401) {
1685        commonEventPublishData = {
1686          data: 'SUCCESS'
1687        };
1688      }
1689    };
1690    commoneventmanager.publish('SUB_InputMethod_IME_PrivateDateTransferred_1101', commonEventPublishData, this.publishCallback);
1691  }
1692
1693  private async wrapAssertWithTwoIn1Judgement(assertRunnable: () => Promise<boolean>): Promise<() => Promise<boolean>> {
1694    try {
1695      return () => assertRunnable();
1696    } catch (err) {
1697      console.info(TAG + ` Throw err is ${JSON.stringify(err)}`);
1698      return () => Promise.resolve(false);
1699    }
1700  }
1701
1702  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0100(): Promise<void> {
1703    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0100', await this.wrapAssertWithTwoIn1Judgement(async () => {
1704      let attachOptions = this.InputClient.getAttachOptions();
1705
1706      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0100 attachOptions is' + JSON.stringify(attachOptions));
1707
1708      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.NONE;
1709    }));
1710  }
1711
1712  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0200(): Promise<void> {
1713    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0200', await this.wrapAssertWithTwoIn1Judgement(async () => {
1714      let attachOptions = this.InputClient.getAttachOptions();
1715
1716      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0200 attachOptions is' + JSON.stringify(attachOptions));
1717
1718      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.MOUSE;
1719    }));
1720  }
1721
1722  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0300(): Promise<void> {
1723    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0300', await this.wrapAssertWithTwoIn1Judgement(async () => {
1724      let attachOptions = this.InputClient.getAttachOptions();
1725
1726      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0300 attachOptions is' + JSON.stringify(attachOptions));
1727
1728      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.TOUCH;
1729    }));
1730  }
1731
1732  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0400(): Promise<void> {
1733    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0400', await this.wrapAssertWithTwoIn1Judgement(async () => {
1734      let attachOptions = this.InputClient.getAttachOptions();
1735
1736      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0400 attachOptions is' + JSON.stringify(attachOptions));
1737
1738      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.OTHER;
1739    }));
1740  }
1741
1742  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0500(): Promise<void> {
1743    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0500', await this.wrapAssertWithTwoIn1Judgement(async () => {
1744      let attachOptions = this.InputClient.getAttachOptions();
1745
1746      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0500 attachOptions is' + JSON.stringify(attachOptions));
1747
1748      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.NONE;
1749    }));
1750  }
1751
1752  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0600(): Promise<void> {
1753    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0600', await this.wrapAssertWithTwoIn1Judgement(async () => {
1754      let attachOptions = this.InputClient.getAttachOptions();
1755
1756      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0600 attachOptions is' + JSON.stringify(attachOptions));
1757
1758      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.MOUSE;
1759    }));
1760  }
1761
1762  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0700(): Promise<void> {
1763    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0700', await this.wrapAssertWithTwoIn1Judgement(async () => {
1764      let attachOptions = this.InputClient.getAttachOptions();
1765
1766      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0700 attachOptions is' + JSON.stringify(attachOptions));
1767
1768      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.TOUCH;
1769    }));
1770  }
1771
1772  async Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0800(): Promise<void> {
1773    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0800', await this.wrapAssertWithTwoIn1Judgement(async () => {
1774      let attachOptions = this.InputClient.getAttachOptions();
1775
1776      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_getAttachOptions_0800 attachOptions is' + JSON.stringify(attachOptions));
1777
1778      return attachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.OTHER;
1779    }));
1780  }
1781
1782  async Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100(): Promise<void> {
1783    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100', await this.wrapAssertWithTwoIn1Judgement(async () => {
1784      let attachOptions = this.InputClient.getAttachOptions();
1785
1786      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100 attachOptions is' + JSON.stringify(attachOptions));
1787
1788      if (attachOptions.requestKeyboardReason !== inputmethodengine.RequestKeyboardReason.NONE) {
1789        return false;
1790      }
1791
1792      return new Promise((resolve, reject) => {
1793        this.InputClient.on('attachOptionsDidChange', (newAttachOptions) => {
1794          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0100 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1795          resolve(newAttachOptions.requestKeyboardReason === inputmethodengine.RequestKeyboardReason.TOUCH);
1796          this.InputClient.off('attachOptionsDidChange');
1797        });
1798      });
1799    }));
1800  }
1801
1802  async Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200(): Promise<void> {
1803    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200', await this.wrapAssertWithTwoIn1Judgement(async () => {
1804      let attachOptions = this.InputClient.getAttachOptions();
1805
1806      console.info(TAG + '====>Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 attachOptions is' + JSON.stringify(attachOptions));
1807
1808      if (attachOptions.requestKeyboardReason !== inputmethodengine.RequestKeyboardReason.NONE) {
1809        return false;
1810      }
1811
1812      return new Promise((resolve, reject) => {
1813        let count = 0;
1814        let callback1 = (newAttachOptions): void => {
1815          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback1 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1816          if (newAttachOptions.requestKeyboardReason !== inputmethodengine.RequestKeyboardReason.TOUCH) {
1817            console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback1 not called correct reason');
1818            resolve(false);
1819            return;
1820          }
1821          if (count !== 0) {
1822            console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback1 not called first');
1823            resolve(false);
1824            return;
1825          }
1826          count = 1;
1827          this.InputClient.off('attachOptionsDidChange', callback1);
1828        };
1829        let callback2 = (newAttachOptions): void => {
1830          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback2 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1831          if (newAttachOptions.requestKeyboardReason !== inputmethodengine.RequestKeyboardReason.TOUCH) {
1832            console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback2 not called correct reason');
1833            resolve(false);
1834            return;
1835          }
1836          if (count !== 1) {
1837            console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_onAttachOptionsDidChange_0200 callback2 not called first');
1838            resolve(false);
1839            return;
1840          }
1841          count = 2;
1842          this.InputClient.off('attachOptionsDidChange', callback2);
1843        };
1844
1845        this.InputClient.on('attachOptionsDidChange', callback1);
1846        this.InputClient.on('attachOptionsDidChange', callback2);
1847        setTimeout(() => {
1848          resolve(count === 2);
1849        }, 1000);
1850      });
1851    }));
1852  }
1853
1854  async Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100(): Promise<void> {
1855    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100', await this.wrapAssertWithTwoIn1Judgement(async () => {
1856      return new Promise((resolve, reject) => {
1857        let count1 = 0;
1858        let count2 = 0;
1859        let callback1 = (newAttachOptions): void => {
1860          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100 callback1 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1861          ++count1;
1862        };
1863        let callback2 = (newAttachOptions): void => {
1864          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100 callback2 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1865          ++count2;
1866          this.InputClient.off('attachOptionsDidChange', callback2);
1867        };
1868
1869        this.InputClient.on('attachOptionsDidChange', callback1);
1870        this.InputClient.on('attachOptionsDidChange', callback2);
1871        setTimeout(() => {
1872          console.info(TAG + `====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0100 count1 = ${count1}, count2 = ${count2}`);
1873          resolve(count1 === 2 && count2 === 1);
1874          this.InputClient.off('attachOptionsDidChange');
1875        }, 1000);
1876      });
1877    }));
1878  }
1879
1880  async Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200(): Promise<void> {
1881    this.testTemplate('Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200', await this.wrapAssertWithTwoIn1Judgement(async () => {
1882      return new Promise((resolve, reject) => {
1883        let count1 = 0;
1884        let count2 = 0;
1885        let callback1 = (newAttachOptions): void => {
1886          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200 callback1 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1887          ++count1;
1888        };
1889        let callback2 = (newAttachOptions): void => {
1890          console.info(TAG + '====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200 callback2 newAttachOptions is ' + JSON.stringify(newAttachOptions));
1891          ++count2;
1892        };
1893        setTimeout(() => {
1894          this.InputClient.off('attachOptionsDidChange');
1895        }, 200);
1896        this.InputClient.on('attachOptionsDidChange', callback1);
1897        this.InputClient.on('attachOptionsDidChange', callback2);
1898        setTimeout(() => {
1899          console.info(TAG + `====> Sub_Misc_inputMethodEngine_InputClient_offAttachOptionsDidChange_0200 count1 = ${count1}, count2 = ${count2}`);
1900          resolve(count1 === 1 && count2 === 1);
1901          this.InputClient.off('attachOptionsDidChange');
1902        }, 1000);
1903      });
1904    }));
1905  }
1906
1907  private async wrapAssertWithTwoIn1Judgement1(assertRunnable: () => Promise<boolean>): Promise<() => Promise<boolean>> {
1908    return () => assertRunnable();
1909  }
1910
1911  async Sub_InputMethod_IMF_CapitalizeMode_0100(): Promise<void> {
1912    this.testTemplate('Sub_InputMethod_IMF_CapitalizeMode_0100', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1913      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1914
1915      console.info(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0100 editorAttribute is' + JSON.stringify(editorAttribute));
1916
1917      return editorAttribute.capitalizeMode === inputmethodengine.CapitalizeMode.NONE;
1918    }));
1919  }
1920
1921  async Sub_InputMethod_IMF_CapitalizeMode_0200(): Promise<void> {
1922    this.testTemplate('Sub_InputMethod_IMF_CapitalizeMode_0200', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1923      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1924
1925      console.info(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0200 editorAttribute is' + JSON.stringify(editorAttribute));
1926
1927      return editorAttribute.capitalizeMode === inputmethodengine.CapitalizeMode.SENTENCES;
1928    }));
1929  }
1930
1931  async Sub_InputMethod_IMF_CapitalizeMode_0300(): Promise<void> {
1932    this.testTemplate('Sub_InputMethod_IMF_CapitalizeMode_0300', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1933      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1934
1935      console.info(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0300 editorAttribute is' + JSON.stringify(editorAttribute));
1936
1937      return editorAttribute.capitalizeMode === inputmethodengine.CapitalizeMode.WORDS;
1938    }));
1939  }
1940
1941  async Sub_InputMethod_IMF_CapitalizeMode_0400(): Promise<void> {
1942    this.testTemplate('Sub_InputMethod_IMF_CapitalizeMode_0400', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1943      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1944
1945      console.info(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0400 editorAttribute is' + JSON.stringify(editorAttribute));
1946
1947      return editorAttribute.capitalizeMode === inputmethodengine.CapitalizeMode.CHARACTERS;
1948    }));
1949  }
1950
1951  async Sub_InputMethod_IMF_CapitalizeMode_0500(): Promise<void> {
1952    this.testTemplate('Sub_InputMethod_IMF_CapitalizeMode_0500', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1953      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1954
1955      console.info(TAG + '====>Sub_InputMethod_IMF_CapitalizeMode_0500 editorAttribute is' + JSON.stringify(editorAttribute));
1956
1957      return editorAttribute.capitalizeMode === inputmethodengine.CapitalizeMode.NONE;
1958    }));
1959  }
1960
1961  async Sub_InputMethod_IMF_Placeholder_0100(): Promise<void> {
1962    this.testTemplate('Sub_InputMethod_IMF_Placeholder_0100', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1963      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1964      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0100 editorAttribute is' + JSON.stringify(editorAttribute));
1965      let placeholderLength = editorAttribute.placeholder.length;
1966      let abilityNameLength = editorAttribute.abilityName.length;
1967      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0100 placeholderLength is' + JSON.stringify(placeholderLength));
1968      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0100 abilityNameLength is' + JSON.stringify(abilityNameLength));
1969      return placeholderLength === 0 && abilityNameLength === 0;
1970    }));
1971  }
1972
1973  async Sub_InputMethod_IMF_Placeholder_0200(): Promise<void> {
1974    this.testTemplate('Sub_InputMethod_IMF_Placeholder_0200', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1975      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1976      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0200 editorAttribute is' + JSON.stringify(editorAttribute));
1977      let placeholderLength = editorAttribute.placeholder.length;
1978      let abilityNameLength = editorAttribute.abilityName.length;
1979      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0200 placeholderLength is' + JSON.stringify(placeholderLength));
1980      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0200 abilityNameLength is' + JSON.stringify(abilityNameLength));
1981      return placeholderLength === 255 && abilityNameLength === 127;
1982    }));
1983  }
1984
1985  async Sub_InputMethod_IMF_Placeholder_0300(): Promise<void> {
1986    this.testTemplate('Sub_InputMethod_IMF_Placeholder_0300', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1987      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
1988      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0300 editorAttribute is' + JSON.stringify(editorAttribute));
1989      let placeholderLength = editorAttribute.placeholder.length;
1990      let abilityNameLength = editorAttribute.abilityName.length;
1991      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0300 placeholderLength is' + JSON.stringify(placeholderLength));
1992      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0300 abilityNameLength is' + JSON.stringify(abilityNameLength));
1993      return placeholderLength === 255 && abilityNameLength === 127;
1994    }));
1995  }
1996
1997  async Sub_InputMethod_IMF_Placeholder_0400(): Promise<void> {
1998    this.testTemplate('Sub_InputMethod_IMF_Placeholder_0400', await this.wrapAssertWithTwoIn1Judgement1(async () => {
1999      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
2000      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0400 editorAttribute is' + JSON.stringify(editorAttribute));
2001      let placeholderLength = editorAttribute.placeholder.length;
2002      let abilityNameLength = editorAttribute.abilityName.length;
2003      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0400 placeholderLength is' + JSON.stringify(placeholderLength));
2004      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0400 abilityNameLength is' + JSON.stringify(abilityNameLength));
2005      return placeholderLength === 255 && abilityNameLength === 127;
2006    }));
2007  }
2008
2009  async Sub_InputMethod_IMF_Placeholder_0600(): Promise<void> {
2010    this.testTemplate('Sub_InputMethod_IMF_Placeholder_0600', await this.wrapAssertWithTwoIn1Judgement1(async () => {
2011      let editorAttribute: inputmethodengine.EditorAttribute = this.InputClient.getEditorAttributeSync();
2012      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0600 editorAttribute is' + JSON.stringify(editorAttribute));
2013      let placeholderLength = editorAttribute.placeholder.length;
2014      let abilityNameLength = editorAttribute.abilityName.length;
2015      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0600 placeholderLength is' + JSON.stringify(placeholderLength));
2016      console.info(TAG + '====>Sub_InputMethod_IMF_Placeholder_0600 abilityNameLength is' + JSON.stringify(abilityNameLength));
2017      return placeholderLength === 0 && abilityNameLength === 0;
2018    }));
2019  }
2020
2021  async Sub_InputMethod_IMF_DiscardTypingText_0100(): Promise<void> {
2022    this.testTemplate('Sub_InputMethod_IMF_DiscardTypingText_0100', await this.wrapAssertWithTwoIn1Judgement1(async () => {
2023      return new Promise((resolve, reject) => {
2024        let count = 0;
2025        inputmethodengine.getInputMethodAbility().on('discardTypingText', () => {
2026          console.info(TAG + '====> Sub_InputMethod_IMF_DiscardTypingText_0100  is success');
2027          ++count;
2028
2029        });
2030        setTimeout(() => {
2031          console.info(TAG + `====> Sub_InputMethod_IMF_DiscardTypingText_0100 count = ${count}`);
2032          resolve(count === 1);
2033          inputmethodengine.getInputMethodAbility().off('discardTypingText');
2034        }, 1000);
2035      });
2036    }));
2037  }
2038
2039  async Sub_InputMethod_IMF_DiscardTypingText_1000(): Promise<void> {
2040    this.testTemplate('Sub_InputMethod_IMF_DiscardTypingText_1000', await this.wrapAssertWithTwoIn1Judgement1(async () => {
2041      return new Promise((resolve, reject) => {
2042        let count1 = 0;
2043        let count2 = 0;
2044        let callback1 = (): void => {
2045          console.info(TAG + '====> Sub_InputMethod_IMF_DiscardTypingText_1000 callback1  is success' );
2046          ++count1;
2047        };
2048        let callback2 = (): void => {
2049          console.info(TAG + '====> Sub_InputMethod_IMF_DiscardTypingText_1000 callback2  is success' );
2050          ++count2;
2051        };
2052        inputmethodengine.getInputMethodAbility().on('discardTypingText', callback1);
2053        inputmethodengine.getInputMethodAbility().on('discardTypingText', callback2);
2054        inputmethodengine.getInputMethodAbility().off('discardTypingText', callback1);
2055        setTimeout(() => {
2056          console.info(TAG + `====> Sub_InputMethod_IMF_DiscardTypingText_0100 count1 = ${count1}, count2 = ${count2}`);
2057          resolve(count1 === 0 && count2 === 1);
2058          inputmethodengine.getInputMethodAbility().off('discardTypingText');
2059        }, 1000);
2060      });
2061    }));
2062  }
2063
2064  private async testTemplate(testName: string, assertFunction: () => Promise<boolean>): Promise<void> {
2065    console.info(`${TAG}====>receive ${testName} data`);
2066    let commonEventPublishData = {
2067      data: 'FAILED'
2068    };
2069    try {
2070      if (await assertFunction() === true) {
2071        commonEventPublishData = {
2072          data: 'SUCCESS'
2073        };
2074      }
2075    } catch (err) {
2076      if (err.code === 801) {
2077        commonEventPublishData = {
2078          data: 'SUCCESS'
2079        };
2080      }
2081      console.log(`${TAG}====>${testName} catch errL ${JSON.stringify(err)}`);
2082    }
2083    commoneventmanager.publish(testName, commonEventPublishData, this.publishCallback);
2084  }
2085}