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