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 16 #include "DrawingNativePathCommon.h" 17 #include "drawing_color.h" 18 #include "drawing_color_filter.h" 19 #include "drawing_filter.h" 20 #include "drawing_image.h" 21 #include "drawing_matrix.h" 22 #include "drawing_path.h" 23 #include "drawing_path_effect.h" 24 #include "drawing_pen.h" 25 #include "drawing_point.h" 26 #include "drawing_rect.h" 27 #include "drawing_region.h" 28 #include "drawing_round_rect.h" 29 #include "utils/scalar.h" 30 #include "gtest/gtest.h" 31 32 using namespace testing; 33 using namespace testing::ext; 34 35 namespace OHOS { 36 namespace Rosen { 37 namespace Drawing { 38 39 /* 40 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3700 41 * @tc.name: testPathIsClosedNormal 42 * @tc.desc: Test for checking if a path is closed using normal parameters. 43 * @tc.size : SmallTest 44 * @tc.type : Function 45 * @tc.level : Level 0 46 */ 47 HWTEST_F(DrawingNativePathTest, testPathIsClosedNormal, TestSize.Level0) { 48 // 1. Create a path object using OH_Drawing_PathCreate 49 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 50 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 51 OH_Drawing_PathMoveTo(path, 0, 0); 52 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 53 OH_Drawing_PathLineTo(path, 100, 100); 54 // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo 55 OH_Drawing_PathLineTo(path, 0, 100); 56 // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo 57 OH_Drawing_PathLineTo(path, 0, 0); 58 // 6. Close the path using OH_Drawing_PathClose 59 OH_Drawing_PathClose(path); 60 // 7. Check if the path is closed using OH_Drawing_PathIsClosed 61 bool isClosed = OH_Drawing_PathIsClosed(path, false); 62 EXPECT_EQ(isClosed, true); 63 // 8. Free the memory 64 OH_Drawing_PathDestroy(path); 65 } 66 67 /* 68 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3701 69 * @tc.name: testPathIsClosedNormal2 70 * @tc.desc: Test for checking if a path is closed without closing it. 71 * @tc.size : SmallTest 72 * @tc.type : Function 73 * @tc.level : Level 0 74 */ 75 HWTEST_F(DrawingNativePathTest, testPathIsClosedNormal2, TestSize.Level0) { 76 // 1. Create a path object using OH_Drawing_PathCreate 77 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 78 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 79 OH_Drawing_PathMoveTo(path, 0, 0); 80 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 81 OH_Drawing_PathLineTo(path, 100, 100); 82 // 4. Check if the path is closed using OH_Drawing_PathIsClosed 83 bool isClosed = OH_Drawing_PathIsClosed(path, false); 84 EXPECT_EQ(isClosed, false); 85 // 5. Free the memory 86 OH_Drawing_PathDestroy(path); 87 } 88 89 /* 90 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3702 91 * @tc.name: testPathIsClosedNull 92 * @tc.desc: Test for checking if a path is closed with NULL or invalid parameters. 93 * @tc.size : SmallTest 94 * @tc.type : Function 95 * @tc.level : Level 3 96 */ 97 HWTEST_F(DrawingNativePathTest, testPathIsClosedNull, TestSize.Level3) { 98 // 1. Create a path object using OH_Drawing_PathCreate 99 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 100 // 2. Check if the path is closed using OH_Drawing_PathIsClosed with nullptr as the parameter, should return 101 // OH_DRAWING_ERROR_INVALID_PARAMETER 102 OH_Drawing_PathIsClosed(nullptr, false); 103 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 104 // 3. Free the memory 105 OH_Drawing_PathDestroy(path); 106 } 107 108 /* 109 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3800 110 * @tc.name: testPathGetPositionTangentNormal 111 * @tc.desc: Test for getting position and tangent of a path using normal parameters with tangent flag set to true. 112 * @tc.size : SmallTest 113 * @tc.type : Function 114 * @tc.level : Level 0 115 */ 116 HWTEST_F(DrawingNativePathTest, testPathGetPositionTangentNormal, TestSize.Level0) { 117 // 1. Create a path object using OH_Drawing_PathCreate 118 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 119 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 120 OH_Drawing_PathMoveTo(path, 0, 0); 121 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 122 OH_Drawing_PathLineTo(path, 100, 100); 123 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 124 // second parameter to true. 125 OH_Drawing_Point2D position; 126 OH_Drawing_Point2D tangent; 127 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 128 // 5. Free the memory 129 OH_Drawing_PathDestroy(path); 130 } 131 132 /* 133 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3801 134 * @tc.name: testPathGetPositionTangentNormal2 135 * @tc.desc: Test for getting position and tangent of a path using normal parameters with tangent flag set to false. 136 * @tc.size : SmallTest 137 * @tc.type : Function 138 * @tc.level : Level 0 139 */ 140 HWTEST_F(DrawingNativePathTest, testPathGetPositionTangentNormal2, TestSize.Level0) { 141 // 1. Create a path object using OH_Drawing_PathCreate 142 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 143 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 144 OH_Drawing_PathMoveTo(path, 0, 0); 145 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 146 OH_Drawing_PathLineTo(path, 100, 100); 147 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 148 // second parameter to false. 149 OH_Drawing_Point2D position; 150 OH_Drawing_Point2D tangent; 151 OH_Drawing_PathGetPositionTangent(path, false, 50, &position, &tangent); 152 // 5. Free the memory 153 OH_Drawing_PathDestroy(path); 154 } 155 156 /* 157 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3802 158 * @tc.name: testPathGetPositionTangentNull 159 * @tc.desc: Test for getting position and tangent of a path using NULL or invalid parameters. 160 * @tc.size : SmallTest 161 * @tc.type : Function 162 * @tc.level : Level 3 163 */ 164 HWTEST_F(DrawingNativePathTest, testPathGetPositionTangentNull, TestSize.Level3) { 165 // 1. Create a path object using OH_Drawing_PathCreate 166 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 167 // 2. Call OH_Drawing_PathGetPositionTangent with the first parameter as nullptr, expect 168 // OH_DRAWING_ERROR_INVALID_PARAMETER 169 OH_Drawing_PathGetPositionTangent(nullptr, true, 50, nullptr, nullptr); 170 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 171 // 3. Call OH_Drawing_PathGetPositionTangent with the third parameter as 0.00, no crash 172 OH_Drawing_Point2D position; 173 OH_Drawing_Point2D tangent; 174 OH_Drawing_PathGetPositionTangent(path, true, 0.00, &position, &tangent); 175 // 4. Call OH_Drawing_PathGetPositionTangent with the fourth parameter as nullptr, expect 176 // OH_DRAWING_ERROR_INVALID_PARAMETER 177 OH_Drawing_PathGetPositionTangent(path, true, 50, nullptr, &tangent); 178 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 179 // 5. Call OH_Drawing_PathGetPositionTangent with the fifth parameter as nullptr, expect 180 // OH_DRAWING_ERROR_INVALID_PARAMETER 181 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, nullptr); 182 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 183 // 6. Free the memory 184 OH_Drawing_PathDestroy(path); 185 } 186 187 /* 188 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3803 189 * @tc.name: testPathGetPositionTangentAbnormal 190 * @tc.desc: Test for getting position and tangent of a path with abnormal parameters (non-float values). 191 * @tc.size : SmallTest 192 * @tc.type : Function 193 * @tc.level : Level 3 194 */ 195 HWTEST_F(DrawingNativePathTest, testPathGetPositionTangentAbnormal, TestSize.Level3) { 196 // 1. Create a path object using OH_Drawing_PathCreate 197 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 198 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 199 OH_Drawing_PathMoveTo(path, 0, 0); 200 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 201 OH_Drawing_PathLineTo(path, 100, 100); 202 // 4. Call OH_Drawing_PathGetPositionTangent with the third parameter as an integer or character type 203 OH_Drawing_Point2D position; 204 OH_Drawing_Point2D tangent; 205 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 206 // 5. Call OH_Drawing_PathGetPositionTangent with the x coordinate of the fourth parameter as an integer or 207 // character type 208 position = {10, 10.0f}; 209 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 210 // 6. Call OH_Drawing_PathGetPositionTangent with the y coordinate of the fourth parameter as an integer or 211 // character type 212 position = {10.0f, 10}; 213 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 214 // 7. Call OH_Drawing_PathGetPositionTangent with the x coordinate of the fifth parameter as an integer or character 215 // type 216 tangent = {10, 10.0f}; 217 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 218 // 8. Call OH_Drawing_PathGetPositionTangent with the y coordinate of the fifth parameter as an integer or character 219 // type 220 tangent = {10.0f, 10}; 221 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 222 // 9. Free the memory 223 OH_Drawing_PathDestroy(path); 224 } 225 226 /* 227 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3804 228 * @tc.name: testPathGetPositionTangentMaximal 229 * @tc.desc: Test for getting position and tangent of a path with maximal values. 230 * @tc.size : SmallTest 231 * @tc.type : Function 232 * @tc.level : Level 3 233 */ 234 HWTEST_F(DrawingNativePathTest, testPathGetPositionTangentMaximal, TestSize.Level3) { 235 // 1. Create a path object using OH_Drawing_PathCreate 236 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 237 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 238 OH_Drawing_PathMoveTo(path, 0, 0); 239 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 240 OH_Drawing_PathLineTo(path, 100, 100); 241 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 242 // third parameter to a large value FLT_MAX + 1. 243 OH_Drawing_Point2D position; 244 OH_Drawing_Point2D tangent; 245 OH_Drawing_PathGetPositionTangent(path, true, FLT_MAX + 1, &position, &tangent); 246 // 5. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the x 247 // coordinate of the fourth parameter to a large value FLT_MAX + 1. 248 position = {FLT_MAX + 1, 0.0f}; 249 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 250 // 6. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the y 251 // coordinate of the fourth parameter to a large value FLT_MAX + 1. 252 position = {0.0f, FLT_MAX + 1}; 253 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 254 // 7. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the x 255 // coordinate of the fifth parameter to a large value FLT_MAX + 1. 256 tangent = {FLT_MAX + 1, 0.0f}; 257 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 258 // 8. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the y 259 // coordinate of the fifth parameter to a large value FLT_MAX + 1. 260 tangent = {0.0f, FLT_MAX + 1}; 261 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 262 // 9. Free the memory 263 OH_Drawing_PathDestroy(path); 264 } 265 266 /* 267 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3900 268 * @tc.name: testPathOpNormal 269 * @tc.desc: Test for performing path operations using normal parameters. 270 * @tc.size : SmallTest 271 * @tc.type : Function 272 * @tc.level : Level 0 273 */ 274 HWTEST_F(DrawingNativePathTest, testPathOpNormal, TestSize.Level0) { 275 // 1. Create a path object using OH_Drawing_PathCreate 276 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 277 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 278 OH_Drawing_PathMoveTo(path, 0, 0); 279 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 280 OH_Drawing_PathLineTo(path, 100, 100); 281 // 4. Create a path object using OH_Drawing_PathCreate 282 OH_Drawing_Path *src = OH_Drawing_PathCreate(); 283 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo 284 OH_Drawing_PathMoveTo(src, 0, 0); 285 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 286 OH_Drawing_PathLineTo(src, 100, 100); 287 // 7. Perform a path operation on the two paths according to the specified path operation mode. The third parameter 288 // enumerates the possible path operation modes. 289 OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 290 // 8. Free the memory 291 OH_Drawing_PathDestroy(path); 292 } 293 294 /* 295 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3901 296 * @tc.name: testPathOpNull 297 * @tc.desc: Test for performing path operations with NULL or invalid parameters. 298 * @tc.size : SmallTest 299 * @tc.type : Function 300 * @tc.level : Level 3 301 */ 302 HWTEST_F(DrawingNativePathTest, testPathOpNull, TestSize.Level3) { 303 // 1. Create a path object using OH_Drawing_PathCreate 304 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 305 // 2. Create a path object using OH_Drawing_PathCreate 306 OH_Drawing_Path *src = OH_Drawing_PathCreate(); 307 // 3. Call OH_Drawing_PathOp with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 308 OH_Drawing_PathOp(nullptr, src, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 309 // 4. Call OH_Drawing_PathOp with the second parameter as nullptr, expect OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE 310 OH_Drawing_PathOp(path, nullptr, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 311 // 5. Free the memory 312 OH_Drawing_PathDestroy(path); 313 } 314 315 /* 316 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4000 317 * @tc.name: testPathGetMatrixNormal 318 * @tc.desc: Test for getting transformation matrix of a path using normal parameters with matrix flag set to true. 319 * @tc.size : SmallTest 320 * @tc.type : Function 321 * @tc.level : Level 0 322 */ 323 HWTEST_F(DrawingNativePathTest, testPathGetMatrixNormal, TestSize.Level0) { 324 // 1. Create a path object using OH_Drawing_PathCreate 325 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 326 // 2. Create a matrix object using OH_Drawing_MatrixCreate 327 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 328 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 329 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 330 OH_Drawing_PathMoveTo(path, 0, 0); 331 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 332 OH_Drawing_PathLineTo(path, 100, 100); 333 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 334 // second parameter to true. Enumerate the possible values of the fifth parameter to call the interface. 335 OH_Drawing_PathMeasureMatrixFlags flags[] = { 336 GET_POSITION_MATRIX, 337 GET_TANGENT_MATRIX, 338 GET_POSITION_AND_TANGENT_MATRIX, 339 }; 340 for (int i = 0; i < 3; i++) { 341 OH_Drawing_PathGetMatrix(path, true, 50, matrix, flags[i]); 342 } 343 // 6. Free the memory 344 OH_Drawing_PathDestroy(path); 345 OH_Drawing_MatrixDestroy(matrix); 346 } 347 348 /* 349 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4001 350 * @tc.name: testPathGetMatrixNormal2 351 * @tc.desc: Test for getting transformation matrix of a path using normal parameters with matrix flag set to false. 352 * @tc.size : SmallTest 353 * @tc.type : Function 354 * @tc.level : Level 0 355 */ 356 HWTEST_F(DrawingNativePathTest, testPathGetMatrixNormal2, TestSize.Level0) { 357 // 1. Create a path object using OH_Drawing_PathCreate 358 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 359 // 2. Create a matrix object using OH_Drawing_MatrixCreate 360 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 361 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 362 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 363 OH_Drawing_PathMoveTo(path, 0, 0); 364 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 365 OH_Drawing_PathLineTo(path, 100, 100); 366 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 367 // second parameter to false. Enumerate the possible values of the fifth parameter to call the interface. 368 OH_Drawing_PathMeasureMatrixFlags flags[] = { 369 GET_POSITION_MATRIX, 370 GET_TANGENT_MATRIX, 371 GET_POSITION_AND_TANGENT_MATRIX, 372 }; 373 for (int i = 0; i < 3; i++) { 374 OH_Drawing_PathGetMatrix(path, false, 50, matrix, flags[i]); 375 } 376 // 6. Free the memory 377 OH_Drawing_PathDestroy(path); 378 OH_Drawing_MatrixDestroy(matrix); 379 } 380 381 /* 382 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4002 383 * @tc.name: testPathGetMatrixNull 384 * @tc.desc: Test for getting transformation matrix of a path using NULL or invalid parameters. 385 * @tc.size : SmallTest 386 * @tc.type : Function 387 * @tc.level : Level 3 388 */ 389 HWTEST_F(DrawingNativePathTest, testPathGetMatrixNull, TestSize.Level3) { 390 // 1. Create a path object using OH_Drawing_PathCreate 391 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 392 // 2. Create a matrix object using OH_Drawing_MatrixCreate 393 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 394 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 395 // 3. Call OH_Drawing_PathGetMatrix with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 396 OH_Drawing_PathGetMatrix(nullptr, true, 50, matrix, GET_POSITION_MATRIX); 397 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 398 // 4. Call OH_Drawing_PathGetMatrix with the third parameter as 0.00, the call should fail without crashing 399 OH_Drawing_PathGetMatrix(path, true, 0.00, matrix, GET_POSITION_MATRIX); 400 // 5. Call OH_Drawing_PathGetMatrix with the fourth parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 401 OH_Drawing_PathGetMatrix(path, true, 50, nullptr, GET_POSITION_MATRIX); 402 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 403 // 6. Free the memory 404 OH_Drawing_PathDestroy(path); 405 } 406 407 /* 408 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4003 409 * @tc.name: testPathGetMatrixAbnormal 410 * @tc.desc: Test for getting transformation matrix of a path with abnormal parameters (non-float values). 411 * @tc.size : SmallTest 412 * @tc.type : Function 413 * @tc.level : Level 3 414 */ 415 HWTEST_F(DrawingNativePathTest, testPathGetMatrixAbnormal, TestSize.Level3) { 416 // 1. Create a path object using OH_Drawing_PathCreate 417 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 418 // 2. Create a matrix object using OH_Drawing_MatrixCreate 419 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 420 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 421 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 422 OH_Drawing_PathMoveTo(path, 0, 0); 423 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 424 OH_Drawing_PathLineTo(path, 100, 100); 425 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 426 // third parameter to an integer value. 427 OH_Drawing_PathGetMatrix(path, true, 50, matrix, GET_POSITION_MATRIX); 428 // 6. Free the memory 429 OH_Drawing_PathDestroy(path); 430 } 431 432 /* 433 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4004 434 * @tc.name: testPathGetMatrixMaximal 435 * @tc.desc: Test for getting transformation matrix of a path with maximal values. 436 * @tc.size : SmallTest 437 * @tc.type : Function 438 * @tc.level : Level 3 439 */ 440 HWTEST_F(DrawingNativePathTest, testPathGetMatrixMaximal, TestSize.Level3) { 441 // 1. Create a path object using OH_Drawing_PathCreate 442 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 443 // 2. Create a matrix object using OH_Drawing_MatrixCreate 444 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 445 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 446 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 447 OH_Drawing_PathMoveTo(path, 0, 0); 448 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 449 OH_Drawing_PathLineTo(path, 100, 100); 450 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 451 // third parameter to a large value FLT_MAX + 1. 452 OH_Drawing_PathGetMatrix(path, true, FLT_MAX + 1, matrix, GET_POSITION_MATRIX); 453 // 6. Free the memory 454 OH_Drawing_PathDestroy(path); 455 } 456 457 } // namespace Drawing 458 } // namespace Rosen 459 } // namespace OHOS