1 2/* * Copyright (c) 2021 Huawei 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 */ 15import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; 16import inputMethod from '@ohos.inputMethod'; 17 18describe('appInfoTest_input_2', function () { 19 20 /* 21 * @tc.number inputmethod_test_listInputMethod_001 22 * @tc.name Test Indicates the input method which will replace the current one. 23 * @tc.desc Function test 24 * @tc.level 2 25 */ 26 it('inputmethod_test_listInputMethod_001', 0, async function (done) { 27 let inputMethodSetting = inputMethod.getInputMethodSetting(); 28 console.info("inputmethoh_test_001 result:" + JSON.stringify(inputMethodSetting)); 29 inputMethodSetting.listInputMethod((err, data) => { 30 console.info("inputmethoh_test_001 listInputMethod result" + JSON.stringify(data)); 31 expect(err==undefined).assertTrue(); 32 }); 33 done(); 34 }); 35 36 /* 37 * @tc.number inputmethod_test_listInputMethod_002 38 * @tc.name Test Indicates the input method which will replace the current one. 39 * @tc.desc Function test 40 * @tc.level 2 41 */ 42 it('inputmethod_test_listInputMethod_002', 0, async function (done) { 43 let inputMethodSetting = inputMethod.getInputMethodSetting(); 44 console.info("inputmethoh_test_002 result:" + JSON.stringify(inputMethodSetting)); 45 let promise = await inputMethodSetting.listInputMethod(); 46 console.info("inputmethoh_test_002 listInputMethod result" + JSON.stringify(promise)); 47 if (promise.length > 0){ 48 let obj = promise[0] 49 console.info("inputmethoh_test_002 listInputMethod obj" + JSON.stringify(obj)); 50 expect(obj.packageName != null).assertTrue(); 51 expect(obj.methodId != null).assertTrue(); 52 }else{ 53 console.info("inputmethoh_test_002 listInputMethod is null"); 54 expect().assertFail(); 55 } 56 done(); 57 }); 58 59 /* 60 * @tc.number inputmethod_test_listInputMethod_003 61 * @tc.name Test Indicates the input method which will replace the current one. 62 * @tc.desc Function test 63 * @tc.level 2 64 */ 65 it('inputmethod_test_listInputMethod_003', 0, async function (done) { 66 let inputMethodSetting = inputMethod.getInputMethodSetting(); 67 console.info("inputmethod_test_listInputMethod_003 result:" + JSON.stringify(inputMethodSetting)); 68 await inputMethodSetting.listInputMethod().then((data)=>{ 69 console.info("inputmethod_test_listInputMethod_003 listInputMethod result" + JSON.stringify(data)); 70 expect(data.length > 0).assertTrue(); 71 }).catch((err) => { 72 console.info('inputmethod_test_listInputMethod_003 listInputMethod err ' + err); 73 expect(null).assertFail(); 74 }); 75 done(); 76 }); 77 78 /* 79 * @tc.number inputmethod_test_displayOptionalInputMethod_001 80 * @tc.name Test Indicates the input method which will replace the current one. 81 * @tc.desc Function test 82 * @tc.level 2 83 */ 84 it('inputmethod_test_displayOptionalInputMethod_001', 0, async function (done) { 85 let inputMethodSetting = inputMethod.getInputMethodSetting(); 86 console.info("inputmethod_test_displayOptionalInputMethod_001 result:" + JSON.stringify(inputMethodSetting)); 87 inputMethodSetting.displayOptionalInputMethod((err) => { 88 console.info("inputmethod_test_displayOptionalInputMethod_001 err:" + err); 89 expect(err==undefined).assertTrue(); 90 }); 91 done(); 92 }); 93 94 /* 95 * @tc.number inputmethod_test_displayOptionalInputMethod_002 96 * @tc.name Test Indicates the input method which will replace the current one. 97 * @tc.desc Function test 98 * @tc.level 2 99 */ 100 it('inputmethod_test_displayOptionalInputMethod_002', 0, async function (done) { 101 let inputMethodSetting = inputMethod.getInputMethodSetting(); 102 console.info("inputmethod_test_displayOptionalInputMethod_002 result:" + JSON.stringify(inputMethodSetting)); 103 let promise = await inputMethodSetting.displayOptionalInputMethod(); 104 console.info("inputmethod_test_displayOptionalInputMethod_002 result" + JSON.stringify(promise)); 105 expect(promise).assertEqual(undefined) 106 done(); 107 }); 108 109 110 /* 111 * @tc.number inputmethod_test_displayOptionalInputMethod_003 112 * @tc.name Test Indicates the input method which will replace the current one. 113 * @tc.desc Function test 114 * @tc.level 2 115 */ 116 it('inputmethod_test_displayOptionalInputMethod_003', 0, async function (done) { 117 let inputMethodSetting = inputMethod.getInputMethodSetting(); 118 console.info("inputmethod_test_displayOptionalInputMethod_003 result:" + JSON.stringify(inputMethodSetting)); 119 await inputMethodSetting.displayOptionalInputMethod().then(()=>{ 120 console.info("inputmethod_test_displayOptionalInputMethod_003 displayOptionalInputMethod result"); 121 expect(true).assertTrue(); 122 }).catch((err) => { 123 console.info('inputmethod_test_displayOptionalInputMethod_003 listInputMethod err ' + err); 124 expect(null).assertFail(); 125 }); 126 done(); 127 }); 128 129 130 /* 131 * @tc.number inputmethod_test_stopInput_001 132 * @tc.name Test Indicates the input method which will replace the current one. 133 * @tc.desc Function test 134 * @tc.level 2 135 */ 136 it('inputmethod_test_stopInput_001', 0, function (done) { 137 let inputMethodCtrl = inputMethod.getInputMethodController(); 138 console.info("inputmethod_test_stopInput_001 result:" + JSON.stringify(inputMethodCtrl)); 139 inputMethodCtrl.stopInput((err,res) => { 140 console.info("inputmethod_test_stopInput_001 stopInput result" + res); 141 console.info("inputmethod_test_stopInput_001 stopInput result" + err); 142 expect(res == true).assertTrue(); 143 expect(err==undefined).assertTrue(); 144 }); 145 done(); 146 }); 147 148 /* 149 * @tc.number inputmethod_test_stopInput_002 150 * @tc.name Test Indicates the input method which will replace the current one. 151 * @tc.desc Function test 152 * @tc.level 2 153 */ 154 it('inputmethod_test_stopInput_002', 0, async function (done) { 155 let inputMethodCtrl = inputMethod.getInputMethodController(); 156 console.info("inputmethod_test_stopInput_002 result:" + JSON.stringify(inputMethodCtrl)); 157 let promise = await inputMethodCtrl.stopInput(); 158 console.info("inputmethod_test_stopInput_002 inputMethodCtrl stopInput result---" + JSON.stringify(promise)); 159 expect(promise).assertEqual(true) 160 done(); 161 }); 162 163 /* 164 * @tc.number inputmethod_test_stopInput_003 165 * @tc.name Test Indicates the input method which will replace the current one. 166 * @tc.desc Function test 167 * @tc.level 2 168 */ 169 it('inputmethod_test_stopInput_003', 0, async function (done) { 170 let inputMethodCtrl = inputMethod.getInputMethodController(); 171 console.info("inputmethod_test_stopInput_003 result:" + JSON.stringify(inputMethodCtrl)); 172 await inputMethodCtrl.stopInput().then((res)=>{ 173 console.info('inputmethod_test_stopInput_003 stopInput result' + res); 174 expect(res == true).assertTrue(); 175 }).catch((err) => { 176 console.info('inputmethod_test_stopInput_003 stopInput err ' + err); 177 expect(null).assertFail(); 178 }); 179 console.info("inputmethod_test_stopInput_003 inputMethodCtrl stopInput result"); 180 done(); 181 }); 182 183 /* 184 * @tc.number: inputmethod_test_MAX_TYPE_NUM_001 185 * @tc.name: inputMethod::MAX_TYPE_NUM 186 * @tc.desc: Verify Max_ TYPE_ NUM 187 */ 188 it('inputmethod_test_MAX_TYPE_NUM_001', 0, async function (done) { 189 let inputMethodSetting = inputMethod.MAX_TYPE_NUM; 190 console.info("inputmethod_test_001 result:" + inputMethodSetting); 191 expect(inputMethodSetting != null).assertTrue(); 192 done(); 193 }); 194 195 /* 196 * @tc.number inputmethod_test_switchInputMethod_001 197 * @tc.name Test Indicates the input method which will replace the current one. 198 * @tc.desc Function test 199 * @tc.level 2 200 */ 201 it('inputmethod_test_switchInputMethod_001', 0, async function (done) { 202 let inputMethodProperty = { 203 packageName:"com.example.kikakeyboard", 204 methodId:"ServiceExtAbility", 205 name:"com.example.kikakeyboard", 206 id:"ServiceExtAbility" 207 } 208 inputMethod.switchInputMethod(inputMethodProperty).then((data) => { 209 console.info("inputmethod_test_switchInputMethod_001 data:" + data) 210 expect(data).assertEqual(true); 211 }).catch((err) => { 212 console.error('inputmethod_test_switchInputMethod_001 failed because ' + JSON.stringify(err)); 213 }); 214 done(); 215 }); 216 217 /* 218 * @tc.number inputmethod_test_switchInputMethod_002 219 * @tc.name Test Indicates the input method which will replace the current one. 220 * @tc.desc Function test 221 * @tc.level 2 222 */ 223 it('inputmethod_test_switchInputMethod_002', 0, async function (done) { 224 let inputMethodProperty = { 225 packageName:"com.example.kikakeyboard", 226 methodId:"ServiceExtAbility", 227 name:"com.example.kikakeyboard", 228 id:"ServiceExtAbility" 229 } 230 inputMethod.switchInputMethod(inputMethodProperty, (err, data)=>{ 231 if(err){ 232 console.info("inputmethod_test_switchInputMethod_002 error:" + err); 233 expect().assertFail() 234 } 235 console.info("inputmethod_test_switchInputMethod_002 data:" + data) 236 expect(data == true).assertTrue(); 237 }); 238 done(); 239 }); 240 241 /* 242 * @tc.number inputmethod_test_getCurrentInputMethodSubtype_001 243 * @tc.name Test Indicates the input method which will replace the current one. 244 * @tc.desc Function test 245 * @tc.level 2 246 */ 247 it('inputmethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) { 248 let inputMethodSubtype = inputMethod.getCurrentInputMethodSubtype(); 249 console.info("inputmethod_test_getCurrentInputMethodSubtype_001 result:" + JSON.stringify(inputMethodSubtype)); 250 expect(inputMethodSubtype).assertTrue(); 251 done(); 252 }); 253 254 /* 255 * @tc.number inputmethod_test_getCurrentInputMethodSubtype_001 256 * @tc.name Test Indicates the input method which will replace the current one. 257 * @tc.desc Function test 258 * @tc.level 2 259 */ 260 it('inputmethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) { 261 let inputMethodSubProperty = { 262 id: "com.example.kikainput", 263 label: "ServiceExtAbility" 264 } 265 await inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => { 266 console.info("inputmethod_test_switchCurrentInputMethodSubtype_001 data:" + data) 267 expect(data).assertEqual(true); 268 }).catch((err) => { 269 console.error('inputmethod_test_switchCurrentInputMethodSubtype_001 failed because ' + JSON.stringify(err)); 270 }); 271 done(); 272 }); 273 274 /* 275 * @tc.number inputmethod_test_switchCurrentInputMethodSubtype_002 276 * @tc.name Test Indicates the input method which will replace the current one. 277 * @tc.desc Function test 278 * @tc.level 2 279 */ 280 it('inputmethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) { 281 let inputMethodSubProperty = { 282 id: "com.example.kikainput", 283 label: "ServiceExtAbility" 284 } 285 inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err, data)=>{ 286 if(err){ 287 console.info("inputmethod_test_switchCurrentInputMethodSubtype_002 error:" + err); 288 expect().assertFail() 289 } 290 console.info("inputmethod_test_switchCurrentInputMethodSubtype_002 data:" + data) 291 expect(data == true).assertTrue(); 292 }); 293 }); 294 295 /* 296 * @tc.number inputmethod_test_getCurrentInputMethodSubtype_001 297 * @tc.name Test Indicates the input method which will replace the current one. 298 * @tc.desc Function test 299 * @tc.level 2 300 */ 301 it('inputmethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) { 302 let inputMethodSubProperty = { 303 id: "com.example.kikainput", 304 label: "ServiceExtAbility" 305 } 306 await inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => { 307 console.info("inputmethod_test_switchCurrentInputMethodAndSubtype_001 data:" + data) 308 expect(data).assertEqual(true); 309 }).catch((err) => { 310 console.error('inputmethod_test_switchCurrentInputMethodAndSubtype_001 failed because ' + JSON.stringify(err)); 311 }); 312 done(); 313 }); 314 315 /* 316 * @tc.number inputmethod_test_switchCurrentInputMethodAndSubtype_002 317 * @tc.name Test Indicates the input method which will replace the current one. 318 * @tc.desc Function test 319 * @tc.level 2 320 */ 321 it('inputmethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) { 322 let inputMethodProperty = { 323 packageName:"com.example.kikakeyboard", 324 methodId:"ServiceExtAbility" 325 } 326 let inputMethodSubProperty = { 327 id: "com.example.kikainput", 328 label: "ServiceExtAbility" 329 } 330 inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err, data)=>{ 331 if(err){ 332 console.info("inputmethod_test_switchCurrentInputMethodAndSubtype_002 error:" + err); 333 expect().assertFail() 334 } 335 console.info("inputmethod_test_switchCurrentInputMethodAndSubtype_002 data:" + data) 336 expect(data == true).assertTrue(); 337 }); 338 }); 339 340 /* 341 * @tc.number inputmethod_test_ListInputMethodSubtype_001 342 * @tc.name Test Indicates the input method which will replace the current one. 343 * @tc.desc Function test 344 * @tc.level 2 345 */ 346 it('inputmethod_test_ListInputMethodSubtype_001', 0, async function (done) { 347 let inputMethodProperty = { 348 packageName:"com.example.kikakeyboard", 349 methodId:"ServiceExtAbility", 350 name:"com.example.kikakeyboard", 351 id:"ServiceExtAbility", 352 } 353 let inputMethodSetting = inputMethod.getInputMethodSetting(); 354 console.info("inputmethod_test_ListInputMethodSubtype_001 result:" + JSON.stringify(inputMethodSetting)); 355 inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { 356 console.info("inputmethod_test_ListInputMethodSubtype_001 result" + JSON.stringify(data)); 357 expect(err==undefined).assertTrue(); 358 }); 359 done(); 360 }); 361 362 /* 363 * @tc.number inputmethod_test_ListInputMethodSubtype_002 364 * @tc.name Test Indicates the input method which will replace the current one. 365 * @tc.desc Function test 366 * @tc.level 2 367 */ 368 it('inputmethod_test_ListInputMethodSubtype_002', 0, async function (done) { 369 let inputMethodProperty = { 370 packageName:"com.example.kikakeyboard", 371 methodId:"ServiceExtAbility", 372 name:"com.example.kikakeyboard", 373 id:"ServiceExtAbility", 374 } 375 let inputMethodSetting = inputMethod.getInputMethodSetting(); 376 console.info("inputmethod_test_ListInputMethodSubtype_002 result:" + JSON.stringify(inputMethodSetting)); 377 await inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data)=>{ 378 console.info("inputmethod_test_ListInputMethodSubtype_002 result" + JSON.stringify(data)); 379 expect(data.length > 0).assertTrue(); 380 }).catch((err) => { 381 console.info('inputmethod_test_ListInputMethodSubtype_002 listInputMethod err ' + err); 382 expect(null).assertFail(); 383 }); 384 done(); 385 }); 386 387 /* 388 * @tc.number inputmethod_test_ListCurrentInputMethodSubtype_001 389 * @tc.name Test Indicates the input method which will replace the current one. 390 * @tc.desc Function test 391 * @tc.level 2 392 */ 393 it('inputmethod_test_ListCurrentInputMethodSubtype_001', 0, async function (done) { 394 let inputMethodSetting = inputMethod.getInputMethodSetting(); 395 console.info("inputmethod_test_ListCurrentInputMethodSubtype_001 result:" + JSON.stringify(inputMethodSetting)); 396 inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { 397 console.info("inputmethod_test_ListCurrentInputMethodSubtype_001 result" + JSON.stringify(data)); 398 expect(err==undefined).assertTrue(); 399 }); 400 done(); 401 }); 402 403 /* 404 * @tc.number inputmethod_test_ListCurrentInputMethodSubtype_002 405 * @tc.name Test Indicates the input method which will replace the current one. 406 * @tc.desc Function test 407 * @tc.level 2 408 */ 409 it('inputmethod_test_ListCurrentInputMethodSubtype_002', 0, async function (done) { 410 let inputMethodSetting = inputMethod.getInputMethodSetting(); 411 console.info("inputmethod_test_ListCurrentInputMethodSubtype_002 result:" + JSON.stringify(inputMethodSetting)); 412 await inputMethodSetting.listCurrentInputMethodSubtype().then((data)=>{ 413 console.info("inputmethod_test_ListCurrentInputMethodSubtype_002 result" + JSON.stringify(data)); 414 expect(data.length > 0).assertTrue(); 415 }).catch((err) => { 416 console.info('inputmethod_test_ListCurrentInputMethodSubtype_002 err ' + err); 417 expect(null).assertFail(); 418 }); 419 done(); 420 }); 421 422 423 424 425}) 426