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 "gtest/gtest.h" 30 31 using namespace testing; 32 using namespace testing::ext; 33 34 namespace OHOS { 35 namespace Rosen { 36 namespace Drawing { 37 class DrawingNativePathPart3Test : public testing::Test { 38 protected: 39 // 在每个测试用例执行前调用 SetUp()40 void SetUp() override 41 { 42 // 设置代码 43 std::cout << "DrawingNativePathPart3Test Setup code called before each test case." << std::endl; 44 OH_Drawing_ErrorCodeReset(); 45 std::cout << "DrawingNativePathPart3Test errorCodeReset before each test case." << std::endl; 46 } TearDown()47 void TearDown() override 48 { 49 std::cout << "DrawingNativePathPart3Test Setup code called after each test case." << std::endl; 50 OH_Drawing_ErrorCodeReset(); 51 std::cout << "DrawingNativePathPart3Test errorCodeReset after each test case." << std::endl; 52 } 53 }; 54 55 /* 56 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3700 57 * @tc.name: testPathIsClosedNormal 58 * @tc.desc: Test for checking if a path is closed using normal parameters. 59 * @tc.size : SmallTest 60 * @tc.type : Function 61 * @tc.level : Level 0 62 */ 63 HWTEST_F(DrawingNativePathPart3Test, testPathIsClosedNormal, Function | SmallTest | Level0) { 64 // 1. Create a path object using OH_Drawing_PathCreate 65 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 66 // add assert 67 EXPECT_NE(path, nullptr); 68 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 69 OH_Drawing_PathMoveTo(path, 0, 0); 70 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 71 OH_Drawing_PathLineTo(path, 100, 100); 72 // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo 73 OH_Drawing_PathLineTo(path, 0, 100); 74 // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo 75 OH_Drawing_PathLineTo(path, 0, 0); 76 // 6. Close the path using OH_Drawing_PathClose 77 OH_Drawing_PathClose(path); 78 // 7. Check if the path is closed using OH_Drawing_PathIsClosed 79 bool isClosed = OH_Drawing_PathIsClosed(path, false); 80 EXPECT_EQ(isClosed, true); 81 // add assert 82 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 83 // 8. Free the memory 84 OH_Drawing_PathDestroy(path); 85 } 86 87 /* 88 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3701 89 * @tc.name: testPathIsClosedNormal2 90 * @tc.desc: Test for checking if a path is closed without closing it. 91 * @tc.size : SmallTest 92 * @tc.type : Function 93 * @tc.level : Level 0 94 */ 95 HWTEST_F(DrawingNativePathPart3Test, testPathIsClosedNormal2, Function | SmallTest | Level0) { 96 // 1. Create a path object using OH_Drawing_PathCreate 97 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 98 // add assert 99 EXPECT_NE(path, nullptr); 100 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 101 OH_Drawing_PathMoveTo(path, 0, 0); 102 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 103 OH_Drawing_PathLineTo(path, 100, 100); 104 // 4. Check if the path is closed using OH_Drawing_PathIsClosed 105 bool isClosed = OH_Drawing_PathIsClosed(path, false); 106 EXPECT_EQ(isClosed, false); 107 // add assert 108 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 109 // 5. Free the memory 110 OH_Drawing_PathDestroy(path); 111 } 112 113 /* 114 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3702 115 * @tc.name: testPathIsClosedNull 116 * @tc.desc: Test for checking if a path is closed with NULL or invalid parameters. 117 * @tc.size : SmallTest 118 * @tc.type : Function 119 * @tc.level : Level 3 120 */ 121 HWTEST_F(DrawingNativePathPart3Test, testPathIsClosedNull, Function | SmallTest | Level3) { 122 // 1. Create a path object using OH_Drawing_PathCreate 123 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 124 // add assert 125 EXPECT_NE(path, nullptr); 126 // 2. Check if the path is closed using OH_Drawing_PathIsClosed with nullptr as the parameter, should return 127 // OH_DRAWING_ERROR_INVALID_PARAMETER 128 OH_Drawing_PathIsClosed(nullptr, false); 129 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 130 // 3. Free the memory 131 OH_Drawing_PathDestroy(path); 132 } 133 134 /* 135 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3800 136 * @tc.name: testPathGetPositionTangentNormal 137 * @tc.desc: Test for getting position and tangent of a path using normal parameters with tangent flag set to true. 138 * @tc.size : SmallTest 139 * @tc.type : Function 140 * @tc.level : Level 0 141 */ 142 HWTEST_F(DrawingNativePathPart3Test, testPathGetPositionTangentNormal, Function | SmallTest | Level0) { 143 // 1. Create a path object using OH_Drawing_PathCreate 144 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 145 // add assert 146 EXPECT_NE(path, nullptr); 147 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 148 OH_Drawing_PathMoveTo(path, 0, 0); 149 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 150 OH_Drawing_PathLineTo(path, 100, 100); 151 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 152 // second parameter to true. 153 OH_Drawing_Point2D position; 154 OH_Drawing_Point2D tangent; 155 bool isSuccess = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 156 // add assert 157 EXPECT_EQ(isSuccess, true); 158 // add assert 159 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 160 // 5. Free the memory 161 OH_Drawing_PathDestroy(path); 162 } 163 164 /* 165 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3801 166 * @tc.name: testPathGetPositionTangentNormal2 167 * @tc.desc: Test for getting position and tangent of a path using normal parameters with tangent flag set to false. 168 * @tc.size : SmallTest 169 * @tc.type : Function 170 * @tc.level : Level 0 171 */ 172 HWTEST_F(DrawingNativePathPart3Test, testPathGetPositionTangentNormal2, Function | SmallTest | Level0) { 173 // 1. Create a path object using OH_Drawing_PathCreate 174 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 175 // add assert 176 EXPECT_NE(path, nullptr); 177 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 178 OH_Drawing_PathMoveTo(path, 0, 0); 179 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 180 OH_Drawing_PathLineTo(path, 100, 100); 181 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 182 // second parameter to false. 183 OH_Drawing_Point2D position; 184 OH_Drawing_Point2D tangent; 185 bool isSuccess = OH_Drawing_PathGetPositionTangent(path, false, 50, &position, &tangent); 186 // add assert 187 EXPECT_EQ(isSuccess, true); 188 // add assert 189 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 190 // 5. Free the memory 191 OH_Drawing_PathDestroy(path); 192 } 193 194 /* 195 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3802 196 * @tc.name: testPathGetPositionTangentNull 197 * @tc.desc: Test for getting position and tangent of a path using NULL or invalid parameters. 198 * @tc.size : SmallTest 199 * @tc.type : Function 200 * @tc.level : Level 3 201 */ 202 HWTEST_F(DrawingNativePathPart3Test, testPathGetPositionTangentNull, Function | SmallTest | Level3) { 203 // 1. Create a path object using OH_Drawing_PathCreate 204 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 205 // add assert 206 EXPECT_NE(path, nullptr); 207 // 2. Call OH_Drawing_PathGetPositionTangent with the first parameter as nullptr, expect 208 // OH_DRAWING_ERROR_INVALID_PARAMETER 209 OH_Drawing_PathGetPositionTangent(nullptr, true, 50, nullptr, nullptr); 210 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 211 OH_Drawing_ErrorCodeReset(); 212 // 3. Call OH_Drawing_PathGetPositionTangent with the third parameter as 0.00, no crash 213 OH_Drawing_Point2D position; 214 OH_Drawing_Point2D tangent; 215 bool isSuccess = OH_Drawing_PathGetPositionTangent(path, true, 0.00, &position, &tangent); 216 // add assert 217 EXPECT_EQ(isSuccess, false); 218 // 4. Call OH_Drawing_PathGetPositionTangent with the fourth parameter as nullptr, expect 219 // OH_DRAWING_ERROR_INVALID_PARAMETER 220 OH_Drawing_PathGetPositionTangent(path, true, 50, nullptr, &tangent); 221 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 222 OH_Drawing_ErrorCodeReset(); 223 // 5. Call OH_Drawing_PathGetPositionTangent with the fifth parameter as nullptr, expect 224 // OH_DRAWING_ERROR_INVALID_PARAMETER 225 OH_Drawing_PathGetPositionTangent(path, true, 50, &position, nullptr); 226 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 227 // 6. Free the memory 228 OH_Drawing_PathDestroy(path); 229 } 230 231 /* 232 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3803 233 * @tc.name: testPathGetPositionTangentAbnormal 234 * @tc.desc: Test for getting position and tangent of a path with abnormal parameters (non-float values). 235 * @tc.size : SmallTest 236 * @tc.type : Function 237 * @tc.level : Level 3 238 */ 239 HWTEST_F(DrawingNativePathPart3Test, testPathGetPositionTangentAbnormal, Function | SmallTest | Level3) { 240 // 1. Create a path object using OH_Drawing_PathCreate 241 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 242 // add assert 243 EXPECT_NE(path, nullptr); 244 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 245 OH_Drawing_PathMoveTo(path, 0, 0); 246 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 247 OH_Drawing_PathLineTo(path, 100, 100); 248 // 4. Call OH_Drawing_PathGetPositionTangent with the third parameter as an integer or character type 249 OH_Drawing_Point2D position; 250 OH_Drawing_Point2D tangent; 251 bool isSuccess1 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 252 // add assert 253 EXPECT_EQ(isSuccess1, true); 254 // 5. Call OH_Drawing_PathGetPositionTangent with the x coordinate of the fourth parameter as an integer or 255 // character type 256 position = {10, 10.0f}; 257 bool isSuccess2 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 258 // add assert 259 EXPECT_EQ(isSuccess2, true); 260 // 6. Call OH_Drawing_PathGetPositionTangent with the y coordinate of the fourth parameter as an integer or 261 // character type 262 position = {10.0f, 10}; 263 bool isSuccess3 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 264 // add assert 265 EXPECT_EQ(isSuccess3, true); 266 // 7. Call OH_Drawing_PathGetPositionTangent with the x coordinate of the fifth parameter as an integer or character 267 // type 268 tangent = {10, 10.0f}; 269 bool isSuccess4 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 270 // add assert 271 EXPECT_EQ(isSuccess4, true); 272 // 8. Call OH_Drawing_PathGetPositionTangent with the y coordinate of the fifth parameter as an integer or character 273 // type 274 tangent = {10.0f, 10}; 275 bool isSuccess5 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 276 // add assert 277 EXPECT_EQ(isSuccess5, true); 278 // 9. Free the memory 279 OH_Drawing_PathDestroy(path); 280 } 281 282 /* 283 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3804 284 * @tc.name: testPathGetPositionTangentMaximal 285 * @tc.desc: Test for getting position and tangent of a path with maximal values. 286 * @tc.size : SmallTest 287 * @tc.type : Function 288 * @tc.level : Level 3 289 */ 290 HWTEST_F(DrawingNativePathPart3Test, testPathGetPositionTangentMaximal, Function | SmallTest | Level3) { 291 // 1. Create a path object using OH_Drawing_PathCreate 292 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 293 // add assert 294 EXPECT_NE(path, nullptr); 295 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 296 OH_Drawing_PathMoveTo(path, 0, 0); 297 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 298 OH_Drawing_PathLineTo(path, 100, 100); 299 // 4. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the 300 // third parameter to a large value FLT_MAX + 1. 301 OH_Drawing_Point2D position; 302 OH_Drawing_Point2D tangent; 303 bool isSuccess1 = OH_Drawing_PathGetPositionTangent(path, true, FLT_MAX + 1, &position, &tangent); 304 // add assert 305 EXPECT_EQ(isSuccess1, true); 306 // 5. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the x 307 // coordinate of the fourth parameter to a large value FLT_MAX + 1. 308 position = {FLT_MAX + 1, 0.0f}; 309 bool isSuccess2 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 310 // add assert 311 EXPECT_EQ(isSuccess2, true); 312 // 6. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the y 313 // coordinate of the fourth parameter to a large value FLT_MAX + 1. 314 position = {0.0f, FLT_MAX + 1}; 315 bool isSuccess3 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 316 // add assert 317 EXPECT_EQ(isSuccess3, true); 318 // 7. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the x 319 // coordinate of the fifth parameter to a large value FLT_MAX + 1. 320 tangent = {FLT_MAX + 1, 0.0f}; 321 bool isSuccess4 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 322 // add assert 323 EXPECT_EQ(isSuccess4, true); 324 // 8. Get the position and tangent of a point at a specified distance from the starting point of the path. Set the y 325 // coordinate of the fifth parameter to a large value FLT_MAX + 1. 326 tangent = {0.0f, FLT_MAX + 1}; 327 bool isSuccess5 = OH_Drawing_PathGetPositionTangent(path, true, 50, &position, &tangent); 328 // add assert 329 EXPECT_EQ(isSuccess5, true); 330 // 9. Free the memory 331 OH_Drawing_PathDestroy(path); 332 } 333 334 /* 335 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3900 336 * @tc.name: testPathOpNormal 337 * @tc.desc: Test for performing path operations using normal parameters. 338 * @tc.size : SmallTest 339 * @tc.type : Function 340 * @tc.level : Level 0 341 */ 342 HWTEST_F(DrawingNativePathPart3Test, testPathOpNormal, Function | SmallTest | Level0) { 343 // 1. Create a path object using OH_Drawing_PathCreate 344 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 345 // add assert 346 EXPECT_NE(path, nullptr); 347 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 348 OH_Drawing_PathMoveTo(path, 0, 0); 349 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 350 OH_Drawing_PathLineTo(path, 100, 100); 351 // 4. Create a path object using OH_Drawing_PathCreate 352 OH_Drawing_Path *src = OH_Drawing_PathCreate(); 353 // add assert 354 EXPECT_NE(src, nullptr); 355 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo 356 OH_Drawing_PathMoveTo(src, 0, 0); 357 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 358 OH_Drawing_PathLineTo(src, 100, 100); 359 // 7. Perform a path operation on the two paths according to the specified path operation mode. The third parameter 360 // enumerates the possible path operation modes. 361 bool pathOp1 = OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 362 // add assert 363 EXPECT_EQ(pathOp1, true); 364 // add assert 365 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 366 bool pathOp2 = OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_DIFFERENCE); 367 // add assert 368 EXPECT_EQ(pathOp2, true); 369 // add assert 370 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 371 bool pathOp3 = OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_UNION); 372 // add assert 373 EXPECT_EQ(pathOp3, true); 374 // add assert 375 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 376 bool pathOp4 = OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_XOR); 377 // add assert 378 EXPECT_EQ(pathOp4, true); 379 // add assert 380 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 381 bool pathOp5 = OH_Drawing_PathOp(path, src, OH_Drawing_PathOpMode::PATH_OP_MODE_REVERSE_DIFFERENCE); 382 // add assert 383 EXPECT_EQ(pathOp5, true); 384 // add assert 385 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 386 // 8. Free the memory 387 OH_Drawing_PathDestroy(path); 388 OH_Drawing_PathDestroy(src); 389 } 390 391 /* 392 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3901 393 * @tc.name: testPathOpNull 394 * @tc.desc: Test for performing path operations with NULL or invalid parameters. 395 * @tc.size : SmallTest 396 * @tc.type : Function 397 * @tc.level : Level 3 398 */ 399 HWTEST_F(DrawingNativePathPart3Test, testPathOpNull, Function | SmallTest | Level3) { 400 // 1. Create a path object using OH_Drawing_PathCreate 401 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 402 // add assert 403 EXPECT_NE(path, nullptr); 404 // 2. Create a path object using OH_Drawing_PathCreate 405 OH_Drawing_Path *src = OH_Drawing_PathCreate(); 406 // add assert 407 EXPECT_NE(src, nullptr); 408 // 3. Call OH_Drawing_PathOp with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 409 OH_Drawing_PathOp(nullptr, src, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 410 // add assert 411 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 412 OH_Drawing_ErrorCodeReset(); 413 // 4. Call OH_Drawing_PathOp with the second parameter as nullptr, expect OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE 414 OH_Drawing_PathOp(path, nullptr, OH_Drawing_PathOpMode::PATH_OP_MODE_INTERSECT); 415 // add assert 416 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 417 // 5. Free the memory 418 OH_Drawing_PathDestroy(path); 419 OH_Drawing_PathDestroy(src); 420 } 421 422 /* 423 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4000 424 * @tc.name: testPathGetMatrixNormal 425 * @tc.desc: Test for getting transformation matrix of a path using normal parameters with matrix flag set to true. 426 * @tc.size : SmallTest 427 * @tc.type : Function 428 * @tc.level : Level 0 429 */ 430 HWTEST_F(DrawingNativePathPart3Test, testPathGetMatrixNormal, Function | SmallTest | Level0) { 431 // 1. Create a path object using OH_Drawing_PathCreate 432 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 433 // add assert 434 EXPECT_NE(path, nullptr); 435 // 2. Create a matrix object using OH_Drawing_MatrixCreate 436 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 437 // add assert 438 EXPECT_NE(matrix, nullptr); 439 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 440 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 441 OH_Drawing_PathMoveTo(path, 0, 0); 442 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 443 OH_Drawing_PathLineTo(path, 100, 100); 444 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 445 // second parameter to true. Enumerate the possible values of the fifth parameter to call the interface. 446 OH_Drawing_PathMeasureMatrixFlags flags[] = { 447 GET_POSITION_MATRIX, 448 GET_TANGENT_MATRIX, 449 GET_POSITION_AND_TANGENT_MATRIX, 450 }; 451 for (int i = 0; i < 3; i++) { 452 OH_Drawing_ErrorCodeReset(); 453 bool getMatrix = OH_Drawing_PathGetMatrix(path, true, 50, matrix, flags[i]); 454 // add assert 455 EXPECT_EQ(getMatrix, true); 456 // add assert 457 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 458 } 459 // 6. Free the memory 460 OH_Drawing_PathDestroy(path); 461 OH_Drawing_MatrixDestroy(matrix); 462 } 463 464 /* 465 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4001 466 * @tc.name: testPathGetMatrixNormal2 467 * @tc.desc: Test for getting transformation matrix of a path using normal parameters with matrix flag set to false. 468 * @tc.size : SmallTest 469 * @tc.type : Function 470 * @tc.level : Level 0 471 */ 472 HWTEST_F(DrawingNativePathPart3Test, testPathGetMatrixNormal2, Function | SmallTest | Level0) { 473 // 1. Create a path object using OH_Drawing_PathCreate 474 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 475 // add assert 476 EXPECT_NE(path, nullptr); 477 // 2. Create a matrix object using OH_Drawing_MatrixCreate 478 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 479 // add assert 480 EXPECT_NE(matrix, nullptr); 481 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 482 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 483 OH_Drawing_PathMoveTo(path, 0, 0); 484 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 485 OH_Drawing_PathLineTo(path, 100, 100); 486 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 487 // second parameter to false. Enumerate the possible values of the fifth parameter to call the interface. 488 OH_Drawing_PathMeasureMatrixFlags flags[] = { 489 GET_POSITION_MATRIX, 490 GET_TANGENT_MATRIX, 491 GET_POSITION_AND_TANGENT_MATRIX, 492 }; 493 for (int i = 0; i < 3; i++) { 494 OH_Drawing_ErrorCodeReset(); 495 bool getMatrix = OH_Drawing_PathGetMatrix(path, false, 50, matrix, flags[i]); 496 // add assert 497 EXPECT_EQ(getMatrix, true); 498 // add assert 499 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 500 } 501 // 6. Free the memory 502 OH_Drawing_PathDestroy(path); 503 OH_Drawing_MatrixDestroy(matrix); 504 } 505 506 /* 507 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4002 508 * @tc.name: testPathGetMatrixNull 509 * @tc.desc: Test for getting transformation matrix of a path using NULL or invalid parameters. 510 * @tc.size : SmallTest 511 * @tc.type : Function 512 * @tc.level : Level 3 513 */ 514 HWTEST_F(DrawingNativePathPart3Test, testPathGetMatrixNull, Function | SmallTest | Level3) { 515 // 1. Create a path object using OH_Drawing_PathCreate 516 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 517 // add assert 518 EXPECT_NE(path, nullptr); 519 // 2. Create a matrix object using OH_Drawing_MatrixCreate 520 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 521 // add assert 522 EXPECT_NE(matrix, nullptr); 523 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 524 // 3. Call OH_Drawing_PathGetMatrix with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 525 OH_Drawing_PathGetMatrix(nullptr, true, 50, matrix, GET_POSITION_MATRIX); 526 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 527 OH_Drawing_ErrorCodeReset(); 528 // 4. Call OH_Drawing_PathGetMatrix with the third parameter as 0.00, the call should fail without crashing 529 bool getMatrix = OH_Drawing_PathGetMatrix(path, true, 0.00, matrix, GET_POSITION_MATRIX); 530 // add assert 531 EXPECT_EQ(getMatrix, false); 532 // 5. Call OH_Drawing_PathGetMatrix with the fourth parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 533 OH_Drawing_PathGetMatrix(path, true, 50, nullptr, GET_POSITION_MATRIX); 534 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 535 // 6. Free the memory 536 OH_Drawing_PathDestroy(path); 537 OH_Drawing_MatrixDestroy(matrix); 538 } 539 540 /* 541 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4003 542 * @tc.name: testPathGetMatrixAbnormal 543 * @tc.desc: Test for getting transformation matrix of a path with abnormal parameters (non-float values). 544 * @tc.size : SmallTest 545 * @tc.type : Function 546 * @tc.level : Level 3 547 */ 548 HWTEST_F(DrawingNativePathPart3Test, testPathGetMatrixAbnormal, Function | SmallTest | Level3) { 549 // 1. Create a path object using OH_Drawing_PathCreate 550 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 551 // add assert 552 EXPECT_NE(path, nullptr); 553 // 2. Create a matrix object using OH_Drawing_MatrixCreate 554 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 555 // add assert 556 EXPECT_NE(matrix, nullptr); 557 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 558 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 559 OH_Drawing_PathMoveTo(path, 0, 0); 560 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 561 OH_Drawing_PathLineTo(path, 100, 100); 562 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 563 // third parameter to an integer value. 564 bool getMatrix = OH_Drawing_PathGetMatrix(path, true, 50, matrix, GET_POSITION_MATRIX); 565 // add assert 566 EXPECT_EQ(getMatrix, true); 567 // 6. Free the memory 568 OH_Drawing_PathDestroy(path); 569 OH_Drawing_MatrixDestroy(matrix); 570 } 571 572 /* 573 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4004 574 * @tc.name: testPathGetMatrixMaximal 575 * @tc.desc: Test for getting transformation matrix of a path with maximal values. 576 * @tc.size : SmallTest 577 * @tc.type : Function 578 * @tc.level : Level 3 579 */ 580 HWTEST_F(DrawingNativePathPart3Test, testPathGetMatrixMaximal, Function | SmallTest | Level3) { 581 // 1. Create a path object using OH_Drawing_PathCreate 582 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 583 // add assert 584 EXPECT_NE(path, nullptr); 585 // 2. Create a matrix object using OH_Drawing_MatrixCreate 586 OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 587 // add assert 588 EXPECT_NE(matrix, nullptr); 589 OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 590 // 3. Set the starting point of the path using OH_Drawing_PathMoveTo 591 OH_Drawing_PathMoveTo(path, 0, 0); 592 // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo 593 OH_Drawing_PathLineTo(path, 100, 100); 594 // 5. Get the transformation matrix of a point at a specified distance from the starting point of the path. Set the 595 // third parameter to a large value FLT_MAX + 1. 596 bool getMatrix = OH_Drawing_PathGetMatrix(path, true, FLT_MAX + 1, matrix, GET_POSITION_MATRIX); 597 // add assert 598 EXPECT_EQ(getMatrix, true); 599 // 6. Free the memory 600 OH_Drawing_PathDestroy(path); 601 OH_Drawing_MatrixDestroy(matrix); 602 } 603 604 /* 605 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4100 606 * @tc.name: testPathGetSegmentNormal 607 * @tc.desc: Testing the enumeration traversal of the interface for extracting path segments and appending them to the 608 * target path 609 * @tc.size : SmallTest 610 * @tc.type : Function 611 * @tc.level : Level 0 612 */ 613 HWTEST_F(DrawingNativePathPart3Test, testPathGetSegmentNormal, Function | SmallTest | Level0) { 614 // 1. Create a path object using OH_Drawing_PathCreate 615 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 616 EXPECT_NE(path, nullptr); 617 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 618 OH_Drawing_PathMoveTo(path, 100, 100); 619 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo 620 OH_Drawing_PathLineTo(path, 100, 200); 621 OH_Drawing_PathLineTo(path, 200, 200); 622 // 4. Create a target path object using OH_Drawing_PathCreate 623 OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); 624 EXPECT_NE(dstPath, nullptr); 625 bool result = false; 626 OH_Drawing_ErrorCode errorCode; 627 // 5. Parameter enumeration traversal 628 errorCode = OH_Drawing_PathGetSegment(path, true, 120, 180, true, dstPath, &result); 629 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 630 EXPECT_EQ(result, true); 631 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 180, true, dstPath, &result); 632 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 633 EXPECT_EQ(result, true); 634 errorCode = OH_Drawing_PathGetSegment(path, true, 120, 180, false, dstPath, &result); 635 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 636 EXPECT_EQ(result, true); 637 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 180, false, dstPath, &result); 638 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 639 EXPECT_EQ(result, true); 640 // 6. Free the memory 641 OH_Drawing_PathDestroy(path); 642 OH_Drawing_PathDestroy(dstPath); 643 } 644 645 /* 646 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4101 647 * @tc.name: testPathGetSegmentNull 648 * @tc.desc: Tests when an interface that intercepts a path fragment and appends it to the target path passes a null 649 * pointer or invalid parameter 650 * @tc.size : SmallTest 651 * @tc.type : Function 652 * @tc.level : Level 3 653 */ 654 HWTEST_F(DrawingNativePathPart3Test, testPathGetSegmentNull, Function | SmallTest | Level3) { 655 // 1. Create a path object using OH_Drawing_PathCreate 656 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 657 EXPECT_NE(path, nullptr); 658 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 659 OH_Drawing_PathMoveTo(path, 100, 100); 660 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo 661 OH_Drawing_PathLineTo(path, 100, 200); 662 OH_Drawing_PathLineTo(path, 200, 200); 663 // 4. Create a target path object using OH_Drawing_PathCreate 664 OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); 665 EXPECT_NE(dstPath, nullptr); 666 bool result = false; 667 OH_Drawing_ErrorCode errorCode; 668 // 5. The function OH_Drawing_PathGetSegment passes a null pointer to the first argument 669 errorCode = OH_Drawing_PathGetSegment(nullptr, false, 120, 180, true, dstPath, &result); 670 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 671 EXPECT_EQ(result, false); 672 // 6. The function OH_Drawing_PathGetSegment passes 0 to the third argument 673 errorCode = OH_Drawing_PathGetSegment(path, false, 0, 180, true, dstPath, &result); 674 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 675 EXPECT_EQ(result, true); 676 // 7. The function OH_Drawing_PathGetSegment passes 0 to the forth argument 677 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 0, true, dstPath, &result); 678 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 679 EXPECT_EQ(result, false); 680 // 8. The function OH_Drawing_PathGetSegment passes a null pointer to the fifth argument 681 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 180, true, nullptr, &result); 682 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 683 EXPECT_EQ(result, false); 684 // 9. The function OH_Drawing_PathGetSegment passes a null pointer to the sixth argument 685 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 180, true, dstPath, nullptr); 686 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 687 EXPECT_EQ(result, false); 688 // 10. Free the memory 689 OH_Drawing_PathDestroy(path); 690 OH_Drawing_PathDestroy(dstPath); 691 } 692 693 /* 694 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4102 695 * @tc.name: testPathGetSegmentAbnormal 696 * @tc.desc: Test cases where the function intercepts a path fragment and appends it to the destination path with an 697 * passed exception parameter 698 * @tc.size : SmallTest 699 * @tc.type : Function 700 * @tc.level : Level 3 701 */ 702 HWTEST_F(DrawingNativePathPart3Test, testPathGetSegmentAbnormal, Function | SmallTest | Level3) { 703 // 1. Create a path object using OH_Drawing_PathCreate 704 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 705 EXPECT_NE(path, nullptr); 706 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 707 OH_Drawing_PathMoveTo(path, 100, 100); 708 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo 709 OH_Drawing_PathLineTo(path, 100, 200); 710 OH_Drawing_PathLineTo(path, 200, 200); 711 // 4. Create a target path object using OH_Drawing_PathCreate 712 OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); 713 EXPECT_NE(dstPath, nullptr); 714 bool result = false; 715 OH_Drawing_ErrorCode errorCode; 716 // 5. The third argument of the function OH_Drawing_PathGetSegment passes a negative number 717 errorCode = OH_Drawing_PathGetSegment(path, false, -50, 180, true, dstPath, &result); 718 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 719 EXPECT_EQ(result, true); 720 // 6. The fourth parameter of the function OH_Drawing_PathGetSegment passes a number greater than the path length 721 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 999, true, dstPath, &result); 722 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 723 EXPECT_EQ(result, true); 724 // 7. The function OH_Drawing_PathGetSegment passes in the third and fourth arguments equal in value 725 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 120, true, dstPath, &result); 726 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 727 EXPECT_EQ(result, false); 728 // 8. The third argument of the function OH_Drawing_PathGetSegment is greater than the value of the fourth argument 729 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 100, true, dstPath, &result); 730 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 731 EXPECT_EQ(result, false); 732 // 9. Free the memory 733 OH_Drawing_PathDestroy(path); 734 OH_Drawing_PathDestroy(dstPath); 735 } 736 737 /* 738 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4103 739 * @tc.name: testPathGetSegmentMultiplies 740 * @tc.desc: The test function intercepts the path fragment and appends it to the target path loop several times 741 * @tc.size : SmallTest 742 * @tc.type : Function 743 * @tc.level : Level 3 744 */ 745 HWTEST_F(DrawingNativePathPart3Test, testPathGetSegmentMultiplies, Function | SmallTest | Level3) { 746 // 1. Create a path object using OH_Drawing_PathCreate 747 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 748 EXPECT_NE(path, nullptr); 749 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo 750 OH_Drawing_PathMoveTo(path, 100, 100); 751 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo 752 OH_Drawing_PathLineTo(path, 100, 200); 753 OH_Drawing_PathLineTo(path, 200, 200); 754 // 4. Create a target path object using OH_Drawing_PathCreate 755 OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); 756 EXPECT_NE(dstPath, nullptr); 757 bool result = false; 758 OH_Drawing_ErrorCode errorCode; 759 // 5. The function OH_Drawing_PathGetSegment is called 10 times 760 for (int i = 0; i < 10; i++) { 761 errorCode = OH_Drawing_PathGetSegment(path, false, 120, 180, true, dstPath, &result); 762 } 763 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 764 EXPECT_EQ(result, true); 765 // 6. Free the memory 766 OH_Drawing_PathDestroy(path); 767 OH_Drawing_PathDestroy(dstPath); 768 } 769 770 /* 771 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4200 772 * @tc.name: testPathSetPathNormal 773 * @tc.desc: test for testPathSetPathNormal 774 * @tc.size : SmallTest 775 * @tc.type : Function 776 * @tc.level : Level 0 777 */ 778 HWTEST_F(DrawingNativePathPart3Test, testPathSetPathNormal, Function | SmallTest | Level0) { 779 // 1. Create a path object using OH_Drawing_PathCreate. 780 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 781 EXPECT_NE(path, nullptr); 782 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 783 OH_Drawing_PathMoveTo(path, 100, 100); 784 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 785 OH_Drawing_PathLineTo(path, 100, 200); 786 OH_Drawing_PathLineTo(path, 200, 200); 787 // 4. Create a other path object using OH_Drawing_PathCreate. 788 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 789 EXPECT_NE(other, nullptr); 790 OH_Drawing_PathAddCircle(other, 200, 200, 150, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 791 // 5. The function OH_Drawing_PathSetPath is called normally. 792 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathSetPath(path, other); 793 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 794 // 6. Free the memory. 795 OH_Drawing_PathDestroy(path); 796 OH_Drawing_PathDestroy(other); 797 } 798 799 /* 800 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4201 801 * @tc.name: testPathSetPathNull 802 * @tc.desc: test for testPathSetPathNull 803 * @tc.size : SmallTest 804 * @tc.type : Function 805 * @tc.level : Level 3 806 */ 807 HWTEST_F(DrawingNativePathPart3Test, testPathSetPathNull, Function | SmallTest | Level3) { 808 // 1. Create a path object using OH_Drawing_PathCreate. 809 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 810 EXPECT_NE(path, nullptr); 811 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 812 OH_Drawing_PathMoveTo(path, 100, 100); 813 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 814 OH_Drawing_PathLineTo(path, 100, 200); 815 OH_Drawing_PathLineTo(path, 200, 200); 816 // 4. Create a other path object using OH_Drawing_PathCreate. 817 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 818 EXPECT_NE(other, nullptr); 819 OH_Drawing_PathAddCircle(other, 200, 200, 150, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 820 // 5. The function OH_Drawing_PathSetPath passes to nullptr. 821 OH_Drawing_ErrorCode errorCode; 822 errorCode = OH_Drawing_PathSetPath(nullptr, other); 823 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 824 errorCode = OH_Drawing_PathSetPath(path, nullptr); 825 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 826 // 6. Free the memory. 827 OH_Drawing_PathDestroy(path); 828 OH_Drawing_PathDestroy(other); 829 } 830 831 /* 832 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4202 833 * @tc.name: testPathSetPathMulptiCalls 834 * @tc.desc: test for testPathSetPathMulptiCalls 835 * @tc.size : SmallTest 836 * @tc.type : Function 837 * @tc.level : Level 3 838 */ 839 HWTEST_F(DrawingNativePathPart3Test, testPathSetPathMulptiCalls, Function | SmallTest | Level3) { 840 // 1. Create a path object using OH_Drawing_PathCreate. 841 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 842 EXPECT_NE(path, nullptr); 843 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 844 OH_Drawing_PathMoveTo(path, 100, 100); 845 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 846 OH_Drawing_PathLineTo(path, 100, 200); 847 OH_Drawing_PathLineTo(path, 200, 200); 848 // 4. Create a other path object using OH_Drawing_PathCreate. 849 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 850 EXPECT_NE(other, nullptr); 851 OH_Drawing_PathAddCircle(other, 200, 200, 150, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 852 // 5. The function OH_Drawing_PathSetPath is called 10 times. 853 OH_Drawing_ErrorCode errorCode; 854 for (int i = 0; i < 10; i++) { 855 errorCode = OH_Drawing_PathSetPath(path, other); 856 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 857 } 858 // 6. Free the memory. 859 OH_Drawing_PathDestroy(path); 860 OH_Drawing_PathDestroy(other); 861 } 862 863 /* 864 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4300 865 * @tc.name: testPathIsEmptyNormal 866 * @tc.desc: test for testPathIsEmptyNormal 867 * @tc.size : SmallTest 868 * @tc.type : Function 869 * @tc.level : Level 0 870 */ 871 HWTEST_F(DrawingNativePathPart3Test, testPathIsEmptyNormal, Function | SmallTest | Level0) { 872 // 1. Create a path object using OH_Drawing_PathCreate. 873 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 874 EXPECT_NE(path, nullptr); 875 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 876 OH_Drawing_PathMoveTo(path, 100, 100); 877 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 878 OH_Drawing_PathLineTo(path, 100, 200); 879 OH_Drawing_PathLineTo(path, 200, 200); 880 // 4. Initialization of variable. 881 bool isEmpty = true; 882 // 5. The function OH_Drawing_PathIsEmpty is called normally. 883 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathIsEmpty(path, &isEmpty); 884 EXPECT_EQ(isEmpty, false); 885 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 886 // 6. Free the memory. 887 OH_Drawing_PathDestroy(path); 888 } 889 890 /* 891 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4301 892 * @tc.name: testPathIsEmptyNull 893 * @tc.desc: test for testPathIsEmptyNull 894 * @tc.size : SmallTest 895 * @tc.type : Function 896 * @tc.level : Level 3 897 */ 898 HWTEST_F(DrawingNativePathPart3Test, testPathIsEmptyNull, Function | SmallTest | Level3) { 899 // 1. Create a path object using OH_Drawing_PathCreate. 900 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 901 EXPECT_NE(path, nullptr); 902 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 903 OH_Drawing_PathMoveTo(path, 100, 100); 904 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 905 OH_Drawing_PathLineTo(path, 100, 200); 906 OH_Drawing_PathLineTo(path, 200, 200); 907 // 4. Initialization of variable. 908 bool isEmpty = false; 909 // 5. The function OH_Drawing_PathIsEmpty passes to nullptr. 910 OH_Drawing_ErrorCode errorCode; 911 errorCode = OH_Drawing_PathIsEmpty(nullptr, &isEmpty); 912 EXPECT_EQ(isEmpty, false); 913 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 914 errorCode = OH_Drawing_PathIsEmpty(path, nullptr); 915 EXPECT_EQ(isEmpty, false); 916 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 917 // 6. Free the memory. 918 OH_Drawing_PathDestroy(path); 919 } 920 921 /* 922 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4302 923 * @tc.name: testPathIsEmptyMultipleCalls 924 * @tc.desc: test for testPathIsEmptyMultipleCalls 925 * @tc.size : SmallTest 926 * @tc.type : Function 927 * @tc.level : Level 3 928 */ 929 HWTEST_F(DrawingNativePathPart3Test, testPathIsEmptyMultipleCalls, Function | SmallTest | Level3) { 930 // 1. Create a path object using OH_Drawing_PathCreate. 931 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 932 EXPECT_NE(path, nullptr); 933 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 934 OH_Drawing_PathMoveTo(path, 100, 100); 935 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 936 OH_Drawing_PathLineTo(path, 100, 200); 937 OH_Drawing_PathLineTo(path, 200, 200); 938 // 4. Initialization of variable. 939 bool isEmpty = true; 940 // 5. The function OH_Drawing_PathIsEmpty is called 10 times. 941 OH_Drawing_ErrorCode errorCode; 942 for (int i = 0; i < 10; i++) { 943 errorCode = OH_Drawing_PathIsEmpty(path, &isEmpty); 944 EXPECT_EQ(isEmpty, false); 945 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 946 } 947 // 6. Free the memory. 948 OH_Drawing_PathDestroy(path); 949 } 950 951 /* 952 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4400 953 * @tc.name: testPathIsRectNormal 954 * @tc.desc: test for testPathIsRectNormal 955 * @tc.size : SmallTest 956 * @tc.type : Function 957 * @tc.level : Level 0 958 */ 959 HWTEST_F(DrawingNativePathPart3Test, testPathIsRectNormal, Function | SmallTest | Level0) { 960 // 1. Create a path object using OH_Drawing_PathCreate. 961 OH_Drawing_Path *path1 = OH_Drawing_PathCreate(); 962 EXPECT_NE(path1, nullptr); 963 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 964 OH_Drawing_PathMoveTo(path1, 100, 100); 965 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 966 OH_Drawing_PathLineTo(path1, 100, 200); 967 OH_Drawing_PathLineTo(path1, 200, 200); 968 // 4. Create a rect object. 969 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 970 // 5. Initialization of variable. 971 bool isRect = true; 972 // 6. The function OH_Drawing_PathIsRect is called normally. 973 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathIsRect(path1, rect, &isRect); 974 EXPECT_EQ(isRect, false); 975 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 976 // 7. Create a path object using OH_Drawing_PathCreate. 977 OH_Drawing_Path *path2 = OH_Drawing_PathCreate(); 978 EXPECT_NE(path2, nullptr); 979 // 8. Set the path to a rectangle. 980 OH_Drawing_PathAddRect(path2, 0, 0, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 981 // 9. The function OH_Drawing_PathIsRect is called normally. 982 errorCode = OH_Drawing_PathIsRect(path2, rect, &isRect); 983 EXPECT_EQ(isRect, true); 984 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 985 // 10. Free the memory. 986 OH_Drawing_RectDestroy(rect); 987 OH_Drawing_PathDestroy(path1); 988 OH_Drawing_PathDestroy(path2); 989 } 990 991 /* 992 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4401 993 * @tc.name: testPathIsRectNull 994 * @tc.desc: test for testPathIsRectNull 995 * @tc.size : SmallTest 996 * @tc.type : Function 997 * @tc.level : Level 3 998 */ 999 HWTEST_F(DrawingNativePathPart3Test, testPathIsRectNull, Function | SmallTest | Level3) { 1000 // 1. Create a path object using OH_Drawing_PathCreate. 1001 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1002 EXPECT_NE(path, nullptr); 1003 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1004 OH_Drawing_PathMoveTo(path, 100, 100); 1005 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 1006 OH_Drawing_PathLineTo(path, 100, 200); 1007 OH_Drawing_PathLineTo(path, 200, 200); 1008 // 4. Create a rect object. 1009 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 1010 // 5. Initialization of variable. 1011 bool isRect = true; 1012 // 6. The first parameter of the interface OH_Drawing_PathIsRect is passed to nullptr. 1013 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathIsRect(nullptr, rect, &isRect); 1014 EXPECT_EQ(isRect, true); 1015 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1016 // 7. The second parameter of the interface OH_Drawing_PathIsRect is passed to nullptr. 1017 errorCode = OH_Drawing_PathIsRect(path, nullptr, &isRect); 1018 EXPECT_EQ(isRect, false); 1019 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1020 // 8. The third parameter of the interface OH_Drawing_PathIsRect is passed to nullptr. 1021 errorCode = OH_Drawing_PathIsRect(path, rect, nullptr); 1022 EXPECT_EQ(isRect, false); 1023 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1024 // 9. Free the memory. 1025 OH_Drawing_RectDestroy(rect); 1026 OH_Drawing_PathDestroy(path); 1027 } 1028 1029 /* 1030 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4402 1031 * @tc.name: testPathIsRectMultipleCalls 1032 * @tc.desc: test for testPathIsRectMultipleCalls 1033 * @tc.size : SmallTest 1034 * @tc.type : Function 1035 * @tc.level : Level 3 1036 */ 1037 HWTEST_F(DrawingNativePathPart3Test, testPathIsRectMultipleCalls, Function | SmallTest | Level3) { 1038 // 1. Create a path object using OH_Drawing_PathCreate. 1039 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1040 EXPECT_NE(path, nullptr); 1041 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1042 OH_Drawing_PathMoveTo(path, 100, 100); 1043 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 1044 OH_Drawing_PathLineTo(path, 100, 200); 1045 OH_Drawing_PathLineTo(path, 200, 200); 1046 // 4. Create a rect object. 1047 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 1048 // 5. Initialization of variable. 1049 bool isRect = true; 1050 // 6. The interface OH_Drawing_PathIsRect is called 10 times. 1051 OH_Drawing_ErrorCode errorCode; 1052 for (int i = 0; i < 10; i++) { 1053 errorCode = OH_Drawing_PathIsRect(path, rect, &isRect); 1054 EXPECT_EQ(isRect, false); 1055 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1056 } 1057 // 7. Free the memory. 1058 OH_Drawing_RectDestroy(rect); 1059 OH_Drawing_PathDestroy(path); 1060 } 1061 1062 /* 1063 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4500 1064 * @tc.name: testPathGetFillTypeNormal 1065 * @tc.desc: test for testPathGetFillTypeNormal 1066 * @tc.size : SmallTest 1067 * @tc.type : Function 1068 * @tc.level : Level 0 1069 */ 1070 HWTEST_F(DrawingNativePathPart3Test, testPathGetFillTypeNormal, Function | SmallTest | Level0) { 1071 // 1. Create a path object using OH_Drawing_PathCreate. 1072 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1073 EXPECT_NE(path, nullptr); 1074 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1075 OH_Drawing_PathMoveTo(path, 100, 100); 1076 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 1077 OH_Drawing_PathLineTo(path, 100, 200); 1078 OH_Drawing_PathLineTo(path, 200, 200); 1079 // 4. Enumeration traversal. 1080 OH_Drawing_PathFillType pathFillType = PATH_FILL_TYPE_WINDING; 1081 OH_Drawing_PathSetFillType(path, pathFillType); 1082 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathGetFillType(path, &pathFillType); 1083 EXPECT_EQ(pathFillType, OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING); 1084 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1085 1086 pathFillType = PATH_FILL_TYPE_EVEN_ODD; 1087 OH_Drawing_PathSetFillType(path, pathFillType); 1088 errorCode = OH_Drawing_PathGetFillType(path, &pathFillType); 1089 EXPECT_EQ(pathFillType, OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD); 1090 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1091 1092 pathFillType = PATH_FILL_TYPE_INVERSE_WINDING; 1093 OH_Drawing_PathSetFillType(path, pathFillType); 1094 errorCode = OH_Drawing_PathGetFillType(path, &pathFillType); 1095 EXPECT_EQ(pathFillType, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_WINDING); 1096 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1097 1098 pathFillType = PATH_FILL_TYPE_INVERSE_EVEN_ODD; 1099 OH_Drawing_PathSetFillType(path, pathFillType); 1100 errorCode = OH_Drawing_PathGetFillType(path, &pathFillType); 1101 EXPECT_EQ(pathFillType, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_EVEN_ODD); 1102 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1103 // 5. Free the memory. 1104 OH_Drawing_PathDestroy(path); 1105 } 1106 1107 /* 1108 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4501 1109 * @tc.name: testPathGetFillTypeNull 1110 * @tc.desc: test for testPathGetFillTypeNull 1111 * @tc.size : SmallTest 1112 * @tc.type : Function 1113 * @tc.level : Level 3 1114 */ 1115 HWTEST_F(DrawingNativePathPart3Test, testPathGetFillTypeNull, Function | SmallTest | Level3) { 1116 // 1. Create a path object using OH_Drawing_PathCreate. 1117 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1118 EXPECT_NE(path, nullptr); 1119 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1120 OH_Drawing_PathMoveTo(path, 100, 100); 1121 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 1122 OH_Drawing_PathLineTo(path, 100, 200); 1123 OH_Drawing_PathLineTo(path, 200, 200); 1124 // 4. The function OH_Drawing_PathIsEmpty passes to nullptr. 1125 OH_Drawing_PathFillType pathFillType = PATH_FILL_TYPE_WINDING; 1126 OH_Drawing_PathSetFillType(path, pathFillType); 1127 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathGetFillType(nullptr, &pathFillType); 1128 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1129 1130 pathFillType = PATH_FILL_TYPE_EVEN_ODD; 1131 OH_Drawing_PathSetFillType(path, pathFillType); 1132 errorCode = OH_Drawing_PathGetFillType(path, nullptr); 1133 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1134 // 5. Free the memory. 1135 OH_Drawing_PathDestroy(path); 1136 } 1137 1138 /* 1139 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4502 1140 * @tc.name: testPathGetFillTypeMultipleCalls 1141 * @tc.desc: test for testPathGetFillTypeMultipleCalls 1142 * @tc.size : SmallTest 1143 * @tc.type : Function 1144 * @tc.level : Level 3 1145 */ 1146 HWTEST_F(DrawingNativePathPart3Test, testPathGetFillTypeMultipleCalls, Function | SmallTest | Level3) { 1147 // 1. Create a path object using OH_Drawing_PathCreate. 1148 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1149 EXPECT_NE(path, nullptr); 1150 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1151 OH_Drawing_PathMoveTo(path, 100, 100); 1152 // 3. Add two lines segment from the starting point to the target point using OH_Drawing_PathLineTo. 1153 OH_Drawing_PathLineTo(path, 100, 200); 1154 OH_Drawing_PathLineTo(path, 200, 200); 1155 // 4. The function OH_Drawing_PathIsEmpty is called 10 times. 1156 OH_Drawing_ErrorCode errorCode; 1157 OH_Drawing_PathFillType pathFillType = PATH_FILL_TYPE_WINDING; 1158 OH_Drawing_PathSetFillType(path, pathFillType); 1159 for (int i = 0; i < 10; i++) { 1160 errorCode = OH_Drawing_PathGetFillType(path, &pathFillType); 1161 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1162 } 1163 // 5. Free the memory. 1164 OH_Drawing_PathDestroy(path); 1165 } 1166 1167 /* 1168 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4600 1169 * @tc.name: testPathApproximateNormal 1170 * @tc.desc: test for testPathApproximateNormal 1171 * @tc.size : SmallTest 1172 * @tc.type : Function 1173 * @tc.level : Level 0 1174 */ 1175 HWTEST_F(DrawingNativePathPart3Test, testPathApproximateNormal, Function | SmallTest | Level0) { 1176 // 1. Create a path object using OH_Drawing_PathCreate. 1177 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1178 EXPECT_NE(path, nullptr); 1179 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1180 OH_Drawing_PathMoveTo(path, 100, 100); 1181 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1182 OH_Drawing_PathLineTo(path, 200, 200); 1183 float acceptableError = 0.1; 1184 uint32_t count = 0; 1185 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count); 1186 float *vals = new float[count]; 1187 // 4. The interface OH_Drawing_PathApproximate is called normally. 1188 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, &count); 1189 EXPECT_EQ(count, 6); 1190 EXPECT_EQ(vals[0], 0); 1191 EXPECT_EQ(vals[1], 100.0); 1192 EXPECT_EQ(vals[2], 100.0); 1193 EXPECT_EQ(vals[3], 1.0); 1194 EXPECT_EQ(vals[4], 200.0); 1195 EXPECT_EQ(vals[5], 200.0); 1196 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1197 // 5. Free the memory. 1198 OH_Drawing_PathDestroy(path); 1199 } 1200 1201 /* 1202 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4601 1203 * @tc.name: testPathApproximateNull 1204 * @tc.desc: test for testPathApproximateNull 1205 * @tc.size : SmallTest 1206 * @tc.type : Function 1207 * @tc.level : Level 3 1208 */ 1209 HWTEST_F(DrawingNativePathPart3Test, testPathApproximateNull, Function | SmallTest | Level3) { 1210 // 1. Create a path object using OH_Drawing_PathCreate. 1211 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1212 EXPECT_NE(path, nullptr); 1213 float acceptableError = 0.1; 1214 uint32_t count = 0; 1215 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count); 1216 float *vals = new float[count]; 1217 // 2. Verify the empty path. 1218 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, &count); 1219 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1220 // 3. The first parameter of the verification interface is passed as a null pointer. 1221 errorCode = OH_Drawing_PathApproximate(nullptr, acceptableError, vals, &count); 1222 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1223 // 4. The second parameter of the verification interface is passed as 0. 1224 errorCode = OH_Drawing_PathApproximate(path, 0, vals, &count); 1225 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1226 // 5. The third parameter of the verification interface is passed as a null pointer. 1227 errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count); 1228 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1229 // 6. The third parameter and the forth parameter of the verification interface are passed as null pointer. 1230 errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, nullptr); 1231 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1232 // 7. The forth parameter of the verification interface is passed as a null pointer. 1233 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, nullptr); 1234 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1235 // 8. Free the memory. 1236 OH_Drawing_PathDestroy(path); 1237 } 1238 1239 /* 1240 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4602 1241 * @tc.name: testPathApproximateAbnormal 1242 * @tc.desc: test for testPathApproximateAbnormal 1243 * @tc.size : SmallTest 1244 * @tc.type : Function 1245 * @tc.level : Level 3 1246 */ 1247 HWTEST_F(DrawingNativePathPart3Test, testPathApproximateAbnormal, Function | SmallTest | Level3) { 1248 // 1. Create a path object using OH_Drawing_PathCreate. 1249 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1250 EXPECT_NE(path, nullptr); 1251 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1252 OH_Drawing_PathMoveTo(path, 100, 100); 1253 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1254 OH_Drawing_PathLineTo(path, 200, 200); 1255 float acceptableError = 0.1; 1256 uint32_t count = 0; 1257 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count); 1258 float *vals = new float[count]; 1259 // 4. AcceptableError lesses than 0. 1260 errorCode = OH_Drawing_PathApproximate(path, -0.1, vals, &count); 1261 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); 1262 // 3. The length of the array is greater than the length of the actual return point. 1263 uint32_t count1 = 10; 1264 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, &count1); 1265 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1266 // 4. The length of the array is lesses than the length of the actual return point. 1267 uint32_t count2 = 2; 1268 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, &count2); 1269 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1270 // 5. Free the memory. 1271 OH_Drawing_PathDestroy(path); 1272 } 1273 1274 /* 1275 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4603 1276 * @tc.name: testPathApproximateMultiCalls 1277 * @tc.desc: test for testPathApproximateMultiCalls 1278 * @tc.size : SmallTest 1279 * @tc.type : Function 1280 * @tc.level : Level 3 1281 */ 1282 HWTEST_F(DrawingNativePathPart3Test, testPathApproximateMultiCalls, Function | SmallTest | Level3) { 1283 // 1. Create a path object using OH_Drawing_PathCreate. 1284 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1285 EXPECT_NE(path, nullptr); 1286 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1287 OH_Drawing_PathMoveTo(path, 100, 100); 1288 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1289 OH_Drawing_PathLineTo(path, 200, 200); 1290 float acceptableError = 0.1; 1291 uint32_t count = 0; 1292 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count); 1293 float *vals = new float[count]; 1294 // 4. The interface is called in a loop 10 times. 1295 for (int i = 0; i < 10; i++) { 1296 errorCode = OH_Drawing_PathApproximate(path, acceptableError, vals, &count); 1297 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1298 } 1299 // 5. Free the memory. 1300 OH_Drawing_PathDestroy(path); 1301 } 1302 1303 /* 1304 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4700 1305 * @tc.name: testPathInterpolateNormal 1306 * @tc.desc: test for testPathInterpolateNormal 1307 * @tc.size : SmallTest 1308 * @tc.type : Function 1309 * @tc.level : Level 0 1310 */ 1311 HWTEST_F(DrawingNativePathPart3Test, testPathInterpolateNormal, Function | SmallTest | Level0) { 1312 // 1. Create a path object using OH_Drawing_PathCreate. 1313 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1314 EXPECT_NE(path, nullptr); 1315 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1316 OH_Drawing_PathMoveTo(path, 50, 50); 1317 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1318 OH_Drawing_PathLineTo(path, 100, 150); 1319 // 4. Create a path object using OH_Drawing_PathCreate. 1320 OH_Drawing_Path *other1 = OH_Drawing_PathCreate(); 1321 EXPECT_NE(other1, nullptr); 1322 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1323 OH_Drawing_PathMoveTo(other1, 100, 50); 1324 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1325 OH_Drawing_PathLineTo(other1, 200, 300); 1326 // 7. Create a path object using OH_Drawing_PathCreate. 1327 OH_Drawing_Path *other2 = OH_Drawing_PathCreate(); 1328 EXPECT_NE(other2, nullptr); 1329 // 8. Use the interface OH_Drawing_PathArcTo to add the path as an arc. 1330 OH_Drawing_PathArcTo(other2, 100, 100, 800, 800, 0, 180); 1331 // 9. Create a path object using OH_Drawing_PathCreate. 1332 OH_Drawing_Path *interpolatePath = OH_Drawing_PathCreate(); 1333 EXPECT_NE(interpolatePath, nullptr); 1334 bool result = false; 1335 // 10. Call the interface OH_Drawing_PathInterpolate to verify the straight line and the straight line. 1336 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathInterpolate(path, other1, 0.5, &result, interpolatePath); 1337 EXPECT_EQ(result, true); 1338 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1339 // 11. Call the interface OH_Drawing_PathInterpolate to verify straight line and arc. 1340 errorCode = OH_Drawing_PathInterpolate(path, other2, 0.5, &result, interpolatePath); 1341 EXPECT_EQ(result, false); 1342 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1343 // 9. Free the memory. 1344 OH_Drawing_PathDestroy(path); 1345 OH_Drawing_PathDestroy(other1); 1346 OH_Drawing_PathDestroy(other2); 1347 OH_Drawing_PathDestroy(interpolatePath); 1348 } 1349 1350 /* 1351 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4701 1352 * @tc.name: testPathInterpolateNull 1353 * @tc.desc: test for testPathInterpolateNull 1354 * @tc.size : SmallTest 1355 * @tc.type : Function 1356 * @tc.level : Level 3 1357 */ 1358 HWTEST_F(DrawingNativePathPart3Test, testPathInterpolateNull, Function | SmallTest | Level3) { 1359 // 1. Create a path object using OH_Drawing_PathCreate. 1360 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1361 EXPECT_NE(path, nullptr); 1362 // 2. Create a path object using OH_Drawing_PathCreate. 1363 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 1364 EXPECT_NE(other, nullptr); 1365 // 3. Create a path object using OH_Drawing_PathCreate. 1366 OH_Drawing_Path *interpolatePath = OH_Drawing_PathCreate(); 1367 EXPECT_NE(interpolatePath, nullptr); 1368 bool result = false; 1369 // 4. Call the interface OH_Drawing_PathInterpolate to verify the interpolation of the empty path. 1370 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathInterpolate(path, other, 0.5, &result, interpolatePath); 1371 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1372 // 4. Set the starting point of the path using OH_Drawing_PathMoveTo. 1373 OH_Drawing_PathMoveTo(path, 50, 50); 1374 // 5. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1375 OH_Drawing_PathLineTo(path, 100, 150); 1376 // 6. Set the starting point of the path using OH_Drawing_PathMoveTo. 1377 OH_Drawing_PathMoveTo(other, 100, 50); 1378 // 7. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1379 OH_Drawing_PathLineTo(other, 200, 300); 1380 // 8. The first parameter of the verification interface is passed as a null pointer. 1381 errorCode = OH_Drawing_PathInterpolate(nullptr, other, 0.5, &result, interpolatePath); 1382 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1383 // 9. The second parameter of the verification interface is passed as a null pointer. 1384 errorCode = OH_Drawing_PathInterpolate(path, nullptr, 0.5, &result, interpolatePath); 1385 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1386 // 10. The third parameter of the verification interface is passed as 0. 1387 errorCode = OH_Drawing_PathInterpolate(path, other, 0, &result, interpolatePath); 1388 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1389 // 11. The forth parameter of the verification interface is passed as a null pointer 1390 errorCode = OH_Drawing_PathInterpolate(path, other, 0.5, nullptr, interpolatePath); 1391 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1392 // 12. The fifth parameter of the verification interface is passed as a null pointer. 1393 errorCode = OH_Drawing_PathInterpolate(path, other, 0.5, &result, nullptr); 1394 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1395 // 13. Free the memory. 1396 OH_Drawing_PathDestroy(path); 1397 OH_Drawing_PathDestroy(other); 1398 OH_Drawing_PathDestroy(interpolatePath); 1399 } 1400 1401 /* 1402 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4702 1403 * @tc.name: testPathInterpolateAbnormal 1404 * @tc.desc: test for testPathInterpolateAbnormal 1405 * @tc.size : SmallTest 1406 * @tc.type : Function 1407 * @tc.level : Level 3 1408 */ 1409 HWTEST_F(DrawingNativePathPart3Test, testPathInterpolateAbnormal, Function | SmallTest | Level3) { 1410 // 1. Create a path object using OH_Drawing_PathCreate. 1411 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1412 EXPECT_NE(path, nullptr); 1413 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1414 OH_Drawing_PathMoveTo(path, 50, 50); 1415 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1416 OH_Drawing_PathLineTo(path, 100, 150); 1417 // 4. Create a path object using OH_Drawing_PathCreate. 1418 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 1419 EXPECT_NE(other, nullptr); 1420 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1421 OH_Drawing_PathMoveTo(other, 100, 50); 1422 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1423 OH_Drawing_PathLineTo(other, 200, 300); 1424 // 7. Create a path object using OH_Drawing_PathCreate. 1425 OH_Drawing_Path *interpolatePath = OH_Drawing_PathCreate(); 1426 EXPECT_NE(interpolatePath, nullptr); 1427 // 8. The third parameter of the verification interface is passed as a negative number. 1428 bool result = false; 1429 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathInterpolate(path, other, -0.5, &result, interpolatePath); 1430 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); 1431 // 9. The third parameter of the verification interface is passed as a number greater than 1. 1432 errorCode = OH_Drawing_PathInterpolate(path, other, 1.5, &result, interpolatePath); 1433 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); 1434 // 10. Free the memory. 1435 OH_Drawing_PathDestroy(path); 1436 OH_Drawing_PathDestroy(other); 1437 OH_Drawing_PathDestroy(interpolatePath); 1438 } 1439 1440 /* 1441 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4703 1442 * @tc.name: testPathInterpolateMultiCalls 1443 * @tc.desc: test for testPathInterpolateMultiCalls 1444 * @tc.size : SmallTest 1445 * @tc.type : Function 1446 * @tc.level : Level 3 1447 */ 1448 HWTEST_F(DrawingNativePathPart3Test, testPathInterpolateMultiCalls, Function | SmallTest | Level3) { 1449 // 1. Create a path object using OH_Drawing_PathCreate. 1450 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1451 EXPECT_NE(path, nullptr); 1452 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1453 OH_Drawing_PathMoveTo(path, 50, 50); 1454 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1455 OH_Drawing_PathLineTo(path, 100, 150); 1456 // 4. Create a path object using OH_Drawing_PathCreate. 1457 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 1458 EXPECT_NE(other, nullptr); 1459 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1460 OH_Drawing_PathMoveTo(other, 100, 50); 1461 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1462 OH_Drawing_PathLineTo(other, 200, 300); 1463 // 7. Create a path object using OH_Drawing_PathCreate. 1464 OH_Drawing_Path *interpolatePath = OH_Drawing_PathCreate(); 1465 EXPECT_NE(interpolatePath, nullptr); 1466 // 8. The interface is called in a loop 10 times. 1467 bool result = false; 1468 OH_Drawing_ErrorCode errorCode; 1469 for (int i = 0; i < 10; i++) { 1470 errorCode = OH_Drawing_PathInterpolate(path, other, 0.5, &result, interpolatePath); 1471 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1472 } 1473 // 9. Free the memory. 1474 OH_Drawing_PathDestroy(path); 1475 OH_Drawing_PathDestroy(other); 1476 OH_Drawing_PathDestroy(interpolatePath); 1477 } 1478 1479 /* 1480 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4800 1481 * @tc.name: testPathIsInterpolateNormal 1482 * @tc.desc: test for testPathIsInterpolateNormal 1483 * @tc.size : SmallTest 1484 * @tc.type : Function 1485 * @tc.level : Level 0 1486 */ 1487 HWTEST_F(DrawingNativePathPart3Test, testPathIsInterpolateNormal, Function | SmallTest | Level0) { 1488 // 1. Create a path object using OH_Drawing_PathCreate. 1489 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1490 EXPECT_NE(path, nullptr); 1491 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1492 OH_Drawing_PathMoveTo(path, 50, 50); 1493 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1494 OH_Drawing_PathLineTo(path, 100, 150); 1495 // 4. Create a path object using OH_Drawing_PathCreate. 1496 OH_Drawing_Path *other1 = OH_Drawing_PathCreate(); 1497 EXPECT_NE(other1, nullptr); 1498 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1499 OH_Drawing_PathMoveTo(other1, 100, 50); 1500 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1501 OH_Drawing_PathLineTo(other1, 200, 300); 1502 // 7. Create a path object using OH_Drawing_PathCreate. 1503 OH_Drawing_Path *other2 = OH_Drawing_PathCreate(); 1504 EXPECT_NE(other2, nullptr); 1505 // 8. Use the interface OH_Drawing_PathArcTo to add the path as an arc. 1506 OH_Drawing_PathArcTo(other2, 100, 100, 800, 800, 0, 180); 1507 bool result = false; 1508 // 9. Return true when path and other can be interpolated. 1509 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathIsInterpolate(path, other1, &result); 1510 EXPECT_EQ(result, true); 1511 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1512 // 10. Return false when path and other can not be interpolated. 1513 errorCode = OH_Drawing_PathIsInterpolate(path, other2, &result); 1514 EXPECT_EQ(result, false); 1515 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1516 // 11. Free the memory. 1517 OH_Drawing_PathDestroy(path); 1518 OH_Drawing_PathDestroy(other1); 1519 OH_Drawing_PathDestroy(other2); 1520 } 1521 1522 /* 1523 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4801 1524 * @tc.name: testPathIsInterpolateNull 1525 * @tc.desc: test for testPathIsInterpolateNull 1526 * @tc.size : SmallTest 1527 * @tc.type : Function 1528 * @tc.level : Level 3 1529 */ 1530 HWTEST_F(DrawingNativePathPart3Test, testPathIsInterpolateNull, Function | SmallTest | Level3) { 1531 // 1. Create a path object using OH_Drawing_PathCreate. 1532 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1533 EXPECT_NE(path, nullptr); 1534 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1535 OH_Drawing_PathMoveTo(path, 50, 50); 1536 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1537 OH_Drawing_PathLineTo(path, 100, 150); 1538 // 4. Create a path object using OH_Drawing_PathCreate. 1539 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 1540 EXPECT_NE(other, nullptr); 1541 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1542 OH_Drawing_PathMoveTo(other, 100, 50); 1543 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1544 OH_Drawing_PathLineTo(other, 200, 300); 1545 bool result = false; 1546 // 7. The first parameter of the verification interface is passed to nullptr. 1547 OH_Drawing_ErrorCode errorCode = OH_Drawing_PathIsInterpolate(nullptr, other, &result); 1548 EXPECT_EQ(result, false); 1549 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1550 // 8. The second parameter of the verification interface is passed to nullptr. 1551 errorCode = OH_Drawing_PathIsInterpolate(path, nullptr, &result); 1552 EXPECT_EQ(result, false); 1553 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1554 // 9. The third parameter of the verification interface is passed to nullptr. 1555 errorCode = OH_Drawing_PathIsInterpolate(path, other, nullptr); 1556 EXPECT_EQ(result, false); 1557 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1558 // 10. Free the memory. 1559 OH_Drawing_PathDestroy(path); 1560 OH_Drawing_PathDestroy(other); 1561 } 1562 1563 /* 1564 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_4802 1565 * @tc.name: testPathIsInterpolateMultiCalls 1566 * @tc.desc: test for testPathIsInterpolateMultiCalls 1567 * @tc.size : SmallTest 1568 * @tc.type : Function 1569 * @tc.level : Level 3 1570 */ 1571 HWTEST_F(DrawingNativePathPart3Test, testPathIsInterpolateMultiCalls, Function | SmallTest | Level3) { 1572 // 1. Create a path object using OH_Drawing_PathCreate. 1573 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1574 EXPECT_NE(path, nullptr); 1575 // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1576 OH_Drawing_PathMoveTo(path, 50, 50); 1577 // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1578 OH_Drawing_PathLineTo(path, 100, 150); 1579 // 4. Create a path object using OH_Drawing_PathCreate. 1580 OH_Drawing_Path *other = OH_Drawing_PathCreate(); 1581 EXPECT_NE(other, nullptr); 1582 // 5. Set the starting point of the path using OH_Drawing_PathMoveTo. 1583 OH_Drawing_PathMoveTo(other, 100, 50); 1584 // 6. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1585 OH_Drawing_PathLineTo(other, 200, 300); 1586 bool result = false; 1587 // 7. The interface is called in a loop 10 times. 1588 OH_Drawing_ErrorCode errorCode; 1589 for (int i = 0; i < 10; i++) { 1590 errorCode = OH_Drawing_PathIsInterpolate(path, other, &result); 1591 EXPECT_EQ(result, true); 1592 EXPECT_EQ(errorCode, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS); 1593 } 1594 // 8. Free the memory. 1595 OH_Drawing_PathDestroy(path); 1596 OH_Drawing_PathDestroy(other); 1597 } 1598 } // namespace Drawing 1599 } // namespace Rosen 1600 } // namespace OHOS