• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DrawingNativePathPart2Test : public testing::Test {
38     protected:
39     // 在每个测试用例执行前调用
SetUp()40     void SetUp() override
41     {
42         // 设置代码
43         std::cout << "DrawingNativePathPart2Test Setup code called before each test case." << std::endl;
44         OH_Drawing_ErrorCodeReset();
45         std::cout << "DrawingNativePathPart2Test errorCodeReset before each test case." << std::endl;
46     }
TearDown()47     void TearDown() override
48     {
49         std::cout << "DrawingNativePathPart2Test Setup code called after each test case." << std::endl;
50         OH_Drawing_ErrorCodeReset();
51         std::cout << "DrawingNativePathPart2Test errorCodeReset after each test case." << std::endl;
52     }
53 };
54 /*
55  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1900
56  * @tc.name: testPathAddArcNormal
57  * @tc.desc: Test for adding an arc to a path with normal parameters.
58  * @tc.size  : SmallTest
59  * @tc.type  : Function
60  * @tc.level : Level 0
61  */
62 HWTEST_F(DrawingNativePathPart2Test, testPathAddArcNormal, Function | SmallTest | Level0) {
63     // 1. Create a path object using OH_Drawing_PathCreate.
64     OH_Drawing_Path *path = OH_Drawing_PathCreate();
65     // add assert
66     EXPECT_NE(path, nullptr);
67     // 2. Create a rectangle object using OH_Drawing_RectCreate.
68     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
69     // add assert
70     EXPECT_NE(rect, nullptr);
71     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
72     OH_Drawing_PathMoveTo(path, 0, 0);
73     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
74     OH_Drawing_PathLineTo(path, 100, 100);
75     // 5. Add an arc to the path using OH_Drawing_PathAddArc, which serves as the starting point of the new contour.
76     OH_Drawing_PathAddArc(path, rect, 0.0, 0.0);
77     // add assert
78     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
79     // 6. Free the memory.
80     OH_Drawing_PathDestroy(path);
81     OH_Drawing_RectDestroy(rect);
82 }
83 
84 /*
85  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1901
86  * @tc.name: testPathAddArcNull
87  * @tc.desc: Test for adding an arc to a path with NULL or invalid parameters.
88  * @tc.size  : SmallTest
89  * @tc.type  : Function
90  * @tc.level : Level 3
91  */
92 HWTEST_F(DrawingNativePathPart2Test, testPathAddArcNull, Function | SmallTest | Level3) {
93     // 1. Create a path object using OH_Drawing_PathCreate.
94     OH_Drawing_Path *path = OH_Drawing_PathCreate();
95     // add assert
96     EXPECT_NE(path, nullptr);
97     // 2. Create a rectangle object using OH_Drawing_RectCreate.
98     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
99     // add assert
100     EXPECT_NE(rect, nullptr);
101     // 3. Call OH_Drawing_PathAddArc with a nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER
102     // error code.
103     OH_Drawing_PathAddArc(nullptr, rect, 0.0, 0.0);
104     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
105     OH_Drawing_ErrorCodeReset();
106     // 4. Call OH_Drawing_PathAddArc with a nullptr as the second parameter, expecting
107     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
108     OH_Drawing_PathAddArc(path, nullptr, 0.0, 0.0);
109     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
110     // 5. Call OH_Drawing_PathAddArc with 0.0 as the third parameter, expecting failure without crash.
111     OH_Drawing_PathAddArc(path, rect, 0.0, 0.0);
112     // 6. Call OH_Drawing_PathAddArc with 0.0 as the fourth parameter, expecting failure without crash.
113     OH_Drawing_PathAddArc(path, rect, 0.0, 0.0);
114     // 7. Free the memory.
115     OH_Drawing_PathDestroy(path);
116     OH_Drawing_RectDestroy(rect);
117 }
118 
119 /*
120  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1902
121  * @tc.name: testPathAddArcAbnormal
122  * @tc.desc: Test for adding an arc to a path with abnormal data types as parameters.
123  * @tc.size  : SmallTest
124  * @tc.type  : Function
125  * @tc.level : Level 3
126  */
127 HWTEST_F(DrawingNativePathPart2Test, testPathAddArcAbnormal, Function | SmallTest | Level3) {
128     // 1. Create a path object using OH_Drawing_PathCreate.
129     OH_Drawing_Path *path = OH_Drawing_PathCreate();
130     // add assert
131     EXPECT_NE(path, nullptr);
132     // 2. Create a rectangle object using OH_Drawing_RectCreate.
133     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
134     // add assert
135     EXPECT_NE(rect, nullptr);
136     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
137     OH_Drawing_PathMoveTo(path, 0, 0);
138     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
139     OH_Drawing_PathLineTo(path, 100, 100);
140     // 5. Add an arc to the path using OH_Drawing_PathAddArc, passing an integer or character type as the third
141     // parameter.
142     OH_Drawing_PathAddArc(path, rect, 30, 30.0f);
143     // 6. Add an arc to the path using OH_Drawing_PathAddArc, passing an integer or character type as the fourth
144     // parameter.
145     OH_Drawing_PathAddArc(path, rect, 30.0f, 30);
146     // 7. Free the memory.
147     OH_Drawing_PathDestroy(path);
148 }
149 
150 /*
151  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1903
152  * @tc.name: testPathAddArcMaximal
153  * @tc.desc: Test for adding an arc to a path with maximal values as parameters.
154  * @tc.size  : SmallTest
155  * @tc.type  : Function
156  * @tc.level : Level 3
157  */
158 HWTEST_F(DrawingNativePathPart2Test, testPathAddArcMaximal, Function | SmallTest | Level3) {
159     // 1. Create a path object using OH_Drawing_PathCreate.
160     OH_Drawing_Path *path = OH_Drawing_PathCreate();
161     // add assert
162     EXPECT_NE(path, nullptr);
163     // 2. Create a rectangle object using OH_Drawing_RectCreate.
164     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
165     // add assert
166     EXPECT_NE(rect, nullptr);
167     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
168     OH_Drawing_PathMoveTo(path, 0, 0);
169     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
170     OH_Drawing_PathLineTo(path, 100, 100);
171     // 5. Add an arc to the path using OH_Drawing_PathAddArc, passing FLT_MAX + 1 as the third parameter, which will
172     // fail without crashing.
173     OH_Drawing_PathAddArc(path, rect, FLT_MAX + 1, 0.0);
174     // 6. Add an arc to the path using OH_Drawing_PathAddArc, passing FLT_MAX + 1 as the fourth parameter, which will
175     // fail without crashing.
176     OH_Drawing_PathAddArc(path, rect, 0.0, FLT_MAX + 1);
177     // 7. Free the memory.
178     OH_Drawing_PathDestroy(path);
179     OH_Drawing_RectDestroy(rect);
180 }
181 
182 /*
183  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2000
184  * @tc.name: testPathAddPathNormal
185  * @tc.desc: Test for adding a path to another path with normal parameters.
186  * @tc.size  : SmallTest
187  * @tc.type  : Function
188  * @tc.level : Level 0
189  */
190 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathNormal, Function | SmallTest | Level0) {
191     // 1. Create a path object using OH_Drawing_PathCreate.
192     OH_Drawing_Path *path = OH_Drawing_PathCreate();
193     // add assert
194     EXPECT_NE(path, nullptr);
195     // 2. Create a path object using OH_Drawing_PathCreate.
196     OH_Drawing_Path *src = OH_Drawing_PathCreate();
197     // add assert
198     EXPECT_NE(src, nullptr);
199     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
200     OH_Drawing_PathMoveTo(src, 0, 0);
201     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
202     // path src).
203     OH_Drawing_PathLineTo(src, 100, 100);
204     // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPath.
205     OH_Drawing_PathAddPath(path, src, nullptr);
206     // add assert
207     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
208     // 6. Free the memory.
209     OH_Drawing_PathDestroy(path);
210     OH_Drawing_PathDestroy(src);
211 }
212 
213 /*
214  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2001
215  * @tc.name: testPathAddPathNull
216  * @tc.desc: Test for adding a path to another path with NULL or invalid parameters.
217  * @tc.size  : SmallTest
218  * @tc.type  : Function
219  * @tc.level : Level 3
220  */
221 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathNull, Function | SmallTest | Level3) {
222     // 1. Create a path object using OH_Drawing_PathCreate.
223     OH_Drawing_Path *path = OH_Drawing_PathCreate();
224     // add assert
225     EXPECT_NE(path, nullptr);
226     // 2. Create a path object using OH_Drawing_PathCreate.
227     OH_Drawing_Path *src = OH_Drawing_PathCreate();
228     // add assert
229     EXPECT_NE(src, nullptr);
230     // 3. Call OH_Drawing_PathAddPath with a nullptr as the first parameter, expecting
231     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
232     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
233     OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1);
234     OH_Drawing_PathAddPath(nullptr, src, matrix);
235     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
236     OH_Drawing_ErrorCodeReset();
237     // 4. Call OH_Drawing_PathAddPath with a nullptr as the second parameter, expecting
238     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
239     OH_Drawing_PathAddPath(path, nullptr, matrix);
240     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
241     // 5. Call OH_Drawing_PathAddPath with a nullptr as the third parameter, expecting failure without crash.
242     OH_Drawing_PathAddPath(path, src, nullptr);
243     // 6. Free the memory.
244     OH_Drawing_PathDestroy(path);
245     OH_Drawing_PathDestroy(src);
246     OH_Drawing_MatrixDestroy(matrix);
247 }
248 
249 /*
250  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2100
251  * @tc.name: testPathAddPathWithMatrixAndModeNormal
252  * @tc.desc: Test for adding a path to another path with matrix and mode transformations using normal parameters.
253  * @tc.size  : SmallTest
254  * @tc.type  : Function
255  * @tc.level : Level 0
256  */
257 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithMatrixAndModeNormal, Function | SmallTest | Level0) {
258     // 1. Create a path object using OH_Drawing_PathCreate.
259     OH_Drawing_Path *path = OH_Drawing_PathCreate();
260     // add assert
261     EXPECT_NE(path, nullptr);
262     // 2. Create a path object using OH_Drawing_PathCreate.
263     OH_Drawing_Path *src = OH_Drawing_PathCreate();
264     // add assert
265     EXPECT_NE(src, nullptr);
266     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
267     OH_Drawing_PathMoveTo(src, 0, 0);
268     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
269     // path src).
270     OH_Drawing_PathLineTo(src, 100, 100);
271     // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPathWithMatrixAndMode. The fourth
272     // parameter enumerates calling this interface.
273     OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND};
274     for (int i = 0; i < 2; i++) {
275         OH_Drawing_ErrorCodeReset();
276         OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
277         // add assert
278         EXPECT_NE(matrix, nullptr);
279         OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1);
280         OH_Drawing_PathAddPathWithMatrixAndMode(path, src, matrix, modes[i]);
281         // add assert
282         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
283         OH_Drawing_MatrixDestroy(matrix);
284     }
285     // 6. Free the memory.
286     OH_Drawing_PathDestroy(path);
287     OH_Drawing_PathDestroy(src);
288 }
289 
290 /*
291  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2101
292  * @tc.name: testPathAddPathWithMatrixAndModeNull
293  * @tc.desc: Test for adding a path to another path with matrix and mode transformations using NULL or invalid
294  * parameters.
295  * @tc.size  : SmallTest
296  * @tc.type  : Function
297  * @tc.level : Level 3
298  */
299 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithMatrixAndModeNull, Function | SmallTest | Level3) {
300     // 1. Create a path object using OH_Drawing_PathCreate.
301     OH_Drawing_Path *path = OH_Drawing_PathCreate();
302     // add assert
303     EXPECT_NE(path, nullptr);
304     // 2. Create a path object using OH_Drawing_PathCreate.
305     OH_Drawing_Path *src = OH_Drawing_PathCreate();
306     // add assert
307     EXPECT_NE(src, nullptr);
308     // 3. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the first parameter, expecting
309     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
310     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
311     // add assert
312     EXPECT_NE(matrix, nullptr);
313     OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1);
314     OH_Drawing_PathAddPathWithMatrixAndMode(nullptr, src, matrix, PATH_ADD_MODE_APPEND);
315     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
316     OH_Drawing_ErrorCodeReset();
317     // 4. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the second parameter, expecting
318     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
319     OH_Drawing_PathAddPathWithMatrixAndMode(path, nullptr, matrix, PATH_ADD_MODE_APPEND);
320     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
321     // 5. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the third parameter, expecting failure without
322     // crash.
323     OH_Drawing_PathAddPathWithMatrixAndMode(path, src, nullptr, PATH_ADD_MODE_APPEND);
324     // 6. Free the memory.
325     OH_Drawing_PathDestroy(path);
326     OH_Drawing_PathDestroy(src);
327     OH_Drawing_MatrixDestroy(matrix);
328 }
329 
330 /*
331  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2200
332  * @tc.name: testPathAddPathWithModeNormal
333  * @tc.desc: Test for adding a path to another path with mode transformations using normal parameters.
334  * @tc.size  : SmallTest
335  * @tc.type  : Function
336  * @tc.level : Level 0
337  */
338 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithModeNormal, Function | SmallTest | Level0) {
339     // 1. Create a path object using OH_Drawing_PathCreate.
340     OH_Drawing_Path *path = OH_Drawing_PathCreate();
341     // add assert
342     EXPECT_NE(path, nullptr);
343     // 2. Create a path object using OH_Drawing_PathCreate.
344     OH_Drawing_Path *src = OH_Drawing_PathCreate();
345     // add assert
346     EXPECT_NE(src, nullptr);
347     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
348     OH_Drawing_PathMoveTo(src, 0, 0);
349     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
350     // path src).
351     OH_Drawing_PathLineTo(src, 100, 100);
352     // 5. Add the source path to the current path using OH_Drawing_PathAddPathWithMode. The third parameter enumerates
353     // calling this interface.
354     OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND};
355     for (int i = 0; i < 2; i++) {
356         OH_Drawing_ErrorCodeReset();
357         OH_Drawing_PathAddPathWithMode(path, src, modes[i]);
358         // add assert
359         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
360     }
361     // 6. Free the memory.
362     OH_Drawing_PathDestroy(path);
363 }
364 
365 /*
366  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2201
367  * @tc.name: testPathAddPathWithModeNull
368  * @tc.desc: Test for adding a path to another path with mode transformations using NULL or invalid parameters.
369  * @tc.size  : SmallTest
370  * @tc.type  : Function
371  * @tc.level : Level 3
372  */
373 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithModeNull, Function | SmallTest | Level3) {
374     // 1. Create a path object using OH_Drawing_PathCreate.
375     OH_Drawing_Path *path = OH_Drawing_PathCreate();
376     // add assert
377     EXPECT_NE(path, nullptr);
378     // 2. Create a path object using OH_Drawing_PathCreate.
379     OH_Drawing_Path *src = OH_Drawing_PathCreate();
380     // add assert
381     EXPECT_NE(src, nullptr);
382     // 3. Call OH_Drawing_PathAddPathWithMode with a nullptr as the first parameter, expecting
383     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
384     OH_Drawing_PathAddPathWithMode(nullptr, src, PATH_ADD_MODE_APPEND);
385     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
386     OH_Drawing_ErrorCodeReset();
387     // 4. Call OH_Drawing_PathAddPathWithMode with a nullptr as the second parameter, expecting
388     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
389     OH_Drawing_PathAddPathWithMode(path, nullptr, PATH_ADD_MODE_APPEND);
390     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
391     // 5. Free the memory.
392     OH_Drawing_PathDestroy(path);
393     OH_Drawing_PathDestroy(src);
394 }
395 
396 /*
397  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2300
398  * @tc.name: testPathAddPathWithOffsetAndModeNormal
399  * @tc.desc: Test for adding a path to another path with offset and mode transformations using normal parameters.
400  * @tc.size  : SmallTest
401  * @tc.type  : Function
402  * @tc.level : Level 0
403  */
404 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithOffsetAndModeNormal, Function | SmallTest | Level0) {
405     // 1. Create a path object using OH_Drawing_PathCreate.
406     OH_Drawing_Path *path = OH_Drawing_PathCreate();
407     // add assert
408     EXPECT_NE(path, nullptr);
409     // 2. Create a path object using OH_Drawing_PathCreate.
410     OH_Drawing_Path *src = OH_Drawing_PathCreate();
411     // add assert
412     EXPECT_NE(src, nullptr);
413     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
414     OH_Drawing_PathMoveTo(src, 0, 0);
415     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
416     // path src).
417     OH_Drawing_PathLineTo(src, 100, 100);
418     // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPathWithOffsetAndMode. The fifth
419     // parameter enumerates calling this interface.
420     OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND};
421     for (int i = 0; i < 2; i++) {
422         OH_Drawing_ErrorCodeReset();
423         OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0, 10.0, modes[i]);
424         // add assert
425         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
426     }
427     // 6. Free the memory.
428     OH_Drawing_PathDestroy(path);
429     OH_Drawing_PathDestroy(src);
430 }
431 
432 /*
433  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2301
434  * @tc.name: testPathAddPathWithOffsetAndModeNull
435  * @tc.desc: Test for adding a path to another path with offset and mode transformations using NULL or invalid
436  * parameters.
437  * @tc.size  : SmallTest
438  * @tc.type  : Function
439  * @tc.level : Level 3
440  */
441 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithOffsetAndModeNull, Function | SmallTest | Level3) {
442     // 1. Create a path object using OH_Drawing_PathCreate.
443     OH_Drawing_Path *path = OH_Drawing_PathCreate();
444     // add assert
445     EXPECT_NE(path, nullptr);
446     // 2. Create a path object using OH_Drawing_PathCreate.
447     OH_Drawing_Path *src = OH_Drawing_PathCreate();
448     // add assert
449     EXPECT_NE(src, nullptr);
450     // 3. Call OH_Drawing_PathAddPathWithOffsetAndMode with a nullptr as the first parameter, expecting
451     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
452     OH_Drawing_PathAddPathWithOffsetAndMode(nullptr, src, 10.0, 10.0, PATH_ADD_MODE_APPEND);
453     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
454     OH_Drawing_ErrorCodeReset();
455     // 4. Call OH_Drawing_PathAddPathWithOffsetAndMode with a nullptr as the second parameter, expecting
456     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
457     OH_Drawing_PathAddPathWithOffsetAndMode(path, nullptr, 10.0, 10.0, PATH_ADD_MODE_APPEND);
458     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
459     // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with 0.00 as the third parameter, expecting failure without
460     // crash.
461     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 0.0, 10.0, PATH_ADD_MODE_APPEND);
462     // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with 0.00 as the fourth parameter, expecting failure without
463     // crash.
464     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0, 0.0, PATH_ADD_MODE_APPEND);
465     // 7. Free the memory.
466     OH_Drawing_PathDestroy(path);
467     OH_Drawing_PathDestroy(src);
468 }
469 
470 /*
471  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2302
472  * @tc.name: testPathAddPathWithOffsetAndModeAbnormal
473  * @tc.desc: Test for adding a path to another path with offset and mode transformations using abnormal parameters.
474  * @tc.size  : SmallTest
475  * @tc.type  : Function
476  * @tc.level : Level 3
477  */
478 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithOffsetAndModeAbnormal, Function | SmallTest | Level3) {
479     // 1. Create a path object using OH_Drawing_PathCreate.
480     OH_Drawing_Path *path = OH_Drawing_PathCreate();
481     // add assert
482     EXPECT_NE(path, nullptr);
483     // 2. Create a path object using OH_Drawing_PathCreate.
484     OH_Drawing_Path *src = OH_Drawing_PathCreate();
485     // add assert
486     EXPECT_NE(src, nullptr);
487     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
488     OH_Drawing_PathMoveTo(src, 0, 0);
489     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
490     // path src).
491     OH_Drawing_PathLineTo(src, 100, 100);
492     // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with an integer as the third parameter, expecting successful
493     // call.
494     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10, 10.0f, PATH_ADD_MODE_APPEND);
495     // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with an integer as the fourth parameter, expecting successful
496     // call.
497     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0f, 10, PATH_ADD_MODE_APPEND);
498     // 7. Free the memory.
499     OH_Drawing_PathDestroy(path);
500     OH_Drawing_PathDestroy(src);
501 }
502 
503 /*
504  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2303
505  * @tc.name: testPathAddPathWithOffsetAndModeMaximal
506  * @tc.desc: Test for adding a path to another path with offset and mode transformations using maximal values.
507  * @tc.size  : SmallTest
508  * @tc.type  : Function
509  * @tc.level : Level 3
510  */
511 HWTEST_F(DrawingNativePathPart2Test, testPathAddPathWithOffsetAndModeMaximal, Function | SmallTest | Level3) {
512     // 1. Create a path object using OH_Drawing_PathCreate.
513     OH_Drawing_Path *path = OH_Drawing_PathCreate();
514     // add assert
515     EXPECT_NE(path, nullptr);
516     // 2. Create a path object using OH_Drawing_PathCreate.
517     OH_Drawing_Path *src = OH_Drawing_PathCreate();
518     // add assert
519     EXPECT_NE(src, nullptr);
520     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
521     OH_Drawing_PathMoveTo(src, 0, 0);
522     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source
523     // path src).
524     OH_Drawing_PathLineTo(src, 100, 100);
525     // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with the third parameter as FLT_MAX + 1, without crashing.
526     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, FLT_MAX + 1, 10.0f, PATH_ADD_MODE_APPEND);
527     // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with the fourth parameter as FLT_MAX + 1, without crashing.
528     OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0f, FLT_MAX + 1, PATH_ADD_MODE_APPEND);
529     // 7. Free the memory.
530     OH_Drawing_PathDestroy(path);
531 }
532 
533 /*
534  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2400
535  * @tc.name: testPathAddOvalNormal
536  * @tc.desc: Test for adding an oval to a path using normal parameters.
537  * @tc.size  : SmallTest
538  * @tc.type  : Function
539  * @tc.level : Level 0
540  */
541 HWTEST_F(DrawingNativePathPart2Test, testPathAddOvalNormal, Function | SmallTest | Level0) {
542     // 1. Create a path object using OH_Drawing_PathCreate.
543     OH_Drawing_Path *path = OH_Drawing_PathCreate();
544     // add assert
545     EXPECT_NE(path, nullptr);
546     // 2. Create a rectangle object using OH_Drawing_RectCreate.
547     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
548     // add assert
549     EXPECT_NE(rect, nullptr);
550     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
551     OH_Drawing_PathMoveTo(path, 0, 0);
552     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
553     OH_Drawing_PathLineTo(path, 100, 100);
554     // 5. Add an oval to the path with the specified direction using OH_Drawing_PathAddOval. The third parameter
555     // enumerates calling this interface.
556     OH_Drawing_PathDirection directions[] = {PATH_DIRECTION_CW, PATH_DIRECTION_CCW};
557     for (int i = 0; i < 2; i++) {
558         OH_Drawing_ErrorCodeReset();
559         OH_Drawing_PathAddOval(path, rect, directions[i]);
560         // add assert
561         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
562     }
563     // 6. Free the memory.
564     OH_Drawing_PathDestroy(path);
565     OH_Drawing_RectDestroy(rect);
566 }
567 
568 /*
569  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2401
570  * @tc.name: testPathAddOvalNull
571  * @tc.desc: Test for adding an oval to a path using NULL or invalid parameters.
572  * @tc.size  : SmallTest
573  * @tc.type  : Function
574  * @tc.level : Level 3
575  */
576 HWTEST_F(DrawingNativePathPart2Test, testPathAddOvalNull, Function | SmallTest | Level3) {
577     // 1. Create a path object using OH_Drawing_PathCreate.
578     OH_Drawing_Path *path = OH_Drawing_PathCreate();
579     // add assert
580     EXPECT_NE(path, nullptr);
581     // 2. Create a rectangle object using OH_Drawing_RectCreate.
582     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
583     // add assert
584     EXPECT_NE(rect, nullptr);
585     // 3. Call OH_Drawing_PathAddOval with a nullptr as the first parameter, expecting
586     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
587     OH_Drawing_PathAddOval(nullptr, rect, PATH_DIRECTION_CW);
588     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
589     OH_Drawing_ErrorCodeReset();
590     // 4. Call OH_Drawing_PathAddOval with a nullptr as the second parameter, expecting
591     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
592     OH_Drawing_PathAddOval(path, nullptr, PATH_DIRECTION_CW);
593     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
594     // 5. Free the memory.
595     OH_Drawing_PathDestroy(path);
596     OH_Drawing_RectDestroy(rect);
597 }
598 
599 /*
600  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2500
601  * @tc.name: testPathAddPolygonNormal
602  * @tc.desc: Test for adding a polygon to a path with the fourth parameter set to true.
603  * @tc.size  : SmallTest
604  * @tc.type  : Function
605  * @tc.level : Level 0
606  */
607 HWTEST_F(DrawingNativePathPart2Test, testPathAddPolygonNormal, Function | SmallTest | Level0) {
608     // 1. Create a path object using OH_Drawing_PathCreate.
609     OH_Drawing_Path *path = OH_Drawing_PathCreate();
610     // add assert
611     EXPECT_NE(path, nullptr);
612     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
613     OH_Drawing_PathMoveTo(path, 0, 0);
614     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
615     OH_Drawing_PathLineTo(path, 100, 100);
616     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
617     OH_Drawing_PathLineTo(path, 100, 0);
618     // 5. Add a polygon to the path. Set the fourth parameter to true.
619     OH_Drawing_Point2D point1 = {0, 0};
620     OH_Drawing_Point2D point2 = {100, 0};
621     OH_Drawing_Point2D point3 = {100, 100};
622     OH_Drawing_Point2D point4 = {0, 100};
623     OH_Drawing_Point2D points[4] = {point1, point2, point3, point4};
624     OH_Drawing_PathAddPolygon(path, points, 4, true);
625     // add assert
626     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
627     // 6. Free the memory.
628     OH_Drawing_PathDestroy(path);
629 }
630 
631 /*
632  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2501
633  * @tc.name: testPathAddPolygonNormal2
634  * @tc.desc: Test for adding a polygon to a path with the fourth parameter set to false.
635  * @tc.size  : SmallTest
636  * @tc.type  : Function
637  * @tc.level : Level 0
638  */
639 HWTEST_F(DrawingNativePathPart2Test, testPathAddPolygonNormal2, Function | SmallTest | Level0) {
640     // 1. Create a path object using OH_Drawing_PathCreate.
641     OH_Drawing_Path *path = OH_Drawing_PathCreate();
642     // add assert
643     EXPECT_NE(path, nullptr);
644     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
645     OH_Drawing_PathMoveTo(path, 0, 0);
646     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
647     OH_Drawing_PathLineTo(path, 100, 100);
648     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
649     OH_Drawing_PathLineTo(path, 100, 0);
650     // 5. Add a polygon to the path. Set the fourth parameter to false.
651     OH_Drawing_Point2D point1 = {0, 0};
652     OH_Drawing_Point2D point2 = {100, 0};
653     OH_Drawing_Point2D point3 = {100, 100};
654     OH_Drawing_Point2D point4 = {0, 100};
655     OH_Drawing_Point2D points[4] = {point1, point2, point3, point4};
656     OH_Drawing_PathAddPolygon(path, points, 4, false);
657     // add assert
658     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
659     // 6. Free the memory.
660     OH_Drawing_PathDestroy(path);
661 }
662 
663 /*
664  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2502
665  * @tc.name: testPathAddPolygonNull
666  * @tc.desc: Test for adding a polygon to a path using NULL or invalid parameters.
667  * @tc.size  : SmallTest
668  * @tc.type  : Function
669  * @tc.level : Level 3
670  */
671 HWTEST_F(DrawingNativePathPart2Test, testPathAddPolygonNull, Function | SmallTest | Level3) {
672     // 1. Create a path object using OH_Drawing_PathCreate.
673     OH_Drawing_Path *path = OH_Drawing_PathCreate();
674     // add assert
675     EXPECT_NE(path, nullptr);
676     OH_Drawing_Point2D point1 = {0, 0};
677     OH_Drawing_Point2D point2 = {100, 0};
678     OH_Drawing_Point2D point3 = {100, 100};
679     OH_Drawing_Point2D point4 = {0, 100};
680     OH_Drawing_Point2D points[4] = {point1, point2, point3, point4};
681     // 2. Call OH_Drawing_PathAddPolygon with a nullptr as the first parameter, expecting
682     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
683     OH_Drawing_PathAddPolygon(nullptr, points, 4, true);
684     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
685     OH_Drawing_ErrorCodeReset();
686     // 3. Call OH_Drawing_PathAddPolygon with a nullptr as the second parameter, expecting
687     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
688     OH_Drawing_PathAddPolygon(path, nullptr, 4, true);
689     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
690     OH_Drawing_ErrorCodeReset();
691     // 4. Call OH_Drawing_PathAddPolygon with the third parameter as 0, expecting OH_DRAWING_ERROR_INVALID_PARAMETER
692     // error code.
693     OH_Drawing_PathAddPolygon(path, points, 0, true);
694     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
695     // 5. Free the memory.
696     OH_Drawing_PathDestroy(path);
697 }
698 
699 /*
700  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2503
701  * @tc.name: testPathAddPolygonAbnormal
702  * @tc.desc: Test for adding a polygon to a path using abnormal parameters.
703  * @tc.size  : SmallTest
704  * @tc.type  : Function
705  * @tc.level : Level 3
706  */
707 HWTEST_F(DrawingNativePathPart2Test, testPathAddPolygonAbnormal, Function | SmallTest | Level3) {
708     // 1. Create a path object using OH_Drawing_PathCreate.
709     OH_Drawing_Path *path = OH_Drawing_PathCreate();
710     // add assert
711     EXPECT_NE(path, nullptr);
712     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
713     OH_Drawing_PathMoveTo(path, 0, 0);
714     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
715     OH_Drawing_PathLineTo(path, 100, 100);
716     // 4. Add a polygon to the path with the second parameter's x-coordinate as an integer or character type, which will
717     // succeed.
718     OH_Drawing_Point2D point1 = {0, 0};
719     OH_Drawing_Point2D point2 = {100, 0};
720     OH_Drawing_Point2D point3 = {100, 100};
721     OH_Drawing_Point2D point4 = {0, 100};
722     OH_Drawing_Point2D points[4] = {point1, point2, point3, point4};
723     OH_Drawing_PathAddPolygon(path, points, 4, true);
724     // add assert
725     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
726     // 5. Add a polygon to the path with the second parameter's y-coordinate as an integer or character type, which will
727     // succeed.
728     OH_Drawing_PathAddPolygon(path, points, 4, true);
729     // add assert
730     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
731     // 6. Add a polygon to the path with the third parameter as a float or character type, which will succeed.
732     OH_Drawing_PathAddPolygon(path, points, 4.0f, true);
733     // add assert
734     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
735     // 7. Free the memory.
736     OH_Drawing_PathDestroy(path);
737 }
738 
739 /*
740  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2504
741  * @tc.name: testPathAddPolygonMaximal
742  * @tc.desc: Test for adding a polygon to a path using maximal values.
743  * @tc.size  : SmallTest
744  * @tc.type  : Function
745  * @tc.level : Level 3
746  */
747 HWTEST_F(DrawingNativePathPart2Test, testPathAddPolygonMaximal, Function | SmallTest | Level3) {
748     // 1. Create a path object using OH_Drawing_PathCreate.
749     OH_Drawing_Path *path = OH_Drawing_PathCreate();
750     // add assert
751     EXPECT_NE(path, nullptr);
752     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
753     OH_Drawing_PathMoveTo(path, 0, 0);
754     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
755     OH_Drawing_PathLineTo(path, 100, 100);
756     // 4. Add a polygon to the path with the second parameter's x-coordinate set to FLT_MAX + 1, no crash occurs.
757     OH_Drawing_Point2D point1 = {FLT_MAX + 1, 0};
758     OH_Drawing_Point2D point2 = {FLT_MAX + 1, 0};
759     OH_Drawing_Point2D point3 = {FLT_MAX + 1, 100};
760     OH_Drawing_Point2D point4 = {FLT_MAX + 1, 100};
761     OH_Drawing_Point2D points[4] = {point1, point2, point3, point4};
762     OH_Drawing_PathAddPolygon(path, points, 4, true);
763     // add assert
764     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
765     // 5. Add a polygon to the path with the second parameter's y-coordinate set to FLT_MAX + 1, no crash occurs.
766     OH_Drawing_Point2D point5 = {0, FLT_MAX + 1};
767     OH_Drawing_Point2D point6 = {100, FLT_MAX + 1};
768     OH_Drawing_Point2D point7 = {100, FLT_MAX + 1};
769     OH_Drawing_Point2D point8 = {0, FLT_MAX + 1};
770     OH_Drawing_Point2D points2[4] = {point5, point6, point7, point8};
771     OH_Drawing_PathAddPolygon(path, points2, 4, true);
772     // add assert
773     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
774     // 6. Free the memory.
775     OH_Drawing_PathDestroy(path);
776 }
777 
778 /*
779  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2600
780  * @tc.name: testPathAddCircleNormal
781  * @tc.desc: Test for adding a circle to a path using normal parameters.
782  * @tc.size  : SmallTest
783  * @tc.type  : Function
784  * @tc.level : Level 0
785  */
786 HWTEST_F(DrawingNativePathPart2Test, testPathAddCircleNormal, Function | SmallTest | Level0) {
787     // 1. Create a path object using OH_Drawing_PathCreate.
788     OH_Drawing_Path *path = OH_Drawing_PathCreate();
789     // add assert
790     EXPECT_NE(path, nullptr);
791     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
792     OH_Drawing_PathMoveTo(path, 0, 0);
793     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
794     OH_Drawing_PathLineTo(path, 100, 100);
795     // 4. Add a circle to the path with the specified direction.
796     OH_Drawing_PathAddCircle(path, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
797     // add assert
798     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
799     OH_Drawing_PathAddCircle(path, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
800     // add assert
801     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
802     // 5. Free the memory.
803     OH_Drawing_PathDestroy(path);
804 }
805 
806 /*
807  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2601
808  * @tc.name: testPathAddCircleNull
809  * @tc.desc: Test for adding a circle to a path using NULL or invalid parameters.
810  * @tc.size  : SmallTest
811  * @tc.type  : Function
812  * @tc.level : Level 3
813  */
814 HWTEST_F(DrawingNativePathPart2Test, testPathAddCircleNull, Function | SmallTest | Level3) {
815     // 1. Create a path object using OH_Drawing_PathCreate.
816     OH_Drawing_Path *path = OH_Drawing_PathCreate();
817     // add assert
818     EXPECT_NE(path, nullptr);
819     // 2. Call OH_Drawing_PathAddCircle with a nullptr as the first parameter, expecting
820     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
821     OH_Drawing_PathAddCircle(nullptr, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
822     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
823     // 3. Call OH_Drawing_PathAddCircle with the second parameter as 0.00, which will fail without crashing.
824     OH_Drawing_PathAddCircle(path, 0.00, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
825     // 4. Call OH_Drawing_PathAddCircle with the third parameter as 0.00, which will fail without crashing.
826     OH_Drawing_PathAddCircle(path, 50, 0.00, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
827     // 5. Call OH_Drawing_PathAddCircle with the fourth parameter less than or equal to 0.00, expecting
828     // OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE error code.
829     OH_Drawing_PathAddCircle(path, 50, 50, 0.00, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
830     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
831     // 6. Free the memory.
832     OH_Drawing_PathDestroy(path);
833 }
834 
835 /*
836  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2602
837  * @tc.name: testPathAddCircleAbnormal
838  * @tc.desc: Test for adding a circle to a path using abnormal parameters.
839  * @tc.size  : SmallTest
840  * @tc.type  : Function
841  * @tc.level : Level 3
842  */
843 HWTEST_F(DrawingNativePathPart2Test, testPathAddCircleAbnormal, Function | SmallTest | Level3) {
844     // 1. Create a path object using OH_Drawing_PathCreate.
845     OH_Drawing_Path *path = OH_Drawing_PathCreate();
846     // add assert
847     EXPECT_NE(path, nullptr);
848     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
849     OH_Drawing_PathMoveTo(path, 0, 0);
850     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
851     OH_Drawing_PathLineTo(path, 100, 100);
852     // 4. Add a circle to the path with the second parameter as an integer, which will succeed.
853     OH_Drawing_PathAddCircle(path, 50, 50.0f, 10.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
854     // add assert
855     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
856     // 5. Add a circle to the path with the third parameter as an integer, which will succeed.
857     OH_Drawing_PathAddCircle(path, 50.0f, 50, 10.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
858     // add assert
859     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
860     // 6. Add a circle to the path with the fourth parameter as an integer, which will succeed.
861     OH_Drawing_PathAddCircle(path, 50.0f, 50.0f, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
862     // add assert
863     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
864     // 7. Free the memory.
865     OH_Drawing_PathDestroy(path);
866 }
867 
868 /*
869  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2603
870  * @tc.name: testPathAddCircleMaximal
871  * @tc.desc: Test for adding a circle to a path using maximal values.
872  * @tc.size  : SmallTest
873  * @tc.type  : Function
874  * @tc.level : Level 3
875  */
876 HWTEST_F(DrawingNativePathPart2Test, testPathAddCircleMaximal, Function | SmallTest | Level3) {
877     // 1. Create a path object using OH_Drawing_PathCreate.
878     OH_Drawing_Path *path = OH_Drawing_PathCreate();
879     // add assert
880     EXPECT_NE(path, nullptr);
881     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
882     OH_Drawing_PathMoveTo(path, 0, 0);
883     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
884     OH_Drawing_PathLineTo(path, 100, 100);
885     // 4. Add a circle to the path with the second parameter set to FLT_MAX + 1, no crash occurs.
886     OH_Drawing_PathAddCircle(path, FLT_MAX + 1, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
887     // 5. Add a circle to the path with the third parameter set to FLT_MAX + 1, no crash occurs.
888     OH_Drawing_PathAddCircle(path, 50, FLT_MAX + 1, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
889     // 6. Add a circle to the path with the fourth parameter set to FLT_MAX + 1, no crash occurs.
890     OH_Drawing_PathAddCircle(path, 50, 50, FLT_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CCW);
891     // 7. Free the memory.
892     OH_Drawing_PathDestroy(path);
893 }
894 
895 /*
896  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2700
897  * @tc.name: testPathBuildFromSvgStringNormal
898  * @tc.desc: Test for building a path from an SVG string using normal parameters.
899  * @tc.size  : SmallTest
900  * @tc.type  : Function
901  * @tc.level : Level 0
902  */
903 HWTEST_F(DrawingNativePathPart2Test, testPathBuildFromSvgStringNormal, Function | SmallTest | Level0) {
904     // 1. Create a path object using OH_Drawing_PathCreate.
905     OH_Drawing_Path *path = OH_Drawing_PathCreate();
906     // add assert
907     EXPECT_NE(path, nullptr);
908     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
909     OH_Drawing_PathMoveTo(path, 0, 0);
910     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
911     OH_Drawing_PathLineTo(path, 100, 100);
912     // 4. Parse the path represented by the SVG string using OH_Drawing_PathBuildFromSvgString.
913     const char *svgString = "M 0 0 L 100 100";
914     bool svgResult = OH_Drawing_PathBuildFromSvgString(path, svgString);
915     // add assert
916     EXPECT_EQ(svgResult, true);
917     // add assert
918     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
919     // 5. Free the memory.
920     OH_Drawing_PathDestroy(path);
921 }
922 
923 /*
924  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2701
925  * @tc.name: testPathBuildFromSvgStringNull
926  * @tc.desc: Test for building a path from an SVG string using NULL or invalid parameters.
927  * @tc.size  : SmallTest
928  * @tc.type  : Function
929  * @tc.level : Level 3
930  */
931 HWTEST_F(DrawingNativePathPart2Test, testPathBuildFromSvgStringNull, Function | SmallTest | Level3) {
932     // 1. Create a path object using OH_Drawing_PathCreate.
933     OH_Drawing_Path *path = OH_Drawing_PathCreate();
934     // add assert
935     EXPECT_NE(path, nullptr);
936     // 2. Call OH_Drawing_PathBuildFromSvgString with a nullptr as the first parameter, expecting
937     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
938     OH_Drawing_PathBuildFromSvgString(nullptr, "M 0 0 L 100 100");
939     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
940     OH_Drawing_ErrorCodeReset();
941     // 3. Call OH_Drawing_PathBuildFromSvgString with a nullptr as the second parameter, expecting
942     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
943     OH_Drawing_PathBuildFromSvgString(path, nullptr);
944     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
945     // 4. Free the memory.
946     OH_Drawing_PathDestroy(path);
947 }
948 
949 /*
950  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2800
951  * @tc.name: testPathContainsNormal
952  * @tc.desc: Test for checking if a path contains a specified point using normal parameters.
953  * @tc.size  : SmallTest
954  * @tc.type  : Function
955  * @tc.level : Level 0
956  */
957 HWTEST_F(DrawingNativePathPart2Test, testPathContainsNormal, Function | SmallTest | Level0) {
958     // 1. Create a path object using OH_Drawing_PathCreate.
959     OH_Drawing_Path *path = OH_Drawing_PathCreate();
960     // add assert
961     EXPECT_NE(path, nullptr);
962     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
963     OH_Drawing_PathMoveTo(path, 0, 0);
964     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
965     OH_Drawing_PathLineTo(path, 100, 100);
966     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
967     OH_Drawing_PathLineTo(path, 100, 0);
968     // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
969     OH_Drawing_PathLineTo(path, 0, 0);
970     // 6. Close the path using OH_Drawing_PathClose.
971     OH_Drawing_PathClose(path);
972     // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains.
973     EXPECT_EQ(OH_Drawing_PathContains(path, 50, 50), true);
974     // add assert
975     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
976     // 8. Free the memory.
977     OH_Drawing_PathDestroy(path);
978 }
979 
980 /*
981  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2801
982  * @tc.name: testPathContainsNull
983  * @tc.desc: Test for checking if a path contains a specified point using NULL or invalid parameters.
984  * @tc.size  : SmallTest
985  * @tc.type  : Function
986  * @tc.level : Level 3
987  */
988 HWTEST_F(DrawingNativePathPart2Test, testPathContainsNull, Function | SmallTest | Level3) {
989     // 1. Create a path object using OH_Drawing_PathCreate.
990     OH_Drawing_Path *path = OH_Drawing_PathCreate();
991     // add assert
992     EXPECT_NE(path, nullptr);
993     // 2. Call OH_Drawing_PathContains with a nullptr as the first parameter, expecting
994     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
995     OH_Drawing_PathContains(nullptr, 50, 50);
996     // add assert
997     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
998     // 3. Call OH_Drawing_PathContains with the second parameter as 0.00, the call fails without crashing.
999     OH_Drawing_PathContains(path, 0.0, 50);
1000     // 4. Call OH_Drawing_PathContains with the third parameter as 0.00, the call fails without crashing.
1001     OH_Drawing_PathContains(path, 50, 0.0);
1002     // 5. Free the memory.
1003     OH_Drawing_PathDestroy(path);
1004 }
1005 
1006 /*
1007  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2802
1008  * @tc.name: testPathContainsAbnormal
1009  * @tc.desc: Test for checking if a path contains a specified point using abnormal parameters.
1010  * @tc.size  : SmallTest
1011  * @tc.type  : Function
1012  * @tc.level : Level 3
1013  */
1014 HWTEST_F(DrawingNativePathPart2Test, testPathContainsAbnormal, Function | SmallTest | Level3) {
1015     // 1. Create a path object using OH_Drawing_PathCreate.
1016     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1017     // add assert
1018     EXPECT_NE(path, nullptr);
1019     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1020     OH_Drawing_PathMoveTo(path, 0, 0);
1021     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1022     OH_Drawing_PathLineTo(path, 100, 100);
1023     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1024     OH_Drawing_PathLineTo(path, 100, 0);
1025     // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1026     OH_Drawing_PathLineTo(path, 0, 0);
1027     // 6. Close the path using OH_Drawing_PathClose.
1028     OH_Drawing_PathClose(path);
1029     // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains.
1030     OH_Drawing_PathContains(path, 50, 50.0f);
1031     // 8. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains.
1032     OH_Drawing_PathContains(path, 50.0f, 50);
1033     // 9. Free the memory.
1034     OH_Drawing_PathDestroy(path);
1035 }
1036 
1037 /*
1038  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2803
1039  * @tc.name: testPathContainsMaximal
1040  * @tc.desc: Test for checking if a path contains a specified point using maximal values.
1041  * @tc.size  : SmallTest
1042  * @tc.type  : Function
1043  * @tc.level : Level 3
1044  */
1045 HWTEST_F(DrawingNativePathPart2Test, testPathContainsMaximal, Function | SmallTest | Level3) {
1046     // 1. Create a path object using OH_Drawing_PathCreate.
1047     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1048     // add assert
1049     EXPECT_NE(path, nullptr);
1050     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1051     OH_Drawing_PathMoveTo(path, 0, 0);
1052     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1053     OH_Drawing_PathLineTo(path, 100, 0);
1054     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1055     OH_Drawing_PathLineTo(path, 100, 100);
1056     // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1057     OH_Drawing_PathLineTo(path, 0, 100);
1058     // 6. Close the path using OH_Drawing_PathClose.
1059     OH_Drawing_PathClose(path);
1060     // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains with the second
1061     // parameter as FLT_MAX + 1.
1062     OH_Drawing_PathContains(path, FLT_MAX + 1, 50);
1063     // 8. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains with the third
1064     // parameter as FLT_MAX + 1.
1065     OH_Drawing_PathContains(path, 50, FLT_MAX + 1);
1066     // 9. Free the memory.
1067     OH_Drawing_PathDestroy(path);
1068 }
1069 
1070 /*
1071  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2900
1072  * @tc.name: testPathTransformNormal
1073  * @tc.desc: Test for transforming a path using normal parameters.
1074  * @tc.size  : SmallTest
1075  * @tc.type  : Function
1076  * @tc.level : Level 0
1077  */
1078 HWTEST_F(DrawingNativePathPart2Test, testPathTransformNormal, Function | SmallTest | Level0) {
1079     // 1. Create a path object using OH_Drawing_PathCreate.
1080     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1081     // add assert
1082     EXPECT_NE(path, nullptr);
1083     // 2. Create a matrix object using OH_Drawing_MatrixCreate.
1084     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1085     // add assert
1086     EXPECT_NE(matrix, nullptr);
1087     OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
1088     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
1089     OH_Drawing_PathMoveTo(path, 0, 0);
1090     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1091     OH_Drawing_PathLineTo(path, 100, 100);
1092     // 5. Transform the path using OH_Drawing_PathTransform.
1093     OH_Drawing_PathTransform(path, matrix);
1094     // add assert
1095     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1096     // 6. Free the memory.
1097     OH_Drawing_PathDestroy(path);
1098     OH_Drawing_MatrixDestroy(matrix);
1099 }
1100 
1101 /*
1102  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2901
1103  * @tc.name: testPathTransformNull
1104  * @tc.desc: Test for transforming a path using NULL or invalid parameters.
1105  * @tc.size  : SmallTest
1106  * @tc.type  : Function
1107  * @tc.level : Level 3
1108  */
1109 HWTEST_F(DrawingNativePathPart2Test, testPathTransformNull, Function | SmallTest | Level3) {
1110     // 1. Create a path object using OH_Drawing_PathCreate.
1111     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1112     // add assert
1113     EXPECT_NE(path, nullptr);
1114     // 2. Create a matrix object using OH_Drawing_MatrixCreate.
1115     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1116     // add assert
1117     EXPECT_NE(matrix, nullptr);
1118     OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
1119     // 3. Call OH_Drawing_PathTransform with a nullptr as the first parameter, expecting
1120     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1121     OH_Drawing_PathTransform(nullptr, matrix);
1122     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1123     OH_Drawing_ErrorCodeReset();
1124     // 4. Call OH_Drawing_PathTransform with a nullptr as the second parameter, expecting
1125     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1126     OH_Drawing_PathTransform(path, nullptr);
1127     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1128     // 5. Free the memory.
1129     OH_Drawing_PathDestroy(path);
1130     OH_Drawing_MatrixDestroy(matrix);
1131 }
1132 
1133 /*
1134  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3000
1135  * @tc.name: testPathTransformWithPerspectiveClipNormal
1136  * @tc.desc: Test for transforming a path with perspective clip using normal parameters.
1137  * @tc.size  : SmallTest
1138  * @tc.type  : Function
1139  * @tc.level : Level 0
1140  */
1141 HWTEST_F(DrawingNativePathPart2Test, testPathTransformWithPerspectiveClipNormal, Function | SmallTest | Level0) {
1142     // 1. Create a path object src using OH_Drawing_PathCreate.
1143     OH_Drawing_Path *src = OH_Drawing_PathCreate();
1144     // add assert
1145     EXPECT_NE(src, nullptr);
1146     // 2. Create a matrix object using OH_Drawing_MatrixCreate.
1147     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1148     // add assert
1149     EXPECT_NE(matrix, nullptr);
1150     OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
1151     // 3. Create a path object dst using OH_Drawing_PathCreate.
1152     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1153     // 4. Set the starting point of the path using OH_Drawing_PathMoveTo.
1154     OH_Drawing_PathMoveTo(src, 0, 0);
1155     // 5. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1156     OH_Drawing_PathLineTo(src, 100, 100);
1157     // 6. Transform the path using OH_Drawing_PathTransformWithPerspectiveClip, with the fourth parameter set to true.
1158     OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, dst, true);
1159     // add assert
1160     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1161     // 7. Free the memory.
1162     OH_Drawing_PathDestroy(src);
1163     OH_Drawing_PathDestroy(dst);
1164     OH_Drawing_MatrixDestroy(matrix);
1165 }
1166 
1167 /*
1168  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3001
1169  * @tc.name: testPathTransformWithPerspectiveClipNormal2
1170  * @tc.desc: Test for transforming a path with perspective clip using normal parameters with false perspective clip.
1171  * @tc.size  : SmallTest
1172  * @tc.type  : Function
1173  * @tc.level : Level 0
1174  */
1175 HWTEST_F(DrawingNativePathPart2Test, testPathTransformWithPerspectiveClipNormal2, Function | SmallTest | Level0) {
1176     // 1. Create a path object src using OH_Drawing_PathCreate.
1177     OH_Drawing_Path *src = OH_Drawing_PathCreate();
1178     // add assert
1179     EXPECT_NE(src, nullptr);
1180     // 2. Create a matrix object using OH_Drawing_MatrixCreate.
1181     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1182     // add assert
1183     EXPECT_NE(matrix, nullptr);
1184     // 3. Create a path object dst using OH_Drawing_PathCreate.
1185     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1186     // add assert
1187     EXPECT_NE(dst, nullptr);
1188     // 4. Set the starting point of the path using OH_Drawing_PathMoveTo.
1189     OH_Drawing_PathMoveTo(src, 0, 0);
1190     // 5. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1191     OH_Drawing_PathLineTo(src, 100, 100);
1192     // 6. Transform the path using OH_Drawing_PathTransformWithPerspectiveClip, with the fourth parameter set to false.
1193     OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, dst, false);
1194     // add assert
1195     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1196     // 7. Free the memory.
1197     OH_Drawing_PathDestroy(src);
1198     OH_Drawing_PathDestroy(dst);
1199     OH_Drawing_MatrixDestroy(matrix);
1200 }
1201 
1202 /*
1203  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3002
1204  * @tc.name: testPathTransformWithPerspectiveClipNull
1205  * @tc.desc: Test for transforming a path with perspective clip using NULL or invalid parameters.
1206  * @tc.size  : SmallTest
1207  * @tc.type  : Function
1208  * @tc.level : Level 3
1209  */
1210 HWTEST_F(DrawingNativePathPart2Test, testPathTransformWithPerspectiveClipNull, Function | SmallTest | Level3) {
1211     // 1. Create a path object src using OH_Drawing_PathCreate.
1212     OH_Drawing_Path *src = OH_Drawing_PathCreate();
1213     // add assert
1214     EXPECT_NE(src, nullptr);
1215     // 2. Create a matrix object using OH_Drawing_MatrixCreate.
1216     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1217     // add assert
1218     EXPECT_NE(matrix, nullptr);
1219     // 3. Create a path object dst using OH_Drawing_PathCreate.
1220     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1221     // add assert
1222     EXPECT_NE(dst, nullptr);
1223     // 4. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the first parameter, expecting
1224     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1225     OH_Drawing_PathTransformWithPerspectiveClip(nullptr, matrix, dst, true);
1226     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1227     OH_Drawing_ErrorCodeReset();
1228     // 5. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the second parameter, expecting
1229     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1230     OH_Drawing_PathTransformWithPerspectiveClip(src, nullptr, dst, true);
1231     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1232     // 6. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the third parameter, no crash.
1233     OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, nullptr, true);
1234     // 7. Free the memory.
1235     OH_Drawing_PathDestroy(src);
1236     OH_Drawing_PathDestroy(dst);
1237     OH_Drawing_MatrixDestroy(matrix);
1238 }
1239 
1240 /*
1241  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3100
1242  * @tc.name: testPathSetFillTypeNormal
1243  * @tc.desc: Test for setting fill type of a path using normal parameters.
1244  * @tc.size  : SmallTest
1245  * @tc.type  : Function
1246  * @tc.level : Level 0
1247  */
1248 HWTEST_F(DrawingNativePathPart2Test, testPathSetFillTypeNormal, Function | SmallTest | Level0) {
1249     // 1. Create a path object using OH_Drawing_PathCreate.
1250     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1251     // add assert
1252     EXPECT_NE(path, nullptr);
1253     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1254     OH_Drawing_PathMoveTo(path, 0, 0);
1255     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1256     OH_Drawing_PathLineTo(path, 100, 100);
1257     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1258     OH_Drawing_PathLineTo(path, 100, 0);
1259     // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1260     OH_Drawing_PathLineTo(path, 0, 0);
1261     // 6. Close the path using OH_Drawing_PathClose.
1262     OH_Drawing_PathClose(path);
1263     // 7. Set the fill type of the path using OH_Drawing_PathSetFillType, with the second parameter iterating through
1264     // the enumeration.
1265     OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING);
1266     // add assert
1267     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1268     OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD);
1269     // add assert
1270     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1271     OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_WINDING);
1272     // add assert
1273     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1274     OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_EVEN_ODD);
1275     // add assert
1276     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1277     // 8. Free the memory.
1278     OH_Drawing_PathDestroy(path);
1279 }
1280 
1281 /*
1282  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3101
1283  * @tc.name: testPathSetFillTypeNull
1284  * @tc.desc: Test for setting fill type of a path using NULL or invalid parameters.
1285  * @tc.size  : SmallTest
1286  * @tc.type  : Function
1287  * @tc.level : Level 3
1288  */
1289 HWTEST_F(DrawingNativePathPart2Test, testPathSetFillTypeNull, Function | SmallTest | Level3) {
1290     // 1. Create a path object using OH_Drawing_PathCreate.
1291     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1292     // add assert
1293     EXPECT_NE(path, nullptr);
1294     // 2. Call OH_Drawing_PathSetFillType with a nullptr as the first parameter, expecting
1295     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1296     OH_Drawing_PathSetFillType(nullptr, OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING);
1297     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1298     // 3. Call OH_Drawing_PathSetFillType with a value that is not within the enumeration range as the second parameter,
1299     // expecting OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE error code.
1300     OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(-1));
1301     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
1302     // 4. Free the memory.
1303     OH_Drawing_PathDestroy(path);
1304 }
1305 
1306 /*
1307  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3102
1308  * @tc.name: testPathSetFillTypeMultipleCalls
1309  * @tc.desc: Test for setting fill type of a path with multiple calls.
1310  * @tc.size  : SmallTest
1311  * @tc.type  : Function
1312  * @tc.level : Level 3
1313  */
1314 HWTEST_F(DrawingNativePathPart2Test, testPathSetFillTypeMultipleCalls, Function | SmallTest | Level3) {
1315     // 1. Create a path object using OH_Drawing_PathCreate.
1316     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1317     // add assert
1318     EXPECT_NE(path, nullptr);
1319     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1320     OH_Drawing_PathMoveTo(path, 0, 0);
1321     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1322     OH_Drawing_PathLineTo(path, 100, 100);
1323     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1324     OH_Drawing_PathLineTo(path, 100, 0);
1325     // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1326     OH_Drawing_PathLineTo(path, 0, 0);
1327     // 6. Close the path using OH_Drawing_PathClose.
1328     OH_Drawing_PathClose(path);
1329     // 7. Call OH_Drawing_PathSetFillType in a loop 10 times, iterating through the enumeration to set different fill
1330     // rules for the path.
1331     for (int i = 0; i < 10; i++) {
1332         OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(i));
1333     }
1334     // 8. Free the memory.
1335     OH_Drawing_PathDestroy(path);
1336 }
1337 
1338 /*
1339  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3200
1340  * @tc.name: testPathGetLengthNormal
1341  * @tc.desc: Test for getting the length of a path using normal parameters with detailed length.
1342  * @tc.size  : SmallTest
1343  * @tc.type  : Function
1344  * @tc.level : Level 0
1345  */
1346 HWTEST_F(DrawingNativePathPart2Test, testPathGetLengthNormal, Function | SmallTest | Level0) {
1347     // 1. Create a path object using OH_Drawing_PathCreate.
1348     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1349     // add assert
1350     EXPECT_NE(path, nullptr);
1351     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1352     OH_Drawing_PathMoveTo(path, 0, 0);
1353     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1354     OH_Drawing_PathLineTo(path, 100, 100);
1355     // 4. Get the length of the current path by calling OH_Drawing_PathGetLength, with the second parameter set to true.
1356     float length = OH_Drawing_PathGetLength(path, true);
1357     EXPECT_NE(length, 0.0f);
1358     // 5. Free the memory.
1359     OH_Drawing_PathDestroy(path);
1360 }
1361 
1362 /*
1363  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3201
1364  * @tc.name: testPathGetLengthNormal2
1365  * @tc.desc: Test for getting the length of a path using normal parameters without detailed length.
1366  * @tc.size  : SmallTest
1367  * @tc.type  : Function
1368  * @tc.level : Level 0
1369  */
1370 HWTEST_F(DrawingNativePathPart2Test, testPathGetLengthNormal2, Function | SmallTest | Level0) {
1371     // 1. Create a path object using OH_Drawing_PathCreate.
1372     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1373     // add assert
1374     EXPECT_NE(path, nullptr);
1375     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1376     OH_Drawing_PathMoveTo(path, 0, 0);
1377     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1378     OH_Drawing_PathLineTo(path, 100, 100);
1379     // 4. Get the length of the current path by calling OH_Drawing_PathGetLength, with the second parameter set to
1380     // false.
1381     float length = OH_Drawing_PathGetLength(path, false);
1382     EXPECT_NE(length, 0.0f);
1383     // 5. Free the memory.
1384     OH_Drawing_PathDestroy(path);
1385 }
1386 
1387 /*
1388  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3202
1389  * @tc.name: testPathGetLengthNull
1390  * @tc.desc: Test for getting the length of a path using NULL or invalid parameters.
1391  * @tc.size  : SmallTest
1392  * @tc.type  : Function
1393  * @tc.level : Level 3
1394  */
1395 HWTEST_F(DrawingNativePathPart2Test, testPathGetLengthNull, Function | SmallTest | Level3) {
1396     // 1. Create a path object using OH_Drawing_PathCreate.
1397     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1398     // add assert
1399     EXPECT_NE(path, nullptr);
1400     // 2. Call OH_Drawing_PathGetLength with a nullptr as the first parameter, expecting
1401     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1402     OH_Drawing_PathGetLength(nullptr, true);
1403     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1404     // 3. Free the memory.
1405     OH_Drawing_PathDestroy(path);
1406 }
1407 
1408 /*
1409  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3300
1410  * @tc.name: testPathGetBoundsNormal
1411  * @tc.desc: Test for getting the bounds of a path using normal parameters.
1412  * @tc.size  : SmallTest
1413  * @tc.type  : Function
1414  * @tc.level : Level 0
1415  */
1416 HWTEST_F(DrawingNativePathPart2Test, testPathGetBoundsNormal, Function | SmallTest | Level0) {
1417     // 1. Create a path object using OH_Drawing_PathCreate.
1418     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1419     // add assert
1420     EXPECT_NE(path, nullptr);
1421     // 2. Create a rectangle object using OH_Drawing_RectCreate.
1422     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1423     // add assert
1424     EXPECT_NE(rect, nullptr);
1425     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
1426     OH_Drawing_PathMoveTo(path, 0, 0);
1427     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1428     OH_Drawing_PathLineTo(path, 100, 100);
1429     // 5. Get the minimum bounding box that contains the path by calling OH_Drawing_PathGetBounds.
1430     OH_Drawing_PathGetBounds(path, rect);
1431     // add assert
1432     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1433     // 6. Free the memory.
1434     OH_Drawing_PathDestroy(path);
1435     OH_Drawing_RectDestroy(rect);
1436 }
1437 
1438 /*
1439  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3301
1440  * @tc.name: testPathGetBoundsNull
1441  * @tc.desc: Test for getting the bounds of a path using NULL or invalid parameters.
1442  * @tc.size  : SmallTest
1443  * @tc.type  : Function
1444  * @tc.level : Level 3
1445  */
1446 HWTEST_F(DrawingNativePathPart2Test, testPathGetBoundsNull, Function | SmallTest | Level3) {
1447     // 1. Create a path object using OH_Drawing_PathCreate.
1448     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1449     // add assert
1450     EXPECT_NE(path, nullptr);
1451     // 2. Create a rectangle object using OH_Drawing_RectCreate.
1452     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1453     // add assert
1454     EXPECT_NE(rect, nullptr);
1455     // 3. Call OH_Drawing_PathGetBounds with a nullptr as the first parameter, expecting
1456     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1457     OH_Drawing_PathGetBounds(nullptr, rect);
1458     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1459     OH_Drawing_ErrorCodeReset();
1460     // 4. Call OH_Drawing_PathGetBounds with a nullptr as the second parameter, expecting
1461     // OH_DRAWING_ERROR_INVALID_PARAMETER error code.
1462     OH_Drawing_PathGetBounds(path, nullptr);
1463     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1464     // 5. Free the memory.
1465     OH_Drawing_PathDestroy(path);
1466     OH_Drawing_RectDestroy(rect);
1467 }
1468 
1469 /*
1470  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3400
1471  * @tc.name: testPathCloseNormal
1472  * @tc.desc: test for testPathCloseNormal.
1473  * @tc.size  : SmallTest
1474  * @tc.type  : Function
1475  * @tc.level : Level 0
1476  */
1477 HWTEST_F(DrawingNativePathPart2Test, testPathCloseNormal, Function | SmallTest | Level0) {
1478     // 1. Create a path object using OH_Drawing_PathCreate.
1479     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1480     // add assert
1481     EXPECT_NE(path, nullptr);
1482     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1483     OH_Drawing_PathMoveTo(path, 0, 0);
1484     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1485     OH_Drawing_PathLineTo(path, 100, 100);
1486     // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo.
1487     OH_Drawing_PathLineTo(path, 100, 0);
1488     // 5. Close the path by adding a line segment from the last point of the path to the starting point.
1489     OH_Drawing_PathClose(path);
1490     // add assert
1491     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1492     // 6. Free the memory.
1493     OH_Drawing_PathDestroy(path);
1494 }
1495 
1496 /*
1497  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3401
1498  * @tc.name: testPathCloseNull
1499  * @tc.desc: Test for closing a path using NULL or invalid parameters.
1500  * @tc.size  : SmallTest
1501  * @tc.type  : Function
1502  * @tc.level : Level 3
1503  */
1504 HWTEST_F(DrawingNativePathPart2Test, testPathCloseNull, Function | SmallTest | Level3) {
1505     // 1. Create a path object using OH_Drawing_PathCreate.
1506     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1507     // add assert
1508     EXPECT_NE(path, nullptr);
1509     // 2. Call OH_Drawing_PathClose with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error
1510     // code.
1511     OH_Drawing_PathClose(nullptr);
1512     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1513     // 3. Free the memory.
1514     OH_Drawing_PathDestroy(path);
1515 }
1516 
1517 /*
1518  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3500
1519  * @tc.name: testPathOffsetNormal
1520  * @tc.desc: Test for offsetting a path using normal parameters.
1521  * @tc.size  : SmallTest
1522  * @tc.type  : Function
1523  * @tc.level : Level 0
1524  */
1525 HWTEST_F(DrawingNativePathPart2Test, testPathOffsetNormal, Function | SmallTest | Level0) {
1526     // 1. Create a path object using OH_Drawing_PathCreate.
1527     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1528     // add assert
1529     EXPECT_NE(path, nullptr);
1530     // 2. Create a path object using OH_Drawing_PathCreate.
1531     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1532     // add assert
1533     EXPECT_NE(dst, nullptr);
1534     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
1535     OH_Drawing_PathMoveTo(path, 0, 0);
1536     // add assert
1537     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1538     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1539     OH_Drawing_PathLineTo(path, 100, 100);
1540     // add assert
1541     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1542     // 5. Offset all points in the path by a certain distance along the x and y axes, and store the result in the
1543     // destination path object using OH_Drawing_PathOffset.
1544     OH_Drawing_PathOffset(path, dst, 10, 10);
1545     // add assert
1546     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1547     // 6. Free the memory.
1548     OH_Drawing_PathDestroy(path);
1549     OH_Drawing_PathDestroy(dst);
1550 }
1551 
1552 /*
1553  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3501
1554  * @tc.name: testPathOffsetNull
1555  * @tc.desc: Test for offsetting a path using NULL or invalid parameters.
1556  * @tc.size  : SmallTest
1557  * @tc.type  : Function
1558  * @tc.level : Level 3
1559  */
1560 HWTEST_F(DrawingNativePathPart2Test, testPathOffsetNull, Function | SmallTest | Level3) {
1561     // 1. Create a path object using OH_Drawing_PathCreate.
1562     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1563     // add assert
1564     EXPECT_NE(path, nullptr);
1565     // 2. Create a path object using OH_Drawing_PathCreate.
1566     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1567     // add assert
1568     EXPECT_NE(dst, nullptr);
1569     // 3. Call OH_Drawing_PathOffset with a nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER
1570     // error code.
1571     OH_Drawing_PathOffset(nullptr, dst, 10, 10);
1572     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1573     // 4. Call OH_Drawing_PathOffset with a nullptr as the second parameter, expecting failure without crashing.
1574     OH_Drawing_PathOffset(path, nullptr, 10, 10);
1575     // 5. Call OH_Drawing_PathOffset with 0.00 as the third parameter, expecting failure without crashing.
1576     OH_Drawing_PathOffset(path, dst, 0.00, 10);
1577     // 6. Call OH_Drawing_PathOffset with 0.00 as the fourth parameter, expecting failure without crashing.
1578     OH_Drawing_PathOffset(path, dst, 10, 0.00);
1579     // 7. Free the memory.
1580     OH_Drawing_PathDestroy(path);
1581     OH_Drawing_PathDestroy(dst);
1582 }
1583 
1584 /*
1585  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3502
1586  * @tc.name: testPathOffsetAbnormal
1587  * @tc.desc: Test for offsetting a path with abnormal parameters (non-float values).
1588  * @tc.size  : SmallTest
1589  * @tc.type  : Function
1590  * @tc.level : Level 3
1591  */
1592 HWTEST_F(DrawingNativePathPart2Test, testPathOffsetAbnormal, Function | SmallTest | Level3) {
1593     // 1. Create a path object using OH_Drawing_PathCreate.
1594     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1595     // add assert
1596     EXPECT_NE(path, nullptr);
1597     // 2. Create a path object using OH_Drawing_PathCreate.
1598     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1599     // add assert
1600     EXPECT_NE(dst, nullptr);
1601     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
1602     OH_Drawing_PathMoveTo(path, 0, 0);
1603     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1604     OH_Drawing_PathLineTo(path, 100, 100);
1605     // 5. Call OH_Drawing_PathOffset with an integer as the third parameter.
1606     OH_Drawing_PathOffset(path, dst, 10, 10.0f);
1607     // 6. Call OH_Drawing_PathOffset with an integer as the fourth parameter.
1608     OH_Drawing_PathOffset(path, dst, 10.0f, 10);
1609     // 7. Free the memory.
1610     OH_Drawing_PathDestroy(path);
1611     OH_Drawing_PathDestroy(dst);
1612 }
1613 
1614 /*
1615  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3503
1616  * @tc.name: testPathOffsetMaximal
1617  * @tc.desc: Test for offsetting a path with maximal values.
1618  * @tc.size  : SmallTest
1619  * @tc.type  : Function
1620  * @tc.level : Level 3
1621  */
1622 HWTEST_F(DrawingNativePathPart2Test, testPathOffsetMaximal, Function | SmallTest | Level3) {
1623     // 1. Create a path object using OH_Drawing_PathCreate.
1624     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1625     // add assert
1626     EXPECT_NE(path, nullptr);
1627     // 2. Create a path object using OH_Drawing_PathCreate.
1628     OH_Drawing_Path *dst = OH_Drawing_PathCreate();
1629     // add assert
1630     EXPECT_NE(dst, nullptr);
1631     // 3. Set the starting point of the path using OH_Drawing_PathMoveTo.
1632     OH_Drawing_PathMoveTo(path, 0, 0);
1633     // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1634     OH_Drawing_PathLineTo(path, 100, 100);
1635     // 5. Call OH_Drawing_PathOffset with the third parameter set to the maximum value FLT_MAX + 1.
1636     OH_Drawing_PathOffset(path, dst, FLT_MAX + 1, 10.0f);
1637     // 6. Call OH_Drawing_PathOffset with the fourth parameter set to the maximum value FLT_MAX + 1.
1638     OH_Drawing_PathOffset(path, dst, 10.0f, FLT_MAX + 1);
1639     // 7. Free the memory.
1640     OH_Drawing_PathDestroy(path);
1641     OH_Drawing_PathDestroy(dst);
1642 }
1643 
1644 /*
1645  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3600
1646  * @tc.name: testPathResetNormal
1647  * @tc.desc: Test for resetting a path using normal parameters.
1648  * @tc.size  : SmallTest
1649  * @tc.type  : Function
1650  * @tc.level : Level 0
1651  */
1652 HWTEST_F(DrawingNativePathPart2Test, testPathResetNormal, Function | SmallTest | Level0) {
1653     // 1. Create a path object using OH_Drawing_PathCreate.
1654     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1655     // add assert
1656     EXPECT_NE(path, nullptr);
1657     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1658     OH_Drawing_PathMoveTo(path, 0, 0);
1659     // add assert
1660     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1661     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1662     OH_Drawing_PathLineTo(path, 100, 100);
1663     // add assert
1664     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1665     // 4. Reset the custom path data using OH_Drawing_PathReset.
1666     OH_Drawing_PathReset(path);
1667     // add assert
1668     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
1669     // 5. Free the memory.
1670     OH_Drawing_PathDestroy(path);
1671 }
1672 
1673 /*
1674  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3601
1675  * @tc.name: testPathResetNull
1676  * @tc.desc: Test for resetting a path using NULL or invalid parameters.
1677  * @tc.size  : SmallTest
1678  * @tc.type  : Function
1679  * @tc.level : Level 3
1680  */
1681 HWTEST_F(DrawingNativePathPart2Test, testPathResetNull, Function | SmallTest | Level3) {
1682     // 1. Create a path object using OH_Drawing_PathCreate.
1683     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1684     // add assert
1685     EXPECT_NE(path, nullptr);
1686     // 2. Call OH_Drawing_PathReset with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error
1687     // code.
1688     OH_Drawing_PathReset(nullptr);
1689     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1690     // 3. Free the memory.
1691     OH_Drawing_PathDestroy(path);
1692 }
1693 
1694 /*
1695  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3602
1696  * @tc.name: testPathResetMultipleCalls
1697  * @tc.desc: Test for resetting a path with multiple calls.
1698  * @tc.size  : SmallTest
1699  * @tc.type  : Function
1700  * @tc.level : Level 3
1701  */
1702 HWTEST_F(DrawingNativePathPart2Test, testPathResetMultipleCalls, Function | SmallTest | Level3) {
1703     // 1. Create a path object using OH_Drawing_PathCreate.
1704     OH_Drawing_Path *path = OH_Drawing_PathCreate();
1705     // add assert
1706     EXPECT_NE(path, nullptr);
1707     // 2. Set the starting point of the path using OH_Drawing_PathMoveTo.
1708     OH_Drawing_PathMoveTo(path, 0, 0);
1709     // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo.
1710     OH_Drawing_PathLineTo(path, 100, 100);
1711     // 4. Reset the custom path data using OH_Drawing_PathReset.
1712     OH_Drawing_PathReset(path);
1713     // 5. Loop through steps 2 to 4 for 10 times to verify success.
1714     for (int i = 0; i < 10; i++) {
1715         OH_Drawing_PathMoveTo(path, 0, 0);
1716         OH_Drawing_PathLineTo(path, 100, 100);
1717         OH_Drawing_PathReset(path);
1718     }
1719     // 6. Free the memory.
1720     OH_Drawing_PathDestroy(path);
1721 }
1722 
1723 } // namespace Drawing
1724 } // namespace Rosen
1725 } // namespace OHOS