• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021 XXXX Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import app from '@system.app'
17import inputMethod from '@ohos.inputMethod'
18import inputMethodEngine from '@ohos.inputMethodEngine'
19import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
20
21describe("InputMethodTest", function () {
22    beforeAll(function () {
23        console.info('beforeAll called')
24    })
25
26    afterAll(function () {
27        console.info('afterAll called')
28    })
29
30    beforeEach(function () {
31        console.info('beforeEach called')
32    })
33
34    afterEach(function () {
35        console.info('afterEach called')
36    })
37    let mKeyboardDelegate = null;
38    let inputMethodEngineObject = inputMethodEngine.getInputMethodAbility();
39    let textInputClient = null;
40    let kbController = null;
41    let KeyboardDelegate = null;
42
43    /*
44     * @tc.number  inputmethod_test_MAX_TYPE_NUM_001
45     * @tc.name    Test MAX_TYPE_NUM.
46     * @tc.desc    Function test
47     * @tc.level   2
48     */
49    it('inputmethod_test_MAX_TYPE_NUM_001', 0, async function (done) {
50      console.info("************* inputmethod_test_MAX_TYPE_NUM_001 Test start*************");
51      let MAX_NUM = 128;
52      let inputMethodSetting = inputMethod.MAX_TYPE_NUM;
53      console.info("inputmethod_test_001 result:" + inputMethodSetting);
54      expect(inputMethodSetting == MAX_NUM).assertTrue();
55      console.info("************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************");
56      done();
57    });
58
59    /*
60     * @tc.number  inputmethod_test_getInputMethodController_001
61     * @tc.name    Test to get an InputMethodController instance.
62     * @tc.desc    Function test
63     * @tc.level   2
64     */
65    it('inputmethod_test_getInputMethodController_001', 0, async function (done) {
66      console.info("************* inputmethod_test_getInputMethodController_001 Test start*************");
67      let controller = inputMethod.getInputMethodController();
68      expect(controller != undefined).assertTrue();
69      console.info("************* inputmethod_test_getInputMethodController_001 Test end*************");
70      done();
71    });
72
73      /*
74     * @tc.number  inputmethod_test_getController_001
75     * @tc.name    Test to get an InputMethodController instance.
76     * @tc.desc    Function test
77     * @tc.level   2
78     */
79    it('inputmethod_test_getController_001', 0, async function (done) {
80      console.info("************* inputmethod_test_getController_001 Test start*************");
81      let controller = inputMethod.getController();
82      expect(controller != undefined).assertTrue();
83      console.info("************* inputmethod_test_getController_001 Test end*************");
84      done();
85    });
86
87    /*
88     * @tc.number  inputmethod_test_getInputMethodSetting_001
89     * @tc.name    Test to get an InputMethodSetting instance.
90     * @tc.desc    Function test
91     * @tc.level   2
92     */
93    it('inputmethod_test_getInputMethodSetting_001', 0, async function (done) {
94      console.info("************* inputmethod_test_getInputMethodSetting_001 Test start*************");
95      let setting = inputMethod.getInputMethodSetting();
96      expect(setting != undefined).assertTrue();
97      console.info("************* inputmethod_test_getInputMethodSetting_001 Test end*************");
98      done();
99    });
100
101    /*
102     * @tc.number  inputmethod_test_getInputMethodSetting_001
103     * @tc.name    Test to get an InputMethodSetting instance.
104     * @tc.desc    Function test
105     * @tc.level   2
106     */
107    it('inputmethod_test_getSetting_001', 0, async function (done) {
108      console.info("************* inputmethod_test_getSetting_001 Test start*************");
109      let setting = inputMethod.getSetting();
110      expect(setting != undefined).assertTrue();
111      console.info("************* inputmethod_test_getSetting_001 Test end*************");
112      done();
113    });
114
115    /*
116     * @tc.number  inputmethod_test_on_001
117     * @tc.name    Test to subscribe 'imeChange'.
118     * @tc.desc    Function test
119     * @tc.level   2
120     */
121    it('inputmethod_test_on_001', 0, async function (done) {
122      let setting = inputMethod.getSetting();
123      setting.on('imeChange', (err, property, subtype) => {
124        if (err) {
125          console.info("inputmethod_test_on_001 imeChange err:" + err);
126          return;
127        }
128        console.info("inputmethod_test_on_001 imeChange property:" + JSON.stringify(property));
129        console.info("inputmethod_test_on_001 imeChange subtype:" + JSON.stringify(subtype));
130      });
131      done();
132    });
133
134    /*
135     * @tc.number  inputmethod_test_switchInputMethod_001
136     * @tc.name    Test Indicates the input method which will replace the current one.
137     * @tc.desc    Function test
138     * @tc.level   2
139     */
140    it('inputmethod_test_switchInputMethod_001', 0, async function (done) {
141      console.info("************* inputmethod_test_switchInputMethod_001 Test start*************");
142      let inputMethodProperty = {
143        packageName:"com.example.kikakeyboard",
144        methodId:"ServiceExtAbility"
145      }
146      inputMethod.switchInputMethod(inputMethodProperty).then(data => {
147        console.info("inputmethod_test_switchInputMethod_001 data:" + data)
148        expect(data == true).assertTrue();
149      }).catch( err=> {
150        console.info("inputmethod_test_switchInputMethod_001 err:" + JSON.stringify(err.message))
151      })
152      console.info("************* inputmethod_test_switchInputMethod_001 Test end*************");
153      done();
154    });
155
156    /*
157     * @tc.number  inputmethod_test_getCurrentInputMethod_001
158     * @tc.name    Test get current input method.
159     * @tc.desc    Function test
160     * @tc.level   2
161     */
162    it('inputmethod_test_getCurrentInputMethod_001', 0, async function (done) {
163      console.info("************* inputmethod_test_getCurrentInputMethod_001 Test start*************");
164      let property = inputMethod.getCurrentInputMethod();
165      console.info("getCurrentInputMethod_test_001 result property:" + property.packageName);
166      console.info("getCurrentInputMethod_test_001 result property:" + property.methodId);
167      expect(property != undefined).assertTrue();
168      console.info("************* inputmethod_test_getCurrentInputMethod_001 Test end*************");
169      done();
170    });
171
172    /*
173    * @tc.number  inputmethod_test_listInputMethod_001
174    * @tc.name    Test list input methods.
175    * @tc.desc    Function test
176    * @tc.level   2
177    */
178    it('inputmethod_test_listInputMethod_001', 0, async function (done) {
179      console.info("************* inputmethod_test_listInputMethod_001 Test start*************");
180      let inputMethodSetting = inputMethod.getInputMethodSetting();
181      console.info("listInputMethod_001 result:" + JSON.stringify(inputMethodSetting));
182      inputMethodSetting.listInputMethod((err, data) => {
183        if (err) {
184          console.error("listInputMethod callback result---err: " + JSON.stringify(err.message));
185          expect().assertFail();
186        }
187          console.info("listInputMethod_001 listInputMethod result" + JSON.stringify(data));
188          expect(err == undefined).assertTrue();
189      });
190      console.info("************* inputmethod_test_listInputMethod_001 Test end*************");
191       done();
192    });
193
194    /*
195     * @tc.number  inputmethod_test_listInputMethod_002
196     * @tc.name    Test list input methods.
197     * @tc.desc    Function test
198     * @tc.level   2
199     */
200    it('inputmethod_test_listInputMethod_002', 0, async function (done) {
201      console.info("************* inputmethod_test_listInputMethod_002 Test start*************");
202      let inputMethodSetting = inputMethod.getInputMethodSetting();
203      console.info("inputmethod_test_listInputMethod_002 result:" + JSON.stringify(inputMethodSetting));
204      await inputMethodSetting.listInputMethod().then((data)=>{
205        console.info("inputmethod_test_listInputMethod_002 listInputMethod result" + JSON.stringify(data));
206        expect(data.length > 0).assertTrue();
207      }).catch((err) => {
208        console.info('inputmethod_test_listInputMethod_002 listInputMethod err ' + JSON.stringify(err.message));
209        expect(null).assertFail();
210      });
211      console.info("************* inputmethod_test_listInputMethod_002 Test end*************");
212      done();
213    });
214
215    /*
216     * @tc.number  inputmethod_test_listInputMethod_003
217     * @tc.name    Test list input methods.
218     * @tc.desc    Function test
219     * @tc.level   2
220     */
221        it('inputmethod_test_listInputMethod_003', 0, async function (done) {
222          console.info("************* inputmethod_test_listInputMethod_003 Test start*************");
223          let inputMethodSetting = inputMethod.getInputMethodSetting();
224          console.info("inputmethod_test_listInputMethod_003 result:" + JSON.stringify(inputMethodSetting));
225          await inputMethodSetting.listInputMethod(true).then((data)=>{
226            console.info("inputmethod_test_listInputMethod_003 listInputMethod result" + JSON.stringify(data));
227            expect(data.length > 0).assertTrue();
228          }).catch((err) => {
229            console.info('inputmethod_test_listInputMethod_003 listInputMethod err ' + JSON.stringify(err.message));
230            expect(null).assertFail();
231          });
232          done();
233          console.info("************* inputmethod_test_listInputMethod_003 Test end*************");
234        });
235
236      /*
237      * @tc.number  inputmethod_test_listInputMethod_004
238      * @tc.name    Test list input methods.
239      * @tc.desc    Function test
240      * @tc.level   2
241      */
242      it('inputmethod_test_listInputMethod_004', 0, async function (done) {
243        console.info("************* inputmethod_test_listInputMethod_004 Test start*************");
244        let inputMethodSetting = inputMethod.getInputMethodSetting();
245        console.info("inputmethoh_test_004 result:" + JSON.stringify(inputMethodSetting));
246        inputMethodSetting.listInputMethod(true, (err, data) => {
247          if (err) {
248            console.error("listInputMethod callback result---err: " + JSON.stringify(err.message));
249            expect().assertFail();
250          }
251            console.info("inputmethoh_test_004 listInputMethod result" + JSON.stringify(data));
252            expect(err == undefined).assertTrue();
253        });
254        console.info("************* inputmethod_test_listInputMethod_004 Test end*************");
255         done();
256      });
257    /*
258     * @tc.number  inputmethod_test_switchCurrentInputMethodSubtype_001
259     * @tc.name    Test Indicates the input method subtype which will replace the current one.
260     * @tc.desc    Function test
261     * @tc.level   2
262     */
263    it('inputmethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) {
264      console.info("************* inputmethod_test_switchCurrentInputMethodSubtype_001 Test start*************");
265      let InputMethodSubtype = {
266        name:"com.example.kikakeyboard",
267        id:"ServiceExtAbility",
268        locale:"en_US.ISO-8859-1",
269        language:"en",
270        extra:{},
271      }
272      inputMethod.switchCurrentInputMethodSubtype(InputMethodSubtype).then(data => {
273        console.info("inputmethod_test_switchCurrentInputMethodSubtype_001 data:" + data)
274        expect(data == true).assertTrue();
275      }).catch( err=> {
276        console.info("inputmethod_test_switchCurrentInputMethodSubtype_001 err:" + JSON.stringify(err.message))
277      })
278      console.info("************* inputmethod_test_switchCurrentInputMethodSubtype_001 Test end*************");
279      done();
280    });
281
282    /*
283     * @tc.number  inputmethod_test_switchCurrentInputMethodSubtype_002
284     * @tc.name    Test Indicates the input method which will replace the current one.
285     * @tc.desc    Function test
286     * @tc.level   2
287     */
288    it('inputmethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) {
289      console.info("************* inputmethod_test_switchCurrentInputMethodSubtype Test start*************");
290      let InputMethodSubtype = {
291        name:"com.example.kikakeyboard",
292        id:"ServiceExtAbility",
293        locale:"en_US.ISO-8859-1",
294        language:"en",
295        extra:{},
296      }
297      inputMethod.switchInputMethod(InputMethodSubtype, (err, data)=>{
298        if(err){
299          console.info("inputmethod_test_switchCurrentInputMethodSubtype error:" + JSON.stringify(err.message));
300          expect().assertFail();
301        }
302        console.info("inputmethod_test_switchCurrentInputMethodSubtype data:" + data)
303        expect(data == true).assertTrue();
304      });
305      console.info("************* inputmethod_test_switchCurrentInputMethodSubtype Test end*************");
306      done();
307    });
308
309    /*
310     * @tc.number  inputmethod_test_switchCurrentInputMethodAndSubtype_001
311     * @tc.name    Test Indicates the input method subtype which will replace the current one.
312     * @tc.desc    Function test
313     * @tc.level   2
314     */
315    it('inputmethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) {
316      console.info("************* inputmethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************");
317      let InputMethodSubtype = {
318        name:"com.example.kikakeyboard",
319        id:"ServiceExtAbility",
320        locale:"en_US.ISO-8859-1",
321        language:"en",
322        extra:{},
323      }
324      let inputMethodProperty = {
325        packageName:"com.example.kikakeyboard",
326        methodId:"ServiceExtAbility"
327      }
328      inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, InputMethodSubtype).then(data => {
329        console.info("inputmethod_test_switchCurrentInputMethodAndSubtype_001 data:" + data)
330        expect(data == true).assertTrue();
331      }).catch( err=> {
332        console.info("inputmethod_test_switchCurrentInputMethodAndSubtype_001 err:" + JSON.stringify(err.message))
333      })
334      console.info("************* inputmethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************");
335      done();
336    });
337
338    /*
339     * @tc.number  inputmethod_test_switchCurrentInputMethodAndSubtype_002
340     * @tc.name    Test Indicates the input method which will replace the current one.
341     * @tc.desc    Function test
342     * @tc.level   2
343     */
344    it('inputmethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) {
345      console.info("************* inputmethod_test_switchCurrentInputMethodAndSubtype Test start*************");
346      let InputMethodSubtype = {
347        name:"com.example.kikakeyboard",
348        id:"ServiceExtAbility",
349        locale:"en_US.ISO-8859-1",
350        language:"en",
351        extra:{},
352      }
353      let inputMethodProperty = {
354        packageName:"com.example.kikakeyboard",
355        methodId:"ServiceExtAbility"
356      }
357      inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, InputMethodSubtype, (err, data)=>{
358        if(err){
359          console.info("inputmethod_test_switchCurrentInputMethodAndSubtype error:" + JSON.stringify(err.message));
360          expect().assertFail();
361        }
362        console.info("inputmethod_test_switchCurrentInputMethodAndSubtype data:" + data)
363        expect(data == true).assertTrue();
364      });
365      console.info("************* inputmethod_test_switchCurrentInputMethodAndSubtype Test end*************");
366      done();
367    });
368
369    /*
370    * @tc.number  inputmethod_test_listInputMethodSubtype_001
371    * @tc.name    Test list input method subtypes.
372    * @tc.desc    Function test
373    * @tc.level   2
374    */
375    it('inputmethod_test_listInputMethodSubtype_001', 0, async function (done) {
376      console.info("************* inputmethod_test_listInputMethodSubtype_001 Test start*************");
377      let inputMethodProperty = {
378        name:"com.example.kikakeyboard",
379        id:"ServiceExtAbility"
380      }
381      let inputMethodSetting = inputMethod.getSetting();
382      console.info("listInputMethodSubtype_001 result:" + JSON.stringify(inputMethodSetting));
383      inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => {
384        if (err) {
385          console.error("listInputMethodSubtype callback result---err: " + JSON.stringify(err.message));
386          expect().assertFail();
387          return;
388        }
389          console.info("listInputMethodSubtype_001 listInputMethodSubtype result" + JSON.stringify(data));
390          expect().assertTrue();
391      });
392      console.info("************* inputmethod_test_listInputMethodSubtype_001 Test end*************");
393       done();
394    });
395
396    /*
397     * @tc.number  inputmethod_test_listInputMethodSubtype_002
398     * @tc.name    Test list input method subtypes.
399     * @tc.desc    Function test
400     * @tc.level   2
401     */
402    it('inputmethod_test_listInputMethodSubtype_002', 0, async function (done) {
403      console.info("************* inputmethod_test_listInputMethodSubtype_002 Test start*************");
404      let inputMethodProperty = {
405        name:"com.example.kikakeyboard",
406        id:"ServiceExtAbility"
407      }
408      let inputMethodSetting = inputMethod.getSetting();
409      console.info("inputmethod_test_listInputMethodSubtype_002 result:" + JSON.stringify(inputMethodSetting));
410      inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data)=>{
411        console.info("inputmethod_test_listInputMethodSubtype_002 listInputMethodSubtype result" + JSON.stringify(data));
412        expect(data.length > 0).assertTrue();
413      }).catch((err) => {
414        console.info('inputmethod_test_listInputMethodSubtype_002 listInputMethodSubtype err ' + JSON.stringify(err.message));
415        expect(null).assertFail();
416      });
417      console.info("************* inputmethod_test_listInputMethodSubtype_002 Test end*************");
418      done();
419    });
420
421    /*
422     * @tc.number  inputmethod_test_getCurrentInputMethodSubtype_001
423     * @tc.name    Test get current input method.
424     * @tc.desc    Function test
425     * @tc.level   2
426     */
427    it('inputmethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) {
428      console.info("************* inputmethod_test_getCurrentInputMethodSubtype_001 Test start*************");
429      let property = inputMethod.getCurrentInputMethodSubtype();
430      expect(property != undefined).assertTrue();
431      console.info("************* inputmethod_test_getCurrentInputMethodSubtype_001 Test end*************");
432      done();
433    });
434
435    /*
436    * @tc.number  inputmethod_test_listCurrentInputMethodSubtype_001
437    * @tc.name    Test list current input method subtypes.
438    * @tc.desc    Function test
439    * @tc.level   2
440    */
441    it('inputmethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) {
442      console.info("************* inputmethod_test_listCurrentInputMethodSubtype_001 Test start*************");
443      let inputMethodSetting = inputMethod.getSetting();
444      console.info("listCurrentInputMethodSubtype_001 result:" + JSON.stringify(inputMethodSetting));
445      inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
446        if (err) {
447          console.error("listCurrentInputMethodSubtype callback result---err: " + JSON.stringify(err.message));
448          expect().assertFail();
449        }
450          console.info("listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype result" + JSON.stringify(data));
451          expect(err == undefined).assertTrue();
452      });
453      console.info("************* inputmethod_test_listCurrentInputMethodSubtype_001 Test end*************");
454       done();
455    });
456
457    /*
458     * @tc.number  inputmethod_test_listCurrentInputMethodSubtype_002
459     * @tc.name    Test list current input method subtypes.
460     * @tc.desc    Function test
461     * @tc.level   2
462     */
463    it('inputmethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) {
464      console.info("************* inputmethod_test_listCurrentInputMethodSubtype_002 Test start*************");
465      let inputMethodSetting = inputMethod.getSetting();
466      console.info("inputmethod_test_listCurrentInputMethodSubtype_002 result:" + JSON.stringify(inputMethodSetting));
467      inputMethodSetting.listCurrentInputMethodSubtype().then((data)=>{
468        console.info("inputmethod_test_listCurrentInputMethodSubtype_002 listInputMethod result" + JSON.stringify(data));
469        expect(data.length > 0).assertTrue();
470      }).catch((err) => {
471        console.info('inputmethod_test_listCurrentInputMethodSubtype_002 listInputMethod err ' + JSON.stringify(err.message));
472        expect(null).assertFail();
473      });
474      console.info("************* inputmethod_test_listCurrentInputMethodSubtype_002 Test end*************");
475      done();
476    });
477
478       /*
479     * @tc.number  inputmethod_test_getInputMethods_001
480     * @tc.name    Test list input methods.
481     * @tc.desc    Function test
482     * @tc.level   2
483     */
484       it('inputmethod_test_getInputMethods_001', 0, async function (done) {
485        console.info("************* inputmethod_test_getInputMethods_001 Test start*************");
486        let inputMethodSetting = inputMethod.getSetting();
487        console.info("inputmethod_test_getInputMethods_001 result:" + JSON.stringify(inputMethodSetting));
488        inputMethodSetting.getInputMethods(true).then((data)=>{
489          console.info("inputmethod_test_getInputMethods_001 getInputMethods result" + JSON.stringify(data));
490          expect(data.length > 0).assertTrue();
491        }).catch((err) => {
492          console.info('inputmethod_test_getInputMethods_001 getInputMethods err ' + JSON.stringify(err.message));
493          expect(null).assertFail();
494        });
495        done();
496        console.info("************* inputmethod_test_getInputMethods_001 Test end*************");
497      });
498
499    /*
500    * @tc.number  inputmethod_test_getInputMethods_002
501    * @tc.name    Test list input methods.
502    * @tc.desc    Function test
503    * @tc.level   2
504    */
505    it('inputmethod_test_getInputMethods_002', 0, async function (done) {
506      console.info("************* inputmethod_test_getInputMethods_002 Test start*************");
507      let inputMethodSetting = inputMethod.getSetting();
508      console.info("inputmethod_test_getInputMethods_002 result:" + JSON.stringify(inputMethodSetting));
509      inputMethodSetting.getInputMethods(true, (err, data) => {
510        if (err) {
511          console.error("getInputMethods callback result---err: " + JSON.stringify(err.message));
512          expect().assertFail();
513        }
514          console.info("inputmethod_test_getInputMethods_002 getInputMethods result" + JSON.stringify(data));
515          expect(err == undefined).assertTrue();
516      });
517      console.info("************* inputmethod_test_getInputMethods_002 Test end*************");
518       done();
519    });
520
521    /*
522     * @tc.number  inputmethod_test_displayOptionalInputMethod_001
523     * @tc.name    Test displays a dialog box for selecting an input method.
524     * @tc.desc    Function test
525     * @tc.level   2
526     */
527    it('inputmethod_test_displayOptionalInputMethod_001', 0, async function (done) {
528      console.info("************* inputmethod_test_displayOptionalInputMethod_001 Test start*************");
529      let inputMethodSetting = inputMethod.getInputMethodSetting();
530      console.info("inputmethod_test_displayOptionalInputMethod_001 result:" + JSON.stringify(inputMethodSetting));
531      inputMethodSetting.displayOptionalInputMethod((err) => {
532        console.info("inputmethod_test_displayOptionalInputMethod_001 err:" + JSON.stringify(err.message));
533        expect(err == undefined).assertTrue();
534      });
535      console.info("************* inputmethod_test_displayOptionalInputMethod_001 Test end*************");
536     done();
537    });
538
539    /*
540     * @tc.number  inputmethod_test_displayOptionalInputMethod_002
541     * @tc.name    Test displays a dialog box for selecting an input method.
542     * @tc.desc    Function test
543     * @tc.level   2
544     */
545    it('inputmethod_test_displayOptionalInputMethod_002', 0, async function (done) {
546      console.info("************* inputmethod_test_displayOptionalInputMethod_002 Test start*************");
547      let inputMethodSetting = inputMethod.getInputMethodSetting();
548      console.info("inputmethod_test_displayOptionalInputMethod_002 result:" + JSON.stringify(inputMethodSetting));
549      inputMethodSetting.displayOptionalInputMethod().then(()=>{
550        console.info("inputmethod_test_displayOptionalInputMethod_002 displayOptionalInputMethod result");
551        expect(true).assertTrue();
552      }).catch((err) => {
553        console.info('inputmethod_test_displayOptionalInputMethod_002 listInputMethod err ' + JSON.stringify(err.message));
554        expect(null).assertFail();
555      });
556      console.info("************* inputmethod_test_displayOptionalInputMethod_002 Test end*************");
557      done();
558    });
559
560    /*
561     * @tc.number  inputmethod_test_showOptionalInputMethods_001
562     * @tc.name    Test displays a dialog box for selecting an input method.
563     * @tc.desc    Function test
564     * @tc.level   2
565     */
566    it('inputmethod_test_showOptionalInputMethods_001', 0, async function (done) {
567      console.info("************* inputmethod_test_showOptionalInputMethods_001 Test start*************");
568      let inputMethodSetting = inputMethod.getSetting();
569      console.info("inputmethod_test_showOptionalInputMethods_001 result:" + JSON.stringify(inputMethodSetting));
570      inputMethodSetting.showOptionalInputMethods((err) => {
571        console.info("inputmethod_test_showOptionalInputMethods_001 err:" + JSON.stringify(err.message));
572        expect(err == undefined).assertTrue();
573      });
574      console.info("************* inputmethod_test_showOptionalInputMethods_001 Test end*************");
575     done();
576    });
577
578    /*
579     * @tc.number  inputmethod_test_showOptionalInputMethods_002
580     * @tc.name    Test displays a dialog box for selecting an input method.
581     * @tc.desc    Function test
582     * @tc.level   2
583     */
584    it('inputmethod_test_showOptionalInputMethods_002', 0, async function (done) {
585      console.info("************* inputmethod_test_showOptionalInputMethods_002 Test start*************");
586      let inputMethodSetting = inputMethod.getSetting();
587      console.info("inputmethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting));
588      inputMethodSetting.showOptionalInputMethods().then(()=>{
589        console.info("inputmethod_test_showOptionalInputMethods_002 showOptionalInputMethods result");
590        expect(true).assertTrue();
591      }).catch((err) => {
592        console.info('inputmethod_test_showOptionalInputMethods_002 showOptionalInputMethods err ' + JSON.stringify(err.message));
593        expect(null).assertFail();
594      });
595      console.info("************* inputmethod_test_showOptionalInputMethods_002 Test end*************");
596      done();
597    });
598
599    /*
600     * @tc.number  inputmethod_test_showSoftKeyboard_001
601     * @tc.name    Test Indicates the input method which will show softboard with calback.
602     * @tc.desc    Function test
603     * @tc.level   2
604     */
605    it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) {
606      console.info("************* inputmethod_test_showSoftKeyboard_001 Test start*************");
607      let inputMethodCtrl = inputMethod.getInputMethodController()
608      inputMethodCtrl.showSoftKeyboard((err)=>{
609        if (err == undefined) {
610          console.info("showSoftKeyboard callbace success" );
611        } else {
612          console.info('showSoftKeyboard callbace failed : ' + JSON.stringify(err.message));
613          expect().assertFail();
614        }
615      });
616      console.info("************* inputmethod_test_showSoftKeyboard_001 Test end*************");
617      done();
618    });
619
620    /*
621     * @tc.number  inputmethod_test_showSoftKeyboard_002
622     * @tc.name    Test Indicates the input method which will show softboard with Promise.
623     * @tc.desc    Function test
624     * @tc.level   2
625     */
626    it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) {
627      console.info("************* inputmethod_test_showSoftKeyboard_002 Test start*************");
628      let inputMethodCtrl = inputMethod.getInputMethodController()
629      inputMethodCtrl.showSoftKeyboard().then((data) =>{
630        console.info("showSoftKeyboard promise success" );
631      }).catch((err) => {
632        console.info('showSoftKeyboard promise failed : ' + JSON.stringify(err.message));
633        expect().assertFail();
634      })
635      console.info("************* inputmethod_test_showSoftKeyboard_002 Test end*************");
636      done();
637    });
638
639    /*
640     * @tc.number  inputmethod_test_hideSoftKeyboard_001
641     * @tc.name    Test Indicates the input method which will hide softboard with calback.
642     * @tc.desc    Function test
643     * @tc.level   2
644     */
645    it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) {
646      console.info("************* inputmethod_test_hideSoftKeyboard_001 Test start*************");
647      let inputMethodCtrl = inputMethod.getInputMethodController()
648      inputMethodCtrl.hideSoftKeyboard((data)=>{
649        if(data == undefined){
650          console.info("hideSoftKeyboard callbace success" );
651        }else{
652          console.info('hideSoftKeyboard callbace failed : ' + JSON.stringify(err.message))
653          expect().assertFail();
654        }
655      });
656      console.info("************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
657      done();
658    });
659
660    /*
661     * @tc.number  inputmethod_test_hideSoftKeyboard_002
662     * @tc.name    Test Indicates the input method which will hide softboard with Promise.
663     * @tc.desc    Function test
664     * @tc.level   2
665     */
666    it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) {
667      console.info("************* inputmethod_test_hideSoftKeyboard_002 Test start*************");
668      let inputMethodCtrl = inputMethod.getInputMethodController()
669      inputMethodCtrl.hideSoftKeyboard().then((data) =>{
670        console.info("hideSoftKeyboard promise success" );
671      }).catch((err) => {
672        console.info('hideSoftKeyboard promise failed : ' + JSON.stringify(err.message));
673        expect().assertFail();
674      })
675      console.info("************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
676      done();
677    });
678
679    /*
680     * @tc.number  inputmethod_test_stopInputSession_001
681     * @tc.name    Test Indicates the input method which will hides the keyboard.
682     * @tc.desc    Function test
683     * @tc.level   2
684     */
685    it('inputmethod_test_stopInputSession_001', 0, function (done) {
686      console.info("************* inputmethod_test_stopInputSession_001 Test start*************");
687      let inputMethodCtrl = inputMethod.getController();
688      console.info("inputmethod_test_stopInputSession_001 result:" + JSON.stringify(inputMethodCtrl));
689      inputMethodCtrl.stopInputSession((err, res) => {
690        if (err) {
691          console.info("inputmethod_test_stopInputSession_001 stopInput result" + JSON.stringify(err.message));
692          expect().assertFail();
693          return;
694        }
695        console.info("inputmethod_test_stopInputSession_001 callback success" );
696        expect(res == true).assertTrue();
697      });
698      console.info("************* inputmethod_test_stopInputSession_001 Test end*************");
699      done();
700    });
701
702    it('inputMethodEngine_test_Off_000', 0 , async function (done) {
703      inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => {
704        console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
705        console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
706      });
707      inputMethodEngineObject.off('setSubtype', (err) => {
708        console.info("inputMethodEngine beforeEach setSubtype:" + err);
709      });
710      inputMethodEngineObject.off('keyboardShow', (err) => {
711        console.info("inputMethodEngine beforeEach keyboardShow:" + err);
712      });
713      inputMethodEngineObject.off('keyboardHide', (err) => {
714        console.info("inputMethodEngine beforeEach keyboardHide:" + err);
715      });
716      KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
717      KeyboardDelegate.off('keyDown', (keyEvent) => {
718        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
719        expect(keyEvent.keyCode).assertEqual('1');
720
721        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
722        expect(keyEvent.keyAction).assertEqual('1');
723
724      });
725      KeyboardDelegate.off('keyUp', (keyEvent) => {
726        console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
727        expect(keyEvent.keyCode).assertEqual('1');
728        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
729        expect(keyEvent.keyAction).assertEqual('0');
730
731      });
732      KeyboardDelegate.off('cursorContextChange', (x, y, height) => {
733        console.info("inputMethodEngine beforeEach cursorContextChange x:" + x);
734        console.info("inputMethodEngine beforeEach cursorContextChange y:" + y);
735        console.info("inputMethodEngine beforeEach cursorContextChange height:" + height);
736      });
737      KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
738        console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
739        console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
740        console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
741        console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
742      });
743      KeyboardDelegate.off('textChange', (text) => {
744        console.info("inputMethodEngine beforeEach textChange:" + text);
745      });
746      done();
747    });
748
749    it('inputMethodEngine_test_000', 0, async function (done) {
750      inputMethodEngineObject.on('inputStart', (controller, client) => {
751        console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(controller));
752        console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(client));
753        textInputClient = client;
754        kbController = controller;
755      });
756      inputMethodEngineObject.on('setSubtype', (err) => {
757        console.info("inputMethodEngine beforeEach setSubtype:" + err);
758      });
759      inputMethodEngineObject.on('keyboardShow', (err) => {
760        console.info("inputMethodEngine beforeEach keyboardShow:" + err);
761      });
762      inputMethodEngineObject.on('keyboardHide', (err) => {
763        console.info("inputMethodEngine beforeEach keyboardHide:" + err);
764      });
765      mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
766      mKeyboardDelegate.on('keyDown', (keyEvent) => {
767        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
768        expect(keyEvent.keyCode).assertEqual('1');
769
770        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
771        expect(keyEvent.keyAction).assertEqual('1');
772
773
774      });
775      mKeyboardDelegate.on('keyUp', (keyEvent) => {
776        console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
777        expect(keyEvent.keyCode).assertEqual('1');
778        console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
779        expect(keyEvent.keyAction).assertEqual('0');
780
781      });
782      mKeyboardDelegate.on('cursorContextChange', (x, y, height) => {
783        console.info("inputMethodEngine beforeEach cursorContextChange x:" + x);
784        console.info("inputMethodEngine beforeEach cursorContextChange y:" + y);
785        console.info("inputMethodEngine beforeEach cursorContextChange height:" + height);
786      });
787      mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
788        console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
789        console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
790        console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
791        console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
792      });
793      mKeyboardDelegate.on('textChange', (text) => {
794        console.info("inputMethodEngine beforeEach textChange:" + text);
795      });
796      done();
797    });
798
799    it('inputMethodEngine_test_001', 0, async function (done) {
800      let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED;
801      console.info("inputMethodEngine_test_001 result:" + keyType);
802      expect(keyType).assertEqual(0);
803      done();
804    });
805
806    it('inputMethodEngine_test_002', 0, async function (done) {
807      let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO;
808      console.info("inputMethodEngine_test_002 result:" + keyType);
809      expect(keyType).assertEqual(2);
810      done();
811    });
812
813    it('inputMethodEngine_test_003', 0, async function (done) {
814      let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH;
815      console.info("inputMethodEngine_test_003 result:" + keyType);
816      expect(keyType).assertEqual(3);
817      done();
818    });
819
820    it('inputMethodEngine_test_004', 0, async function (done) {
821      let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND;
822      console.info("inputMethodEngine_test_004 result:" + keyType);
823      expect(keyType).assertEqual(4);
824      done();
825    });
826
827    it('inputMethodEngine_test_005', 0, async function (done) {
828      let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT;
829      console.info("inputMethodEngine_test_005 result:" + keyType);
830      expect(keyType).assertEqual(5);
831      done();
832    });
833
834    it('inputMethodEngine_test_006', 0, async function (done) {
835      let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE;
836      console.info("inputMethodEngine_test_006 result:" + keyType);
837      expect(keyType).assertEqual(6);
838      done();
839    });
840
841    it('inputMethodEngine_test_007', 0, async function (done) {
842      let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS;
843      console.info("inputMethodEngine_test_007 result:" + keyType);
844      expect(keyType).assertEqual(7);
845      done();
846    });
847
848    it('inputMethodEngine_test_008', 0, async function (done) {
849      let keyType = inputMethodEngine.PATTERN_NULL;
850      console.info("inputMethodEngine_test_008 result:" + keyType);
851      expect(keyType).assertEqual(-1);
852      done();
853    });
854
855    it('inputMethodEngine_test_009', 0, async function (done) {
856      let keyType = inputMethodEngine.PATTERN_TEXT;
857      console.info("inputMethodEngine_test_009 result:" + keyType);
858      expect(keyType).assertEqual(0);
859      done();
860    });
861
862    it('inputMethodEngine_test_010', 0, async function (done) {
863      let keyType = inputMethodEngine.PATTERN_NUMBER;
864      console.info("inputMethodEngine_test_010 result:" + keyType);
865      expect(keyType).assertEqual(2);
866      done();
867    });
868
869    it('inputMethodEngine_test_011', 0, async function (done) {
870      let keyType = inputMethodEngine.PATTERN_PHONE;
871      console.info("inputMethodEngine_test_011 result:" + keyType);
872      expect(keyType).assertEqual(3);
873      done();
874    });
875
876    it('inputMethodEngine_test_012', 0, async function (done) {
877      let keyType = inputMethodEngine.PATTERN_DATETIME;
878      console.info("inputMethodEngine_test_012 result:" + keyType);
879      expect(keyType).assertEqual(4);
880      done();
881    });
882
883    it('inputMethodEngine_test_013', 0, async function (done) {
884      let keyType = inputMethodEngine.PATTERN_EMAIL;
885      console.info("inputMethodEngine_test_013 result:" + keyType);
886      expect(keyType).assertEqual(5);
887      done();
888    });
889
890    it('inputMethodEngine_test_014', 0, async function (done) {
891      let keyType = inputMethodEngine.PATTERN_URI;
892      console.info("inputMethodEngine_test_014 result:" + keyType);
893      expect(keyType).assertEqual(6);
894      done();
895    });
896
897    it('inputMethodEngine_test_015', 0, async function (done) {
898      let keyType = inputMethodEngine.PATTERN_PASSWORD;
899      console.info("inputMethodEngine_test_015 result:" + keyType);
900      expect(keyType).assertEqual(7);
901      done();
902    });
903
904    it('inputMethodEngine_test_016', 0, async function (done) {
905      let keyType = inputMethodEngine.FLAG_SELECTING;
906      console.info("inputMethodEngine_test_016 result:" + keyType);
907      expect(keyType).assertEqual(2);
908      done();
909    });
910
911    it('inputMethodEngine_test_017', 0, async function (done) {
912      let keyType = inputMethodEngine.FLAG_SINGLE_LINE;
913      console.info("inputMethodEngine_test_017 result:" + keyType);
914      expect(keyType).assertEqual(1);
915      done();
916    });
917
918    it('inputMethodEngine_test_018', 0, async function (done) {
919      let keyType = inputMethodEngine.DISPLAY_MODE_PART;
920      console.info("inputMethodEngine_test_018 result:" + keyType);
921      expect(keyType).assertEqual(0);
922      done();
923    });
924
925    it('inputMethodEngine_test_019', 0, async function (done) {
926      let keyType = inputMethodEngine.DISPLAY_MODE_FULL;
927      console.info("inputMethodEngine_test_019 result:" + keyType);
928      expect(keyType).assertEqual(1);
929      done();
930    });
931
932    it('inputMethodEngine_test_020', 0, async function (done) {
933      let keyType = inputMethodEngine.OPTION_ASCII;
934      console.info("inputMethodEngine_test_020 result:" + keyType);
935      expect(keyType).assertEqual(20);
936      done();
937    });
938
939    it('inputMethodEngine_test_021', 0, async function (done) {
940      let keyType = inputMethodEngine.OPTION_NONE;
941      console.info("inputMethodEngine_test_021 result:" + keyType);
942      expect(keyType).assertEqual(0);
943      done();
944    });
945
946    it('inputMethodEngine_test_022', 0, async function (done) {
947      let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS;
948      console.info("inputMethodEngine_test_022 result:" + keyType);
949      expect(keyType).assertEqual(2);
950      done();
951    });
952
953    it('inputMethodEngine_test_023', 0, async function (done) {
954      let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES;
955      console.info("inputMethodEngine_test_023 result:" + keyType);
956      expect(keyType).assertEqual(8);
957      done();
958    });
959
960    it('inputMethodEngine_test_024', 0, async function (done) {
961      let keyType = inputMethodEngine.OPTION_AUTO_WORDS;
962      console.info("inputMethodEngine_test_024 result:" + keyType);
963      expect(keyType).assertEqual(4);
964      done();
965    });
966
967    it('inputMethodEngine_test_025', 0, async function (done) {
968      let keyType = inputMethodEngine.OPTION_MULTI_LINE;
969      console.info("inputMethodEngine_test_025 result:" + keyType);
970      expect(keyType).assertEqual(1);
971      done();
972    });
973
974    it('inputMethodEngine_test_026', 0, async function (done) {
975      let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN;
976      console.info("inputMethodEngine_test_026 result:" + keyType);
977      expect(keyType).assertEqual(10);
978      done();
979    });
980
981    it('inputMethodEngine_test_027', 0, async function (done) {
982      if (textInputClient == null) {
983        expect(textInputClient == null).assertEqual(true);
984      } else {
985        textInputClient.sendKeyFunction(0, (value) => {
986          console.info("inputMethodEngine_test_027 textInputClient sendKeyFunction:" + value);
987          expect(value).assertEqual(true);
988        });
989      }
990      done();
991    });
992
993    it('inputMethodEngine_test_028', 0, async function (done) {
994      if (textInputClient == null) {
995        expect(textInputClient == null).assertEqual(true);
996      } else {
997        let promise = textInputClient.sendKeyFunction(0);
998        promise.then(res => {
999          console.info("inputMethodEngine_test_028 listInputMethod promise result-----" + JSON.stringify(res));
1000          expect(res).assertEqual(true);
1001        }).catch(err => {
1002          console.info("inputMethodEngine_test_028 listInputMethod promise error----" + JSON.stringify(err));
1003          expect().assertFail();
1004        });
1005      }
1006      done();
1007    });
1008
1009    it('inputMethodEngine_test_029', 0, async function (done) {
1010      if (textInputClient == null) {
1011        expect(textInputClient == null).assertEqual(true);
1012      } else {
1013        textInputClient.deleteForward(1, (value) => {
1014          console.info("inputMethodEngine_test_029 deleteForward:" + value);
1015          expect(value).assertEqual(true);
1016        });
1017      }
1018      done();
1019    });
1020
1021    it('inputMethodEngine_test_030', 0, async function (done) {
1022      if (textInputClient == null) {
1023        expect(textInputClient == null).assertEqual(true);
1024      } else {
1025        let promise = textInputClient.deleteForward(1);
1026        promise.then(res => {
1027          console.info("inputMethodEngine_test_030 deleteForward promise result-----" + JSON.stringify(res));
1028          expect(res).assertEqual(true);
1029        }).catch(err => {
1030          console.info("inputMethodEngine_test_030 deleteForward promise error----" + JSON.stringify(err));
1031          expect().assertFail();
1032        });
1033      }
1034      done();
1035    });
1036
1037    it('inputMethodEngine_test_031', 0, async function (done) {
1038      if (textInputClient == null) {
1039        expect(textInputClient == null).assertEqual(true);
1040      } else {
1041        textInputClient.deleteBackward(1, (value) => {
1042          console.info("inputMethodEngine_test_031 deleteBackward:" + value);
1043          expect(value).assertEqual(true);
1044        });
1045      }
1046      done();
1047    });
1048
1049    it('inputMethodEngine_test_032', 0, async function (done) {
1050      if (textInputClient == null) {
1051        expect(textInputClient == null).assertEqual(true);
1052      } else {
1053        let promise = textInputClient.deleteBackward(1);
1054        promise.then(res => {
1055          console.info("inputMethodEngine_test_032 deleteBackward promise result-----" + JSON.stringify(res));
1056          expect(res).assertEqual(true);
1057        }).catch(err => {
1058          console.info("inputMethodEngine_test_032 deleteBackward promise error----" + JSON.stringify(err));
1059          expect().assertFail();
1060        });
1061      }
1062      done();
1063    });
1064
1065    it('inputMethodEngine_test_033', 0, async function (done) {
1066      if (textInputClient == null) {
1067        expect(textInputClient == null).assertEqual(true);
1068      } else {
1069        textInputClient.InsertText('test', (value) => {
1070          console.info("inputMethodEngine_test_033 InsertText:" + value);
1071          expect(value).assertEqual(true);
1072        });
1073      }
1074      done();
1075    });
1076
1077    it('inputMethodEngine_test_034', 0, async function (done) {
1078      if (textInputClient == null) {
1079        expect(textInputClient == null).assertEqual(true);
1080      } else {
1081        let promise = textInputClient.InsertText('test');
1082        promise.then(res => {
1083          console.info("inputMethodEngine_test_034 InsertText promise result-----" + JSON.stringify(res));
1084          expect(res).assertEqual(true);
1085        }).catch(err => {
1086          console.info("inputMethodEngine_test_034 InsertText promise error----" + JSON.stringify(err));
1087          expect().assertFail();
1088        });
1089      }
1090      done();
1091    });
1092
1093    it('inputMethodEngine_test_035', 0, async function (done) {
1094      if (textInputClient == null) {
1095        expect(textInputClient == null).assertEqual(true);
1096      } else {
1097        textInputClient.getForward(1, (value) => {
1098          console.info("inputMethodEngine_test_035 getForward:" + value);
1099          expect(value).assertEqual(true);
1100        });
1101      }
1102      done();
1103    });
1104
1105    it('inputMethodEngine_test_036', 0, async function (done) {
1106      if (textInputClient == null) {
1107        expect(textInputClient == null).assertEqual(true);
1108      } else {
1109        let promise = textInputClient.getForward(1);
1110        promise.then(res => {
1111          console.info("inputMethodEngine_test_036 getForward promise result-----" + JSON.stringify(res));
1112          expect(res).assertEqual(true);
1113        }).catch(err => {
1114          console.info("inputMethodEngine_test_036 getForward promise error----" + JSON.stringify(err));
1115          expect().assertFail();
1116        });
1117      }
1118      done();
1119    });
1120
1121    it('inputMethodEngine_test_037', 0, async function (done) {
1122      if (textInputClient == null) {
1123        expect(textInputClient == null).assertEqual(true);
1124      } else {
1125        textInputClient.getEditorAttribute(1, (editorAttribute) => {
1126          console.info("inputMethodEngine_test_037 getEditorAttribute:" + value);
1127          expect(editorAttribute.inputPattern).assertEqual(1);
1128          expect(editorAttribute.enterKeyType).assertEqual(1);
1129        });
1130      }
1131      done();
1132    });
1133
1134    it('inputMethodEngine_test_038', 0, async function (done) {
1135      if (textInputClient == null) {
1136        expect(textInputClient == null).assertEqual(true);
1137      } else {
1138        let promise = textInputClient.getEditorAttribute();
1139        promise.then(res => {
1140          console.info("inputMethodEngine_test_038 getEditorAttribute promise result-----" + JSON.stringify(res));
1141          expect(res.inputPattern).assertEqual(1);
1142          expect(res.enterKeyType).assertEqual(1);
1143        }).catch(err => {
1144          console.info("inputMethodEngine_test_038 getEditorAttribute promise error----" + JSON.stringify(err));
1145          expect().assertFail();
1146        });
1147      }
1148      done();
1149    });
1150
1151    it('inputMethodEngine_test_039', 0, async function (done) {
1152      if (kbController == null) {
1153        expect(kbController == null).assertEqual(true);
1154      } else {
1155        kbController.hideKeyboard((err) => {
1156          if (err == undefined) {
1157            console.info("inputMethodEngine_test_039 hideKeyboard success.");
1158          } else {
1159            console.info('inputMethodEngine_test_039 hideKeyboard callbace failed : ' + JSON.stringify(err.message));
1160            expect().assertFail();
1161          }
1162        });
1163      }
1164      done();
1165    });
1166
1167    it('inputMethodEngine_test_040', 0, async function (done) {
1168      if (kbController == null) {
1169        expect(kbController == null).assertEqual(true);
1170      } else {
1171        let promise = kbController.hideKeyboard();
1172        promise.then(res => {
1173          console.info("inputMethodEngine_test_040 hideKeyboard promise success.");
1174        }).catch(err => {
1175          console.info("inputMethodEngine_test_040 hideKeyboard promise error----" + JSON.stringify(err));
1176          expect().assertFail();
1177        });
1178      }
1179      done();
1180    });
1181
1182    it('inputMethodEngine_test_041', 0, async function (done) {
1183      if (textInputClient == null) {
1184        expect(textInputClient == null).assertEqual(true);
1185      } else {
1186        textInputClient.getBackward(1, (value) => {
1187          console.info("inputMethodEngine_test_041 getBackward:" + value);
1188          expect(value).assertEqual(true);
1189        });
1190      }
1191      done();
1192    });
1193
1194    it('inputMethodEngine_test_042', 0, async function (done) {
1195      if (textInputClient == null) {
1196        expect(textInputClient == null).assertEqual(true);
1197      } else {
1198        let promise = textInputClient.getBackward(1);
1199        promise.then(res => {
1200          console.info("inputMethodEngine_test_042 getBackward promise result-----" + JSON.stringify(res));
1201          expect(res).assertEqual(true);
1202        }).catch(err => {
1203          console.info("inputMethodEngine_test_042 getBackward promise error----" + JSON.stringify(err));
1204          expect().assertFail();
1205        });
1206      }
1207      done();
1208    });
1209
1210    it('inputMethodEngine_test_043', 0, async function (done) {
1211      let keyType = inputMethodEngine.WINDOW_TYPE_INPUT_METHOD_FLOAT;
1212      console.error("inputMethodEngine_test_043 result:" + keyType);
1213      expect(keyType == 2105).assertTrue();
1214      done();
1215    });
1216
1217    it('inputMethodEngine_test_044', 0, async function (done) {
1218      if (textInputClient == null) {
1219        expect(textInputClient == null).assertEqual(true);
1220      } else {
1221        textInputClient.moveCursor(inputMethodEngine.CURSOR_UP, (value) => {
1222          console.info("inputMethodEngine_test_044 moveCursor:" + value);
1223          expect(value == null).assertEqual(true);
1224        });
1225      }
1226      done();
1227    });
1228
1229    it('inputMethodEngine_test_045', 0, async function (done) {
1230      if (textInputClient == null) {
1231        expect(textInputClient == null).assertEqual(true);
1232      } else {
1233        textInputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (value) => {
1234          console.info("inputMethodEngine_test_045 moveCursor:" + value);
1235          expect(value == null).assertEqual(true);
1236        });
1237      }
1238      done();
1239    });
1240
1241    it('inputMethodEngine_test_046', 0, async function (done) {
1242      if (textInputClient == null) {
1243        expect(textInputClient == null).assertEqual(true);
1244      } else {
1245        textInputClient.moveCursor(inputMethodEngine.CURSOR_LEFT).then(res => {
1246          console.info("inputMethodEngine_test_046 moveCursor promise result-----" + JSON.stringify(res));
1247          expect(res == null).assertEqual(true);
1248        }).catch(err => {
1249          console.info("inputMethodEngine_test_046 moveCursor promise error----" + JSON.stringify(err));
1250          expect().assertFail();
1251        });
1252      }
1253      done();
1254    });
1255
1256    it('inputMethodEngine_test_047', 0, async function (done) {
1257      if (textInputClient == null) {
1258        expect(textInputClient == null).assertEqual(true);
1259      } else {
1260        textInputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT).then(res => {
1261          console.info("inputMethodEngine_test_047 moveCursor promise result-----" + JSON.stringify(res));
1262          expect(res == null).assertEqual(true);
1263        }).catch(err => {
1264          console.info("inputMethodEngine_test_047 moveCursor promise error----" + JSON.stringify(err));
1265          expect().assertFail();
1266        });
1267      }
1268      done();
1269    });
1270
1271    it('inputMethodEngine_test_048', 0, async function (done) {
1272      if (kbController == null) {
1273        expect(kbController == null).assertEqual(true);
1274      } else {
1275        kbController.hide((err) => {
1276          if (err == undefined) {
1277            console.info("inputMethodEngine_test_048 hide success.");
1278          } else {
1279            console.info('inputMethodEngine_test_048 hide callbace failed : ' + JSON.stringify(err.message));
1280            expect().assertFail();
1281          }
1282        });
1283      }
1284      done();
1285    });
1286
1287    it('inputMethodEngine_test_049', 0, async function (done) {
1288      if (kbController == null) {
1289        expect(kbController == null).assertEqual(true);
1290      } else {
1291        let promise = kbController.hide();
1292        promise.then(res => {
1293          console.info("inputMethodEngine_test_049 hide promise success.");
1294        }).catch(err => {
1295          console.info("inputMethodEngine_test_049 hide promise error----" + JSON.stringify(err));
1296          expect().assertFail();
1297        });
1298      }
1299      done();
1300    });
1301})
1302