1/* 2 * Copyright (c) 2022 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 "@ohos/hypium" 16import { RenderNode, DrawContext } from "@ohos.arkui.node" 17import drawing from "@ohos.graphics.drawing" 18import common2D from "@ohos.graphics.common2D" 19import image from "@ohos.multimedia.image" 20import { UiDriver, BY, ON, PointerMatrix } from '@ohos.UiTest' 21import { BusinessError } from '@ohos.base'; 22import buffer from '@ohos.buffer'; 23 24export default function graphicDrawing(context, windowStage, abilityStorage) { 25 describe('drawing_pressure_test', function () { 26 console.log('describe graphic_drawing_test start!!!') 27 28 function buttonClick(buttonText, msgStr) { 29 console.info(msgStr + `case come in buttonClick fun`) 30 return new Promise(async (resolve, reject) => { 31 let driver = await UiDriver.create() 32 console.info(msgStr + `case come in buttonClick fun 222`) 33 console.info(msgStr + `driver is ${JSON.stringify(driver)}`) 34 await sleep(1000) 35 console.info(msgStr + `UiDriver start`) 36 let button = null 37 button = await driver.findComponent(BY.text(buttonText)) 38 console.info(msgStr + `button is ${JSON.stringify(button)}`) 39 await sleep(1000) 40 if (button) { 41 console.info(msgStr + `button click begin`) 42 await button.click() 43 console.info(msgStr + `button click end`) 44 resolve(msgStr + 'get button successed') 45 } else { 46 console.info(msgStr + `inter else: button is null`) 47 reject(msgStr + 'get button failed') 48 } 49 }) 50 } 51 52 async function sleep(time) { 53 let timeoutId = null; 54 let promise = new Promise(resolve => { 55 timeoutId = setTimeout(() => { 56 resolve('sleep finished'); 57 }, time); 58 }) 59 let result = await promise; 60 clearTimeout(timeoutId) 61 } 62 63 let pressureTestNum = 100; 64 let blendModeArr = ['CLEAR', 'SRC', 'DST', 'SRC_OVER', 'DST_OVER', 'SRC_IN', 'DST_IN', 'SRC_OUT', 65 'DST_OUT', 'SRC_ATOP', 'DST_ATOP', 'XOR', 'PLUS', 'MODULATE', 'SCREEN', 'OVERLAY', 'DARKEN', 66 'LIGHTEN', 'COLOR_DODGE', 'COLOR_BURN', 'HARD_LIGHT', 'SOFT_LIGHT', 'DIFFERENCE', 'EXCLUSION', 67 'MULTIPLY', 'HUE', 'SATURATION', 'COLOR', 'LUMINOSITY'] 68 let pixel; 69 beforeAll(async function () { 70 const color: ArrayBuffer = new ArrayBuffer(40000); // 96为需要创建的像素buffer大小,取值为:height * width *4 71 let opts: image.InitializationOptions = { 72 editable: true, pixelFormat: 3, size: { 73 height: 100, width: 100 74 } 75 } 76 pixel = await image.createPixelMap(color, opts); 77 }) 78 /** 79 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2650 80 * @tc.name : testPath_LineTo_PressureTest 81 * @tc.desc : Used to add a line segment from the last point of the path to the destination point 82 * @tc.size : MediumTest 83 * @tc.type : Function 84 * @tc.level : Level 3 85 */ 86 it('testPath_LineTo_PressureTest', 0, async function () { 87 let msg = "testPath_LineTo_PressureTest" 88 console.info(msg + 'begin'); 89 let path = new drawing.Path(); 90 for (let i = 0;i < pressureTestNum; i++) { 91 console.log(msg + 'step is: ' + i) 92 try { 93 path.moveTo(10, 10); 94 } catch (err) { 95 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 96 expect().assertFail(); 97 } 98 try { 99 path.lineTo(10, 15); 100 } catch (err) { 101 console.info(msg + 'lineTo error cause: ' + JSON.stringify(err)); 102 expect().assertFail(); 103 } 104 try { 105 path.close(); 106 } catch (err) { 107 console.info(msg + 'close error cause: ' + JSON.stringify(err)); 108 expect().assertFail(); 109 } 110 } 111 }) 112 /** 113 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2660 114 * @tc.name : testPath_ArcTo_PressureTest 115 * @tc.desc : Used to add an arc to a path 116 * @tc.size : MediumTest 117 * @tc.type : Function 118 * @tc.level : Level 3 119 */ 120 it('testPath_ArcTo_PressureTest', 0, async function () { 121 let msg = "testPath_ArcTo_PressureTest" 122 console.info(msg + 'begin'); 123 let path = new drawing.Path(); 124 for (let i = 0;i < pressureTestNum; i++) { 125 console.log(msg + 'step is: ' + i) 126 try { 127 path.moveTo(10, 10); 128 } catch (err) { 129 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 130 expect().assertFail(); 131 } 132 try { 133 path.arcTo(10, 15, 10, 10, 10, 10); 134 } catch (err) { 135 console.info(msg + 'arcTo error cause: ' + JSON.stringify(err)); 136 expect().assertFail(); 137 } 138 try { 139 path.close(); 140 } catch (err) { 141 console.info(msg + 'close error cause: ' + JSON.stringify(err)); 142 expect().assertFail(); 143 } 144 } 145 }) 146 /** 147 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2670 148 * @tc.name : testPath_QuadTo_PressureTest 149 * @tc.desc : Used to add a second order Bessel smooth curve from the last point of the path to the destination point 150 * @tc.size : MediumTest 151 * @tc.type : Function 152 * @tc.level : Level 3 153 */ 154 it('testPath_QuadTo_PressureTest', 0, async function () { 155 let msg = "testPath_QuadTo_PressureTest" 156 console.info(msg + 'begin'); 157 let path = new drawing.Path(); 158 for (let i = 0;i < pressureTestNum; i++) { 159 console.log(msg + 'step is: ' + i) 160 try { 161 path.moveTo(10, 10); 162 } catch (err) { 163 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 164 expect().assertFail(); 165 } 166 try { 167 path.quadTo(10, 15, 10, 10); 168 } catch (err) { 169 console.info(msg + 'quadTo error cause: ' + JSON.stringify(err)); 170 expect().assertFail(); 171 } 172 try { 173 path.close(); 174 } catch (err) { 175 console.info(msg + 'close error cause: ' + JSON.stringify(err)); 176 expect().assertFail(); 177 } 178 } 179 }) 180 /** 181 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2680 182 * @tc.name : testPath_CubicTo_PressureTest 183 * @tc.desc : Third order Bessel smooth curve 184 * @tc.size : MediumTest 185 * @tc.type : Function 186 * @tc.level : Level 3 187 */ 188 it('testPath_CubicTo_PressureTest', 0, async function () { 189 let msg = "testPath_CubicTo_PressureTest" 190 console.info(msg + 'begin'); 191 let path = new drawing.Path(); 192 for (let i = 0;i < pressureTestNum; i++) { 193 console.log(msg + 'step is: ' + i) 194 try { 195 path.moveTo(10, 10); 196 } catch (err) { 197 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 198 expect().assertFail(); 199 } 200 try { 201 path.cubicTo(10, 10, 10, 10, 15, 15); 202 } catch (err) { 203 console.info(msg + 'cubicTo error cause: ' + JSON.stringify(err)); 204 expect().assertFail(); 205 } 206 try { 207 path.close(); 208 } catch (err) { 209 console.info(msg + 'close error cause: ' + JSON.stringify(err)); 210 expect().assertFail(); 211 } 212 } 213 }) 214 /** 215 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3010 216 * @tc.name : testPath_Reset_PressureTest 217 * @tc.desc : Used to reset custom path data 218 * @tc.size : MediumTest 219 * @tc.type : Function 220 * @tc.level : Level 3 221 */ 222 it('testPath_Reset_PressureTest', 0, async function () { 223 let msg = "testPath_Reset_PressureTest" 224 console.info(msg + 'begin'); 225 let path = new drawing.Path(); 226 for (let i = 0;i < pressureTestNum; i++) { 227 console.log(msg + 'step is: ' + i) 228 try { 229 path.moveTo(10, 10); 230 } catch (err) { 231 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 232 expect().assertFail(); 233 } 234 try { 235 path.cubicTo(10, 10, 10, 10, 15, 15); 236 } catch (err) { 237 console.info(msg + 'cubicTo error cause: ' + JSON.stringify(err)); 238 expect().assertFail(); 239 } 240 try { 241 path.reset(); 242 } catch (err) { 243 console.info(msg + 'reset error cause: ' + JSON.stringify(err)); 244 expect().assertFail(); 245 } 246 } 247 }) 248 /** 249 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2690 250 * @tc.name : testCanvas_DrawRect_PressureTest 251 * @tc.desc : Used to draw a rectangle 252 * @tc.size : MediumTest 253 * @tc.type : Function 254 * @tc.level : Level 3 255 */ 256 it('testCanvas_DrawRect_PressureTest', 0, async function () { 257 let msg = "testCanvas_DrawRect_PressureTest" 258 console.info(msg + 'begin'); 259 let canvas = new drawing.Canvas(pixel) 260 console.info(msg + 'canvas is: ' + JSON.stringify(canvas)); 261 const pen = new drawing.Pen(); 262 try { 263 pen.setStrokeWidth(5); 264 console.info(msg + 'setStrokeWidth successed'); 265 } catch (err) { 266 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 267 expect().assertFail(); 268 } 269 try { 270 pen.setColor({ 271 alpha: 255, red: 255, green: 0, blue: 0 272 }); 273 console.info(msg + 'setColor successed'); 274 } catch (err) { 275 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 276 expect().assertFail(); 277 } 278 for (let i = 0;i < pressureTestNum; i++) { 279 console.log(msg + 'step is: ' + i) 280 try { 281 canvas.attachPen(pen); 282 console.info(msg + 'attachPen successed'); 283 } catch (err) { 284 console.info(msg + `attachPen errorCode is: ${err.code} + errormsg is: ${err.message}`); 285 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 286 expect().assertFail(); 287 } 288 try { 289 canvas.drawRect({ 290 left: 0, right: 0, top: 10, bottom: 10 291 }); 292 console.info(msg + 'drawRect successed'); 293 } catch (err) { 294 console.info(msg + `drawRect errorCode is: ${err.code} + errorMsg is: ${err.message}`); 295 expect().assertFail(); 296 } 297 try { 298 canvas.detachPen(); 299 console.info(msg + 'detachPen successed'); 300 } catch (err) { 301 console.info(msg + `detachPen errorCode is: ${err.code} + errorMsg is: ${err.message}`); 302 expect().assertFail(); 303 } 304 } 305 }) 306 /** 307 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2700 308 * @tc.name : testCanvas_DrawCircle_PressureTest 309 * @tc.desc : Used to draw a circle 310 * @tc.size : MediumTest 311 * @tc.type : Function 312 * @tc.level : Level 3 313 */ 314 it('testCanvas_DrawCircle_PressureTest', 0, async function () { 315 let msg = "testCanvas_DrawCircle_PressureTest" 316 console.info(msg + 'begin'); 317 let canvas = new drawing.Canvas(pixel) 318 console.info(msg + 'canvas is: ' + JSON.stringify(canvas)); 319 const pen = new drawing.Pen(); 320 try { 321 pen.setStrokeWidth(5); 322 console.info(msg + 'setStrokeWidth successed'); 323 } catch (err) { 324 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 325 expect().assertFail(); 326 } 327 try { 328 pen.setColor({ 329 alpha: 255, red: 255, green: 0, blue: 0 330 }); 331 console.info(msg + 'setColor successed'); 332 } catch (err) { 333 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 334 expect().assertFail(); 335 } 336 for (let i = 0;i < pressureTestNum; i++) { 337 console.log(msg + 'step is: ' + i) 338 try { 339 canvas.attachPen(pen); 340 console.info(msg + 'attachPen successed'); 341 } catch (err) { 342 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 343 expect().assertFail(); 344 } 345 try { 346 canvas.drawCircle(10, 10, 2); 347 console.info(msg + 'drawCircle successed'); 348 } catch (err) { 349 console.info(msg + 'drawCircle error cause: ' + JSON.stringify(err)); 350 expect().assertFail(); 351 } 352 try { 353 canvas.detachPen(); 354 console.info(msg + 'detachPen successed'); 355 } catch (err) { 356 console.info(msg + 'detachPen error cause: ' + JSON.stringify(err)); 357 expect().assertFail(); 358 } 359 } 360 }) 361 /** 362 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2710 363 * @tc.name : testCanvas_DrawImage_PressureTest 364 * @tc.desc : Used to draw a picture 365 * @tc.size : MediumTest 366 * @tc.type : Function 367 * @tc.level : Level 3 368 */ 369 it('testCanvas_DrawImage_PressureTest', 0, async function () { 370 let msg = "testCanvas_DrawImage_PressureTest" 371 console.info(msg + 'begin'); 372 await buttonClick('UpdateDrawNode', msg).catch(async err => { 373 console.info(msg + err); 374 expect().assertFail(); 375 }) 376 let pixelMap_: image.PixelMap | null = null; 377 //96为需要创建的像素buffer大小,取值为:height * width *4 378 const color: ArrayBuffer = new ArrayBuffer(96); 379 let opts: image.InitializationOptions = { 380 editable: true, pixelFormat: 3, size: { 381 height: 4, width: 6 382 } 383 } 384 await image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => { 385 pixelMap_ = pixelMap 386 console.info(msg + 'Succeeded in creating pixelmap.'); 387 }).catch((error: BusinessError) => { 388 console.error(msg + 'Failed to create pixelmap.'); 389 expect().assertFail(); 390 }) 391 392 let canvas = new drawing.Canvas(pixelMap_) 393 console.info(msg + 'canvas is: ' + JSON.stringify(canvas)); 394 for (let i = 0;i < pressureTestNum; i++) { 395 console.log(msg + 'step is: ' + i) 396 try { 397 canvas.drawImage(pixelMap_, 0, 0); 398 console.info(msg + 'drawImage successed'); 399 } catch (err) { 400 console.info(msg + 'drawImage error cause: ' + JSON.stringify(err)); 401 expect().assertFail(); 402 } 403 } 404 }) 405 /** 406 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2720 407 * @tc.name : testCanvas_DrawColor_PressureTest 408 * @tc.desc : Paint background color 409 * @tc.size : MediumTest 410 * @tc.type : Function 411 * @tc.level : Level 3 412 */ 413 it('testCanvas_DrawColor_PressureTest', 0, async function () { 414 let msg = "testCanvas_DrawColor_PressureTest" 415 console.info(msg + 'begin'); 416 let canvas = new drawing.Canvas(pixel) 417 let color: common2D.Color = { 418 alpha: 255, 419 red: 0, 420 green: 10, 421 blue: 10 422 } 423 for (let i = 0;i < pressureTestNum; i++) { 424 console.log(msg + 'step is: ' + i) 425 try { 426 canvas.drawColor(color, drawing.BlendMode.CLEAR); 427 console.info(msg + 'drawColor successed'); 428 } catch (err) { 429 console.info(msg + 'drawColor error cause: ' + JSON.stringify(err)); 430 expect().assertFail(); 431 } 432 } 433 }) 434 /** 435 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2730 436 * @tc.name : testCanvas_DrawPoint_PressureTest 437 * @tc.desc : Used to draw a point 438 * @tc.size : MediumTest 439 * @tc.type : Function 440 * @tc.level : Level 3 441 */ 442 it('testCanvas_DrawPoint_PressureTest', 0, async function () { 443 let msg = "testCanvas_DrawPoint_PressureTest" 444 console.info(msg + 'begin'); 445 let canvas = new drawing.Canvas(pixel) 446 const pen = new drawing.Pen(); 447 try { 448 pen.setStrokeWidth(5); 449 console.info(msg + 'setStrokeWidth successed'); 450 } catch (err) { 451 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 452 expect().assertFail(); 453 } 454 try { 455 pen.setColor({ 456 alpha: 255, red: 255, green: 0, blue: 0 457 }); 458 console.info(msg + 'setColor successed'); 459 } catch (err) { 460 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 461 expect().assertFail(); 462 } 463 try { 464 canvas.attachPen(pen); 465 console.info(msg + 'attachPen successed'); 466 } catch (err) { 467 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 468 expect().assertFail(); 469 } 470 for (let i = 0;i < pressureTestNum; i++) { 471 console.log(msg + 'step is: ' + i) 472 try { 473 canvas.drawPoint(10, 10); 474 console.info(msg + 'drawPoint successed'); 475 } catch (err) { 476 console.info(msg + 'drawPoint error cause: ' + JSON.stringify(err)); 477 expect().assertFail(); 478 } 479 } 480 try { 481 canvas.detachPen(); 482 console.info(msg + 'detachPen successed'); 483 } catch (err) { 484 console.info(msg + 'detachPen error cause: ' + JSON.stringify(err)); 485 expect().assertFail(); 486 } 487 }) 488 /** 489 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2740 490 * @tc.name : testCanvas_DrawPath_PressureTest 491 * @tc.desc : Used to draw a custom path 492 * @tc.size : MediumTest 493 * @tc.type : Function 494 * @tc.level : Level 3 495 */ 496 it('testCanvas_DrawPath_PressureTest', 0, async function () { 497 let msg = "testCanvas_DrawPath_PressureTest" 498 console.info(msg + 'begin'); 499 let canvas = new drawing.Canvas(pixel) 500 const pen = new drawing.Pen(); 501 let path = new drawing.Path(); 502 try { 503 pen.setStrokeWidth(5); 504 console.info(msg + 'setStrokeWidth successed'); 505 } catch (err) { 506 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 507 expect().assertFail(); 508 } 509 try { 510 pen.setColor({ 511 alpha: 255, red: 255, green: 0, blue: 0 512 }); 513 console.info(msg + 'setColor successed'); 514 } catch (err) { 515 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 516 expect().assertFail(); 517 } 518 try { 519 path.moveTo(10, 10); 520 console.info(msg + 'moveTo successed'); 521 } catch (err) { 522 console.info(msg + 'moveTo error cause: ' + JSON.stringify(err)); 523 expect().assertFail(); 524 } 525 try { 526 path.cubicTo(10, 10, 10, 10, 15, 15); 527 console.info(msg + 'cubicTo successed'); 528 } catch (err) { 529 console.info(msg + 'cubicTo error cause: ' + JSON.stringify(err)); 530 expect().assertFail(); 531 } 532 try { 533 path.close(); 534 console.info(msg + 'close successed'); 535 } catch (err) { 536 console.info(msg + 'close error cause: ' + JSON.stringify(err)); 537 expect().assertFail(); 538 } 539 try { 540 canvas.attachPen(pen); 541 console.info(msg + 'attachPen successed'); 542 } catch (err) { 543 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 544 expect().assertFail(); 545 } 546 for (let i = 0;i < pressureTestNum; i++) { 547 console.log(msg + 'step is: ' + i) 548 try { 549 canvas.drawPath(path); 550 console.info(msg + 'drawPath successed'); 551 } catch (err) { 552 console.info(msg + 'drawPath error cause: ' + JSON.stringify(err)); 553 expect().assertFail(); 554 } 555 } 556 try { 557 canvas.detachPen(); 558 console.info(msg + 'detachPen successed'); 559 } catch (err) { 560 console.info(msg + 'detachPen error cause: ' + JSON.stringify(err)); 561 expect().assertFail(); 562 } 563 }) 564 /** 565 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2750 566 * @tc.name : testCanvas_DrawLine_PressureTest 567 * @tc.desc : Used to draw a straight line segment 568 * @tc.size : MediumTest 569 * @tc.type : Function 570 * @tc.level : Level 3 571 */ 572 it('testCanvas_DrawLine_PressureTest', 0, async function () { 573 let msg = "testCanvas_DrawLine_PressureTest" 574 console.info(msg + 'begin'); 575 576 let canvas = new drawing.Canvas(pixel) 577 const pen = new drawing.Pen(); 578 try { 579 pen.setStrokeWidth(5); 580 console.info(msg + 'setStrokeWidth successed'); 581 } catch (err) { 582 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 583 expect().assertFail(); 584 } 585 try { 586 pen.setColor({ 587 alpha: 255, red: 255, green: 0, blue: 0 588 }); 589 console.info(msg + 'setColor successed'); 590 } catch (err) { 591 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 592 expect().assertFail(); 593 } 594 try { 595 canvas.attachPen(pen); 596 console.info(msg + 'attachPen successed'); 597 } catch (err) { 598 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 599 expect().assertFail(); 600 } 601 for (let i = 0;i < pressureTestNum; i++) { 602 console.log(msg + 'step is: ' + i) 603 try { 604 canvas.drawLine(0, 0, 20, 20); 605 console.info(msg + 'drawLine successed'); 606 } catch (err) { 607 console.info(msg + 'drawLine error cause: ' + JSON.stringify(err)); 608 expect().assertFail(); 609 } 610 } 611 try { 612 canvas.detachPen(); 613 console.info(msg + 'detachPen successed'); 614 } catch (err) { 615 console.info(msg + 'detachPen error cause: ' + JSON.stringify(err)); 616 expect().assertFail(); 617 } 618 }) 619 /** 620 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2900 621 * @tc.name : testCanvas_DrawLine_PressureTest_Second 622 * @tc.desc : Used to draw a straight line segment 623 * @tc.size : MediumTest 624 * @tc.type : Function 625 * @tc.level : Level 3 626 */ 627 it('testCanvas_DrawLine_PressureTest_Second', 0, async function () { 628 let msg = "testCanvas_DrawLine_PressureTest_Second" 629 console.info(msg + 'begin'); 630 for (let i = 0;i < pressureTestNum; i++) { 631 console.log(msg + 'step is: ' + i) 632 let canvas = new drawing.Canvas(pixel) 633 const pen = new drawing.Pen(); 634 try { 635 pen.setStrokeWidth(5); 636 console.info(msg + 'setStrokeWidth successed'); 637 } catch (err) { 638 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 639 expect().assertFail(); 640 } 641 try { 642 pen.setColor({ 643 alpha: 255, red: 255, green: 0, blue: 0 644 }); 645 console.info(msg + 'setColor successed'); 646 } catch (err) { 647 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 648 expect().assertFail(); 649 } 650 try { 651 canvas.attachPen(pen); 652 console.info(msg + 'attachPen successed'); 653 } catch (err) { 654 console.info(msg + 'attachPen error cause: ' + JSON.stringify(err)); 655 expect().assertFail(); 656 } 657 try { 658 canvas.drawLine(0, 0, 20, 20); 659 console.info(msg + 'drawLine successed'); 660 } catch (err) { 661 console.info(msg + 'drawLine error cause: ' + JSON.stringify(err)); 662 expect().assertFail(); 663 } 664 try { 665 canvas.detachPen(); 666 console.info(msg + 'detachPen successed'); 667 } catch (err) { 668 console.info(msg + 'detachPen error cause: ' + JSON.stringify(err)); 669 expect().assertFail(); 670 } 671 } 672 }) 673 /** 674 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2770 675 * @tc.name : testTextBlob_MakeFromString_PressureTest 676 * @tc.desc : Converts a string value to a TextBlob object 677 * @tc.size : MediumTest 678 * @tc.type : Function 679 * @tc.level : Level 3 680 */ 681 it('testTextBlob_MakeFromString_PressureTest', 0, async function () { 682 let msg = "testTextBlob_MakeFromString_PressureTest" 683 console.info(msg + 'begin'); 684 let font = new drawing.Font(); 685 try { 686 font.setSize(20); 687 } catch (err) { 688 console.info(msg + 'font setSize error cause: ' + JSON.stringify(err)); 689 expect().assertFail(); 690 } 691 for (let i = 0;i < pressureTestNum; i++) { 692 console.log(msg + 'step is: ' + i) 693 try { 694 const textBlob = drawing.TextBlob.makeFromString("drawing", font, drawing.TextEncoding.TEXT_ENCODING_UTF8); 695 expect(textBlob != null).assertTrue(); 696 } catch (err) { 697 console.info(msg + 'makeFromString error cause: ' + JSON.stringify(err)); 698 expect().assertFail(); 699 } 700 } 701 }) 702 /** 703 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2780 704 * @tc.name : testTextBlob_MakeFromRunBuffer_PressureTest 705 * @tc.desc : Create a Textblob object based on the RunBuffer information 706 * @tc.size : MediumTest 707 * @tc.type : Function 708 * @tc.level : Level 3 709 */ 710 it('testTextBlob_MakeFromRunBuffer_PressureTest', 0, async function () { 711 let msg = "testTextBlob_MakeFromRunBuffer_PressureTest" 712 console.info(msg + 'begin'); 713 let runBuffer = null; 714 let textBlob = null 715 let canvas = new drawing.Canvas(pixel) 716 const font = new drawing.Font(); 717 const brush = new drawing.Brush(); 718 try { 719 font.setSize(20); 720 } catch (err) { 721 console.info(msg + 'font setSize error cause: ' + JSON.stringify(err)); 722 expect().assertFail(); 723 } 724 runBuffer = [ 725 { 726 glyph: 65, positionX: 0, positionY: 0 727 }, 728 { 729 glyph: 227, positionX: 14.9, positionY: 0 730 }, 731 { 732 glyph: 283, positionX: 25.84, positionY: 0 733 }, 734 { 735 glyph: 283, positionX: 30.62, positionY: 0 736 }, 737 { 738 glyph: 299, positionX: 35.4, positionY: 0 739 } 740 ]; 741 for (let i = 0;i < pressureTestNum; i++) { 742 console.log(msg + 'step is: ' + i) 743 try { 744 textBlob = drawing.TextBlob.makeFromRunBuffer(runBuffer, font, null); 745 } catch (err) { 746 console.info(msg + 'makeFromRunBuffer error cause: ' + JSON.stringify(err)); 747 expect().assertFail(); 748 } 749 try { 750 brush.setColor({ 751 alpha: 255, red: 255, green: 0, blue: 0 752 }); 753 } catch (err) { 754 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 755 expect().assertFail(); 756 } 757 try { 758 canvas.attachBrush(brush); 759 } catch (err) { 760 console.info(msg + 'attachBrush error cause: ' + JSON.stringify(err)); 761 expect().assertFail(); 762 } 763 try { 764 canvas.drawTextBlob(textBlob, 20, 20); 765 } catch (err) { 766 console.info(msg + 'drawTextBlob error cause: ' + JSON.stringify(err)); 767 expect().assertFail(); 768 } 769 try { 770 canvas.detachBrush(); 771 } catch (err) { 772 console.info(msg + 'detachBrush error cause: ' + JSON.stringify(err)); 773 expect().assertFail(); 774 } 775 } 776 }) 777 /** 778 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3020 779 * @tc.name : testTextBlob_Bounds_PressureTest 780 * @tc.desc : Gets the rectangular area of the text bounding box 781 * @tc.size : MediumTest 782 * @tc.type : Function 783 * @tc.level : Level 3 784 */ 785 it('testTextBlob_Bounds_PressureTest', 0, async function () { 786 let msg = "testTextBlob_Bounds_PressureTest" 787 console.info(msg + 'begin'); 788 const font = new drawing.Font(); 789 for (let i = 0;i < pressureTestNum; i++) { 790 console.log(msg + 'step is: ' + i) 791 let textBlob = null 792 try { 793 textBlob = drawing.TextBlob.makeFromString("drawing", font, drawing.TextEncoding.TEXT_ENCODING_UTF8); 794 expect(textBlob != null).assertTrue(); 795 } catch (err) { 796 console.info(msg + 'makeFromString error cause: ' + JSON.stringify(err)); 797 expect().assertFail(); 798 } 799 try { 800 let bd = textBlob.bounds(); 801 expect(bd != null).assertTrue(); 802 } catch (err) { 803 console.info(msg + 'bounds error cause: ' + JSON.stringify(err)); 804 expect().assertFail(); 805 } 806 } 807 }) 808 /** 809 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2790 810 * @tc.name : testTypeface_GetFamilyName_PressureTest 811 * @tc.desc : Gets the series name of the font 812 * @tc.size : MediumTest 813 * @tc.type : Function 814 * @tc.level : Level 3 815 */ 816 it('testTypeface_GetFamilyName_PressureTest', 0, async function () { 817 let msg = "testTypeface_GetFamilyName_PressureTest" 818 console.info(msg + 'begin'); 819 const font = new drawing.Font(); 820 let typeface = null; 821 try { 822 typeface = font.getTypeface(); 823 } catch (err) { 824 console.info(msg + 'getTypeface error cause: ' + JSON.stringify(err)); 825 expect().assertFail(); 826 } 827 for (let i = 0;i < pressureTestNum; i++) { 828 console.log(msg + 'step is: ' + i) 829 try { 830 const fontFamilyName = typeface.getFamilyName(); 831 expect(fontFamilyName != null).assertTrue(); 832 } catch (err) { 833 console.info(msg + 'getFamilyName error cause: ' + JSON.stringify(err)); 834 expect().assertFail(); 835 } 836 } 837 }) 838 /** 839 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2800 840 * @tc.name : testFont_EnableSubpixel_PressureTest 841 * @tc.desc : Enable font subpixel level text rendering 842 * @tc.size : MediumTest 843 * @tc.type : Function 844 * @tc.level : Level 3 845 */ 846 it('testFont_EnableSubpixel_PressureTest', 0, async function () { 847 let msg = "testFont_EnableSubpixel_PressureTest" 848 console.info(msg + 'begin'); 849 let font = new drawing.Font(); 850 for (let i = 0;i < pressureTestNum; i++) { 851 console.log(msg + 'step is: ' + i) 852 try { 853 font.enableSubpixel(true); 854 } catch (err) { 855 console.info(msg + 'enableSubpixel error cause: ' + JSON.stringify(err)); 856 expect().assertFail(); 857 } 858 } 859 }) 860 /** 861 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2810 862 * @tc.name : testFont_EnableEmbolden_PressureTest 863 * @tc.desc : Enable font bold 864 * @tc.size : MediumTest 865 * @tc.type : Function 866 * @tc.level : Level 3 867 */ 868 it('testFont_EnableEmbolden_PressureTest', 0, async function () { 869 let msg = "testFont_EnableEmbolden_PressureTest" 870 console.info(msg + 'begin'); 871 const font = new drawing.Font(); 872 for (let i = 0;i < pressureTestNum; i++) { 873 console.log(msg + 'step is: ' + i) 874 try { 875 font.enableEmbolden(true); 876 } catch (err) { 877 console.info(msg + 'enableEmbolden error cause: ' + JSON.stringify(err)); 878 expect().assertFail(); 879 } 880 } 881 }) 882 /** 883 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2820 884 * @tc.name : testFont_EnableLinearMetrics_PressureTest 885 * @tc.desc : Enable linear scaling of glyphs 886 * @tc.size : MediumTest 887 * @tc.type : Function 888 * @tc.level : Level 3 889 */ 890 it('testFont_EnableLinearMetrics_PressureTest', 0, async function () { 891 let msg = "testFont_EnableLinearMetrics_PressureTest" 892 console.info(msg + 'begin'); 893 let font = new drawing.Font(); 894 for (let i = 0;i < pressureTestNum; i++) { 895 console.log(msg + 'step is: ' + i) 896 try { 897 font.enableLinearMetrics(true); 898 } catch (err) { 899 console.info(msg + 'enableLinearMetrics error cause: ' + JSON.stringify(err)); 900 expect().assertFail(); 901 } 902 } 903 }) 904 /** 905 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2830 906 * @tc.name : testFont_SetSize_PressureTest 907 * @tc.desc : Set font size 908 * @tc.size : MediumTest 909 * @tc.type : Function 910 * @tc.level : Level 3 911 */ 912 it('testFont_SetSize_PressureTest', 0, async function () { 913 let msg = "testFont_SetSize_PressureTest" 914 console.info(msg + 'begin'); 915 let font = new drawing.Font(); 916 for (let i = 0;i < pressureTestNum; i++) { 917 console.log(msg + 'step is: ' + i) 918 try { 919 font.setSize(i); 920 } catch (err) { 921 console.info(msg + 'setSize error cause: ' + JSON.stringify(err)); 922 expect().assertFail(); 923 } 924 try { 925 let num = font.getSize(); 926 expect(num).assertEqual(i) 927 } catch (err) { 928 console.info(msg + 'getSize error cause: ' + JSON.stringify(err)); 929 expect().assertFail(); 930 } 931 } 932 }) 933 /** 934 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2840 935 * @tc.name : testFont_SetTypeface_PressureTest 936 * @tc.desc : Set font 937 * @tc.size : MediumTest 938 * @tc.type : Function 939 * @tc.level : Level 3 940 */ 941 it('testFont_SetTypeface_PressureTest', 0, async function () { 942 let msg = "testFont_SetTypeface_PressureTest" 943 console.info(msg + 'begin'); 944 const font = new drawing.Font(); 945 for (let i = 0;i < pressureTestNum; i++) { 946 console.log(msg + 'step is: ' + i) 947 try { 948 font.setTypeface(new drawing.Typeface()); 949 } catch (err) { 950 console.info(msg + 'setTypeface error cause: ' + JSON.stringify(err)); 951 expect().assertFail(); 952 } 953 } 954 }) 955 /** 956 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2850 957 * @tc.name : testFont_GetTypeface_PressureTest 958 * @tc.desc : Get font 959 * @tc.size : MediumTest 960 * @tc.type : Function 961 * @tc.level : Level 3 962 */ 963 it('testFont_GetTypeface_PressureTest', 0, async function () { 964 let msg = "testFont_GetTypeface_PressureTest" 965 console.info(msg + 'begin'); 966 const font = new drawing.Font(); 967 for (let i = 0;i < pressureTestNum; i++) { 968 console.log(msg + 'step is: ' + i) 969 try { 970 let ft = font.getTypeface(); 971 expect(ft != null).assertTrue(); 972 } catch (err) { 973 console.info(msg + 'getTypeface error cause: ' + JSON.stringify(err)); 974 expect().assertFail(); 975 } 976 } 977 }) 978 /** 979 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2860 980 * @tc.name : testFont_GetMetrics_PressureTest 981 * @tc.desc : Gets the FontMetrics property associated with the font 982 * @tc.size : MediumTest 983 * @tc.type : Function 984 * @tc.level : Level 3 985 */ 986 it('testFont_GetMetrics_PressureTest', 0, async function () { 987 let msg = "testFont_GetMetrics_PressureTest" 988 console.info(msg + 'begin'); 989 const font = new drawing.Font(); 990 for (let i = 0;i < pressureTestNum; i++) { 991 console.log(msg + 'step is: ' + i) 992 try { 993 let metrics = font.getMetrics(); 994 expect(metrics != null).assertTrue(); 995 expect(metrics.top != null).assertTrue(); 996 expect(metrics.ascent != null).assertTrue(); 997 expect(metrics.descent != null).assertTrue(); 998 expect(metrics.bottom != null).assertTrue(); 999 expect(metrics.leading != null).assertTrue(); 1000 } catch (err) { 1001 console.info(msg + 'getMetrics error cause: ' + JSON.stringify(err)); 1002 expect().assertFail(); 1003 } 1004 } 1005 }) 1006 /** 1007 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2870 1008 * @tc.name : testFont_MeasureText_PressureTest 1009 * @tc.desc : Measure the width of text 1010 * @tc.size : MediumTest 1011 * @tc.type : Function 1012 * @tc.level : Level 3 1013 */ 1014 it('testFont_MeasureText_PressureTest', 0, async function () { 1015 let msg = "testFont_MeasureText_PressureTest" 1016 console.info(msg + 'begin'); 1017 const font = new drawing.Font(); 1018 for (let i = 0;i < pressureTestNum; i++) { 1019 console.log(msg + 'step is: ' + i) 1020 try { 1021 let TextWidth = font.measureText('testFont_MeasureText', drawing.TextEncoding.TEXT_ENCODING_UTF8); 1022 expect(TextWidth != null).assertTrue(); 1023 } catch (err) { 1024 console.info(msg + 'measureText error cause: ' + JSON.stringify(err)); 1025 expect().assertFail(); 1026 } 1027 } 1028 }) 1029 /** 1030 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2880 1031 * @tc.name : testColorFilter_CreateBlendModeColorFilter_PressureTest 1032 * @tc.desc : Creates a color filter using the specified color and blending mode 1033 * @tc.size : MediumTest 1034 * @tc.type : Function 1035 * @tc.level : Level 3 1036 */ 1037 it('testColorFilter_CreateBlendModeColorFilter_PressureTest', 0, async function () { 1038 let msg = "testColorFilter_CreateBlendModeColorFilter_PressureTest" 1039 console.info(msg + 'begin'); 1040 for (let i = 0;i < pressureTestNum; i++) { 1041 console.log(msg + 'step is: ' + i) 1042 try { 1043 const color: common2D.Color = { 1044 alpha: 255, red: 255, green: 0, blue: 0 1045 }; 1046 let colorFilter = drawing.ColorFilter.createBlendModeColorFilter(color, drawing.BlendMode.SRC); 1047 expect(colorFilter != null).assertTrue(); 1048 } catch (err) { 1049 console.info(msg + 'createBlendModeColorFilter error cause: ' + JSON.stringify(err)); 1050 expect().assertFail(); 1051 } 1052 } 1053 }) 1054 /** 1055 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2760 1056 * @tc.name : testColorFilter_CreateComposeColorFilter_PressureTest 1057 * @tc.desc : Create a combined color filter that applies inner for filtering and then outer for filtering 1058 * @tc.size : MediumTest 1059 * @tc.type : Function 1060 * @tc.level : Level 3 1061 */ 1062 it('testColorFilter_CreateComposeColorFilter_PressureTest', 0, async function () { 1063 let msg = "testColorFilter_CreateComposeColorFilter_PressureTest" 1064 console.info(msg + 'begin'); 1065 for (let i = 0;i < pressureTestNum; i++) { 1066 console.log(msg + 'step is: ' + i) 1067 try { 1068 const color: common2D.Color = { 1069 alpha: 255, red: 255, green: 0, blue: 0 1070 }; 1071 let colorFilter1 = drawing.ColorFilter.createBlendModeColorFilter(color, drawing.BlendMode.SRC); 1072 let colorFilter2 = drawing.ColorFilter.createBlendModeColorFilter(color, drawing.BlendMode.DST); 1073 let colorFilter = drawing.ColorFilter.createComposeColorFilter(colorFilter1, colorFilter2); 1074 expect(colorFilter1 != null).assertTrue(); 1075 expect(colorFilter2 != null).assertTrue(); 1076 expect(colorFilter != null).assertTrue(); 1077 } catch (err) { 1078 console.info(msg + 'createComposeColorFilter error cause: ' + JSON.stringify(err)); 1079 expect().assertFail(); 1080 } 1081 } 1082 }) 1083 /** 1084 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2890 1085 * @tc.name : testColorFilter_CreateLinearToSRGBGamma_PressureTest 1086 * @tc.desc : Create a color filter that translates from a linear color space to an SRGB color space 1087 * @tc.size : MediumTest 1088 * @tc.type : Function 1089 * @tc.level : Level 3 1090 */ 1091 it('testColorFilter_CreateLinearToSRGBGamma_PressureTest', 0, async function () { 1092 let msg = "testColorFilter_CreateLinearToSRGBGamma_PressureTest" 1093 console.info(msg + 'begin'); 1094 for (let i = 0;i < pressureTestNum; i++) { 1095 console.log(msg + 'step is: ' + i) 1096 const font = new drawing.Font(); 1097 try { 1098 let colorFilter = drawing.ColorFilter.createLinearToSRGBGamma(); 1099 expect(colorFilter != null).assertTrue(); 1100 } catch (err) { 1101 console.info(msg + 'createLinearToSRGBGamma error cause: ' + JSON.stringify(err)); 1102 expect().assertFail(); 1103 } 1104 } 1105 }) 1106 /** 1107 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2910 1108 * @tc.name : testColorFilter_CreateSRGBGammaToLinear_PressureTest 1109 * @tc.desc : Create a color filter that converts from SRGB color space to linear color space 1110 * @tc.size : MediumTest 1111 * @tc.type : Function 1112 * @tc.level : Level 3 1113 */ 1114 it('testColorFilter_CreateSRGBGammaToLinear_PressureTest', 0, async function () { 1115 let msg = "testColorFilter_CreateSRGBGammaToLinear_PressureTest" 1116 console.info(msg + 'begin'); 1117 const font = new drawing.Font(); 1118 for (let i = 0;i < pressureTestNum; i++) { 1119 console.log(msg + 'step is: ' + i) 1120 try { 1121 let colorFilter = drawing.ColorFilter.createSRGBGammaToLinear(); 1122 expect(colorFilter != null).assertTrue(); 1123 } catch (err) { 1124 console.info(msg + 'createSRGBGammaToLinear error cause: ' + JSON.stringify(err)); 1125 expect().assertFail(); 1126 } 1127 } 1128 }) 1129 /** 1130 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3030 1131 * @tc.name : testColorFilter_CreateLumaColorFilter_PressureTest 1132 * @tc.desc : Create a color filter that multiplies brightness with transparency 1133 * @tc.size : MediumTest 1134 * @tc.type : Function 1135 * @tc.level : Level 3 1136 */ 1137 it('testColorFilter_CreateLumaColorFilter_PressureTest', 0, async function () { 1138 let msg = "testColorFilter_CreateLumaColorFilter_PressureTest" 1139 console.info(msg + 'begin'); 1140 for (let i = 0;i < pressureTestNum; i++) { 1141 console.log(msg + 'step is: ' + i) 1142 try { 1143 let colorFilter = drawing.ColorFilter.createLumaColorFilter(); 1144 expect(colorFilter != null).assertTrue(); 1145 } catch (err) { 1146 console.info(msg + 'createLumaColorFilter error cause: ' + JSON.stringify(err)); 1147 expect().assertFail(); 1148 } 1149 } 1150 }) 1151 /** 1152 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2920 1153 * @tc.name : testPen_SetColor_PressureTest 1154 * @tc.desc : Used to set the color of the brush 1155 * @tc.size : MediumTest 1156 * @tc.type : Function 1157 * @tc.level : Level 3 1158 */ 1159 it('testPen_SetColor_PressureTest', 0, async function () { 1160 let msg = "testPen_SetColor_PressureTest" 1161 console.info(msg + 'begin'); 1162 const color: common2D.Color = { 1163 alpha: 255, red: 255, green: 0, blue: 0 1164 }; 1165 const pen = new drawing.Pen(); 1166 for (let i = 0;i < pressureTestNum; i++) { 1167 console.log(msg + 'step is: ' + i) 1168 try { 1169 pen.setColor(color); 1170 console.log(msg + 'setColor success') 1171 } catch (err) { 1172 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 1173 expect().assertFail(); 1174 } 1175 } 1176 }) 1177 /** 1178 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2930 1179 * @tc.name : testPen_SetStrokeWidth_PressureTest 1180 * @tc.desc : Used to set the line width of the brush 1181 * @tc.size : MediumTest 1182 * @tc.type : Function 1183 * @tc.level : Level 3 1184 */ 1185 it('testPen_SetStrokeWidth_PressureTest', 0, async function () { 1186 let msg = "testPen_SetStrokeWidth_PressureTest" 1187 console.info(msg + 'begin'); 1188 const pen = new drawing.Pen(); 1189 for (let i = 0;i < pressureTestNum; i++) { 1190 console.log(msg + 'step is: ' + i) 1191 try { 1192 pen.setStrokeWidth(5); 1193 console.log(msg + 'setStrokeWidth success') 1194 } catch (err) { 1195 console.info(msg + 'setStrokeWidth error cause: ' + JSON.stringify(err)); 1196 expect().assertFail(); 1197 } 1198 } 1199 }) 1200 /** 1201 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2940 1202 * @tc.name : testPen_SetAntiAlias_PressureTest 1203 * @tc.desc : Used to set whether the brush is anti-aliasing enabled 1204 * @tc.size : MediumTest 1205 * @tc.type : Function 1206 * @tc.level : Level 3 1207 */ 1208 it('testPen_SetAntiAlias_PressureTest', 0, async function () { 1209 let msg = "testPen_SetAntiAlias_PressureTest" 1210 console.info(msg + 'begin'); 1211 const pen = new drawing.Pen(); 1212 let bool = true 1213 for (let i = 0;i < pressureTestNum; i++) { 1214 console.log(msg + 'step is: ' + i) 1215 try { 1216 pen.setAntiAlias(bool); 1217 console.log(msg + 'setAntiAlias success ' + bool) 1218 bool = !bool; 1219 } catch (err) { 1220 console.info(msg + 'setAntiAlias error cause: ' + JSON.stringify(err)); 1221 expect().assertFail(); 1222 } 1223 } 1224 }) 1225 /** 1226 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2950 1227 * @tc.name : testPen_SetAlpha_PressureTest 1228 * @tc.desc : Used to set the transparency of the brush 1229 * @tc.size : MediumTest 1230 * @tc.type : Function 1231 * @tc.level : Level 3 1232 */ 1233 it('testPen_SetAlpha_PressureTest', 0, async function () { 1234 let msg = "testPen_SetAlpha_PressureTest" 1235 console.info(msg + 'begin'); 1236 const pen = new drawing.Pen(); 1237 let opacityNum = 0 1238 for (let i = 0;i < pressureTestNum; i++) { 1239 console.log(msg + 'step is: ' + i) 1240 try { 1241 pen.setAlpha(opacityNum); 1242 console.log(msg + 'setAlpha success opacityNum is: ' + opacityNum) 1243 } catch (err) { 1244 console.info(msg + 'setAlpha error cause: ' + JSON.stringify(err)); 1245 expect().assertFail(); 1246 } 1247 opacityNum = opacityNum > 255 ? 0 : opacityNum + 1 1248 } 1249 }) 1250 /** 1251 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3040 1252 * @tc.name : testPen_SetColorFilter_PressureTest 1253 * @tc.desc : Used to add additional color filters to the brush 1254 * @tc.size : MediumTest 1255 * @tc.type : Function 1256 * @tc.level : Level 3 1257 */ 1258 it('testPen_SetColorFilter_PressureTest', 0, async function () { 1259 let msg = "testPen_SetColorFilter_PressureTest" 1260 console.info(msg + 'begin'); 1261 for (let i = 0;i < pressureTestNum; i++) { 1262 console.log(msg + 'step is: ' + i) 1263 const pen = new drawing.Pen(); 1264 let colorFilter = null; 1265 try { 1266 colorFilter = drawing.ColorFilter.createLinearToSRGBGamma(); 1267 expect(colorFilter != null).assertTrue(); 1268 } catch (err) { 1269 console.info(msg + 'createLinearToSRGBGamma error cause: ' + JSON.stringify(err)); 1270 expect().assertFail(); 1271 } 1272 try { 1273 pen.setColorFilter(colorFilter); 1274 } catch (err) { 1275 console.info(msg + 'setColorFilter error cause: ' + JSON.stringify(err)); 1276 expect().assertFail(); 1277 } 1278 } 1279 }) 1280 /** 1281 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3050 1282 * @tc.name : testPen_SetBlendMode_AllMode_PressureTest 1283 * @tc.desc : Used to set the blending mode of the brush 1284 * @tc.size : MediumTest 1285 * @tc.type : Function 1286 * @tc.level : Level 3 1287 */ 1288 it('testPen_SetBlendMode_AllMode_PressureTest', 0, async function () { 1289 let msg = "testPen_SetBlendMode_AllMode_PressureTest" 1290 console.info(msg + 'begin'); 1291 for (let i = 0;i < pressureTestNum; i++) { 1292 console.log(msg + 'step is: ' + i) 1293 const pen = new drawing.Pen(); 1294 try { 1295 for (let i = 0;i < blendModeArr.length; i++) { 1296 pen.setBlendMode(drawing.BlendMode[blendModeArr[i]]); 1297 } 1298 } catch (err) { 1299 console.info(msg + 'setBlendMode error cause: ' + JSON.stringify(err)); 1300 expect().assertFail(); 1301 } 1302 } 1303 }) 1304 /** 1305 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2960 1306 * @tc.name : testPen_SetDither_PressureTest 1307 * @tc.desc : Turn on the shake paint effect of the brush 1308 * @tc.size : MediumTest 1309 * @tc.type : Function 1310 * @tc.level : Level 3 1311 */ 1312 it('testPen_SetDither_PressureTest', 0, async function () { 1313 let msg = "testPen_SetDither_PressureTest" 1314 console.info(msg + 'begin'); 1315 const pen = new drawing.Pen(); 1316 let bool = true 1317 for (let i = 0;i < pressureTestNum; i++) { 1318 console.log(msg + 'step is: ' + i) 1319 try { 1320 pen.setDither(true); 1321 console.log(msg + 'setDither success ' + bool) 1322 bool = !bool; 1323 } catch (err) { 1324 console.info(msg + 'setDither error cause: ' + JSON.stringify(err)); 1325 expect().assertFail(); 1326 } 1327 } 1328 }) 1329 /** 1330 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2970 1331 * @tc.name : testBrush_setColor_PressureTest 1332 * @tc.desc : Used to set the color of the brush 1333 * @tc.size : MediumTest 1334 * @tc.type : Function 1335 * @tc.level : Level 3 1336 */ 1337 it('testBrush_setColor_PressureTest', 0, async function () { 1338 let msg = "testBrush_setColor_PressureTest" 1339 console.info(msg + 'begin'); 1340 const color: common2D.Color = { 1341 alpha: 255, red: 255, green: 0, blue: 0 1342 }; 1343 const brush = new drawing.Brush(); 1344 for (let i = 0;i < pressureTestNum; i++) { 1345 console.log(msg + 'step is: ' + i) 1346 try { 1347 brush.setColor(color); 1348 console.log(msg + 'setColor success ') 1349 } catch (err) { 1350 console.info(msg + 'setColor error cause: ' + JSON.stringify(err)); 1351 expect().assertFail(); 1352 } 1353 } 1354 }) 1355 /** 1356 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2980 1357 * @tc.name : testBrush_SetAntiAlias_PressureTest 1358 * @tc.desc : Used to set whether to enable anti-aliasing of the brush 1359 * @tc.size : MediumTest 1360 * @tc.type : Function 1361 * @tc.level : Level 3 1362 */ 1363 it('testBrush_SetAntiAlias_PressureTest', 0, async function () { 1364 let msg = "testBrush_SetAntiAlias_PressureTest" 1365 console.info(msg + 'begin'); 1366 const brush = new drawing.Brush(); 1367 let bool = true 1368 for (let i = 0;i < pressureTestNum; i++) { 1369 console.log(msg + 'step is: ' + i) 1370 try { 1371 brush.setAntiAlias(true); 1372 console.log(msg + 'setAntiAlias success ' + bool) 1373 bool = !bool; 1374 } catch (err) { 1375 console.info(msg + 'setAntiAlias error cause: ' + JSON.stringify(err)); 1376 expect().assertFail(); 1377 } 1378 } 1379 }) 1380 /** 1381 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_2990 1382 * @tc.name : testBrush_SetAlpha_PressureTest 1383 * @tc.desc : Used to set the transparency of the brush 1384 * @tc.size : MediumTest 1385 * @tc.type : Function 1386 * @tc.level : Level 3 1387 */ 1388 it('testBrush_SetAlpha_PressureTest', 0, async function () { 1389 let msg = "testBrush_SetAlpha_PressureTest" 1390 console.info(msg + 'begin'); 1391 const brush = new drawing.Brush(); 1392 let opacityNum = 0 1393 for (let i = 0;i < pressureTestNum; i++) { 1394 console.log(msg + 'step is: ' + i) 1395 try { 1396 brush.setAlpha(128); 1397 console.log(msg + 'setAlpha success opacityNum is: ' + opacityNum) 1398 } catch (err) { 1399 console.info(msg + 'setAlpha error cause: ' + JSON.stringify(err)); 1400 expect().assertFail(); 1401 } 1402 opacityNum = opacityNum > 255 ? 0 : opacityNum + 1 1403 } 1404 }) 1405 /** 1406 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3000 1407 * @tc.name : testBrush_SetBlendMode_AllMode_PressureTest 1408 * @tc.desc : Used to set the blending mode of the brush 1409 * @tc.size : MediumTest 1410 * @tc.type : Function 1411 * @tc.level : Level 3 1412 */ 1413 it('testBrush_SetBlendMode_AllMode_PressureTest', 0, async function () { 1414 let msg = "testBrush_SetBlendMode_AllMode_PressureTest" 1415 console.info(msg + 'begin'); 1416 const brush = new drawing.Brush(); 1417 for (let i = 0;i < pressureTestNum; i++) { 1418 console.log(msg + 'step is: ' + i) 1419 try { 1420 for (let i = 0;i < blendModeArr.length; i++) { 1421 brush.setBlendMode(drawing.BlendMode[blendModeArr[i]]); 1422 console.log(msg + 'setBlendMode success ') 1423 } 1424 } catch (err) { 1425 console.info(msg + 'setBlendMode error cause: ' + JSON.stringify(err)); 1426 expect().assertFail(); 1427 } 1428 } 1429 }) 1430 /** 1431 * @tc.number : SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICDRAWING_JS_API_3060 1432 * @tc.name : testBrush_SetColorFilter_PressureTest 1433 * @tc.desc : Used to add additional color filters to the brush 1434 * @tc.size : MediumTest 1435 * @tc.type : Function 1436 * @tc.level : Level 3 1437 */ 1438 it('testBrush_SetColorFilter_PressureTest', 0, async function () { 1439 let msg = "testBrush_SetColorFilter_PressureTest" 1440 console.info(msg + 'begin'); 1441 for (let i = 0;i < pressureTestNum; i++) { 1442 console.log(msg + 'step is: ' + i) 1443 const brush = new drawing.Brush(); 1444 let colorFilter = null; 1445 try { 1446 colorFilter = drawing.ColorFilter.createLinearToSRGBGamma(); 1447 expect(colorFilter != null).assertTrue(); 1448 } catch (err) { 1449 console.info(msg + 'createLinearToSRGBGamma error cause: ' + JSON.stringify(err)); 1450 expect().assertFail(); 1451 } 1452 try { 1453 brush.setColorFilter(colorFilter); 1454 } catch (err) { 1455 console.info(msg + 'setColorFilter error cause: ' + JSON.stringify(err)); 1456 expect().assertFail(); 1457 } 1458 } 1459 }) 1460 }) 1461}