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 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0100 40 * @tc.name: testPathCreateNormal 41 * @tc.desc: Test for creating a path object with normal parameters. 42 * @tc.size : SmallTest 43 * @tc.type : Function 44 * @tc.level : Level 0 45 */ 46 HWTEST_F(DrawingNativePathTest, testPathCreateNormal, TestSize.Level0) { 47 // 1. Call OH_Drawing_PathCreate to create a path object 48 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 49 EXPECT_NE(path, nullptr); 50 // 2. Free memory 51 OH_Drawing_PathDestroy(path); 52 } 53 54 /* 55 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0200 56 * @tc.name: testPathCopyNormal 57 * @tc.desc: Test for copying a path with normal parameters and checking the copied path length. 58 * @tc.size : SmallTest 59 * @tc.type : Function 60 * @tc.level : Level 0 61 */ 62 HWTEST_F(DrawingNativePathTest, testPathCopyNormal, TestSize.Level0) { 63 // 1. Create a path object 1 by calling OH_Drawing_PathCreate 64 OH_Drawing_Path *path1 = OH_Drawing_PathCreate(); 65 EXPECT_NE(path1, nullptr); 66 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 67 OH_Drawing_PathMoveTo(path1, 0, 0); 68 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 69 OH_Drawing_PathLineTo(path1, 100, 100); 70 // 4. Add a line segment from the last point of the path to the target point to the path by calling 71 // OH_Drawing_PathLineTo 72 OH_Drawing_PathLineTo(path1, 200, 200); 73 // 5. Add a line segment from the last point of the path to the target point to the path by calling 74 // OH_Drawing_PathLineTo 75 OH_Drawing_PathLineTo(path1, 300, 300); 76 // 6. Close the path by calling OH_Drawing_PathClose 77 OH_Drawing_PathClose(path1); 78 // 7. Copy path 1 to path 2 by calling OH_Drawing_PathCopy 79 OH_Drawing_Path *path2 = OH_Drawing_PathCopy(path1); 80 // 8. Get the length of path 2 by calling OH_Drawing_PathGetLength 81 bool isEqual = IsScalarAlmostEqual(OH_Drawing_PathGetLength(path1, false), OH_Drawing_PathGetLength(path2, false)); 82 EXPECT_TRUE(isEqual); 83 // 9. Free memory 84 OH_Drawing_PathDestroy(path1); 85 } 86 87 /* 88 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0201 89 * @tc.name: testPathCopyNull 90 * @tc.desc: Test for copying a path with NULL parameters. 91 * @tc.size : SmallTest 92 * @tc.type : Function 93 * @tc.level : Level 3 94 */ 95 HWTEST_F(DrawingNativePathTest, testPathCopyNull, TestSize.Level3) { 96 // 1. Create a path object by calling OH_Drawing_PathCreate 97 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 98 // 2. Copy a path with nullptr as the parameter 99 OH_Drawing_Path *path2 = OH_Drawing_PathCopy(nullptr); 100 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 101 // 3. Free memory 102 OH_Drawing_PathDestroy(path); 103 OH_Drawing_PathDestroy(path2); 104 } 105 106 /* 107 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0202 108 * @tc.name: testPathCopyInputDestroyed 109 * @tc.desc: Test for copying a path and checking if the copied path is affected after the original path is destroyed. 110 * @tc.size : SmallTest 111 * @tc.type : Function 112 * @tc.level : Level 3 113 */ 114 HWTEST_F(DrawingNativePathTest, testPathCopyInputDestroyed, TestSize.Level3) { 115 // 1. Create a path object 1 by calling OH_Drawing_PathCreate 116 OH_Drawing_Path *path1 = OH_Drawing_PathCreate(); 117 EXPECT_NE(path1, nullptr); 118 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 119 OH_Drawing_PathMoveTo(path1, 0, 0); 120 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 121 OH_Drawing_PathLineTo(path1, 100, 100); 122 // 4. Add a line segment from the last point of the path to the target point to the path by calling 123 // OH_Drawing_PathLineTo 124 OH_Drawing_PathLineTo(path1, 200, 200); 125 // 5. Add a line segment from the last point of the path to the target point to the path by calling 126 // OH_Drawing_PathLineTo 127 OH_Drawing_PathLineTo(path1, 300, 300); 128 // 6. Close the path by calling OH_Drawing_PathClose 129 OH_Drawing_PathClose(path1); 130 // 7. Copy path 1 to path 2 by calling OH_Drawing_PathCopy 131 OH_Drawing_Path *path2 = OH_Drawing_PathCopy(path1); 132 // 8. Destroy path 1 by calling OH_Drawing_PathDestroy 133 OH_Drawing_PathDestroy(path1); 134 // 9. Get the length of path 2 by calling OH_Drawing_PathGetLength, if the return value is not 0, it means 135 // destroying path 1 does not affect path 2 136 EXPECT_NE(OH_Drawing_PathGetLength(path2, false), 0); 137 // 10. Free memory 138 OH_Drawing_PathDestroy(path2); 139 } 140 141 /* 142 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0300 143 * @tc.name: testPathDestroyNormal 144 * @tc.desc: Test for creating and destroying a path object with normal parameters. 145 * @tc.size : SmallTest 146 * @tc.type : Function 147 * @tc.level : Level 0 148 */ 149 HWTEST_F(DrawingNativePathTest, testPathDestroyNormal, TestSize.Level0) { 150 // 1. Call OH_Drawing_PathCreate to create a path object 151 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 152 // 2. Free memory by calling OH_Drawing_PathDestroy 153 OH_Drawing_PathDestroy(path); 154 } 155 156 /* 157 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0301 158 * @tc.name: testPathDestroyNull 159 * @tc.desc: Test for destroying a path object with NULL parameters. 160 * @tc.size : SmallTest 161 * @tc.type : Function 162 * @tc.level : Level 3 163 */ 164 HWTEST_F(DrawingNativePathTest, testPathDestroyNull, TestSize.Level3) { 165 // 1. Call OH_Drawing_PathCreate to create a path object 166 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 167 // 2. Call OH_Drawing_PathDestroy with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error 168 // code 169 OH_Drawing_PathDestroy(nullptr); 170 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 171 // 3. Free memory 172 OH_Drawing_PathDestroy(path); 173 } 174 175 /* 176 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0400 177 * @tc.name: testPathMoveToNormal 178 * @tc.desc: Test for moving a path to a normal position with valid parameters. 179 * @tc.size : SmallTest 180 * @tc.type : Function 181 * @tc.level : Level 0 182 */ 183 HWTEST_F(DrawingNativePathTest, testPathMoveToNormal, TestSize.Level0) { 184 // 1. Create a path object by calling OH_Drawing_PathCreate 185 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 186 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 187 OH_Drawing_PathMoveTo(path, 0, 0); 188 // 3. Free memory by calling OH_Drawing_PathDestroy 189 OH_Drawing_PathDestroy(path); 190 } 191 192 /* 193 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0401 194 * @tc.name: testPathMoveToNull 195 * @tc.desc: Test for moving a path with NULL or invalid parameters. 196 * @tc.size : SmallTest 197 * @tc.type : Function 198 * @tc.level : Level 3 199 */ 200 HWTEST_F(DrawingNativePathTest, testPathMoveToNull, TestSize.Level3) { 201 // 1. Create a path object by calling OH_Drawing_PathCreate 202 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 203 // 2. Call OH_Drawing_PathMoveTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 204 // error code 205 OH_Drawing_PathMoveTo(nullptr, 1, 1); 206 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 207 // 3. Call OH_Drawing_PathMoveTo with 0.00 as the second parameter 208 OH_Drawing_PathMoveTo(path, 0.00, 1); 209 // 4. Call OH_Drawing_PathMoveTo with 0.00 as the third parameter 210 OH_Drawing_PathMoveTo(path, 1, 0.00); 211 // 5. Free memory 212 OH_Drawing_PathDestroy(path); 213 } 214 215 /* 216 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0402 217 * @tc.name: testPathMoveToAbnormal 218 * @tc.desc: Test for moving a path with abnormal data types as parameters. 219 * @tc.size : SmallTest 220 * @tc.type : Function 221 * @tc.level : Level 3 222 */ 223 HWTEST_F(DrawingNativePathTest, testPathMoveToAbnormal, TestSize.Level3) { 224 // 1. Create a path object by calling OH_Drawing_PathCreate 225 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 226 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo with an integer or character type as the 227 // second parameter 228 OH_Drawing_PathMoveTo(path, 2, 1.0f); 229 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo with an integer or character type as the 230 // third parameter 231 OH_Drawing_PathMoveTo(path, 1.0f, 2); 232 // 4. Free memory by calling OH_Drawing_PathDestroy 233 OH_Drawing_PathDestroy(path); 234 } 235 236 /* 237 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0403 238 * @tc.name: testPathMoveToMaximal 239 * @tc.desc: Test for moving a path with maximal values as parameters. 240 * @tc.size : SmallTest 241 * @tc.type : Function 242 * @tc.level : Level 3 243 */ 244 HWTEST_F(DrawingNativePathTest, testPathMoveToMaximal, TestSize.Level3) { 245 // 1. Create a path object by calling OH_Drawing_PathCreate 246 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 247 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo with the second parameter as the maximum 248 // value of FLT_MAX + 1, no crash 249 OH_Drawing_PathMoveTo(path, FLT_MAX + 1, 1.0); 250 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo with the third parameter as the maximum 251 // value of FLT_MAX + 1, no crash 252 OH_Drawing_PathMoveTo(path, 1.0, FLT_MAX + 1); 253 // 4. Free memory 254 OH_Drawing_PathDestroy(path); 255 } 256 257 /* 258 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0500 259 * @tc.name: testPathLineToNormal 260 * @tc.desc: Test for adding a line to a path with normal parameters. 261 * @tc.size : SmallTest 262 * @tc.type : Function 263 * @tc.level : Level 0 264 */ 265 HWTEST_F(DrawingNativePathTest, testPathLineToNormal, TestSize.Level0) { 266 // 1. Create a path object by calling OH_Drawing_PathCreate 267 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 268 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 269 OH_Drawing_PathMoveTo(path, 0, 0); 270 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 271 OH_Drawing_PathLineTo(path, 100, 100); 272 // 4. Free memory by calling OH_Drawing_PathDestroy 273 OH_Drawing_PathDestroy(path); 274 } 275 276 /* 277 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0501 278 * @tc.name: testPathLineToNull 279 * @tc.desc: Test for adding a line to a path with NULL or invalid parameters. 280 * @tc.size : SmallTest 281 * @tc.type : Function 282 * @tc.level : Level 3 283 */ 284 HWTEST_F(DrawingNativePathTest, testPathLineToNull, TestSize.Level3) { 285 // 1. Create a path object by calling OH_Drawing_PathCreate 286 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 287 // 2. Call OH_Drawing_PathLineTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 288 // error code 289 OH_Drawing_PathLineTo(nullptr, 1, 1); 290 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 291 // 3. Call OH_Drawing_PathLineTo with 0.00 as the second parameter, no crash 292 OH_Drawing_PathLineTo(path, 0.00, 1); 293 // 4. Call OH_Drawing_PathLineTo with 0.00 as the third parameter, no crash 294 OH_Drawing_PathLineTo(path, 1, 0.00); 295 // 5. Free memory 296 OH_Drawing_PathDestroy(path); 297 } 298 299 /* 300 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0502 301 * @tc.name: testPathLineToAbnormal 302 * @tc.desc: Test for moving a path with abnormal data types as parameters. 303 * @tc.size : SmallTest 304 * @tc.type : Function 305 * @tc.level : Level 3 306 */ 307 HWTEST_F(DrawingNativePathTest, testPathLineToAbnormal, TestSize.Level3) { 308 // 1. Create a path object by calling OH_Drawing_PathCreate 309 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 310 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 311 OH_Drawing_PathMoveTo(path, 0, 0); 312 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 313 // with an integer or character type as the second parameter 314 OH_Drawing_PathLineTo(path, 2, 1.0f); 315 // 4. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 316 // with an integer or character type as the third parameter 317 OH_Drawing_PathLineTo(path, 1.0f, 2); 318 // 5. Free memory by calling OH_Drawing_PathDestroy 319 OH_Drawing_PathDestroy(path); 320 } 321 322 /* 323 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0503 324 * @tc.name: testPathLineToMaximal 325 * @tc.desc: Test for moving a path with maximal values as parameters. 326 * @tc.size : SmallTest 327 * @tc.type : Function 328 * @tc.level : Level 3 329 */ 330 HWTEST_F(DrawingNativePathTest, testPathLineToMaximal, TestSize.Level3) { 331 // 1. Create a path object by calling OH_Drawing_PathCreate 332 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 333 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 334 OH_Drawing_PathMoveTo(path, 0, 0); 335 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 336 // with the second parameter as the maximum value of FLT_MAX + 1, no crash 337 OH_Drawing_PathLineTo(path, FLT_MAX + 1, 1.0); 338 // 4. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 339 // with the third parameter as the maximum value of FLT_MAX + 1, no crash 340 OH_Drawing_PathLineTo(path, 1.0, FLT_MAX + 1); 341 // 5. Free memory by calling OH_Drawing_PathDestroy 342 OH_Drawing_PathDestroy(path); 343 } 344 345 /* 346 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0600 347 * @tc.name: testPathArcToNormal 348 * @tc.desc: Test for adding an arc to a path with normal parameters. 349 * @tc.size : SmallTest 350 * @tc.type : Function 351 * @tc.level : Level 0 352 */ 353 HWTEST_F(DrawingNativePathTest, testPathArcToNormal, TestSize.Level0) { 354 // 1. Create a path object by calling OH_Drawing_PathCreate 355 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 356 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 357 OH_Drawing_PathMoveTo(path, 0, 0); 358 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 359 OH_Drawing_PathLineTo(path, 100, 100); 360 // 4. Add a line segment from the last point of the path to the target point to the path by calling 361 // OH_Drawing_PathLineTo 362 OH_Drawing_PathLineTo(path, 200, 200); 363 // 5. Add a line segment from the last point of the path to the target point to the path by calling 364 // OH_Drawing_PathLineTo 365 OH_Drawing_PathLineTo(path, 300, 300); 366 // 6. Close the path by calling OH_Drawing_PathClose 367 OH_Drawing_PathClose(path); 368 // 7. Add an arc to the path by calling OH_Drawing_PathArcTo 369 OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, 90); 370 // 8. Free memory by calling OH_Drawing_PathDestroy 371 OH_Drawing_PathDestroy(path); 372 } 373 374 /* 375 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0601 376 * @tc.name: testPathArcToNull 377 * @tc.desc: Test for adding an arc to a path with NULL or invalid parameters. 378 * @tc.size : SmallTest 379 * @tc.type : Function 380 * @tc.level : Level 3 381 */ 382 HWTEST_F(DrawingNativePathTest, testPathArcToNull, TestSize.Level3) { 383 // 1. Create a path object by calling OH_Drawing_PathCreate 384 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 385 // 2. Call OH_Drawing_PathArcTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 386 // error code 387 OH_Drawing_PathArcTo(nullptr, 10, 10, 20, 0, 0, 90); 388 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 389 // 3. Call OH_Drawing_PathArcTo with 0.00 as the second parameter, no crash 390 OH_Drawing_PathArcTo(path, 0.00, 10, 20, 0, 0, 90); 391 // 4. Call OH_Drawing_PathArcTo with 0.00 as the third parameter, no crash 392 OH_Drawing_PathArcTo(path, 10, 0.00, 20, 0, 0, 90); 393 // 5. Call OH_Drawing_PathArcTo with 0.00 as the fourth parameter, no crash 394 OH_Drawing_PathArcTo(path, 10, 10, 0.00, 0, 0, 90); 395 // 6. Call OH_Drawing_PathArcTo with 0.00 as the fifth parameter, no crash 396 OH_Drawing_PathArcTo(path, 10, 10, 20, 0.00, 0, 90); 397 // 7. Call OH_Drawing_PathArcTo with 0.00 as the sixth parameter, no crash 398 OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0.00, 90); 399 // 8. Call OH_Drawing_PathArcTo with 0.00 as the seventh parameter, no crash 400 OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, 0.00); 401 // 9. Free memory 402 OH_Drawing_PathDestroy(path); 403 } 404 405 /* 406 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0602 407 * @tc.name: testPathArcToAbnormal 408 * @tc.desc: Test for adding an arc to a path with abnormal data types as parameters. 409 * @tc.size : SmallTest 410 * @tc.type : Function 411 * @tc.level : Level 3 412 */ 413 HWTEST_F(DrawingNativePathTest, testPathArcToAbnormal, TestSize.Level3) { 414 // 1. Create a path object by calling OH_Drawing_PathCreate 415 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 416 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 417 OH_Drawing_PathMoveTo(path, 0, 0); 418 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 419 OH_Drawing_PathLineTo(path, 100, 100); 420 // 4. Add a line segment from the last point of the path to the target point to the path by calling 421 // OH_Drawing_PathLineTo 422 OH_Drawing_PathLineTo(path, 200, 200); 423 // 5. Add a line segment from the last point of the path to the target point to the path by calling 424 // OH_Drawing_PathLineTo 425 OH_Drawing_PathLineTo(path, 300, 300); 426 // 6. Close the path by calling OH_Drawing_PathClose 427 OH_Drawing_PathClose(path); 428 // 7. Add an arc to the path by calling OH_Drawing_PathArcTo with integer parameters 429 OH_Drawing_PathArcTo(path, 10, 10, 20, 20, 20, 90); 430 // 8. Free memory by calling OH_Drawing_PathDestroy 431 OH_Drawing_PathDestroy(path); 432 } 433 434 /* 435 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0603 436 * @tc.name: testPathArcToMaximal 437 * @tc.desc: Test for adding an arc to a path with maximal values as parameters. 438 * @tc.size : SmallTest 439 * @tc.type : Function 440 * @tc.level : Level 3 441 */ 442 HWTEST_F(DrawingNativePathTest, testPathArcToMaximal, TestSize.Level3) { 443 // 1. Create a path object by calling OH_Drawing_PathCreate 444 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 445 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 446 OH_Drawing_PathMoveTo(path, 0, 0); 447 // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 448 OH_Drawing_PathLineTo(path, 100, 100); 449 // 4. Add a line segment from the last point of the path to the target point to the path by calling 450 // OH_Drawing_PathLineTo 451 OH_Drawing_PathLineTo(path, 200, 200); 452 // 5. Add a line segment from the last point of the path to the target point to the path by calling 453 // OH_Drawing_PathLineTo 454 OH_Drawing_PathLineTo(path, 300, 300); 455 // 6. Close the path by calling OH_Drawing_PathClose 456 OH_Drawing_PathClose(path); 457 // 7. Add an arc to the path by calling OH_Drawing_PathArcTo with the second parameter as the maximum value of 458 // FLT_MAX + 1, no crash 459 OH_Drawing_PathArcTo(path, FLT_MAX + 1, 10, 20, 0, 0, 90); 460 // 8. Add an arc to the path by calling OH_Drawing_PathArcTo with the third parameter as the maximum value of 461 // FLT_MAX + 1, no crash 462 OH_Drawing_PathArcTo(path, 10, FLT_MAX + 1, 20, 0, 0, 90); 463 // 9. Add an arc to the path by calling OH_Drawing_PathArcTo with the fourth parameter as the maximum value of 464 // FLT_MAX + 1, no crash 465 OH_Drawing_PathArcTo(path, 10, 10, FLT_MAX + 1, 0, 0, 90); 466 // 10. Add an arc to the path by calling OH_Drawing_PathArcTo with the fifth parameter as the maximum value of 467 // FLT_MAX + 1, no crash 468 OH_Drawing_PathArcTo(path, 10, 10, 20, FLT_MAX + 1, 0, 90); 469 // 11. Add an arc to the path by calling OH_Drawing_PathArcTo with the sixth parameter as the maximum value of 470 // FLT_MAX + 1, no crash 471 OH_Drawing_PathArcTo(path, 10, 10, 20, 0, FLT_MAX + 1, 90); 472 // 12. Add an arc to the path by calling OH_Drawing_PathArcTo with the seventh parameter as the maximum value of 473 // FLT_MAX + 1, no crash 474 OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, FLT_MAX + 1); 475 // 13. Free memory 476 OH_Drawing_PathDestroy(path); 477 } 478 479 /* 480 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0700 481 * @tc.name: testPathQuadToNormal 482 * @tc.desc: Test for adding a quadratic Bezier curve to a path with normal parameters. 483 * @tc.size : SmallTest 484 * @tc.type : Function 485 * @tc.level : Level 0 486 */ 487 HWTEST_F(DrawingNativePathTest, testPathQuadToNormal, TestSize.Level0) { 488 // 1. Create a path object by calling OH_Drawing_PathCreate 489 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 490 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 491 OH_Drawing_PathMoveTo(path, 0, 0); 492 // 3. Add a quadratic Bezier curve from the last point of the path to the target point by calling 493 // OH_Drawing_PathQuadTo 494 OH_Drawing_PathQuadTo(path, 100, 100, 200, 200); 495 // 4. Free memory by calling OH_Drawing_PathDestroy 496 OH_Drawing_PathDestroy(path); 497 } 498 499 /* 500 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0701 501 * @tc.name: testPathQuadToNull 502 * @tc.desc: Test for adding a quadratic Bezier curve to a path with NULL or invalid parameters. 503 * @tc.size : SmallTest 504 * @tc.type : Function 505 * @tc.level : Level 3 506 */ 507 HWTEST_F(DrawingNativePathTest, testPathQuadToNull, TestSize.Level3) { 508 // 1. Create a path object by calling OH_Drawing_PathCreate 509 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 510 // 2. Call OH_Drawing_PathQuadTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 511 // error code 512 OH_Drawing_PathQuadTo(nullptr, 100, 100, 200, 200); 513 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 514 // 3. Call OH_Drawing_PathQuadTo with 0.00 as the second parameter, no crash 515 OH_Drawing_PathQuadTo(path, 0.00, 100, 200, 200); 516 // 4. Call OH_Drawing_PathQuadTo with 0.00 as the third parameter, no crash 517 OH_Drawing_PathQuadTo(path, 100, 0.00, 200, 200); 518 // 5. Call OH_Drawing_PathQuadTo with 0.00 as the fourth parameter, no crash 519 OH_Drawing_PathQuadTo(path, 100, 100, 0.00, 200); 520 // 6. Call OH_Drawing_PathQuadTo with 0.00 as the fifth parameter, no crash 521 OH_Drawing_PathQuadTo(path, 100, 100, 200, 0.00); 522 // 7. Free memory 523 OH_Drawing_PathDestroy(path); 524 } 525 526 /* 527 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0702 528 * @tc.name: testPathQuadToAbnormal 529 * @tc.desc: Test for adding a quadratic Bezier curve to a path with abnormal data types as parameters. 530 * @tc.size : SmallTest 531 * @tc.type : Function 532 * @tc.level : Level 3 533 */ 534 HWTEST_F(DrawingNativePathTest, testPathQuadToAbnormal, TestSize.Level3) { 535 // 1. Create a path object by calling OH_Drawing_PathCreate 536 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 537 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 538 OH_Drawing_PathMoveTo(path, 0, 0); 539 // 3. Add a quadratic Bezier curve to the path with the second parameter as an integer 540 OH_Drawing_PathQuadTo(path, 100, 100.0f, 200.0f, 200.0f); 541 // 4. Add a quadratic Bezier curve to the path with the third parameter as an integer 542 OH_Drawing_PathQuadTo(path, 100.0f, 100, 200.0f, 200.0f); 543 // 5. Add a quadratic Bezier curve to the path with the fourth parameter as an integer 544 OH_Drawing_PathQuadTo(path, 100.0f, 100.0f, 200, 200.0f); 545 // 6. Add a quadratic Bezier curve to the path with the fifth parameter as an integer 546 OH_Drawing_PathQuadTo(path, 100.0f, 100.0f, 200.0f, 200); 547 // 7. Free memory by calling OH_Drawing_PathDestroy 548 OH_Drawing_PathDestroy(path); 549 } 550 551 /* 552 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0703 553 * @tc.name: testPathQuadToMaximal 554 * @tc.desc: Test for adding a quadratic Bezier curve to a path with maximal values as parameters. 555 * @tc.size : SmallTest 556 * @tc.type : Function 557 * @tc.level : Level 3 558 */ 559 HWTEST_F(DrawingNativePathTest, testPathQuadToMaximal, TestSize.Level3) { 560 // 1. Create a path object by calling OH_Drawing_PathCreate 561 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 562 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 563 OH_Drawing_PathMoveTo(path, 0, 0); 564 // 3. Call OH_Drawing_PathQuadTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 565 OH_Drawing_PathQuadTo(path, FLT_MAX + 1, 100, 200, 200); 566 // 4. Call OH_Drawing_PathQuadTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 567 OH_Drawing_PathQuadTo(path, 100, FLT_MAX + 1, 200, 200); 568 // 5. Call OH_Drawing_PathQuadTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 569 OH_Drawing_PathQuadTo(path, 100, 100, FLT_MAX + 1, 200); 570 // 6. Call OH_Drawing_PathQuadTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 571 OH_Drawing_PathQuadTo(path, 100, 100, 200, FLT_MAX + 1); 572 // 7. Free memory by calling OH_Drawing_PathDestroy 573 OH_Drawing_PathDestroy(path); 574 } 575 576 /* 577 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0800 578 * @tc.name: testPathConicToNormal 579 * @tc.desc: Test for adding a conic curve to a path with normal parameters. 580 * @tc.size : SmallTest 581 * @tc.type : Function 582 * @tc.level : Level 0 583 */ 584 HWTEST_F(DrawingNativePathTest, testPathConicToNormal, TestSize.Level0) { 585 // 1. Create a path object by calling OH_Drawing_PathCreate 586 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 587 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 588 OH_Drawing_PathMoveTo(path, 0, 0); 589 // 3. Add a line segment from the last point of the path to the target point by calling OH_Drawing_PathLineTo 590 OH_Drawing_PathLineTo(path, 100, 100); 591 // 4. Add a quadratic Bezier curve to the path by calling OH_Drawing_PathConicTo 592 OH_Drawing_PathConicTo(path, 50, 50, 100, 100, 0.5); 593 // 5. Free memory by calling OH_Drawing_PathDestroy 594 OH_Drawing_PathDestroy(path); 595 } 596 597 /* 598 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0801 599 * @tc.name: testPathConicToNull 600 * @tc.desc: Test for adding a conic curve to a path with NULL or invalid parameters. 601 * @tc.size : SmallTest 602 * @tc.type : Function 603 * @tc.level : Level 3 604 */ 605 HWTEST_F(DrawingNativePathTest, testPathConicToNull, TestSize.Level3) { 606 // 1. Create a path object by calling OH_Drawing_PathCreate 607 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 608 // 2. Call OH_Drawing_PathConicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 609 // error code 610 OH_Drawing_PathConicTo(nullptr, 50, 50, 100, 100, 0.5); 611 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 612 // 3. Call OH_Drawing_PathConicTo with 0.00 as the second parameter, no crash 613 OH_Drawing_PathConicTo(path, 0.00, 50, 100, 100, 0.5); 614 // 4. Call OH_Drawing_PathConicTo with 0.00 as the third parameter, no crash 615 OH_Drawing_PathConicTo(path, 50, 0.00, 100, 100, 0.5); 616 // 5. Call OH_Drawing_PathConicTo with 0.00 as the fourth parameter, no crash 617 OH_Drawing_PathConicTo(path, 50, 50, 0.00, 100, 0.5); 618 // 6. Call OH_Drawing_PathConicTo with 0.00 as the fifth parameter, no crash 619 OH_Drawing_PathConicTo(path, 50, 50, 100, 0.00, 0.5); 620 // 7. Call OH_Drawing_PathConicTo with 0.00 as the sixth parameter, no crash 621 OH_Drawing_PathConicTo(path, 50, 50, 100, 100, 0.00); 622 // 8. Free memory by calling OH_Drawing_PathDestroy 623 OH_Drawing_PathDestroy(path); 624 } 625 626 /* 627 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0802 628 * @tc.name: testPathConicToAbnormal 629 * @tc.desc: Test for adding a conic curve to a path with abnormal data types as parameters. 630 * @tc.size : SmallTest 631 * @tc.type : Function 632 * @tc.level : Level 3 633 */ 634 HWTEST_F(DrawingNativePathTest, testPathConicToAbnormal, TestSize.Level3) { 635 // 1. Create a path object by calling OH_Drawing_PathCreate 636 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 637 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 638 OH_Drawing_PathMoveTo(path, 0, 0); 639 // 3. Add a line segment from the last point of the path to the target point by calling OH_Drawing_PathLineTo 640 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 641 // 4. Add a conic curve to the path with the second parameter as an integer or character type 642 OH_Drawing_PathConicTo(path, 50, 50.0f, 100.0f, 100.0f, 0.5f); 643 // 5. Add a conic curve to the path with the third parameter as an integer or character type 644 OH_Drawing_PathConicTo(path, 50.0f, 50, 100.0f, 100.0f, 0.5f); 645 // 6. Add a conic curve to the path with the fourth parameter as an integer or character type 646 OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100, 100.0f, 0.5f); 647 // 7. Add a conic curve to the path with the fifth parameter as an integer or character type 648 OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100.0f, 100, 0.5f); 649 // 8. Add a conic curve to the path with the sixth parameter as an integer or character type 650 OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100.0f, 100.0f, 1); 651 // 9. Free memory by calling OH_Drawing_PathDestroy 652 OH_Drawing_PathDestroy(path); 653 } 654 655 /* 656 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0803 657 * @tc.name: testPathConicToMaximal 658 * @tc.desc: Test for adding a conic curve to a path with maximal values as parameters. 659 * @tc.size : SmallTest 660 * @tc.type : Function 661 * @tc.level : Level 3 662 */ 663 HWTEST_F(DrawingNativePathTest, testPathConicToMaximal, TestSize.Level3) { 664 // 1. Create a path object by calling OH_Drawing_PathCreate 665 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 666 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 667 OH_Drawing_PathMoveTo(path, 0, 0); 668 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 669 OH_Drawing_PathLineTo(path, 100, 100); 670 // 4. Call OH_Drawing_PathConicTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 671 OH_Drawing_PathConicTo(path, FLT_MAX + 1, 50, 100, 100, 0.5); 672 // 5. Call OH_Drawing_PathConicTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 673 OH_Drawing_PathConicTo(path, 50, FLT_MAX + 1, 100, 100, 0.5); 674 // 6. Call OH_Drawing_PathConicTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 675 OH_Drawing_PathConicTo(path, 50, 50, FLT_MAX + 1, 100, 0.5); 676 // 7. Call OH_Drawing_PathConicTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 677 OH_Drawing_PathConicTo(path, 50, 50, 100, FLT_MAX + 1, 0.5); 678 // 8. Call OH_Drawing_PathConicTo with the sixth parameter as the maximum value of FLT_MAX + 1, no crash 679 OH_Drawing_PathConicTo(path, 50, 50, 100, 100, FLT_MAX + 1); 680 // 9. Free memory by calling OH_Drawing_PathDestroy 681 OH_Drawing_PathDestroy(path); 682 } 683 684 /* 685 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0900 686 * @tc.name: testPathCubicToNormal 687 * @tc.desc: Test for adding a cubic Bezier curve to a path with normal parameters. 688 * @tc.size : SmallTest 689 * @tc.type : Function 690 * @tc.level : Level 0 691 */ 692 HWTEST_F(DrawingNativePathTest, testPathCubicToNormal, TestSize.Level0) { 693 // 1. Create a path object by calling OH_Drawing_PathCreate 694 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 695 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 696 OH_Drawing_PathMoveTo(path, 0, 0); 697 // 3. Add a cubic Bezier curve from the last point of the path to the target point by calling OH_Drawing_PathCubicTo 698 OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, 300); 699 // 4. Free memory by calling OH_Drawing_PathDestroy 700 OH_Drawing_PathDestroy(path); 701 } 702 703 /* 704 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0901 705 * @tc.name: testPathCubicToNull 706 * @tc.desc: Test for adding a cubic Bezier curve to a path with NULL or invalid parameters. 707 * @tc.size : SmallTest 708 * @tc.type : Function 709 * @tc.level : Level 3 710 */ 711 HWTEST_F(DrawingNativePathTest, testPathCubicToNull, TestSize.Level3) { 712 // 1. Create a path object by calling OH_Drawing_PathCreate 713 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 714 // 2. Call OH_Drawing_PathCubicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 715 // error code 716 OH_Drawing_PathCubicTo(nullptr, 100, 100, 200, 200, 300, 300); 717 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 718 // 3. Call OH_Drawing_PathCubicTo with 0.00 as the second parameter, no crash 719 OH_Drawing_PathCubicTo(path, 0.00, 100, 200, 200, 300, 300); 720 // 4. Call OH_Drawing_PathCubicTo with 0.00 as the third parameter, no crash 721 OH_Drawing_PathCubicTo(path, 100, 0.00, 200, 200, 300, 300); 722 // 5. Call OH_Drawing_PathCubicTo with 0.00 as the fourth parameter, no crash 723 OH_Drawing_PathCubicTo(path, 100, 100, 0.00, 200, 300, 300); 724 // 6. Call OH_Drawing_PathCubicTo with 0.00 as the fifth parameter, no crash 725 OH_Drawing_PathCubicTo(path, 100, 100, 200, 0.00, 300, 300); 726 // 7. Call OH_Drawing_PathCubicTo with 0.00 as the sixth parameter, no crash 727 OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 0.00, 300); 728 // 8. Call OH_Drawing_PathCubicTo with 0.00 as the seventh parameter, no crash 729 OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, 0.00); 730 // 9. Free memory by calling OH_Drawing_PathDestroy 731 OH_Drawing_PathDestroy(path); 732 } 733 734 /* 735 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0902 736 * @tc.name: testPathCubicToAbnormal 737 * @tc.desc: Test for adding a cubic Bezier curve to a path with abnormal data types as parameters. 738 * @tc.size : SmallTest 739 * @tc.type : Function 740 * @tc.level : Level 3 741 */ 742 HWTEST_F(DrawingNativePathTest, testPathCubicToAbnormal, TestSize.Level3) { 743 // 1. Create a path object by calling OH_Drawing_PathCreate 744 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 745 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 746 OH_Drawing_PathMoveTo(path, 0, 0); 747 // 3. Add a cubic Bezier curve to the path with the second parameter as an integer 748 OH_Drawing_PathCubicTo(path, 100, 100.0f, 200.0f, 200.0f, 300.0f, 300.0f); 749 // 4. Add a cubic Bezier curve to the path with the third parameter as an integer 750 OH_Drawing_PathCubicTo(path, 100.0f, 100, 200.0f, 200.0f, 300.0f, 300.0f); 751 // 5. Add a cubic Bezier curve to the path with the fourth parameter as an integer 752 OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200, 200.0f, 300.0f, 300.0f); 753 // 6. Add a cubic Bezier curve to the path with the fifth parameter as an integer 754 OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200, 300.0f, 300.0f); 755 // 7. Add a cubic Bezier curve to the path with the sixth parameter as an integer 756 OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300, 300.0f); 757 // 8. Add a cubic Bezier curve to the path with the seventh parameter as an integer 758 OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300.0f, 300); 759 // 9. Free memory by calling OH_Drawing_PathDestroy 760 OH_Drawing_PathDestroy(path); 761 } 762 763 /* 764 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0903 765 * @tc.name: testPathCubicToMaximal 766 * @tc.desc: Test for adding a cubic Bezier curve to a path with maximal values as parameters. 767 * @tc.size : SmallTest 768 * @tc.type : Function 769 * @tc.level : Level 3 770 */ 771 HWTEST_F(DrawingNativePathTest, testPathCubicToMaximal, TestSize.Level3) { 772 // 1. Create a path object by calling OH_Drawing_PathCreate 773 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 774 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 775 OH_Drawing_PathMoveTo(path, 0, 0); 776 // 3. Call OH_Drawing_PathCubicTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 777 OH_Drawing_PathCubicTo(path, FLT_MAX + 1, 100, 200, 200, 300, 300); 778 // 4. Call OH_Drawing_PathCubicTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 779 OH_Drawing_PathCubicTo(path, 100, FLT_MAX + 1, 200, 200, 300, 300); 780 // 5. Call OH_Drawing_PathCubicTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 781 OH_Drawing_PathCubicTo(path, 100, 100, FLT_MAX + 1, 200, 300, 300); 782 // 6. Call OH_Drawing_PathCubicTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 783 OH_Drawing_PathCubicTo(path, 100, 100, 200, FLT_MAX + 1, 300, 300); 784 // 7. Call OH_Drawing_PathCubicTo with the sixth parameter as the maximum value of FLT_MAX + 1, no crash 785 OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, FLT_MAX + 1, 300); 786 // 8. Call OH_Drawing_PathCubicTo with the seventh parameter as the maximum value of FLT_MAX + 1, no crash 787 OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, FLT_MAX + 1); 788 // 9. Free memory by calling OH_Drawing_PathDestroy 789 OH_Drawing_PathDestroy(path); 790 } 791 792 /* 793 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1000 794 * @tc.name: testPathRMoveToNormal 795 * @tc.desc: Test for setting a relative move to a path with normal parameters. 796 * @tc.size : SmallTest 797 * @tc.type : Function 798 * @tc.level : Level 0 799 */ 800 HWTEST_F(DrawingNativePathTest, testPathRMoveToNormal, TestSize.Level0) { 801 // 1. Create a path object by calling OH_Drawing_PathCreate 802 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 803 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 804 OH_Drawing_PathMoveTo(path, 0, 0); 805 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 806 OH_Drawing_PathLineTo(path, 100, 100); 807 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 808 OH_Drawing_PathRMoveTo(path, 100, 100); 809 // 5. Free memory by calling OH_Drawing_PathDestroy 810 OH_Drawing_PathDestroy(path); 811 } 812 813 /* 814 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1001 815 * @tc.name: testPathRMoveToNull 816 * @tc.desc: Test for setting a relative move to a path with NULL or invalid parameters. 817 * @tc.size : SmallTest 818 * @tc.type : Function 819 * @tc.level : Level 3 820 */ 821 HWTEST_F(DrawingNativePathTest, testPathRMoveToNull, TestSize.Level3) { 822 // 1. Create a path object by calling OH_Drawing_PathCreate 823 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 824 // 2. Call OH_Drawing_PathRMoveTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 825 // error code 826 OH_Drawing_PathRMoveTo(nullptr, 100, 100); 827 // 3. Call OH_Drawing_PathRMoveTo with 0.00 as the second parameter, no crash 828 OH_Drawing_PathRMoveTo(path, 0.00, 100); 829 // 4. Call OH_Drawing_PathRMoveTo with 0.00 as the third parameter, no crash 830 OH_Drawing_PathRMoveTo(path, 100, 0.00); 831 // 5. Free memory by calling OH_Drawing_PathDestroy 832 OH_Drawing_PathDestroy(path); 833 } 834 835 /* 836 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1002 837 * @tc.name: testPathRMoveToAbnormal 838 * @tc.desc: Test for setting a relative move to a path with abnormal data types as parameters. 839 * @tc.size : SmallTest 840 * @tc.type : Function 841 * @tc.level : Level 3 842 */ 843 HWTEST_F(DrawingNativePathTest, testPathRMoveToAbnormal, TestSize.Level3) { 844 // 1. Create a path object by calling OH_Drawing_PathCreate 845 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 846 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 847 OH_Drawing_PathMoveTo(path, 0, 0); 848 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 849 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 850 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 851 OH_Drawing_PathRMoveTo(path, 100, 100.0f); 852 // 5. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 853 OH_Drawing_PathRMoveTo(path, 100.0f, 100); 854 // 6. Free memory by calling OH_Drawing_PathDestroy 855 OH_Drawing_PathDestroy(path); 856 } 857 858 /* 859 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1003 860 * @tc.name: testPathRMoveToMaximal 861 * @tc.desc: Test for setting a relative move to a path with maximal values as parameters. 862 * @tc.size : SmallTest 863 * @tc.type : Function 864 * @tc.level : Level 3 865 */ 866 HWTEST_F(DrawingNativePathTest, testPathRMoveToMaximal, TestSize.Level3) { 867 // 1. Create a path object by calling OH_Drawing_PathCreate 868 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 869 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 870 OH_Drawing_PathMoveTo(path, 0, 0); 871 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 872 OH_Drawing_PathLineTo(path, 100, 100); 873 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 874 OH_Drawing_PathRMoveTo(path, FLT_MAX + 1, 100); 875 // 5. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 876 OH_Drawing_PathRMoveTo(path, 100, FLT_MAX + 1); 877 // 6. Free memory by calling OH_Drawing_PathDestroy 878 OH_Drawing_PathDestroy(path); 879 } 880 881 /* 882 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1100 883 * @tc.name: testPathRLineToNormal 884 * @tc.desc: Test for adding a relative line to a path with normal parameters. 885 * @tc.size : SmallTest 886 * @tc.type : Function 887 * @tc.level : Level 0 888 */ 889 HWTEST_F(DrawingNativePathTest, testPathRLineToNormal, TestSize.Level0) { 890 // 1. Create a path object by calling OH_Drawing_PathCreate 891 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 892 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 893 OH_Drawing_PathMoveTo(path, 0, 0); 894 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 895 OH_Drawing_PathLineTo(path, 100, 100); 896 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 897 OH_Drawing_PathRMoveTo(path, 100, 100); 898 // 5. Add a relative line to the path from the current endpoint to the target point by calling 899 // OH_Drawing_PathRLineTo 900 OH_Drawing_PathRLineTo(path, 100, 100); 901 // 6. Free memory by calling OH_Drawing_PathDestroy 902 OH_Drawing_PathDestroy(path); 903 } 904 905 /* 906 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1101 907 * @tc.name: testPathRLineToNull 908 * @tc.desc: Test for adding a relative line to a path with NULL or invalid parameters. 909 * @tc.size : SmallTest 910 * @tc.type : Function 911 * @tc.level : Level 3 912 */ 913 HWTEST_F(DrawingNativePathTest, testPathRLineToNull, TestSize.Level3) { 914 // 1. Create a path object by calling OH_Drawing_PathCreate 915 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 916 // 2. Call OH_Drawing_PathRLineTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 917 // error code 918 OH_Drawing_PathRLineTo(nullptr, 100, 100); 919 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 920 // 3. Call OH_Drawing_PathRLineTo with 0.00 as the second parameter, no crash 921 OH_Drawing_PathRLineTo(path, 0.00, 100); 922 // 4. Call OH_Drawing_PathRLineTo with 0.00 as the third parameter, no crash 923 OH_Drawing_PathRLineTo(path, 100, 0.00); 924 // 5. Free memory by calling OH_Drawing_PathDestroy 925 OH_Drawing_PathDestroy(path); 926 } 927 928 /* 929 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1102 930 * @tc.name: testPathRLineToAbnormal 931 * @tc.desc: Test for adding a relative line to a path with abnormal data types as parameters. 932 * @tc.size : SmallTest 933 * @tc.type : Function 934 * @tc.level : Level 3 935 */ 936 HWTEST_F(DrawingNativePathTest, testPathRLineToAbnormal, TestSize.Level3) { 937 // 1. Create a path object by calling OH_Drawing_PathCreate 938 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 939 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 940 OH_Drawing_PathMoveTo(path, 0, 0); 941 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 942 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 943 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 944 OH_Drawing_PathRMoveTo(path, 100, 100); 945 // 5. Add a relative line to the path from the current endpoint to the target point by calling 946 // OH_Drawing_PathRLineTo 947 OH_Drawing_PathRLineTo(path, 100.0f, 100); 948 // 6. Add a relative line to the path from the current endpoint to the target point by calling 949 // OH_Drawing_PathRLineTo 950 OH_Drawing_PathRLineTo(path, 100, 100.0f); 951 // 7. Free memory by calling OH_Drawing_PathDestroy 952 OH_Drawing_PathDestroy(path); 953 } 954 955 /* 956 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1103 957 * @tc.name: testPathRLineToMaximal 958 * @tc.desc: Test for adding a relative line to a path with maximal values as parameters. 959 * @tc.size : SmallTest 960 * @tc.type : Function 961 * @tc.level : Level 3 962 */ 963 HWTEST_F(DrawingNativePathTest, testPathRLineToMaximal, TestSize.Level3) { 964 // 1. Create a path object by calling OH_Drawing_PathCreate 965 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 966 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 967 OH_Drawing_PathMoveTo(path, 0, 0); 968 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 969 OH_Drawing_PathLineTo(path, 100, 100); 970 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 971 OH_Drawing_PathRMoveTo(path, 100, 100); 972 // 5. Add a relative line to the path from the current endpoint to the target point by calling 973 // OH_Drawing_PathRLineTo 974 OH_Drawing_PathRLineTo(path, FLT_MAX + 1, 100); 975 // 6. Add a relative line to the path from the current endpoint to the target point by calling 976 // OH_Drawing_PathRLineTo 977 OH_Drawing_PathRLineTo(path, 100, FLT_MAX + 1); 978 // 7. Free memory by calling OH_Drawing_PathDestroy 979 OH_Drawing_PathDestroy(path); 980 } 981 982 /* 983 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1200 984 * @tc.name: testPathRQuadToNormal 985 * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with normal parameters. 986 * @tc.size : SmallTest 987 * @tc.type : Function 988 * @tc.level : Level 0 989 */ 990 HWTEST_F(DrawingNativePathTest, testPathRQuadToNormal, TestSize.Level0) { 991 // 1. Create a path object by calling OH_Drawing_PathCreate 992 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 993 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 994 OH_Drawing_PathMoveTo(path, 0, 0); 995 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 996 OH_Drawing_PathLineTo(path, 100, 100); 997 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 998 OH_Drawing_PathRMoveTo(path, 100, 100); 999 // 5. Add a relative quadratic Bezier curve to the path from the current endpoint to the target point by calling 1000 // OH_Drawing_PathRQuadTo 1001 OH_Drawing_PathRQuadTo(path, 100, 100, 200, 200); 1002 // 6. Free memory by calling OH_Drawing_PathDestroy 1003 OH_Drawing_PathDestroy(path); 1004 } 1005 1006 /* 1007 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1201 1008 * @tc.name: testPathRQuadToNull 1009 * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with NULL or invalid parameters. 1010 * @tc.size : SmallTest 1011 * @tc.type : Function 1012 * @tc.level : Level 3 1013 */ 1014 HWTEST_F(DrawingNativePathTest, testPathRQuadToNull, TestSize.Level3) { 1015 // 1. Create a path object by calling OH_Drawing_PathCreate 1016 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1017 // 2. Call OH_Drawing_PathRQuadTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1018 // error code 1019 OH_Drawing_PathRQuadTo(nullptr, 0, 0, 0, 0); 1020 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1021 // 3. Call OH_Drawing_PathRQuadTo with 0.00 as the second parameter, no crash 1022 OH_Drawing_PathRQuadTo(path, 0.00, 100, 100, 300); 1023 // 4. Call OH_Drawing_PathRQuadTo with 0.00 as the third parameter, no crash 1024 OH_Drawing_PathRQuadTo(path, 100, 0.00, 100, 300); 1025 // 5. Call OH_Drawing_PathRQuadTo with 0.00 as the fourth parameter, no crash 1026 OH_Drawing_PathRQuadTo(path, 100, 100, 0.00, 300); 1027 // 6. Call OH_Drawing_PathRQuadTo with 0.00 as the fifth parameter, no crash 1028 OH_Drawing_PathRQuadTo(path, 100, 100, 100, 0.00); 1029 // 7. Free memory by calling OH_Drawing_PathDestroy 1030 OH_Drawing_PathDestroy(path); 1031 } 1032 1033 /* 1034 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1202 1035 * @tc.name: testPathRQuadToAbnormal 1036 * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with abnormal data types as parameters. 1037 * @tc.size : SmallTest 1038 * @tc.type : Function 1039 * @tc.level : Level 3 1040 */ 1041 HWTEST_F(DrawingNativePathTest, testPathRQuadToAbnormal, TestSize.Level3) { 1042 // 1. Create a path object by calling OH_Drawing_PathCreate 1043 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1044 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1045 OH_Drawing_PathMoveTo(path, 0, 0); 1046 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1047 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1048 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1049 OH_Drawing_PathRMoveTo(path, 100, 100); 1050 // 5. Call OH_Drawing_PathRQuadTo with an integer or character type as the second parameter 1051 OH_Drawing_PathRQuadTo(path, 100, 100.0f, 100.0f, 300.0f); 1052 // 6. Call OH_Drawing_PathRQuadTo with an integer or character type as the third parameter 1053 OH_Drawing_PathRQuadTo(path, 100.0f, 100, 100.0f, 300.0f); 1054 // 7. Call OH_Drawing_PathRQuadTo with an integer or character type as the fourth parameter 1055 OH_Drawing_PathRQuadTo(path, 100.0f, 100.0f, 100, 300.0f); 1056 // 8. Call OH_Drawing_PathRQuadTo with an integer or character type as the fifth parameter 1057 OH_Drawing_PathRQuadTo(path, 100.0f, 100.0f, 100.0f, 300); 1058 // 9. Free memory 1059 OH_Drawing_PathDestroy(path); 1060 } 1061 1062 /* 1063 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1203 1064 * @tc.name: testPathRQuadToMaximal 1065 * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with maximal values as parameters. 1066 * @tc.size : SmallTest 1067 * @tc.type : Function 1068 * @tc.level : Level 3 1069 */ 1070 HWTEST_F(DrawingNativePathTest, testPathRQuadToMaximal, TestSize.Level3) { 1071 // 1. Create a path object by calling OH_Drawing_PathCreate 1072 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1073 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1074 OH_Drawing_PathMoveTo(path, 0, 0); 1075 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1076 OH_Drawing_PathLineTo(path, 100, 100); 1077 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1078 OH_Drawing_PathRMoveTo(path, 100, 100); 1079 // 5. Call OH_Drawing_PathRQuadTo with a second parameter of FLT_MAX + 1 1080 OH_Drawing_PathRQuadTo(path, FLT_MAX + 1, 100, 100, 300); 1081 // 6. Call OH_Drawing_PathRQuadTo with a third parameter of FLT_MAX + 1 1082 OH_Drawing_PathRQuadTo(path, 100, FLT_MAX + 1, 100, 300); 1083 // 7. Call OH_Drawing_PathRQuadTo with a fourth parameter of FLT_MAX + 1 1084 OH_Drawing_PathRQuadTo(path, 100, 100, FLT_MAX + 1, 300); 1085 // 8. Call OH_Drawing_PathRQuadTo with a fifth parameter of FLT_MAX + 1 1086 OH_Drawing_PathRQuadTo(path, 100, 100, 100, FLT_MAX + 1); 1087 // 9. Free memory by calling OH_Drawing_PathDestroy 1088 OH_Drawing_PathDestroy(path); 1089 } 1090 1091 /* 1092 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1300 1093 * @tc.name: testPathRConicToNormal 1094 * @tc.desc: Test for adding a relative conic curve to a path with normal parameters. 1095 * @tc.size : SmallTest 1096 * @tc.type : Function 1097 * @tc.level : Level 0 1098 */ 1099 HWTEST_F(DrawingNativePathTest, testPathRConicToNormal, TestSize.Level0) { 1100 // 1. Create a path object by calling OH_Drawing_PathCreate 1101 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1102 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1103 OH_Drawing_PathMoveTo(path, 0, 0); 1104 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1105 OH_Drawing_PathLineTo(path, 100, 100); 1106 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1107 OH_Drawing_PathRMoveTo(path, 100, 100); 1108 // 5. Add a relative conic curve to the path from the current endpoint to the target point by calling 1109 // OH_Drawing_PathRConicTo 1110 OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, 5); 1111 // 6. Free memory by calling OH_Drawing_PathDestroy 1112 OH_Drawing_PathDestroy(path); 1113 } 1114 1115 /* 1116 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1301 1117 * @tc.name: testPathRConicToNull 1118 * @tc.desc: Test for adding a relative conic curve to a path with NULL or invalid parameters. 1119 * @tc.size : SmallTest 1120 * @tc.type : Function 1121 * @tc.level : Level 3 1122 */ 1123 HWTEST_F(DrawingNativePathTest, testPathRConicToNull, TestSize.Level3) { 1124 // 1. Create a path object by calling OH_Drawing_PathCreate 1125 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1126 // 2. Call OH_Drawing_PathRConicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1127 // error code 1128 OH_Drawing_PathRConicTo(nullptr, 100, 100, 100, 300, 5); 1129 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1130 // 3. Call OH_Drawing_PathRConicTo with 0.00 as the second parameter, no crash 1131 OH_Drawing_PathRConicTo(path, 0.00, 100, 100, 300, 5); 1132 // 4. Call OH_Drawing_PathRConicTo with 0.00 as the third parameter, no crash 1133 OH_Drawing_PathRConicTo(path, 100, 0.00, 100, 300, 5); 1134 // 5. Call OH_Drawing_PathRConicTo with 0.00 as the fourth parameter, no crash 1135 OH_Drawing_PathRConicTo(path, 100, 100, 0.00, 300, 5); 1136 // 6. Call OH_Drawing_PathRConicTo with 0.00 as the fifth parameter, no crash 1137 OH_Drawing_PathRConicTo(path, 100, 100, 100, 0.00, 5); 1138 // 7. Call OH_Drawing_PathRConicTo with 0.00 as the sixth parameter, no crash 1139 OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, 0.00); 1140 // 8. Free memory by calling OH_Drawing_PathDestroy 1141 OH_Drawing_PathDestroy(path); 1142 } 1143 1144 /* 1145 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1302 1146 * @tc.name: testPathRConicToAbnormal 1147 * @tc.desc: Test for adding a relative conic curve to a path with abnormal data types as parameters. 1148 * @tc.size : SmallTest 1149 * @tc.type : Function 1150 * @tc.level : Level 3 1151 */ 1152 HWTEST_F(DrawingNativePathTest, testPathRConicToAbnormal, TestSize.Level3) { 1153 // 1. Create a path object by calling OH_Drawing_PathCreate 1154 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1155 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1156 OH_Drawing_PathMoveTo(path, 0, 0); 1157 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1158 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1159 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1160 OH_Drawing_PathRMoveTo(path, 100, 100); 1161 // 5. Call OH_Drawing_PathRConicTo with an integer as the second parameter 1162 OH_Drawing_PathRConicTo(path, 100, 100.0f, 100.0f, 300.0f, 5.0f); 1163 // 6. Call OH_Drawing_PathRConicTo with an integer as the third parameter 1164 OH_Drawing_PathRConicTo(path, 100.0f, 100, 100.0f, 300.0f, 5.0f); 1165 // 7. Call OH_Drawing_PathRConicTo with an integer as the fourth parameter 1166 OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100, 300.0f, 5.0f); 1167 // 8. Call OH_Drawing_PathRConicTo with an integer as the fifth parameter 1168 OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100.0f, 300, 5.0f); 1169 // 9. Call OH_Drawing_PathRConicTo with an integer as the sixth parameter 1170 OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100.0f, 300.0f, 5); 1171 // 10. Free memory by calling OH_Drawing_PathDestroy 1172 OH_Drawing_PathDestroy(path); 1173 } 1174 1175 /* 1176 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1303 1177 * @tc.name: testPathRConicToMaximal 1178 * @tc.desc: Test for adding a relative conic curve to a path with maximal values as parameters. 1179 * @tc.size : SmallTest 1180 * @tc.type : Function 1181 * @tc.level : Level 3 1182 */ 1183 HWTEST_F(DrawingNativePathTest, testPathRConicToMaximal, TestSize.Level3) { 1184 // 1. Create a path object by calling OH_Drawing_PathCreate 1185 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1186 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1187 OH_Drawing_PathMoveTo(path, 0, 0); 1188 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1189 OH_Drawing_PathLineTo(path, 100, 100); 1190 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1191 OH_Drawing_PathRMoveTo(path, 100, 100); 1192 // 5. Call OH_Drawing_PathRConicTo with a second parameter of FLT_MAX + 1, no crash 1193 OH_Drawing_PathRConicTo(path, FLT_MAX + 1, 100, 100, 300, 5); 1194 // 6. Call OH_Drawing_PathRConicTo with a third parameter of FLT_MAX + 1, no crash 1195 OH_Drawing_PathRConicTo(path, 100, FLT_MAX + 1, 100, 300, 5); 1196 // 7. Call OH_Drawing_PathRConicTo with a fourth parameter of FLT_MAX + 1, no crash 1197 OH_Drawing_PathRConicTo(path, 100, 100, FLT_MAX + 1, 300, 5); 1198 // 8. Call OH_Drawing_PathRConicTo with a fifth parameter of FLT_MAX + 1, no crash 1199 OH_Drawing_PathRConicTo(path, 100, 100, 100, FLT_MAX + 1, 5); 1200 // 9. Call OH_Drawing_PathRConicTo with a sixth parameter of FLT_MAX + 1, no crash 1201 OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, FLT_MAX + 1); 1202 // 10. Free memory by calling OH_Drawing_PathDestroy 1203 OH_Drawing_PathDestroy(path); 1204 } 1205 1206 /* 1207 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1400 1208 * @tc.name: testPathRCubicToNormal 1209 * @tc.desc: Test for adding a relative cubic Bezier curve to a path with normal parameters. 1210 * @tc.size : SmallTest 1211 * @tc.type : Function 1212 * @tc.level : Level 0 1213 */ 1214 HWTEST_F(DrawingNativePathTest, testPathRCubicToNormal, TestSize.Level0) { 1215 // 1. Create a path object by calling OH_Drawing_PathCreate 1216 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1217 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1218 OH_Drawing_PathMoveTo(path, 0, 0); 1219 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1220 OH_Drawing_PathLineTo(path, 100, 100); 1221 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1222 OH_Drawing_PathRMoveTo(path, 100, 100); 1223 // 5. Add a relative cubic Bezier curve to the path from the current endpoint to the target point by calling 1224 // OH_Drawing_PathRCubicTo 1225 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, 300); 1226 // 6. Free memory by calling OH_Drawing_PathDestroy 1227 OH_Drawing_PathDestroy(path); 1228 } 1229 1230 /* 1231 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1401 1232 * @tc.name: testPathRCubicToNull 1233 * @tc.desc: Test for adding a relative cubic Bezier curve to a path with NULL or invalid parameters. 1234 * @tc.size : SmallTest 1235 * @tc.type : Function 1236 * @tc.level : Level 3 1237 */ 1238 HWTEST_F(DrawingNativePathTest, testPathRCubicToNull, TestSize.Level3) { 1239 // 1. Create a path object by calling OH_Drawing_PathCreate 1240 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1241 // 2. Call OH_Drawing_PathRCubicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1242 // error code 1243 OH_Drawing_PathRCubicTo(nullptr, 100, 100, 200, 200, 300, 300); 1244 // 3. Call OH_Drawing_PathRCubicTo with 0.00 as the second parameter, no crash 1245 OH_Drawing_PathRCubicTo(path, 0.00, 100, 200, 200, 300, 300); 1246 // 4. Call OH_Drawing_PathRCubicTo with 0.00 as the third parameter, no crash 1247 OH_Drawing_PathRCubicTo(path, 100, 0.00, 200, 200, 300, 300); 1248 // 5. Call OH_Drawing_PathRCubicTo with 0.00 as the fourth parameter, no crash 1249 OH_Drawing_PathRCubicTo(path, 100, 100, 0.00, 200, 300, 300); 1250 // 6. Call OH_Drawing_PathRCubicTo with 0.00 as the fifth parameter, no crash 1251 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 0.00, 300, 300); 1252 // 7. Call OH_Drawing_PathRCubicTo with 0.00 as the sixth parameter, no crash 1253 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 0.00, 300); 1254 // 8. Call OH_Drawing_PathRCubicTo with 0.00 as the seventh parameter, no crash 1255 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, 0.00); 1256 // 9. Free memory by calling OH_Drawing_PathDestroy 1257 OH_Drawing_PathDestroy(path); 1258 } 1259 1260 /* 1261 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1402 1262 * @tc.name: testPathRCubicToAbnormal 1263 * @tc.desc: Test for adding a relative cubic Bezier curve to a path with abnormal data types as parameters. 1264 * @tc.size : SmallTest 1265 * @tc.type : Function 1266 * @tc.level : Level 3 1267 */ 1268 HWTEST_F(DrawingNativePathTest, testPathRCubicToAbnormal, TestSize.Level3) { 1269 // 1. Create a path object by calling OH_Drawing_PathCreate 1270 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1271 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1272 OH_Drawing_PathMoveTo(path, 0, 0); 1273 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1274 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1275 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1276 OH_Drawing_PathRMoveTo(path, 100, 100); 1277 // 5. Call OH_Drawing_PathRCubicTo with an integer as the second parameter 1278 OH_Drawing_PathRCubicTo(path, 100, 100.0f, 200.0f, 200.0f, 300.0f, 300.0f); 1279 // 6. Call OH_Drawing_PathRCubicTo with an integer as the third parameter 1280 OH_Drawing_PathRCubicTo(path, 100.0f, 100, 200.0f, 200.0f, 300.0f, 300.0f); 1281 // 7. Call OH_Drawing_PathRCubicTo with an integer as the fourth parameter 1282 OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200, 200.0f, 300.0f, 300.0f); 1283 // 8. Call OH_Drawing_PathRCubicTo with an integer as the fifth parameter 1284 OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200, 300.0f, 300.0f); 1285 // 9. Call OH_Drawing_PathRCubicTo with an integer as the sixth parameter 1286 OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300, 300.0f); 1287 // 10. Call OH_Drawing_PathRCubicTo with an integer as the seventh parameter 1288 OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300.0f, 300); 1289 // 11. Free memory 1290 OH_Drawing_PathDestroy(path); 1291 } 1292 1293 /* 1294 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1403 1295 * @tc.name: testPathRCubicToMaximal 1296 * @tc.desc: Test for adding a relative cubic Bezier curve to a path with maximal values as parameters. 1297 * @tc.size : SmallTest 1298 * @tc.type : Function 1299 * @tc.level : Level 3 1300 */ 1301 HWTEST_F(DrawingNativePathTest, testPathRCubicToMaximal, TestSize.Level3) { 1302 // 1. Create a path object by calling OH_Drawing_PathCreate 1303 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1304 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1305 OH_Drawing_PathMoveTo(path, 0, 0); 1306 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1307 OH_Drawing_PathLineTo(path, 100, 100); 1308 // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1309 OH_Drawing_PathRMoveTo(path, 100, 100); 1310 // 5. Call OH_Drawing_PathRCubicTo with the second parameter as the maximum value FLT_MAX+1, no crash 1311 OH_Drawing_PathRCubicTo(path, FLT_MAX + 1, 100, 200, 200, 300, 300); 1312 // 6. Call OH_Drawing_PathRCubicTo with the third parameter as the maximum value FLT_MAX+1, no crash 1313 OH_Drawing_PathRCubicTo(path, 100, FLT_MAX + 1, 200, 200, 300, 300); 1314 // 7. Call OH_Drawing_PathRCubicTo with the fourth parameter as the maximum value FLT_MAX+1, no crash 1315 OH_Drawing_PathRCubicTo(path, 100, 100, FLT_MAX + 1, 200, 300, 300); 1316 // 8. Call OH_Drawing_PathRCubicTo with the fifth parameter as the maximum value FLT_MAX+1, no crash 1317 OH_Drawing_PathRCubicTo(path, 100, 100, 200, FLT_MAX + 1, 300, 300); 1318 // 9. Call OH_Drawing_PathRCubicTo with the sixth parameter as the maximum value FLT_MAX+1, no crash 1319 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, FLT_MAX + 1, 300); 1320 // 10. Call OH_Drawing_PathRCubicTo with the seventh parameter as the maximum value FLT_MAX+1, no crash 1321 OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, FLT_MAX + 1); 1322 // 11. Free memory 1323 OH_Drawing_PathDestroy(path); 1324 } 1325 1326 /* 1327 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1500 1328 * @tc.name: testPathAddRectNormal 1329 * @tc.desc: Test for adding a rectangle to a path with normal parameters. 1330 * @tc.size : SmallTest 1331 * @tc.type : Function 1332 * @tc.level : Level 0 1333 */ 1334 HWTEST_F(DrawingNativePathTest, testPathAddRectNormal, TestSize.Level0) { 1335 // 1. Create a path object by calling OH_Drawing_PathCreate 1336 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1337 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1338 OH_Drawing_PathMoveTo(path, 0, 0); 1339 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1340 OH_Drawing_PathLineTo(path, 100, 100); 1341 // 4. Add a rectangle outline to the path with the specified direction by calling OH_Drawing_PathAddRect. Iterate 1342 // through the enum to call this interface. 1343 OH_Drawing_PathAddRect(path, 100, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1344 // 5. Free memory 1345 OH_Drawing_PathDestroy(path); 1346 } 1347 1348 /* 1349 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1501 1350 * @tc.name: testPathAddRectNull 1351 * @tc.desc: Test for adding a rectangle to a path with NULL or invalid parameters. 1352 * @tc.size : SmallTest 1353 * @tc.type : Function 1354 * @tc.level : Level 3 1355 */ 1356 HWTEST_F(DrawingNativePathTest, testPathAddRectNull, TestSize.Level3) { 1357 // 1. Create a path object by calling OH_Drawing_PathCreate 1358 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1359 // 2. Call OH_Drawing_PathAddRect with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 1360 OH_Drawing_PathAddRect(nullptr, 100, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1361 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1362 // 3. Call OH_Drawing_PathAddRect with 0.00 as the second parameter, no crash 1363 OH_Drawing_PathAddRect(path, 0.00, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1364 // 4. Call OH_Drawing_PathAddRect with 0.00 as the third parameter, no crash 1365 OH_Drawing_PathAddRect(path, 100, 0.00, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1366 // 5. Call OH_Drawing_PathAddRect with 0.00 as the fourth parameter, no crash 1367 OH_Drawing_PathAddRect(path, 100, 100, 0.00, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1368 // 6. Call OH_Drawing_PathAddRect with 0.00 as the fifth parameter, no crash 1369 OH_Drawing_PathAddRect(path, 100, 100, 200, 0.00, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1370 // 7. Free memory 1371 OH_Drawing_PathDestroy(path); 1372 } 1373 1374 /* 1375 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1502 1376 * @tc.name: testPathAddRectAbnormal 1377 * @tc.desc: Test for adding a rectangle to a path with abnormal data types as parameters. 1378 * @tc.size : SmallTest 1379 * @tc.type : Function 1380 * @tc.level : Level 3 1381 */ 1382 HWTEST_F(DrawingNativePathTest, testPathAddRectAbnormal, TestSize.Level3) { 1383 // 1. Create a path object by calling OH_Drawing_PathCreate 1384 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1385 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1386 OH_Drawing_PathMoveTo(path, 0, 0); 1387 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1388 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1389 // 4. Call OH_Drawing_PathAddRect with an integer as the second parameter 1390 OH_Drawing_PathAddRect(path, 100, 100.0f, 200.0f, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1391 // 5. Call OH_Drawing_PathAddRect with an integer as the third parameter 1392 OH_Drawing_PathAddRect(path, 100.0f, 100, 200.0f, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1393 // 6. Call OH_Drawing_PathAddRect with an integer as the fourth parameter 1394 OH_Drawing_PathAddRect(path, 100.0f, 100.0f, 200, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1395 // 7. Call OH_Drawing_PathAddRect with an integer as the fifth parameter 1396 OH_Drawing_PathAddRect(path, 100.0f, 100.0f, 200.0f, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1397 // 8. Free memory 1398 OH_Drawing_PathDestroy(path); 1399 } 1400 1401 /* 1402 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1503 1403 * @tc.name: testPathAddRectMaximal 1404 * @tc.desc: Test for adding a rectangle to a path with maximal values as parameters. 1405 * @tc.size : SmallTest 1406 * @tc.type : Function 1407 * @tc.level : Level 3 1408 */ 1409 HWTEST_F(DrawingNativePathTest, testPathAddRectMaximal, TestSize.Level3) { 1410 // 1. Create a path object by calling OH_Drawing_PathCreate 1411 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1412 // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1413 OH_Drawing_PathMoveTo(path, 0, 0); 1414 // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1415 OH_Drawing_PathLineTo(path, 100, 100); 1416 // 4. Call OH_Drawing_PathAddRect with the second parameter as the maximum value FLT_MAX+1, no crash 1417 OH_Drawing_PathAddRect(path, FLT_MAX + 1, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1418 // 5. Call OH_Drawing_PathAddRect with the third parameter as the maximum value FLT_MAX+1, no crash 1419 OH_Drawing_PathAddRect(path, 100, FLT_MAX + 1, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1420 // 6. Call OH_Drawing_PathAddRect with the fourth parameter as the maximum value FLT_MAX+1, no crash 1421 OH_Drawing_PathAddRect(path, 100, 100, FLT_MAX + 1, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1422 // 7. Call OH_Drawing_PathAddRect with the fifth parameter as the maximum value FLT_MAX+1, no crash 1423 OH_Drawing_PathAddRect(path, 100, 100, 200, FLT_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1424 // 8. Free memory 1425 OH_Drawing_PathDestroy(path); 1426 } 1427 1428 /* 1429 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1600 1430 * @tc.name: testPathAddRectWithInitialCornerNormal 1431 * @tc.desc: Test for adding a rectangle to a path with initial corner and normal parameters. 1432 * @tc.size : SmallTest 1433 * @tc.type : Function 1434 * @tc.level : Level 0 1435 */ 1436 HWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerNormal, TestSize.Level0) { 1437 // 1. Create a path object by calling OH_Drawing_PathCreate 1438 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1439 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1440 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1441 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1442 OH_Drawing_PathMoveTo(path, 0, 0); 1443 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1444 OH_Drawing_PathLineTo(path, 100, 100); 1445 // 5. Add a rectangle outline to the path with the specified direction by calling 1446 // OH_Drawing_PathAddRectWithInitialCorner. Iterate through the enum to call this interface. 1447 OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1448 // 6. Free memory 1449 OH_Drawing_PathDestroy(path); 1450 OH_Drawing_RectDestroy(rect); 1451 } 1452 1453 /* 1454 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1601 1455 * @tc.name: testPathAddRectWithInitialCornerNull 1456 * @tc.desc: Test for adding a rectangle to a path with initial corner and NULL or invalid parameters. 1457 * @tc.size : SmallTest 1458 * @tc.type : Function 1459 * @tc.level : Level 3 1460 */ 1461 HWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerNull, TestSize.Level3) { 1462 // 1. Create a path object by calling OH_Drawing_PathCreate 1463 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1464 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1465 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1466 // 3. Call OH_Drawing_PathAddRectWithInitialCorner with the first parameter as nullptr, expect 1467 // OH_DRAWING_ERROR_INVALID_PARAMETER 1468 OH_Drawing_PathAddRectWithInitialCorner(nullptr, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1469 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1470 // 4. Call OH_Drawing_PathAddRectWithInitialCorner with the second parameter as nullptr, expect 1471 // OH_DRAWING_ERROR_INVALID_PARAMETER 1472 OH_Drawing_PathAddRectWithInitialCorner(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1473 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1474 // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as 0 1475 OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1476 // 6. Free memory 1477 OH_Drawing_PathDestroy(path); 1478 OH_Drawing_RectDestroy(rect); 1479 } 1480 1481 /* 1482 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1602 1483 * @tc.name: testPathAddRectWithInitialCornerAbnormal 1484 * @tc.desc: Test for adding a rectangle to a path with initial corner and abnormal data types as parameters. 1485 * @tc.size : SmallTest 1486 * @tc.type : Function 1487 * @tc.level : Level 3 1488 */ 1489 HWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerAbnormal, TestSize.Level3) { 1490 // 1. Create a path object by calling OH_Drawing_PathCreate 1491 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1492 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1493 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1494 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1495 OH_Drawing_PathMoveTo(path, 0, 0); 1496 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1497 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1498 // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as a float or a character 1499 OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 5.0f); 1500 // 6. Free memory 1501 OH_Drawing_PathDestroy(path); 1502 OH_Drawing_RectDestroy(rect); 1503 } 1504 1505 /* 1506 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1603 1507 * @tc.name: testPathAddRectWithInitialCornerMaximal 1508 * @tc.desc: Test for adding a rectangle to a path with initial corner and maximal values as parameters. 1509 * @tc.size : SmallTest 1510 * @tc.type : Function 1511 * @tc.level : Level 3 1512 */ 1513 HWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerMaximal, TestSize.Level3) { 1514 // 1. Create a path object by calling OH_Drawing_PathCreate 1515 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1516 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1517 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1518 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1519 OH_Drawing_PathMoveTo(path, 0, 0); 1520 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1521 OH_Drawing_PathLineTo(path, 100, 100); 1522 // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as the maximum value INT32_MAX, no 1523 // crash 1524 OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, INT32_MAX); 1525 // 6. Free memory 1526 OH_Drawing_PathDestroy(path); 1527 } 1528 1529 /* 1530 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1700 1531 * @tc.name: testPathAddRoundRectNormal 1532 * @tc.desc: Test for adding a round rectangle to a path with normal parameters. 1533 * @tc.size : SmallTest 1534 * @tc.type : Function 1535 * @tc.level : Level 0 1536 */ 1537 HWTEST_F(DrawingNativePathTest, testPathAddRoundRectNormal, TestSize.Level0) { 1538 // 1. Create a path object by calling OH_Drawing_PathCreate 1539 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1540 // 2. Create a rounded rectangle object by calling OH_Drawing_RoundRectCreate 1541 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1542 OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20); 1543 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1544 OH_Drawing_PathMoveTo(path, 0, 0); 1545 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1546 OH_Drawing_PathLineTo(path, 100, 100); 1547 // 5. Add the rounded rectangle outline to the path with the specified direction by calling 1548 // OH_Drawing_PathAddRoundRect. Iterate through the enum to call this interface. 1549 OH_Drawing_PathDirection directions[] = { 1550 PATH_DIRECTION_CW, 1551 PATH_DIRECTION_CCW, 1552 }; 1553 for (int i = 0; i < sizeof(directions) / sizeof(directions[0]); i++) { 1554 OH_Drawing_PathAddRoundRect(path, roundRect, directions[i]); 1555 } 1556 // 6. Free memory 1557 OH_Drawing_PathDestroy(path); 1558 OH_Drawing_RoundRectDestroy(roundRect); 1559 OH_Drawing_RectDestroy(rect); 1560 } 1561 1562 /* 1563 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1701 1564 * @tc.name: testPathAddRoundRectNull 1565 * @tc.desc: Test for adding a round rectangle to a path with NULL or invalid parameters. 1566 * @tc.size : SmallTest 1567 * @tc.type : Function 1568 * @tc.level : Level 3 1569 */ 1570 HWTEST_F(DrawingNativePathTest, testPathAddRoundRectNull, TestSize.Level3) { 1571 // 1. Create a path object by calling OH_Drawing_PathCreate 1572 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1573 // 2. Create a rounded rectangle object by calling OH_Drawing_RoundRectCreate 1574 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1575 OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20); 1576 // 3. Call OH_Drawing_PathAddRoundRect with the first parameter as nullptr, expect 1577 // OH_DRAWING_ERROR_INVALID_PARAMETER 1578 OH_Drawing_PathAddRoundRect(nullptr, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1579 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1580 // 4. Call OH_Drawing_PathAddRoundRect with the second parameter as nullptr, expect 1581 // OH_DRAWING_ERROR_INVALID_PARAMETER 1582 OH_Drawing_PathAddRoundRect(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1583 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1584 // 5. Free memory 1585 OH_Drawing_PathDestroy(path); 1586 OH_Drawing_RoundRectDestroy(roundRect); 1587 OH_Drawing_RectDestroy(rect); 1588 } 1589 1590 /* 1591 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1800 1592 * @tc.name: testPathAddOvalWithInitialPointNormal 1593 * @tc.desc: Test for adding an oval to a path with initial point and normal parameters. 1594 * @tc.size : SmallTest 1595 * @tc.type : Function 1596 * @tc.level : Level 0 1597 */ 1598 HWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointNormal, TestSize.Level0) { 1599 // 1. Create a path object by calling OH_Drawing_PathCreate 1600 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1601 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1602 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1603 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1604 OH_Drawing_PathMoveTo(path, 0, 0); 1605 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1606 OH_Drawing_PathLineTo(path, 100, 100); 1607 // 5. Add an oval to the path, where the rectangle object is the bounding rectangle of the oval. Iterate through the 1608 // enum to call this interface. 1609 OH_Drawing_PathDirection directions[] = { 1610 PATH_DIRECTION_CW, 1611 PATH_DIRECTION_CCW, 1612 }; 1613 for (int i = 0; i < sizeof(directions) / sizeof(directions[0]); i++) { 1614 OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 10, directions[i]); 1615 } 1616 // 6. Free memory 1617 OH_Drawing_PathDestroy(path); 1618 OH_Drawing_RectDestroy(rect); 1619 } 1620 1621 /* 1622 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1801 1623 * @tc.name: testPathAddOvalWithInitialPointNull 1624 * @tc.desc: Test for adding an oval to a path with initial point and NULL or invalid parameters. 1625 * @tc.size : SmallTest 1626 * @tc.type : Function 1627 * @tc.level : Level 3 1628 */ 1629 HWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointNull, TestSize.Level3) { 1630 // 1. Create a path object by calling OH_Drawing_PathCreate 1631 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1632 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1633 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1634 // 3. Call OH_Drawing_PathAddOvalWithInitialPoint with the first parameter as nullptr, expect 1635 // OH_DRAWING_ERROR_INVALID_PARAMETER 1636 OH_Drawing_PathAddOvalWithInitialPoint(nullptr, rect, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1637 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1638 // 4. Call OH_Drawing_PathAddOvalWithInitialPoint with the second parameter as nullptr, expect 1639 // OH_DRAWING_ERROR_INVALID_PARAMETER 1640 OH_Drawing_PathAddOvalWithInitialPoint(path, nullptr, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1641 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1642 // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as 0, no crash 1643 OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 0, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1644 // 6. Free memory 1645 OH_Drawing_PathDestroy(path); 1646 OH_Drawing_RectDestroy(rect); 1647 } 1648 1649 /* 1650 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1802 1651 * @tc.name: testPathAddOvalWithInitialPointAbnormal 1652 * @tc.desc: Test for adding an oval to a path with initial point and abnormal data types as parameters. 1653 * @tc.size : SmallTest 1654 * @tc.type : Function 1655 * @tc.level : Level 3 1656 */ 1657 HWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointAbnormal, TestSize.Level3) { 1658 // 1. Create a path object by calling OH_Drawing_PathCreate 1659 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1660 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1661 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1662 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1663 OH_Drawing_PathMoveTo(path, 0, 0); 1664 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1665 OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1666 // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as a float or a character 1667 OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 5.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1668 // 6. Free memory 1669 OH_Drawing_PathDestroy(path); 1670 OH_Drawing_RectDestroy(rect); 1671 } 1672 1673 /* 1674 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1803 1675 * @tc.name: testPathAddOvalWithInitialPointMaximal 1676 * @tc.desc: Test for adding an oval to a path with initial point and maximal values as parameters. 1677 * @tc.size : SmallTest 1678 * @tc.type : Function 1679 * @tc.level : Level 3 1680 */ 1681 HWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointMaximal, TestSize.Level3) { 1682 // 1. Create a path object by calling OH_Drawing_PathCreate 1683 OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1684 // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1685 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1686 // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1687 OH_Drawing_PathMoveTo(path, 0, 0); 1688 // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1689 OH_Drawing_PathLineTo(path, 100, 100); 1690 // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as the maximum value UINT32_MAX + 1, no 1691 // crash 1692 OH_Drawing_PathAddOvalWithInitialPoint(path, rect, UINT32_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1693 // 6. Free memory 1694 OH_Drawing_PathDestroy(path); 1695 OH_Drawing_RectDestroy(rect); 1696 } 1697 1698 } // namespace Drawing 1699 } // namespace Rosen 1700 } // namespace OHOS