1//@ts-nocheck 2/* 3 * Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod'; 17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 18import * as env from './lib/Const'; 19 20function expectTrue(data: boolean) { 21 try { 22 expect(data).assertTrue(); 23 } catch (err) { 24 console.info('assertion failure'); 25 } 26}; 27 28function expectContain(a: ESObject, b: ESObject) { 29 try { 30 expect(a).assertContain(b); 31 } catch (err) { 32 console.info('assertion failure'); 33 } 34}; 35 36function expectFalse() { 37 try { 38 expect().assertFail(); 39 } catch (err) { 40 console.info('assertion failure'); 41 } 42}; 43 44let st:ESObject = null; 45 46const sleep = (timeout: number) : Promise<ESObject> => { 47 return new Promise(resolve => { 48 const st = setTimeout(() => { 49 resolve(null); 50 }, timeout); 51 }); 52}; 53export default function inputMethodTest() { 54 describe('inputMethod_changeSelection', () => { 55 56 beforeEach( 57 async () => { 58 try { 59 let data = await inputMethod.getController().attach(true, { 60 inputAttribute: { 61 textInputType: 1, enterKeyType: 2 62 } 63 }); 64 console.info(`attach inputMethod success, data: ${JSON.stringify(data)}`); 65 } catch (error) { 66 console.info(`attach inputMethod fail, error: [${error.code}, ${error.message}]`); 67 } 68 ; 69 } 70 ); 71 afterEach( 72 async () => { 73 try { 74 await inputMethod.getController().detach(); 75 console.info(`clsoe inputMethod success}`); 76 } catch (error) { 77 console.info(`clsoe inputMethod fial, error: [${error.code}, ${error.message}]`); 78 } 79 ; 80 clearTimeout(st); 81 } 82 ); 83 /** 84 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0100 85 * @tc.name Call the changeSelection interface in Async mode, enter the parameter text='Input method keyboard 86 * test hey hey', start=0, end=5 87 * @tc.desc Function test 88 */ 89 it('SUB_Misc_inputMethod_changeSelection_Async_0100', 0, async (done: Function) => { 90 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0100'; 91 const TEXT = '输入法键盘测试嘿嘿'; 92 const START = 0; 93 const END = 5; 94 let CallBack = (error: BusinessError, data: ESObject) => { 95 if (error) { 96 console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`); 97 expectFalse(); 98 done(); 99 return; 100 } else { 101 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 102 done(); 103 return; 104 } 105 }; 106 try { 107 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 108 } catch (error) { 109 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 110 expectFalse(); 111 done(); 112 return; 113 } 114 ; 115 }); 116 117 /** 118 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0200 119 * @tc.name Call the changeSelection interface in Async mode, enter the parameter text='Input method keyboard 120 * test hey hey', start=0, end=10 121 * @tc.desc Function test 122 */ 123 it('SUB_Misc_inputMethod_changeSelection_Async_0200', 0, async (done: Function) => { 124 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0200'; 125 const TEXT = '输入法键盘测试嘿嘿'; 126 const START = 0; 127 const END = 10; 128 let CallBack = (error: BusinessError, data: ESObject) => { 129 if (error) { 130 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 131 expectFalse(); 132 done(); 133 return; 134 } else { 135 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 136 done(); 137 return; 138 } 139 }; 140 try { 141 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 142 } catch (error) { 143 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 144 expectFalse(); 145 done(); 146 return; 147 } 148 ; 149 }); 150 151 /** 152 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0300 153 * @tc.name Call the changeSelection interface in Async mode, enter the parameter text='Input method keyboard 154 * test hey hey', start=- 1, end=5 155 * @tc.desc Function test 156 */ 157 it('SUB_Misc_inputMethod_changeSelection_Async_0300', 0, async (done: Function) => { 158 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0300'; 159 const TEXT = '输入法键盘测试嘿嘿'; 160 const START = -1; 161 const END = 5; 162 let CallBack = (error: BusinessError, data: ESObject) => { 163 if (error) { 164 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 165 expectFalse(); 166 done(); 167 return; 168 } else { 169 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 170 done(); 171 return; 172 } 173 }; 174 try { 175 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 176 } catch (error) { 177 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 178 expectFalse(); 179 done(); 180 return; 181 } 182 ; 183 }); 184 185 /** 186 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0400 187 * @tc.name Call the changeSelection interface in Async mode, enter the parameter text='Input method keyboard 188 * test hehe', start=8, end=2 189 * @tc.desc Function test 190 */ 191 it('SUB_Misc_inputMethod_changeSelection_Async_0400', 0, async (done: Function) => { 192 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0400'; 193 const TEXT = '输入法键盘测试嘿嘿'; 194 const START = 8; 195 const END = 2; 196 let CallBack = (error: BusinessError, data: ESObject) => { 197 if (error) { 198 console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`); 199 expectFalse(); 200 done(); 201 return; 202 } else { 203 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 204 done(); 205 return; 206 } 207 }; 208 try { 209 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 210 } catch (error) { 211 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 212 done(); 213 return; 214 } 215 ; 216 }); 217 218 /** 219 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0500 220 * @tc.name Async mode calls changeSelection interface, input parameter text=123 221 * @tc.desc Function test 222 */ 223 it('SUB_Misc_inputMethod_changeSelection_Async_0500', 0, async (done: Function) => { 224 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0500'; 225 const START = 0; 226 const END = 5; 227 let CallBack = (error: BusinessError, data: ESObject) => { 228 if (error) { 229 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 230 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 231 done(); 232 return; 233 } else { 234 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 235 expectFalse(); 236 done(); 237 return; 238 } 239 }; 240 try { 241 inputMethod.getController().changeSelection(env.INVALID_TYPE_NUMBER_123, START, END, CallBack); 242 } catch (error) { 243 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 244 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 245 done(); 246 return; 247 } 248 ; 249 }); 250 251 /** 252 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0600 253 * @tc.name Async mode calls changeSelection interface, input parameter text='' 254 * @tc.desc Function test 255 */ 256 it('SUB_Misc_inputMethod_changeSelection_Async_0600', 0, async (done: Function) => { 257 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0600'; 258 const START = 0; 259 const END = 5; 260 let CallBack = (error: BusinessError, data: ESObject) => { 261 if (error) { 262 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 263 expectFalse(); 264 done(); 265 return; 266 } else { 267 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 268 done(); 269 return; 270 } 271 }; 272 try { 273 inputMethod.getController().changeSelection(env.INVALID_STRING_NULL, START, END, CallBack); 274 } catch (error) { 275 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 276 expectFalse(); 277 done(); 278 return; 279 } 280 ; 281 }); 282 283 /** 284 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0700 285 * @tc.name Async mode calls changeSelection interface, input parameter start='0' 286 * @tc.desc Function test 287 */ 288 it('SUB_Misc_inputMethod_changeSelection_Async_0700', 0, async (done: Function) => { 289 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0700'; 290 const TEXT = '输入法键盘测试嘿嘿'; 291 const START: ESObject = '0'; 292 const END = 5; 293 let CallBack = (error: BusinessError, data: ESObject) => { 294 if (error) { 295 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 296 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 297 done(); 298 return; 299 } else { 300 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 301 expectFalse(); 302 done(); 303 return; 304 } 305 }; 306 try { 307 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 308 } catch (error) { 309 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 310 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 311 done(); 312 return; 313 } 314 ; 315 }); 316 317 /** 318 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_0800 319 * @tc.name Async mode calls changeSelection interface, input parameter end='5' 320 * @tc.desc Function test 321 */ 322 it('SUB_Misc_inputMethod_changeSelection_Async_0800', 0, async (done: Function) => { 323 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_0800'; 324 const TEXT = '输入法键盘测试嘿嘿'; 325 const START = 0; 326 const END: ESObject = '5'; 327 let CallBack = (error: BusinessError, data: ESObject) => { 328 if (error) { 329 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 330 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 331 done(); 332 return; 333 } else { 334 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 335 expectFalse(); 336 done(); 337 return; 338 } 339 }; 340 try { 341 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 342 } catch (error) { 343 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 344 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 345 done(); 346 return; 347 } 348 ; 349 }); 350 351 /** 352 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_1100 353 * @tc.name The input method keyboard is not bound, and the changeSelection interface is called in Async mode 354 * @tc.desc Function test 355 */ 356 it('SUB_Misc_inputMethod_changeSelection_Async_1100', 0, async (done: Function) => { 357 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_1100'; 358 const TEXT = '输入法键盘测试嘿嘿'; 359 const START = 0; 360 const END: ESObject = 5; 361 let CallBack = (error: BusinessError, data: ESObject) => { 362 if (error) { 363 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 364 expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED); 365 done(); 366 return; 367 } else { 368 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 369 expectFalse(); 370 done(); 371 return; 372 } 373 }; 374 try { 375 let data = await inputMethod.getController().detach(); 376 console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`); 377 } catch (error) { 378 console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`); 379 expectFalse(); 380 done(); 381 return; 382 } 383 ; 384 try { 385 inputMethod.getController().changeSelection(TEXT, START, END, CallBack); 386 } catch (error) { 387 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 388 expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED); 389 done(); 390 return; 391 } 392 ; 393 }); 394 395 /** 396 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_1200 397 * @tc.name Async mode calls the changeSelection interface, and an invalid input parameter is passed in 398 * @tc.desc Function test 399 */ 400 it('SUB_Misc_inputMethod_changeSelection_Async_1200', 0, async (done: Function) => { 401 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_1200'; 402 const TEXT = '输入法键盘测试嘿嘿'; 403 const START = 0; 404 const END: ESObject = 5; 405 let CallBack = (error: BusinessError, data: ESObject) => { 406 if (error) { 407 console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`); 408 expectFalse(); 409 done(); 410 return; 411 } else { 412 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 413 done(); 414 return; 415 } 416 }; 417 try { 418 inputMethod.getController().changeSelection(TEXT, START, END, CallBack, env.INVALID_TYPE_STRING_A); 419 } catch (error) { 420 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 421 expectFalse(); 422 done(); 423 return; 424 } 425 ; 426 }); 427 428 /** 429 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_1300 430 * @tc.name Async mode calls changeSelection interface. Missing parameter text must be passed in 431 * @tc.desc Function test 432 */ 433 it('SUB_Misc_inputMethod_changeSelection_Async_1300', 0, async (done: Function) => { 434 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_1300'; 435 const START: ESObject = 0; 436 const END: ESObject = 5; 437 let CallBack = (error: BusinessError, data: ESObject) => { 438 if (error) { 439 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 440 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 441 done(); 442 return; 443 } else { 444 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 445 expectFalse(); 446 done(); 447 return; 448 } 449 }; 450 try { 451 inputMethod.getController().changeSelection(START, END, CallBack); 452 } catch (error) { 453 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 454 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 455 done(); 456 return; 457 } 458 ; 459 }); 460 461 /** 462 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_1400 463 * @tc.name Async mode calls the changeSelection interface. If it is missing, the parameter start must be passed in 464 * @tc.desc Function test 465 */ 466 it('SUB_Misc_inputMethod_changeSelection_Async_1400', 0, async (done: Function) => { 467 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_1400'; 468 const TEXT = '输入法键盘测试嘿嘿'; 469 const END: ESObject = 5; 470 let CallBack = (error: BusinessError, data: ESObject) => { 471 if (error) { 472 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 473 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 474 done(); 475 return; 476 } else { 477 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 478 expectFalse(); 479 done(); 480 return; 481 } 482 }; 483 try { 484 inputMethod.getController().changeSelection(TEXT, END, CallBack); 485 } catch (error) { 486 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 487 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 488 done(); 489 return; 490 } 491 ; 492 }); 493 494 /** 495 * @tc.number SUB_Misc_inputMethod_changeSelection_Async_1500 496 * @tc.name Async mode calls the changeSelection interface, and the missing parameter must be passed in 497 * @tc.desc Function test 498 */ 499 it('SUB_Misc_inputMethod_changeSelection_Async_1500', 0, async (done: Function) => { 500 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Async_1500'; 501 const TEXT = '输入法键盘测试嘿嘿'; 502 const START = 0; 503 let CallBack = (error: BusinessError, data: ESObject) => { 504 if (error) { 505 console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`); 506 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 507 done(); 508 return; 509 } else { 510 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 511 expectFalse(); 512 done(); 513 return; 514 } 515 }; 516 try { 517 inputMethod.getController().changeSelection(TEXT, START, CallBack); 518 } catch (error) { 519 console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`); 520 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 521 done(); 522 return; 523 } 524 ; 525 }); 526 527 /** 528 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0100 529 * @tc.name Call changeSelection interface in Promise mode, enter the parameter text='Input method keyboard 530 * test hey hey', start=0, end=5 531 * @tc.desc Function test 532 */ 533 it('SUB_Misc_inputMethod_changeSelection_Promise_0100', 0, async (done: Function) => { 534 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0100'; 535 const TEXT = '输入法键盘测试嘿嘿'; 536 const START = 0; 537 const END = 5; 538 try { 539 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 540 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 541 done(); 542 return; 543 } catch (error) { 544 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 545 expectFalse(); 546 done(); 547 return; 548 } 549 }); 550 551 /** 552 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0200 553 * @tc.name Call changeSelection interface in Promise mode, enter the parameter text='Input method keyboard 554 * test hey hey', start=0, end=10 555 * @tc.desc Function test 556 */ 557 it('SUB_Misc_inputMethod_changeSelection_Promise_0200', 0, async (done: Function) => { 558 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0200'; 559 const TEXT = '输入法键盘测试嘿嘿'; 560 const START = 0; 561 const END = 10; 562 try { 563 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 564 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 565 done(); 566 return; 567 } catch (error) { 568 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 569 expectFalse(); 570 done(); 571 return; 572 } 573 }); 574 575 /** 576 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0300 577 * @tc.name Call changeSelection interface in Promise mode, enter text='Input method keyboard test hey hey', 578 * start=- 1, end=5 579 * @tc.desc Function test 580 */ 581 it('SUB_Misc_inputMethod_changeSelection_Promise_0300', 0, async (done: Function) => { 582 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0300'; 583 const TEXT = '输入法键盘测试嘿嘿'; 584 const START = -1; 585 const END = 5; 586 try { 587 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 588 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 589 done(); 590 return; 591 } catch (error) { 592 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 593 expectFalse(); 594 done(); 595 return; 596 } 597 }); 598 599 /** 600 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0400 601 * @tc.name Call changeSelection interface in Promise mode, enter the parameter text='Input method keyboard 602 * test hey hey', start=8, end=2 603 * @tc.desc Function test 604 */ 605 it('SUB_Misc_inputMethod_changeSelection_Promise_0400', 0, async (done: Function) => { 606 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0400'; 607 const TEXT = '输入法键盘测试嘿嘿'; 608 const START = 8; 609 const END = 2; 610 try { 611 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 612 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 613 done(); 614 return; 615 } catch (error) { 616 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 617 expectFalse(); 618 done(); 619 return; 620 } 621 }); 622 623 /** 624 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0500 625 * @tc.name Call changeSelection interface in Promise mode, input parameter text=123 626 * @tc.desc Function test 627 */ 628 it('SUB_Misc_inputMethod_changeSelection_Promise_0500', 0, async (done: Function) => { 629 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0500'; 630 const START = 0; 631 const END = 5; 632 try { 633 let data = await inputMethod.getController().changeSelection(env.INVALID_TYPE_NUMBER_123, START, END); 634 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 635 expectFalse(); 636 done(); 637 return; 638 } catch (error) { 639 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 640 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 641 done(); 642 return; 643 } 644 }); 645 646 /** 647 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0600 648 * @tc.name Promise mode calls changeSelection interface, input parameter text='' 649 * @tc.desc Function test 650 */ 651 it('SUB_Misc_inputMethod_changeSelection_Promise_0600', 0, async (done: Function) => { 652 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0600'; 653 const START = 0; 654 const END = 5; 655 try { 656 let data = await inputMethod.getController().changeSelection(env.INVALID_STRING_NULL, START, END); 657 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 658 done(); 659 return; 660 } catch (error) { 661 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 662 expectFalse(); 663 done(); 664 return; 665 } 666 }); 667 668 /** 669 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0700 670 * @tc.name Promise mode calls changeSelection interface, input parameter start='0' 671 * @tc.desc Function test 672 */ 673 it('SUB_Misc_inputMethod_changeSelection_Promise_0700', 0, async (done: Function) => { 674 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0700'; 675 const TEXT = '输入法键盘测试嘿嘿'; 676 const START: ESObject = '0'; 677 const END = 5; 678 try { 679 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 680 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 681 expectFalse(); 682 done(); 683 return; 684 } catch (error) { 685 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 686 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 687 done(); 688 return; 689 } 690 }); 691 692 /** 693 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_0800 694 * @tc.name Call changeSelection interface in Promise mode, input parameter end='5' 695 * @tc.desc Function test 696 */ 697 it('SUB_Misc_inputMethod_changeSelection_Promise_0800', 0, async (done: Function) => { 698 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_0800'; 699 const TEXT = '输入法键盘测试嘿嘿'; 700 const START = 0; 701 const END: ESObject = '5'; 702 try { 703 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 704 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 705 expectFalse(); 706 done(); 707 return; 708 } catch (error) { 709 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 710 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 711 done(); 712 return; 713 } 714 }); 715 716 /** 717 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_1100 718 * @tc.name Do not bind the input method keyboard, and call the changeSelection interface in Promise mode 719 * @tc.desc Function test 720 */ 721 it('SUB_Misc_inputMethod_changeSelection_Promise_1100', 0, async (done: Function) => { 722 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_1100'; 723 const TEXT = '输入法键盘测试嘿嘿'; 724 const START = 0; 725 const END: ESObject = 5; 726 try { 727 let data = await inputMethod.getController().detach(); 728 console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`); 729 } catch (error) { 730 console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`); 731 expectFalse(); 732 done(); 733 return; 734 } 735 ; 736 try { 737 let data = await inputMethod.getController().changeSelection(TEXT, START, END); 738 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 739 expectFalse(); 740 done(); 741 return; 742 } catch (error) { 743 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 744 expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED); 745 done(); 746 return; 747 } 748 }); 749 750 /** 751 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_1200 752 * @tc.name The Promise method calls the changeSelection interface, and an invalid input parameter is passed in 753 * @tc.desc Function test 754 */ 755 it('SUB_Misc_inputMethod_changeSelection_Promise_1200', 0, async (done: Function) => { 756 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_1200'; 757 const TEXT = '输入法键盘测试嘿嘿'; 758 const START = 0; 759 const END: ESObject = 5; 760 try { 761 let data = await inputMethod.getController().changeSelection(TEXT, START, END, env.INVALID_TYPE_STRING_A); 762 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 763 done(); 764 return; 765 } catch (error) { 766 console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`); 767 expectFalse(); 768 done(); 769 return; 770 } 771 }); 772 773 /** 774 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_1300 775 * @tc.name The promise method calls the changeSelection interface, and the missing parameter text must be 776 * passed in 777 * @tc.desc Function test 778 */ 779 it('SUB_Misc_inputMethod_changeSelection_Promise_1300', 0, async (done: Function) => { 780 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_1300'; 781 const START = 0; 782 const END: ESObject = 5; 783 try { 784 let data = await inputMethod.getController().changeSelection(START, END); 785 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 786 expectFalse(); 787 done(); 788 return; 789 } catch (error) { 790 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 791 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 792 done(); 793 return; 794 } 795 }); 796 797 /** 798 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_1400 799 * @tc.name The promise method calls the changeSelection interface. If it is missing, the parameter start must 800 * be passed in 801 * @tc.desc Function test 802 */ 803 it('SUB_Misc_inputMethod_changeSelection_Promise_1400', 0, async (done: Function) => { 804 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_1400'; 805 const TEXT = '输入法键盘测试嘿嘿'; 806 const END: ESObject = 5; 807 try { 808 let data = await inputMethod.getController().changeSelection(TEXT, END); 809 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 810 expectFalse(); 811 done(); 812 return; 813 } catch (error) { 814 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 815 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 816 done(); 817 return; 818 } 819 }); 820 821 /** 822 * @tc.number SUB_Misc_inputMethod_changeSelection_Promise_1500 823 * @tc.name The promise method calls the changeSelection interface, and the missing parameter must be passed in 824 * @tc.desc Function test 825 */ 826 it('SUB_Misc_inputMethod_changeSelection_Promise_1500', 0, async (done: Function) => { 827 const CASE_NAME = 'SUB_Misc_inputMethod_changeSelection_Promise_1500'; 828 const TEXT = '输入法键盘测试嘿嘿'; 829 const START: ESObject = 0; 830 try { 831 let data = await inputMethod.getController().changeSelection(TEXT, START); 832 console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`); 833 expectFalse(); 834 done(); 835 return; 836 } catch (error) { 837 console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`); 838 expectTrue(error.code === env.INVALID_INPUT_PARAMETER); 839 done(); 840 return; 841 } 842 }); 843 844 }) 845}