1/* 2 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; 17import drawing from '@ohos.graphics.drawing'; 18import { getEnumCount } from './utils'; 19import common2D from '@ohos.graphics.common2D'; 20 21export default function drawingTsPath2Test() { 22 describe('DrawingTsPath2Test', () => { 23 const DEFAULT = 0; 24 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 25 beforeAll(() => { 26 27 }) 28 beforeEach(() => { 29 // Presets an action, which is performed before each unit test case starts. 30 // The number of execution times is the same as the number of test cases defined by **it**. 31 // This API supports only one parameter: preset action function. 32 }) 33 afterEach(() => { 34 // Presets a clear action, which is performed after each unit test case ends. 35 // The number of execution times is the same as the number of test cases defined by **it**. 36 // This API supports only one parameter: clear action function. 37 }) 38 afterAll(() => { 39 // Presets a clear action, which is performed after all test cases of the test suite end. 40 // This API supports only one parameter: clear action function. 41 }) 42 43 /** 44 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0800 45 * @tc.name : testPathAddArcNormal 46 * @tc.desc : testPathAddArcNormal 47 * @tc.size : MediumTest 48 * @tc.type : Function 49 * @tc.level : Level0 50 */ 51 it('testPathAddArcNormal', DEFAULT, () => { 52 const msg = 'testPathAddArcNormal'; 53 let path = new drawing.Path(); 54 const maxVal = Number.MAX_VALUE; 55 56 try { 57 path.addArc({ 58 left: 10, right: 400, top: 100, bottom: 300 59 }, 90, 180); 60 path.addArc({ 61 left: 10.1, right: 400.1, top: 100.1, bottom: 300.1 62 }, 90.1, 180.1); 63 path.addArc({ 64 left: -10.1, right: 400.1, top: -100.1, bottom: 300.1 65 }, -90, -180); 66 path.addArc({ 67 left: 10, right: -400, top: 100, bottom: -300 68 }, 450, 361); 69 path.addArc({ 70 left: 100, right: 100, top: 100, bottom: 300 71 }, 45, 36); 72 path.addArc({ 73 left: 100, right: 100, top: 100, bottom: 100 74 }, 100, -200); 75 path.addArc({ 76 left: maxVal, right: maxVal, top: maxVal, bottom: maxVal 77 }, maxVal, maxVal); 78 path.close() 79 console.info(msg + 'reset successes'); 80 } catch (e) { 81 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 82 expect().assertFail() 83 } 84 }) 85 86 /** 87 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0801 88 * @tc.name : testPathAddArcMultipleCalls 89 * @tc.desc : testPathAddArcMultipleCalls 90 * @tc.size : MediumTest 91 * @tc.type : Function 92 * @tc.level : Level3 93 */ 94 it('testPathAddArcMultipleCalls', DEFAULT, () => { 95 const msg = 'testPathAddArcMultipleCalls'; 96 let path = new drawing.Path(); 97 98 try { 99 for (let i = 0; i < 20; i += 1) { 100 path.addArc({ 101 left: Math.random(), 102 right: Math.random(), 103 top: Math.random(), 104 bottom: Math.random(), 105 }, Math.random(), Math.random()); 106 } 107 path.close(); 108 console.info(msg + 'reset successes'); 109 } catch (e) { 110 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 111 expect().assertFail() 112 } 113 }) 114 115 /** 116 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0802 117 * @tc.name : testPathAddArcToNull 118 * @tc.desc : testPathAddArcToNull 119 * @tc.size : MediumTest 120 * @tc.type : Function 121 * @tc.level : Level3 122 */ 123 it('testPathAddArcToNull', DEFAULT, () => { 124 const msg = 'testPathAddArcToNull'; 125 let path = new drawing.Path(); 126 127 try { 128 path.addArc(null, 90, 180); 129 console.info(msg + `reset error`); 130 expect().assertFail() 131 } catch (e) { 132 console.info(msg + 'reset successes'); 133 } 134 135 try { 136 path.addArc({ 137 left: 10, right: 400, top: 100, bottom: 300 138 }, null, 180); 139 console.info(msg + `reset error`); 140 expect().assertFail() 141 } catch (e) { 142 console.info(msg + 'reset successes'); 143 } 144 145 try { 146 path.addArc({ 147 left: 10, right: 400, top: 100, bottom: 300 148 }, 90, null); 149 console.info(msg + `reset error`); 150 expect().assertFail() 151 } catch (e) { 152 console.info(msg + 'reset successes'); 153 } 154 155 try { 156 path.addArc(undefined, 90, 180); 157 console.info(msg + `reset error`); 158 expect().assertFail() 159 } catch (e) { 160 console.info(msg + 'reset successes'); 161 } 162 163 try { 164 path.addArc({ 165 left: 10, right: 400, top: 100, bottom: 300 166 }, undefined, 180); 167 console.info(msg + `reset error`); 168 expect().assertFail() 169 } catch (e) { 170 console.info(msg + 'reset successes'); 171 } 172 173 try { 174 path.addArc({ 175 left: 10, right: 400, top: 100, bottom: 300 176 }, 90, undefined); 177 console.info(msg + `reset error`); 178 expect().assertFail() 179 } catch (e) { 180 console.info(msg + 'reset successes'); 181 } 182 183 try { 184 path.addArc({ 185 left: null, right: 400, top: 100, bottom: 300 186 }, 90, 180); 187 console.info(msg + `reset error`); 188 expect().assertFail() 189 } catch (e) { 190 console.info(msg + 'reset successes'); 191 } 192 193 try { 194 path.addArc({ 195 left: 10, right: null, top: 100, bottom: 300 196 }, 90, 180); 197 console.info(msg + `reset error`); 198 expect().assertFail() 199 } catch (e) { 200 console.info(msg + 'reset successes'); 201 } 202 203 try { 204 path.addArc({ 205 left: 10, right: 400, top: null, bottom: 300 206 }, 90, 180); 207 console.info(msg + `reset error`); 208 expect().assertFail() 209 } catch (e) { 210 console.info(msg + 'reset successes'); 211 } 212 213 try { 214 path.addArc({ 215 left: 10, right: 400, top: 100, bottom: null 216 }, 90, 180); 217 console.info(msg + `reset error`); 218 expect().assertFail() 219 } catch (e) { 220 console.info(msg + 'reset successes'); 221 } 222 223 try { 224 path.addArc({ 225 left: undefined, right: 400, top: 100, bottom: 300 226 }, 90, 180); 227 console.info(msg + `reset error`); 228 expect().assertFail() 229 } catch (e) { 230 console.info(msg + 'reset successes'); 231 } 232 233 try { 234 path.addArc({ 235 left: 10, right: undefined, top: 100, bottom: 300 236 }, 90, 180); 237 console.info(msg + `reset error`); 238 expect().assertFail() 239 } catch (e) { 240 console.info(msg + 'reset successes'); 241 } 242 243 try { 244 path.addArc({ 245 left: 10, right: 400, top: undefined, bottom: 300 246 }, 90, 180); 247 console.info(msg + `reset error`); 248 expect().assertFail() 249 } catch (e) { 250 console.info(msg + 'reset successes'); 251 } 252 253 try { 254 path.addArc({ 255 left: 10, right: 400, top: 100, bottom: undefined 256 }, 90, 180); 257 console.info(msg + `reset error`); 258 expect().assertFail() 259 } catch (e) { 260 console.info(msg + 'reset successes'); 261 } 262 }) 263 264 265 /** 266 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0900 267 * @tc.name : testPathAddCircleNormal 268 * @tc.desc : testPathAddCircleNormal 269 * @tc.size : MediumTest 270 * @tc.type : Function 271 * @tc.level : Level0 272 */ 273 it('testPathAddCircleNormal', DEFAULT, () => { 274 const msg = 'testPathAddCircleNormal'; 275 let path = new drawing.Path(); 276 const maxVal = Number.MAX_VALUE 277 278 try { 279 path.addCircle(100, 200, 50, drawing.PathDirection.CLOCKWISE); 280 path.addCircle(100.1, 300.1, 50.1, drawing.PathDirection.COUNTER_CLOCKWISE); 281 path.addCircle(200, 200, 50); 282 path.addCircle(maxVal, maxVal, maxVal); 283 path.addCircle(-200, -200, 200); 284 285 path.addCircle(100, 200, -1, drawing.PathDirection.CLOCKWISE); 286 path.addCircle(100, 200, 0); 287 288 path.close(); 289 console.info(msg + 'reset successes'); 290 } catch (e) { 291 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 292 expect().assertFail() 293 } 294 }) 295 296 297 /** 298 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0901 299 * @tc.name : testPathAddCircleMultipleCalls 300 * @tc.desc : testPathAddCircleMultipleCalls 301 * @tc.size : MediumTest 302 * @tc.type : Function 303 * @tc.level : Level3 304 */ 305 it('testPathAddCircleMultipleCalls', DEFAULT, () => { 306 const msg = 'testPathAddCircleMultipleCalls'; 307 let path = new drawing.Path(); 308 309 try { 310 for (let i = 0; i < 20; i += 1) { 311 const randomEnum = Math.floor(Math.random() * getEnumCount(drawing.PathDirection)) 312 path.addCircle(Math.random(), Math.random(), Math.random(), randomEnum) 313 } 314 path.close(); 315 console.info(msg + 'reset successes'); 316 } catch (e) { 317 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 318 expect().assertFail() 319 } 320 }) 321 322 323 /** 324 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0902 325 * @tc.name : testPathAddCircleToNull 326 * @tc.desc : testPathAddCircleToNull 327 * @tc.size : MediumTest 328 * @tc.type : Function 329 * @tc.level : Level3 330 */ 331 it('testPathAddCircleToNull', DEFAULT, () => { 332 const msg = 'testPathAddCircleToNull'; 333 let path = new drawing.Path(); 334 try { 335 path.addCircle(null, 200, 50, drawing.PathDirection.CLOCKWISE); 336 console.info(msg + `reset error`); 337 expect().assertFail() 338 } catch (e) { 339 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 340 expect(e.code).assertEqual(401); 341 } 342 343 try { 344 path.addCircle(100, null, 50, drawing.PathDirection.CLOCKWISE); 345 console.info(msg + `reset error`); 346 expect().assertFail() 347 } catch (e) { 348 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 349 expect(e.code).assertEqual(401); 350 } 351 352 try { 353 path.addCircle(100, 200, null, drawing.PathDirection.CLOCKWISE); 354 console.info(msg + `reset error`); 355 expect().assertFail() 356 } catch (e) { 357 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 358 expect(e.code).assertEqual(401); 359 } 360 361 try { 362 path.addCircle(100, 200, 50, null); 363 console.info(msg + `reset error`); 364 expect().assertFail() 365 } catch (e) { 366 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 367 expect(e.code).assertEqual(401); 368 } 369 370 try { 371 path.addCircle(undefined, 200, 50, drawing.PathDirection.CLOCKWISE); 372 console.info(msg + `reset error`); 373 expect().assertFail() 374 } catch (e) { 375 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 376 expect(e.code).assertEqual(401); 377 } 378 379 try { 380 path.addCircle(100, undefined, 50, drawing.PathDirection.CLOCKWISE); 381 console.info(msg + `reset error`); 382 expect().assertFail() 383 } catch (e) { 384 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 385 expect(e.code).assertEqual(401); 386 } 387 388 try { 389 path.addCircle(100, 200, undefined, drawing.PathDirection.CLOCKWISE); 390 console.info(msg + `reset error`); 391 expect().assertFail() 392 } catch (e) { 393 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 394 expect(e.code).assertEqual(401); 395 } 396 397 try { 398 path.addCircle(100, 200, 50, undefined); 399 console.info(msg + `reset error`); 400 expect().assertFail() 401 } catch (e) { 402 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 403 expect(e.code).assertEqual(401); 404 } 405 }) 406 407 408 /** 409 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_0904 410 * @tc.name : testPathAddCircleAbnormal 411 * @tc.desc : testPathAddCircleAbnormal 412 * @tc.size : MediumTest 413 * @tc.type : Function 414 * @tc.level : Level3 415 */ 416 it('testPathAddCircleAbnormal', DEFAULT, () => { 417 const msg = 'testPathAddCircleAbnormal'; 418 let path = new drawing.Path(); 419 420 try { 421 path.addCircle(100, 200, 50, 10); 422 console.info(msg + `reset error`); 423 expect().assertFail() 424 } catch (e) { 425 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 426 expect(e.code).assertEqual(401); 427 } 428 }) 429 430 431 /** 432 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1000 433 * @tc.name : testPathAddOvalNormal 434 * @tc.desc : testPathAddOvalNormal 435 * @tc.size : MediumTest 436 * @tc.type : Function 437 * @tc.level : Level0 438 */ 439 it('testPathAddOvalNormal', DEFAULT, () => { 440 const msg = 'testPathAddOvalNormal'; 441 let path = new drawing.Path(); 442 let maxVal = Number.MAX_VALUE; 443 444 try { 445 path.addOval({ 446 left: 10, right: 400, top: 100, bottom: 300 447 }, 4, drawing.PathDirection.CLOCKWISE); 448 path.addOval({ 449 left: 10, right: 400, top: 100, bottom: 300 450 }, 5, drawing.PathDirection.CLOCKWISE); 451 path.addOval({ 452 left: 10.1, right: 400.1, top: 100.1, bottom: 300.1 453 }, 4.1); 454 path.addOval({ 455 left: 10, right: 400, top: 100, bottom: 300 456 }, 5, drawing.PathDirection.COUNTER_CLOCKWISE); 457 path.addOval({ 458 left: 10.1, right: 400.1, top: 100.1, bottom: 300.1 459 }, 5.1); 460 path.addOval({ 461 left: -10, right: 400, top: -10, bottom: 300 462 }, 1); 463 path.addOval({ 464 left: 10, right: -400, top: 100, bottom: -300 465 }, 5, drawing.PathDirection.CLOCKWISE); 466 path.addOval({ 467 left: maxVal, right: maxVal, top: maxVal, bottom: maxVal 468 }, 0); 469 path.addOval({ 470 left: 100, right: 100, top: 100, bottom: 200 471 }, 1); 472 path.addOval({ 473 left: 100, right: 100, top: 100, bottom: 200 474 }, 3); 475 path.addOval({ 476 left: 100, right: 100, top: 100, bottom: 100 477 }, 10); 478 479 path.close(); 480 console.info(msg + 'reset successes'); 481 } catch (e) { 482 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 483 expect().assertFail() 484 } 485 }) 486 487 488 /** 489 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1001 490 * @tc.name : testPathAddOvalMultipleCalls 491 * @tc.desc : testPathAddOvalMultipleCalls 492 * @tc.size : MediumTest 493 * @tc.type : Function 494 * @tc.level : Level3 495 */ 496 it('testPathAddOvalMultipleCalls', DEFAULT, () => { 497 const msg = 'testPathAddOvalMultipleCalls'; 498 let path = new drawing.Path(); 499 500 try { 501 for (let i = 0; i < 20; i += 1) { 502 const randomEnum = Math.floor(Math.random() * getEnumCount(drawing.PathDirection)); 503 path.addOval({ 504 left: Math.random(), right: Math.random(), top: Math.random(), bottom: Math.random() 505 }, Math.random(), randomEnum); 506 } 507 path.close(); 508 console.info(msg + 'reset successes'); 509 } catch (e) { 510 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 511 expect().assertFail() 512 } 513 }) 514 515 516 /** 517 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1002 518 * @tc.name : testPathAddOvalToNull 519 * @tc.desc : testPathAddOvalToNull 520 * @tc.size : MediumTest 521 * @tc.type : Function 522 * @tc.level : Level3 523 */ 524 it('testPathAddOvalToNull', DEFAULT, () => { 525 const msg = 'testPathAddOvalToNull'; 526 let path = new drawing.Path(); 527 528 try { 529 path.addOval(null, 5, drawing.PathDirection.CLOCKWISE); 530 console.info(msg + `reset error`); 531 expect().assertFail() 532 } catch (e) { 533 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 534 expect(e.code).assertEqual(401); 535 } 536 537 try { 538 path.addOval({ 539 left: 10, right: 400, top: 100, bottom: 300 540 }, null, drawing.PathDirection.CLOCKWISE); 541 console.info(msg + `reset error`); 542 expect().assertFail() 543 } catch (e) { 544 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 545 expect(e.code).assertEqual(401); 546 } 547 548 try { 549 path.addOval({ 550 left: 10, right: 400, top: 100, bottom: 300 551 }, 5, null); 552 console.info(msg + `reset error`); 553 expect().assertFail() 554 } catch (e) { 555 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 556 expect(e.code).assertEqual(401); 557 } 558 559 try { 560 path.addOval(undefined, 5, drawing.PathDirection.CLOCKWISE); 561 console.info(msg + `reset error`); 562 expect().assertFail() 563 } catch (e) { 564 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 565 expect(e.code).assertEqual(401); 566 } 567 568 try { 569 path.addOval({ 570 left: 10, right: 400, top: 100, bottom: 300 571 }, undefined, drawing.PathDirection.CLOCKWISE); 572 console.info(msg + `reset error`); 573 expect().assertFail() 574 } catch (e) { 575 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 576 expect(e.code).assertEqual(401); 577 } 578 579 try { 580 path.addOval({ 581 left: null, right: 400, top: 100, bottom: 300 582 }, 5, drawing.PathDirection.CLOCKWISE); 583 console.info(msg + `reset error`); 584 expect().assertFail() 585 } catch (e) { 586 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 587 expect(e.code).assertEqual(401); 588 } 589 590 try { 591 path.addOval({ 592 left: 10, right: null, top: 100, bottom: 300 593 }, 5, drawing.PathDirection.COUNTER_CLOCKWISE); 594 console.info(msg + `reset error`); 595 expect().assertFail() 596 } catch (e) { 597 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 598 expect(e.code).assertEqual(401); 599 } 600 601 try { 602 path.addOval({ 603 left: 10, right: 400, top: null, bottom: 300 604 }, 5, drawing.PathDirection.COUNTER_CLOCKWISE); 605 console.info(msg + `reset error`); 606 expect().assertFail() 607 } catch (e) { 608 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 609 expect(e.code).assertEqual(401); 610 } 611 612 try { 613 path.addOval({ 614 left: 10, right: 400, top: 100, bottom: null 615 }, 5, drawing.PathDirection.CLOCKWISE); 616 console.info(msg + `reset error`); 617 expect().assertFail() 618 } catch (e) { 619 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 620 expect(e.code).assertEqual(401); 621 } 622 623 try { 624 path.addOval({ 625 left: undefined, right: 400, top: 100, bottom: 300 626 }, 5, drawing.PathDirection.CLOCKWISE); 627 console.info(msg + `reset error`); 628 expect().assertFail() 629 } catch (e) { 630 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 631 expect(e.code).assertEqual(401); 632 } 633 634 try { 635 path.addOval({ 636 left: 10, right: undefined, top: 100, bottom: 300 637 }, 5, drawing.PathDirection.COUNTER_CLOCKWISE); 638 console.info(msg + `reset error`); 639 expect().assertFail() 640 } catch (e) { 641 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 642 expect(e.code).assertEqual(401); 643 } 644 645 try { 646 path.addOval({ 647 left: 10, right: 400, top: undefined, bottom: 300 648 }, 5, drawing.PathDirection.COUNTER_CLOCKWISE); 649 console.info(msg + `reset error`); 650 expect().assertFail() 651 } catch (e) { 652 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 653 expect(e.code).assertEqual(401); 654 } 655 656 try { 657 path.addOval({ 658 left: 10, right: 400, top: 100, bottom: undefined 659 }, 5, drawing.PathDirection.CLOCKWISE); 660 console.info(msg + `reset error`); 661 expect().assertFail() 662 } catch (e) { 663 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 664 expect(e.code).assertEqual(401); 665 } 666 }) 667 668 669 /** 670 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1004 671 * @tc.name : testPathAddOvalAbnormal 672 * @tc.desc : testPathAddOvalAbnormal 673 * @tc.size : MediumTest 674 * @tc.type : Function 675 * @tc.level : Level3 676 */ 677 it('testPathAddOvalAbnormal', DEFAULT, () => { 678 const msg = 'testPathAddOvalAbnormal'; 679 const path = new drawing.Path(); 680 681 try { 682 path.addOval({ 683 left: 10, right: 400, top: 100, bottom: 300 684 }, -1, drawing.PathDirection.CLOCKWISE); 685 console.info(msg + `reset error`); 686 expect().assertFail() 687 } catch (e) { 688 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 689 expect(e.code).assertEqual(401); 690 } 691 692 try { 693 path.addOval({ 694 left: 10, right: 400, top: 100, bottom: 300 695 }, 4, 10); 696 console.info(msg + `reset error`); 697 expect().assertFail() 698 } catch (e) { 699 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 700 expect(e.code).assertEqual(401); 701 } 702 }) 703 704 705 /** 706 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1100 707 * @tc.name : testPathAddRectNormal 708 * @tc.desc : testPathAddRectNormal 709 * @tc.size : MediumTest 710 * @tc.type : Function 711 * @tc.level : Level0 712 */ 713 it('testPathAddRectNormal', DEFAULT, () => { 714 const msg = 'testPathAddRectNormal'; 715 let path = new drawing.Path(); 716 const maxVal = Number.MAX_VALUE; 717 718 try { 719 path.addRect({ 720 left: 10, right: 400, top: 100, bottom: 300 721 }, drawing.PathDirection.CLOCKWISE); 722 path.addRect({ 723 left: 10, right: 400, top: 100, bottom: 300 724 }, drawing.PathDirection.COUNTER_CLOCKWISE); 725 path.addRect({ 726 left: 10.1, right: 400.1, top: 100.1, bottom: 300.1 727 }); 728 path.addOval({ 729 left: -10, right: 400, top: -10, bottom: 300 730 }, 300); 731 path.addRect({ 732 left: 10, right: -400, top: 100, bottom: -300 733 }, drawing.PathDirection.CLOCKWISE); 734 path.addRect({ 735 left: maxVal, right: maxVal, top: maxVal, bottom: maxVal 736 }); 737 path.addRect({ 738 left: 100, right: 100, top: 100, bottom: 200 739 }); 740 path.addRect({ 741 left: 100, right: 100, top: 100, bottom: 100 742 }); 743 path.close(); 744 console.info(msg + 'reset successes'); 745 } catch (e) { 746 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 747 expect().assertFail() 748 } 749 }) 750 751 752 /** 753 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1101 754 * @tc.name : testPathAddRectMultipleCalls 755 * @tc.desc : testPathAddRectMultipleCalls 756 * @tc.size : MediumTest 757 * @tc.type : Function 758 * @tc.level : Level3 759 */ 760 it('testPathAddRectMultipleCalls', DEFAULT, () => { 761 const msg = 'testPathAddRectMultipleCalls'; 762 let path = new drawing.Path(); 763 764 try { 765 for (let i = 0; i < 20; i += 1) { 766 const randomEnum = Math.floor(Math.random() * getEnumCount(drawing.PathDirection)) 767 path.addRect({ 768 left: Math.random(), right: Math.random(), top: Math.random(), bottom: Math.random() 769 }, randomEnum) 770 } 771 path.close(); 772 console.info(msg + 'reset successes'); 773 } catch (e) { 774 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 775 expect().assertFail() 776 } 777 }) 778 779 780 /** 781 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1102 782 * @tc.name : testPathAddRectToNull 783 * @tc.desc : testPathAddRectToNull 784 * @tc.size : MediumTest 785 * @tc.type : Function 786 * @tc.level : Level3 787 */ 788 it('testPathAddRectToNull', DEFAULT, () => { 789 const msg = 'testPathAddRectToNull'; 790 let path = new drawing.Path(); 791 792 try { 793 path.addRect(null, drawing.PathDirection.CLOCKWISE); 794 console.info(msg + `reset error`); 795 expect().assertFail() 796 } catch (e) { 797 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 798 expect(e.code).assertEqual(401); 799 } 800 801 try { 802 path.addRect({ 803 left: 10, right: 400, top: 100, bottom: 300 804 }, null); 805 console.info(msg + `reset error`); 806 expect().assertFail() 807 } catch (e) { 808 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 809 expect(e.code).assertEqual(401); 810 } 811 812 try { 813 path.addRect(undefined, drawing.PathDirection.CLOCKWISE); 814 console.info(msg + `reset error`); 815 expect().assertFail() 816 } catch (e) { 817 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 818 expect(e.code).assertEqual(401); 819 } 820 821 try { 822 path.addRect({ 823 left: 10, right: 400, top: 100, bottom: 300 824 }, undefined); 825 console.info(msg + `reset error`); 826 expect().assertFail() 827 } catch (e) { 828 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 829 expect(e.code).assertEqual(401); 830 } 831 832 try { 833 path.addRect({ 834 left: null, right: 400, top: 100, bottom: 300 835 }, drawing.PathDirection.CLOCKWISE); 836 console.info(msg + `reset error`); 837 expect().assertFail() 838 } catch (e) { 839 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 840 expect(e.code).assertEqual(401); 841 } 842 843 try { 844 path.addRect({ 845 left: 10, right: null, top: 100, bottom: 300 846 }, drawing.PathDirection.COUNTER_CLOCKWISE); 847 console.info(msg + `reset error`); 848 expect().assertFail() 849 } catch (e) { 850 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 851 expect(e.code).assertEqual(401); 852 } 853 854 try { 855 path.addRect({ 856 left: 10, right: 400, top: null, bottom: 300 857 }, drawing.PathDirection.COUNTER_CLOCKWISE); 858 console.info(msg + `reset error`); 859 expect().assertFail() 860 } catch (e) { 861 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 862 expect(e.code).assertEqual(401); 863 } 864 865 try { 866 path.addRect({ 867 left: 10, right: 400, top: 100, bottom: null 868 }, drawing.PathDirection.CLOCKWISE); 869 console.info(msg + `reset error`); 870 expect().assertFail() 871 } catch (e) { 872 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 873 expect(e.code).assertEqual(401); 874 } 875 876 try { 877 path.addRect({ 878 left: undefined, right: 400, top: 100, bottom: 300 879 }, drawing.PathDirection.CLOCKWISE); 880 console.info(msg + `reset error`); 881 expect().assertFail() 882 } catch (e) { 883 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 884 expect(e.code).assertEqual(401); 885 } 886 887 try { 888 path.addRect({ 889 left: 10, right: undefined, top: 100, bottom: 300 890 }, drawing.PathDirection.COUNTER_CLOCKWISE); 891 console.info(msg + `reset error`); 892 expect().assertFail() 893 } catch (e) { 894 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 895 expect(e.code).assertEqual(401); 896 } 897 898 try { 899 path.addRect({ 900 left: 10, right: 400, top: undefined, bottom: 300 901 }, drawing.PathDirection.COUNTER_CLOCKWISE); 902 console.info(msg + `reset error`); 903 expect().assertFail() 904 } catch (e) { 905 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 906 expect(e.code).assertEqual(401); 907 } 908 909 try { 910 path.addRect({ 911 left: 10, right: 400, top: 100, bottom: undefined 912 }, drawing.PathDirection.CLOCKWISE); 913 console.info(msg + `reset error`); 914 expect().assertFail() 915 } catch (e) { 916 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 917 expect(e.code).assertEqual(401); 918 } 919 }) 920 921 922 /** 923 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1104 924 * @tc.name : testPathAddRectAbnormal 925 * @tc.desc : testPathAddRectAbnormal 926 * @tc.size : MediumTest 927 * @tc.type : Function 928 * @tc.level : Level3 929 */ 930 it('testPathAddRectAbnormal', DEFAULT, () => { 931 const msg = 'testPathAddRectAbnormal'; 932 let path = new drawing.Path(); 933 934 try { 935 path.addRect({ 936 left: 10, right: 400, top: 100, bottom: 300 937 }, 10); 938 path.close(); 939 console.info(msg + `reset error`); 940 expect().assertFail() 941 } catch (e) { 942 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 943 expect(e.code).assertEqual(401); 944 } 945 }) 946 947 948 /** 949 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1200 950 * @tc.name : testPathAddRoundRectNormal 951 * @tc.desc : testPathAddRoundRectNormal 952 * @tc.size : MediumTest 953 * @tc.type : Function 954 * @tc.level : Level0 955 */ 956 it('testPathAddRoundRectNormal', DEFAULT, () => { 957 const msg = 'testPathAddRoundRectNormal'; 958 959 try { 960 let path = new drawing.Path(); 961 let roundRect = new drawing.RoundRect({ 962 left: 10, right: 400, top: 100, bottom: 300 963 }, 50, 50); 964 path.addRoundRect(roundRect, drawing.PathDirection.CLOCKWISE); 965 path.addRoundRect(roundRect, drawing.PathDirection.COUNTER_CLOCKWISE); 966 path.addRoundRect(roundRect); 967 path.close(); 968 console.info(msg + 'reset successes'); 969 } catch (e) { 970 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 971 expect().assertFail() 972 } 973 }) 974 975 976 /** 977 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1201 978 * @tc.name : testPathAddRoundRectMultipleCalls 979 * @tc.desc : testPathAddRoundRectMultipleCalls 980 * @tc.size : MediumTest 981 * @tc.type : Function 982 * @tc.level : Level3 983 */ 984 it('testPathAddRoundRectMultipleCalls', DEFAULT, () => { 985 const msg = 'testPathAddRoundRectMultipleCalls'; 986 let path = new drawing.Path(); 987 988 try { 989 for (let i = 0; i < 20; i += 1) { 990 let roundRect = new drawing.RoundRect({ 991 left: 10, right: 400, top: 100, bottom: 300 992 }, 50, 50); 993 const randomEnum = Math.floor(Math.random() * getEnumCount(drawing.PathDirection)) 994 path.addRoundRect(roundRect, randomEnum); 995 } 996 path.close(); 997 console.info(msg + 'reset successes'); 998 } catch (e) { 999 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1000 expect().assertFail() 1001 } 1002 }) 1003 1004 1005 /** 1006 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1202 1007 * @tc.name : testPathAddRoundRectToNull 1008 * @tc.desc : testPathAddRoundRectToNull 1009 * @tc.size : MediumTest 1010 * @tc.type : Function 1011 * @tc.level : Level3 1012 */ 1013 it('testPathAddRoundRectToNull', DEFAULT, () => { 1014 const msg = 'testPathAddRoundRectToNull'; 1015 let path = new drawing.Path(); 1016 let roundRect = new drawing.RoundRect({ 1017 left: 10, right: 400, top: 100, bottom: 300 1018 }, 50, 50); 1019 1020 try { 1021 path.addRoundRect(null, drawing.PathDirection.CLOCKWISE); 1022 console.info(msg + `reset error`); 1023 expect().assertFail() 1024 } catch (e) { 1025 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1026 expect(e.code).assertEqual(401); 1027 } 1028 1029 try { 1030 path.addRoundRect(roundRect, null); 1031 console.info(msg + `reset error`); 1032 expect().assertFail() 1033 } catch (e) { 1034 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1035 expect(e.code).assertEqual(401); 1036 } 1037 1038 try { 1039 path.addRoundRect(undefined, drawing.PathDirection.CLOCKWISE); 1040 console.info(msg + `reset error`); 1041 expect().assertFail() 1042 } catch (e) { 1043 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1044 expect(e.code).assertEqual(401); 1045 } 1046 1047 try { 1048 path.addRoundRect(roundRect, undefined); 1049 console.info(msg + `reset error`); 1050 expect().assertFail() 1051 } catch (e) { 1052 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1053 expect(e.code).assertEqual(401); 1054 } 1055 }) 1056 1057 1058 /** 1059 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1204 1060 * @tc.name : testPathAddRoundRectAbnormal 1061 * @tc.desc : testPathAddRoundRectAbnormal 1062 * @tc.size : MediumTest 1063 * @tc.type : Function 1064 * @tc.level : Level3 1065 */ 1066 it('testPathAddRoundRectAbnormal', DEFAULT, () => { 1067 const msg = 'testPathAddRoundRectAbnormal'; 1068 let path = new drawing.Path(); 1069 1070 try { 1071 let roundRect = new drawing.RoundRect({ 1072 left: 10, right: 400, top: 100, bottom: 300 1073 }, 50, 50); 1074 path.addRoundRect(roundRect, 10); 1075 console.info(msg + 'reset error'); 1076 expect().assertFail(); 1077 } catch (e) { 1078 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}`); 1079 expect(e.code).assertEqual(401); 1080 } 1081 }) 1082 1083 1084 /** 1085 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1300 1086 * @tc.name : testPathAddPathNormal 1087 * @tc.desc : testPathAddPathNormal 1088 * @tc.size : MediumTest 1089 * @tc.type : Function 1090 * @tc.level : Level0 1091 */ 1092 it('testPathAddPathNormal', DEFAULT, () => { 1093 const msg = 'testPathAddPathNormal'; 1094 1095 try { 1096 let path = new drawing.Path(); 1097 let matrix = new drawing.Matrix(); 1098 let dstPath = new drawing.Path(); 1099 dstPath.addPath(path, matrix); 1100 path.addOval({ 1101 left: 10, right: 400, top: 100, bottom: 300 1102 }, 5, drawing.PathDirection.CLOCKWISE); 1103 dstPath.addPath(path); 1104 matrix.setMatrix([5, 0, 0, 0, 1, 2, 0, 0, 1]); 1105 path.addCircle(100, 200, 50, drawing.PathDirection.COUNTER_CLOCKWISE); 1106 dstPath.addPath(path, matrix); 1107 1108 dstPath .addPath(path, null); 1109 1110 path.close(); 1111 console.info(msg + 'reset successes'); 1112 } catch (e) { 1113 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1114 expect().assertFail() 1115 } 1116 }) 1117 1118 1119 /** 1120 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1301 1121 * @tc.name : testPathAddPathMultipleCalls 1122 * @tc.desc : testPathAddPathMultipleCalls 1123 * @tc.size : MediumTest 1124 * @tc.type : Function 1125 * @tc.level : Level3 1126 */ 1127 it('testPathAddPathMultipleCalls', DEFAULT, () => { 1128 const msg = 'testPathAddPathMultipleCalls'; 1129 1130 try { 1131 const dstPath = new drawing.Path() 1132 for (let i = 0; i < 20; i += 1) { 1133 let path = new drawing.Path(); 1134 let matrix = new drawing.Matrix(); 1135 dstPath.addPath(path, matrix); 1136 } 1137 console.info(msg + 'reset successes'); 1138 } catch (e) { 1139 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1140 expect().assertFail() 1141 } 1142 }) 1143 1144 1145 /** 1146 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1302 1147 * @tc.name : testPathAddPathToNull 1148 * @tc.desc : testPathAddPathToNull 1149 * @tc.size : MediumTest 1150 * @tc.type : Function 1151 * @tc.level : Level3 1152 */ 1153 it('testPathAddPathToNull', DEFAULT, () => { 1154 const msg = 'testPathAddPathToNull'; 1155 1156 try { 1157 let dstPath = new drawing.Path(); 1158 let matrix = new drawing.Matrix(); 1159 dstPath.addPath(null, matrix); 1160 console.info(msg + `reset error`); 1161 expect().assertFail() 1162 } catch (e) { 1163 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1164 expect(e.code).assertEqual(401); 1165 } 1166 1167 try { 1168 let dstPath = new drawing.Path(); 1169 let matrix = new drawing.Matrix(); 1170 dstPath.addPath(undefined, matrix); 1171 console.info(msg + `reset error`); 1172 expect().assertFail() 1173 } catch (e) { 1174 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1175 expect(e.code).assertEqual(401); 1176 } 1177 1178 try { 1179 let dstPath = new drawing.Path(); 1180 let path = new drawing.Path(); 1181 dstPath.addPath(path, undefined); 1182 console.info(msg + `reset error`); 1183 expect().assertFail() 1184 } catch (e) { 1185 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1186 expect(e.code).assertEqual(401); 1187 } 1188 }) 1189 1190 1191 /** 1192 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1400 1193 * @tc.name : testPathTransformNormal 1194 * @tc.desc : testPathTransformNormal 1195 * @tc.size : MediumTest 1196 * @tc.type : Function 1197 * @tc.level : Level0 1198 */ 1199 it('testPathTransformNormal', DEFAULT, () => { 1200 const msg = 'testPathTransformNormal'; 1201 1202 try { 1203 let path = new drawing.Path(); 1204 let matrix = new drawing.Matrix(); 1205 path.transform(matrix); 1206 1207 let roundRect = new drawing.RoundRect({ 1208 left: 10, right: 400, top: 100, bottom: 300 1209 }, 50, 50); 1210 path.addRoundRect(roundRect, drawing.PathDirection.CLOCKWISE); 1211 path.transform(matrix); 1212 1213 path.close(); 1214 console.info(msg + 'reset successes'); 1215 } catch (e) { 1216 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1217 expect().assertFail() 1218 } 1219 }) 1220 1221 1222 /** 1223 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1401 1224 * @tc.name : testPathTransformMultipleCalls 1225 * @tc.desc : testPathTransformMultipleCalls 1226 * @tc.size : MediumTest 1227 * @tc.type : Function 1228 * @tc.level : Level3 1229 */ 1230 it('testPathTransformMultipleCalls', DEFAULT, () => { 1231 const msg = 'testPathTransformMultipleCalls'; 1232 1233 try { 1234 for (let i = 0; i < 20; i += 1) { 1235 let path = new drawing.Path(); 1236 let matrix = new drawing.Matrix(); 1237 1238 path.transform(matrix); 1239 path.close(); 1240 } 1241 console.info(msg + 'reset successes'); 1242 } catch (e) { 1243 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1244 expect().assertFail() 1245 } 1246 }) 1247 1248 1249 /** 1250 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1402 1251 * @tc.name : testPathTransformToNull 1252 * @tc.desc : testPathTransformToNull 1253 * @tc.size : MediumTest 1254 * @tc.type : Function 1255 * @tc.level : Level3 1256 */ 1257 it('testPathTransformToNull', DEFAULT, () => { 1258 const msg = 'testPathTransformToNull'; 1259 1260 try { 1261 let path = new drawing.Path(); 1262 path.transform(null); 1263 console.info(msg + `reset error`); 1264 expect().assertFail() 1265 } catch (e) { 1266 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1267 expect(e.code).assertEqual(401); 1268 } 1269 1270 try { 1271 let path = new drawing.Path(); 1272 path.transform(undefined); 1273 console.info(msg + `reset error`); 1274 expect().assertFail() 1275 } catch (e) { 1276 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1277 expect(e.code).assertEqual(401); 1278 } 1279 }) 1280 1281 1282 /** 1283 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1500 1284 * @tc.name : testPathContainsNormal 1285 * @tc.desc : testPathContainsNormal 1286 * @tc.size : MediumTest 1287 * @tc.type : Function 1288 * @tc.level : Level0 1289 */ 1290 it('testPathContainsNormal', DEFAULT, () => { 1291 const msg = 'testPathContainsNormal'; 1292 1293 try { 1294 let path = new drawing.Path(); 1295 let rect: common2D.Rect = { 1296 left: 50, top: 50, right: 250, bottom: 250 1297 }; 1298 path.addRect(rect, drawing.PathDirection.CLOCKWISE); 1299 expect(path.contains(0, 0)).assertEqual(false); 1300 expect(path.contains(50, 50)).assertEqual(true); 1301 expect(path.contains(60.1, 60.1)).assertEqual(true); 1302 expect(path.contains(-10, -10)).assertEqual(false); 1303 console.info(msg + 'reset successes.'); 1304 } catch (e) { 1305 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1306 expect().assertFail() 1307 } 1308 }) 1309 1310 /** 1311 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1501 1312 * @tc.name : testPathContainsMultipleCalls 1313 * @tc.desc : testPathContainsMultipleCalls 1314 * @tc.size : MediumTest 1315 * @tc.type : Function 1316 * @tc.level : Level3 1317 */ 1318 it('testPathContainsMultipleCalls', DEFAULT, () => { 1319 const msg = 'testPathContainsMultipleCalls'; 1320 1321 try { 1322 let path = new drawing.Path(); 1323 for (let i = 0; i < 20; i += 1) { 1324 let rect: common2D.Rect = { 1325 left: 50, top: 50, right: 250, bottom: 250 1326 }; 1327 path.addRect(rect, drawing.PathDirection.CLOCKWISE); 1328 const val = path.contains(Math.random() * 200 + 50, Math.random() * 200 + 50); 1329 expect(val).assertEqual(true); 1330 } 1331 console.info(msg + 'reset successes'); 1332 } catch (e) { 1333 console.info(msg + `reset errorCode is: ${e.code} + errormsg is: ${e.message}`); 1334 expect().assertFail() 1335 } 1336 }) 1337 1338 1339 /** 1340 * @tc.number : SUB_BASIC_GRAPHICS_SPECIAL_API_TS_DRAWING_PATH_1502 1341 * @tc.name : testPathContainsToNull 1342 * @tc.desc : testPathContainsToNull 1343 * @tc.size : MediumTest 1344 * @tc.type : Function 1345 * @tc.level : Level3 1346 */ 1347 it('testPathContainsToNull', DEFAULT, () => { 1348 const msg = 'testPathContainsToNull'; 1349 const path = new drawing.Path(); 1350 1351 try { 1352 path.contains(null, 100); 1353 console.info(msg + `reset error`); 1354 expect().assertFail() 1355 } catch (e) { 1356 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1357 expect(e.code).assertEqual(401); 1358 } 1359 1360 try { 1361 path.contains(100, null); 1362 console.info(msg + `reset error`); 1363 expect().assertFail() 1364 } catch (e) { 1365 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1366 expect(e.code).assertEqual(401); 1367 } 1368 1369 try { 1370 path.contains(undefined, 100); 1371 console.info(msg + `reset error`); 1372 expect().assertFail() 1373 } catch (e) { 1374 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1375 expect(e.code).assertEqual(401); 1376 } 1377 1378 try { 1379 path.contains(100, undefined); 1380 console.info(msg + `reset error`); 1381 expect().assertFail() 1382 } catch (e) { 1383 console.info(msg + `reset successes. errorCode is: ${e.code} + errormsg is: ${e.message}}`); 1384 expect(e.code).assertEqual(401); 1385 } 1386 }) 1387 1388 }) 1389}