1 /*
2  * Copyright (c) 2022-2024 Huawei Device 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, Hardware
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 <cstdio>
17 #include "gtest/gtest.h"
18 
19 #include "drawing_error_code.h"
20 #include "drawing_path.h"
21 #include "drawing_matrix.h"
22 #include "drawing_rect.h"
23 #include "drawing_round_rect.h"
24 #include "draw/path.h"
25 #include "utils/scalar.h"
26 
27 using namespace testing;
28 using namespace testing::ext;
29 
30 namespace OHOS {
31 namespace Rosen {
32 namespace Drawing {
33 class NativeDrawingPathTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp() override;
38     void TearDown() override;
39 };
40 
41 constexpr uint32_t INTNUM_TEN = 10;
42 constexpr int32_t NEGATIVE_ONE = -1;
43 constexpr uint32_t ADDPOLYGON_COUNT = 1;
44 
SetUpTestCase()45 void NativeDrawingPathTest::SetUpTestCase() {}
TearDownTestCase()46 void NativeDrawingPathTest::TearDownTestCase() {}
SetUp()47 void NativeDrawingPathTest::SetUp() {}
TearDown()48 void NativeDrawingPathTest::TearDown() {}
49 
50 /*
51  * @tc.name: NativeDrawingPathTest_pathCreate001
52  * @tc.desc: test for create drawing_path.
53  * @tc.type: FUNC
54  * @tc.require: AR000GTO5R
55  */
56 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCreate001, TestSize.Level1)
57 {
58     OH_Drawing_Path* path = OH_Drawing_PathCreate();
59     EXPECT_EQ(path == nullptr, false);
60     OH_Drawing_PathDestroy(path);
61 }
62 
63 /*
64  * @tc.name: NativeDrawingPathTest_pathMoveTo002
65  * @tc.desc: test for PathMoveTo func.
66  * @tc.type: FUNC
67  * @tc.require: AR000GTO5R
68  */
69 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathMoveTo002, TestSize.Level1)
70 {
71     OH_Drawing_Path* path1 = OH_Drawing_PathCreate();
72     OH_Drawing_PathMoveTo(nullptr, 0, 0);
73     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
74     OH_Drawing_PathMoveTo(path1, 20, 20);
75     OH_Drawing_PathMoveTo(path1, -1, 21.5);
76     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path1)->GetBounds().GetWidth(), 21.0));
77     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path1)->GetBounds().GetHeight(), 1.5));
78     OH_Drawing_PathDestroy(path1);
79 }
80 
81 /*
82  * @tc.name: NativeDrawingPathTest_pathLineTo003
83  * @tc.desc: test for PathLineTo func.
84  * @tc.type: FUNC
85  * @tc.require: AR000GTO5R
86  */
87 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathLineTo003, TestSize.Level1)
88 {
89     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
90     OH_Drawing_PathLineTo(nullptr, 0, 0);
91     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
92     OH_Drawing_PathLineTo(path2, 50, 40);
93     OH_Drawing_PathLineTo(path2, -50, 10.2);
94     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 100.0));
95     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 40.0));
96     OH_Drawing_PathDestroy(path2);
97 }
98 
99 /*
100  * @tc.name: NativeDrawingPathTest_pathReset004
101  * @tc.desc: test for PathReset func.
102  * @tc.type: FUNC
103  * @tc.require: AR000GTO5R
104  */
105 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathReset004, TestSize.Level1)
106 {
107     OH_Drawing_Path* path3 = OH_Drawing_PathCreate();
108     OH_Drawing_PathMoveTo(path3, 20, 20);
109     OH_Drawing_PathReset(nullptr);
110     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
111     OH_Drawing_PathReset(path3);
112     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path3)->GetBounds().GetWidth(), 0.0));
113     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path3)->GetBounds().GetHeight(), 0.0));
114     OH_Drawing_PathDestroy(path3);
115 }
116 
117 /*
118  * @tc.name: NativeDrawingPathTest_pathArcTo005
119  * @tc.desc: test for PathArcTo func.
120  * @tc.type: FUNC
121  * @tc.require: AR000GTO5R
122  */
123 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathArcTo005, TestSize.Level1)
124 {
125     OH_Drawing_Path* path4 = OH_Drawing_PathCreate();
126     OH_Drawing_PathArcTo(nullptr, 0, 0, 0, 0, 0, 0);
127     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
128     OH_Drawing_PathArcTo(path4, 10, 10, 20, 0, 0, 90);
129     OH_Drawing_PathArcTo(path4, -10, 10, 10, -10, 0, 90);
130     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path4)->GetBounds().GetWidth(), 0.0));
131     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path4)->GetBounds().GetHeight(), 0.0));
132     OH_Drawing_PathDestroy(path4);
133 }
134 
135 /*
136  * @tc.name: NativeDrawingPathTest_pathQuadTo006
137  * @tc.desc: test for PathQuadTo func.
138  * @tc.type: FUNC
139  * @tc.require: AR000GTO5R
140  */
141 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathQuadTo006, TestSize.Level1)
142 {
143     OH_Drawing_Path* path5 = OH_Drawing_PathCreate();
144     OH_Drawing_PathQuadTo(nullptr, 0, 0, 0, 0);
145     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
146     OH_Drawing_PathQuadTo(path5, 0, 0, 30, 30);
147     OH_Drawing_PathQuadTo(path5, -20.5f, -20.5f, 30, 0);
148     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path5)->GetBounds().GetWidth(), 50.5));
149     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path5)->GetBounds().GetHeight(), 50.5));
150     OH_Drawing_PathDestroy(path5);
151 }
152 
153 /*
154  * @tc.name: NativeDrawingPathTest_pathCubicTo007
155  * @tc.desc: test for PathCubicTo func.
156  * @tc.type: FUNC
157  * @tc.require: AR000GTO5R
158  */
159 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCubicTo007, TestSize.Level1)
160 {
161     OH_Drawing_Path* path6 = OH_Drawing_PathCreate();
162     OH_Drawing_PathCubicTo(nullptr, 0, 0, 0, 0, 0, 0);
163     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
164     OH_Drawing_PathCubicTo(path6, 30, 40, 60, 0, 50, 20);
165     OH_Drawing_PathCubicTo(path6, -30, 40, 60, -30.6f, 50, -20);
166     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path6)->GetBounds().GetWidth(), 90.0));
167     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path6)->GetBounds().GetHeight(), 70.6));
168     OH_Drawing_PathDestroy(path6);
169 }
170 
171 /*
172  * @tc.name: NativeDrawingPathTest_pathClose008
173  * @tc.desc: test for PathClose func.
174  * @tc.type: FUNC
175  * @tc.require: AR000GTO5R
176  */
177 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathClose008, TestSize.Level1)
178 {
179     OH_Drawing_Path* path = OH_Drawing_PathCreate();
180     OH_Drawing_PathLineTo(path, 50, 40);
181     OH_Drawing_PathClose(nullptr);
182     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
183     OH_Drawing_PathClose(path);
184     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.0));
185     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 40.0));
186     OH_Drawing_PathDestroy(path);
187 }
188 
189 /*
190  * @tc.name: NativeDrawingPathTest_pathCopy009
191  * @tc.desc: test for PathCopy func.
192  * @tc.type: FUNC
193  * @tc.require: SR000S9F0C
194  */
195 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCopy009, TestSize.Level1)
196 {
197     OH_Drawing_Path* path = OH_Drawing_PathCreate();
198     // line point x = 50, y = 40
199     OH_Drawing_PathLineTo(path, 50, 40);
200     OH_Drawing_PathClose(path);
201     EXPECT_EQ(OH_Drawing_PathCopy(nullptr), nullptr);
202     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
203     OH_Drawing_Path* pathCopy = OH_Drawing_PathCopy(path);
204     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetWidth(), 50.0));
205     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetHeight(), 40.0));
206     OH_Drawing_PathDestroy(path);
207     OH_Drawing_PathDestroy(pathCopy);
208 }
209 
210 /*
211  * @tc.name: NativeDrawingPathTest_pathAddRect010
212  * @tc.desc: test for PathAddRect func.
213  * @tc.type: FUNC
214  * @tc.require: SR000S9F0C
215  */
216 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRect010, TestSize.Level1)
217 {
218     OH_Drawing_Path* path = OH_Drawing_PathCreate();
219     // rect left[50], top[50],right[250], bottom[250]
220     OH_Drawing_PathAddRect(nullptr, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
221     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
222     OH_Drawing_PathAddRect(path, 0, 0, 0, 0, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE));
223     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
224     OH_Drawing_PathAddRect(path, 0, 0, 0, 0, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN));
225     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
226     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
227     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
228     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.0));
229     OH_Drawing_PathDestroy(path);
230 }
231 
232 /*
233  * @tc.name: NativeDrawingPathTest_pathAddRoundRect011
234  * @tc.desc: test for PathAddRoundRect func.
235  * @tc.type: FUNC
236  * @tc.require: SR000S9F0C
237  */
238 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRoundRect011, TestSize.Level1)
239 {
240     OH_Drawing_Path* path = OH_Drawing_PathCreate();
241     // rect left[50], top[50],right[250], bottom[250]
242     OH_Drawing_PathAddRect(nullptr, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
243     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
244     OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
245     OH_Drawing_PathAddRoundRect(nullptr, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
246     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
247     OH_Drawing_PathAddRoundRect(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
248     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
249     OH_Drawing_PathAddRoundRect(path, roundRect, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE));
250     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
251     OH_Drawing_PathAddRoundRect(path, roundRect, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN));
252     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
253     OH_Drawing_PathAddRoundRect(path, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
254     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
255     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.0));
256     OH_Drawing_PathDestroy(path);
257     OH_Drawing_RoundRectDestroy(roundRect);
258     OH_Drawing_RectDestroy(rect);
259 }
260 
261 /*
262  * @tc.name: NativeDrawingPathTest_pathAddArc012
263  * @tc.desc: test for PathAddArc func.
264  * @tc.type: FUNC
265  * @tc.require: SR000S9F0C
266  */
267 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddArc012, TestSize.Level1)
268 {
269     OH_Drawing_Path* path = OH_Drawing_PathCreate();
270     // rect left[50], top[50],right[250], bottom[250]
271     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
272     OH_Drawing_PathAddArc(nullptr, rect, 0, 180);
273     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
274     OH_Drawing_PathAddArc(path, nullptr, 0, 180);
275     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
276     OH_Drawing_PathAddArc(path, rect, 0, 180);
277     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
278     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 100.0));
279     OH_Drawing_PathDestroy(path);
280     OH_Drawing_RectDestroy(rect);
281 }
282 
283 /*
284  * @tc.name: NativeDrawingPathTest_pathContains013
285  * @tc.desc: test for PathContains func.
286  * @tc.type: FUNC
287  * @tc.require: SR000S9F0C
288  */
289 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathContains013, TestSize.Level1)
290 {
291     OH_Drawing_Path* path = OH_Drawing_PathCreate();
292     // rect left[50], top[50],right[250], bottom[250]
293     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
294     OH_Drawing_PathContains(nullptr, 0, 0);
295     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
296     bool ret = OH_Drawing_PathContains(path, 0, 0);
297     EXPECT_EQ(ret, false);
298     ret = OH_Drawing_PathContains(path, 60, 60);
299     EXPECT_EQ(ret, true);
300     OH_Drawing_PathDestroy(path);
301 }
302 
303 /*
304  * @tc.name: NativeDrawingPathTest_pathTransform014
305  * @tc.desc: test for PathTransform func.
306  * @tc.type: FUNC
307  * @tc.require: SR000S9F0C
308  */
309 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathTransform014, TestSize.Level1)
310 {
311     OH_Drawing_Path* path = OH_Drawing_PathCreate();
312     // rect left[50], top[50],right[250], bottom[250]
313     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
314     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(1, 1);
315     OH_Drawing_PathTransform(nullptr, matrix);
316     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
317     OH_Drawing_PathTransform(path, nullptr);
318     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
319 
320     bool ret = OH_Drawing_PathContains(path, 50, 50);
321     EXPECT_EQ(ret, true);
322     OH_Drawing_PathTransform(path, matrix);
323     ret = OH_Drawing_PathContains(path, 50, 50);
324     EXPECT_EQ(ret, false);
325     OH_Drawing_PathDestroy(path);
326 }
327 
328 /*
329  * @tc.name: NativeDrawingPathTest_pathSetFilltype015
330  * @tc.desc: test for PathSetFillType func.
331  * @tc.type: FUNC
332  * @tc.require: SR000S9F0C
333  */
334 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathSetFilltype015, TestSize.Level1)
335 {
336     OH_Drawing_Path* path = OH_Drawing_PathCreate();
337     OH_Drawing_PathSetFillType(nullptr, PATH_FILL_TYPE_WINDING);
338     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
339     OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(NEGATIVE_ONE));
340     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
341     OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(INTNUM_TEN));
342     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
343     OH_Drawing_PathSetFillType(path, PATH_FILL_TYPE_WINDING);
344     // line point x = 50, y = 40
345     OH_Drawing_PathLineTo(path, 50, 40);
346     OH_Drawing_PathClose(path);
347     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.0));
348     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 40.0));
349     float ret = OH_Drawing_PathGetLength(path, true);
350     EXPECT_TRUE(IsScalarAlmostEqual(ret, 128.062485)); // 128.062485 is length of path
351     OH_Drawing_PathDestroy(path);
352 }
353 
354 /*
355  * @tc.name: NativeDrawingPathTest_pathConicTo016
356  * @tc.desc: test for PathConicTo func.
357  * @tc.type: FUNC
358  * @tc.require: AR000GTO5R
359  */
360 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathConicTo016, TestSize.Level1)
361 {
362     OH_Drawing_Path* path = OH_Drawing_PathCreate();
363     OH_Drawing_PathConicTo(nullptr, 0, 0, 0, 0, 1);
364     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
365     OH_Drawing_PathConicTo(path, 0, 0, 30, 30, 1);
366     OH_Drawing_PathConicTo(path, -20.5f, -20.5f, 30, 0, 1);
367     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.5));
368     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 50.5));
369     OH_Drawing_PathDestroy(path);
370 }
371 
372 /*
373  * @tc.name: NativeDrawingPathTest_pathAddRectWithInitialCorner017
374  * @tc.desc: test for PathAddRectWithInitialCorner func.
375  * @tc.type: FUNC
376  * @tc.require: AR000GTO5R
377  */
378 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRectWithInitialCorner017, TestSize.Level1)
379 {
380     OH_Drawing_Path* path = OH_Drawing_PathCreate();
381     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
382     OH_Drawing_PathAddRectWithInitialCorner(nullptr, rect, PATH_DIRECTION_CW, 0);
383     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
384     OH_Drawing_PathAddRectWithInitialCorner(path, nullptr, PATH_DIRECTION_CW, 0);
385     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
386     OH_Drawing_PathAddRectWithInitialCorner(path, rect, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE), 0);
387     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
388     OH_Drawing_PathAddRectWithInitialCorner(path, rect, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN), 0);
389     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
390     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
391     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
392     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 300.0));
393     OH_Drawing_PathClose(path);
394     OH_Drawing_PathDestroy(path);
395     OH_Drawing_RectDestroy(rect);
396 }
397 
398 /*
399  * @tc.name: NativeDrawingPathTest_pathAddPathWithMode018
400  * @tc.desc: test for PathAddPathWithMode func.
401  * @tc.type: FUNC
402  * @tc.require: AR000GTO5R
403  */
404 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithMode018, TestSize.Level1)
405 {
406     OH_Drawing_Path* path = OH_Drawing_PathCreate();
407     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
408     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
409     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
410     OH_Drawing_PathAddPathWithMode(nullptr, path, PATH_ADD_MODE_APPEND);
411     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
412     OH_Drawing_PathAddPathWithMode(path2, nullptr, PATH_ADD_MODE_APPEND);
413     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
414     OH_Drawing_PathAddPathWithMode(path2, path, PATH_ADD_MODE_APPEND);
415     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
416     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
417     OH_Drawing_PathDestroy(path);
418     OH_Drawing_RectDestroy(rect);
419     OH_Drawing_PathDestroy(path2);
420 }
421 
422 /*
423  * @tc.name: NativeDrawingPathTest_pathAddPathWithOffsetAndMode019
424  * @tc.desc: test for PathAddPathWithOffsetAndMode func.
425  * @tc.type: FUNC
426  * @tc.require: AR000GTO5R
427  */
428 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithOffsetAndMode019, TestSize.Level1)
429 {
430     OH_Drawing_Path* path = OH_Drawing_PathCreate();
431     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
432     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
433     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
434     OH_Drawing_PathAddPathWithOffsetAndMode(nullptr, path, 0, 0, PATH_ADD_MODE_APPEND);
435     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
436     OH_Drawing_PathAddPathWithOffsetAndMode(path2, nullptr, 0, 0, PATH_ADD_MODE_APPEND);
437     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
438     OH_Drawing_PathAddPathWithOffsetAndMode(path2, path, 0, 0, PATH_ADD_MODE_APPEND);
439     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
440     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
441     OH_Drawing_PathDestroy(path);
442     OH_Drawing_RectDestroy(rect);
443     OH_Drawing_PathDestroy(path2);
444 }
445 
446 /*
447  * @tc.name: NativeDrawingPathTest_pathAddPathWithMatrixAndMode020
448  * @tc.desc: test for PathAddPathWithMatrixAndMode func.
449  * @tc.type: FUNC
450  * @tc.require: AR000GTO5R
451  */
452 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithMatrixAndMode020, TestSize.Level1)
453 {
454     OH_Drawing_Path* path = OH_Drawing_PathCreate();
455     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
456     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
457     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
458     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
459 
460     OH_Drawing_PathAddPathWithMatrixAndMode(nullptr, path, matrix, PATH_ADD_MODE_APPEND);
461     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
462     OH_Drawing_PathAddPathWithMatrixAndMode(path2, nullptr, matrix, PATH_ADD_MODE_APPEND);
463     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
464     OH_Drawing_PathAddPathWithMatrixAndMode(path2, path, matrix, PATH_ADD_MODE_APPEND);
465     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
466     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
467 
468     OH_Drawing_Path* pathRect = OH_Drawing_PathCreate();
469     OH_Drawing_PathAddRect(pathRect, 0.0f, 0.0f, 200.0f, 300.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
470     OH_Drawing_MatrixSetMatrix(
471         matrix,
472         5, 4, 0,
473         0, -1, 0,
474         0, 0, 1);
475     OH_Drawing_PathAddPath(pathRect, pathRect, nullptr);
476     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetWidth(), 200.0));
477     OH_Drawing_PathAddPath(pathRect, pathRect, matrix);
478     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetWidth(), 2200.0));
479     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetHeight(), 600.0));
480     OH_Drawing_PathAddPath(nullptr, pathRect, matrix);
481     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
482     OH_Drawing_PathAddPath(pathRect, nullptr, matrix);
483     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
484     OH_Drawing_PathDestroy(path);
485     OH_Drawing_RectDestroy(rect);
486     OH_Drawing_PathDestroy(path2);
487     OH_Drawing_PathDestroy(pathRect);
488     OH_Drawing_MatrixDestroy(matrix);
489 }
490 
491 /*
492  * @tc.name: NativeDrawingPathTest_pathOffset021
493  * @tc.desc: test for PathOffset func.
494  * @tc.type: FUNC
495  * @tc.require: AR000GTO5R
496  */
497 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathOffset021, TestSize.Level1)
498 {
499     OH_Drawing_Path* path = OH_Drawing_PathCreate();
500     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
501     OH_Drawing_PathOffset(nullptr, path2, 0, 0);
502     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
503     OH_Drawing_PathOffset(path, path2, 50, 40);
504     OH_Drawing_PathReset(path);
505     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 0.0));
506     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 0.0));
507     OH_Drawing_PathDestroy(path);
508     OH_Drawing_PathDestroy(path2);
509 }
510 
511 /*
512  * @tc.name: NativeDrawingPathTest_pathAddOvalWithInitialPoint022
513  * @tc.desc: test for PathAddOvalWithInitialPoint func.
514  * @tc.type: FUNC
515  * @tc.require: AR000GTO5R
516  */
517 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddOvalWithInitialPoint022, TestSize.Level1)
518 {
519     OH_Drawing_Path* path9 = OH_Drawing_PathCreate();
520     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
521     OH_Drawing_PathAddOvalWithInitialPoint(nullptr, rect, 0, PATH_DIRECTION_CW);
522     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
523     OH_Drawing_PathAddOvalWithInitialPoint(path9, nullptr, 0, PATH_DIRECTION_CW);
524     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
525     OH_Drawing_PathAddOvalWithInitialPoint(path9, rect, 10, PATH_DIRECTION_CW);
526     OH_Drawing_PathClose(path9);
527     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path9)->GetBounds().GetWidth(), 500.0));
528     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path9)->GetBounds().GetHeight(), 300.0));
529     OH_Drawing_PathDestroy(path9);
530     OH_Drawing_RectDestroy(rect);
531 }
532 
533 /*
534  * @tc.name: NativeDrawingPathTest_pathRMoveTo023
535  * @tc.desc: test for PathRMoveTo func.
536  * @tc.type: FUNC
537  * @tc.require: AR000GTO5R
538  */
539 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRMoveTo023, TestSize.Level1)
540 {
541     OH_Drawing_Path* path10 = OH_Drawing_PathCreate();
542     OH_Drawing_PathRMoveTo(nullptr, 0, 0);
543     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
544     OH_Drawing_PathRMoveTo(path10, 100, 100);
545     OH_Drawing_PathLineTo(path10, 300, 300);
546     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path10)->GetBounds().GetWidth(), 200.0));
547     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path10)->GetBounds().GetHeight(), 200.0));
548     OH_Drawing_PathDestroy(path10);
549 }
550 
551 /*
552  * @tc.name: NativeDrawingPathTest_pathRLineTo024
553  * @tc.desc: test for PathRLineTo func.
554  * @tc.type: FUNC
555  * @tc.require: AR000GTO5R
556  */
557 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRLineTo024, TestSize.Level1)
558 {
559     OH_Drawing_Path* path11 = OH_Drawing_PathCreate();
560     OH_Drawing_PathMoveTo(path11, 100, 100);
561     OH_Drawing_PathRLineTo(nullptr, 0, 0);
562     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
563     OH_Drawing_PathRLineTo(path11, 300, 300);
564     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path11)->GetBounds().GetWidth(), 300.0));
565     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path11)->GetBounds().GetHeight(), 300.0));
566     OH_Drawing_PathDestroy(path11);
567 }
568 
569 /*
570  * @tc.name: NativeDrawingPathTest_pathRQuadTo025
571  * @tc.desc: test for PathRQuadTo func.
572  * @tc.type: FUNC
573  * @tc.require: AR000GTO5R
574  */
575 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRQuadTo025, TestSize.Level1)
576 {
577     OH_Drawing_Path* path12 = OH_Drawing_PathCreate();
578     OH_Drawing_PathQuadTo(path12, 0, 0, 30, 30);
579     OH_Drawing_PathRQuadTo(nullptr, 0, 0, 0, 0);
580     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
581     OH_Drawing_PathRQuadTo(path12, 100, 100, 100, 300);
582     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path12)->GetBounds().GetWidth(), 130.0));
583     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path12)->GetBounds().GetHeight(), 330.0));
584     OH_Drawing_PathDestroy(path12);
585 }
586 
587 /*
588  * @tc.name: NativeDrawingPathTest_pathRConicTo026
589  * @tc.desc: test for PathRConicTo func.
590  * @tc.type: FUNC
591  * @tc.require: AR000GTO5R
592  */
593 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRConicTo026, TestSize.Level1)
594 {
595     OH_Drawing_Path* path13 = OH_Drawing_PathCreate();
596     OH_Drawing_PathRConicTo(nullptr, 0, 0, 0, 0, 1);
597     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
598     OH_Drawing_PathRConicTo(path13, 100, 100, 100, 300, 5);
599     OH_Drawing_PathRConicTo(path13, 100, 100, 100, 300, 5);
600     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path13)->GetBounds().GetWidth(), 200.0));
601     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path13)->GetBounds().GetHeight(), 600.0));
602     OH_Drawing_PathDestroy(path13);
603 }
604 
605 /*
606  * @tc.name: NativeDrawingPathTest_pathRCubicTo027
607  * @tc.desc: test for PathRCubicTo func.
608  * @tc.type: FUNC
609  * @tc.require: AR000GTO5R
610  */
611 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRCubicTo027, TestSize.Level1)
612 {
613     OH_Drawing_Path* path14 = OH_Drawing_PathCreate();
614     OH_Drawing_PathCubicTo(path14, 30, 40, 60, 0, 50, 20);
615     OH_Drawing_PathRCubicTo(nullptr, 0, 0, 0, 0, 0, 0);
616     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
617     OH_Drawing_PathRCubicTo(path14, 30, 40, 60, 0, 50, 20);
618     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path14)->GetBounds().GetWidth(), 110.0));
619     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path14)->GetBounds().GetHeight(), 60.0));
620     OH_Drawing_PathDestroy(path14);
621 }
622 
623 /*
624  * @tc.name: NativeDrawingPathTest_pathTransformWithPerspectiveClip028
625  * @tc.desc: test for PathTransformWithPerspectiveClip func.
626  * @tc.type: FUNC
627  * @tc.require: AR000GTO5R
628  */
629 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathTransformWithPerspectiveClip028, TestSize.Level1)
630 {
631     OH_Drawing_Path* path15 = OH_Drawing_PathCreate();
632     OH_Drawing_PathAddRect(path15, 100, 500, 500, 100, PATH_DIRECTION_CW);
633     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(100, 100);
634     OH_Drawing_PathTransformWithPerspectiveClip(nullptr, matrix, path15, true);
635     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
636     OH_Drawing_PathTransformWithPerspectiveClip(path15, nullptr, path15, true);
637     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
638     OH_Drawing_PathTransformWithPerspectiveClip(path15, matrix, path15, true);
639     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path15)->GetBounds().GetWidth(), 400.0));
640     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path15)->GetBounds().GetHeight(), 400.0));
641     OH_Drawing_PathDestroy(path15);
642     OH_Drawing_MatrixDestroy(matrix);
643 }
644 
645 /*
646  * @tc.name: NativeDrawingPathTest_pathAddPath029
647  * @tc.desc: test for PathAddPath func.
648  * @tc.type: FUNC
649  * @tc.require: AR000GTO5R
650  */
651 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPath029, TestSize.Level1)
652 {
653     OH_Drawing_Path* path16 = OH_Drawing_PathCreate();
654     OH_Drawing_PathAddRect(path16, 100, 500, 500, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
655     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
656     OH_Drawing_MatrixSetMatrix(
657         matrix,
658         1, 0, 0,
659         0, -1, 0,
660         0, 0, 1);
661     OH_Drawing_PathAddPath(nullptr, path16, matrix);
662     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
663     OH_Drawing_PathAddPath(path16, nullptr, matrix);
664     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
665     OH_Drawing_PathAddPath(path16, path16, matrix);
666     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path16)->GetBounds().GetWidth(), 400.0));
667     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path16)->GetBounds().GetHeight(), 1000.0));
668     OH_Drawing_PathDestroy(path16);
669     OH_Drawing_MatrixDestroy(matrix);
670 }
671 
672 /*
673  * @tc.name: NativeDrawingPathTest_PathAddOval030
674  * @tc.desc: test for PathAddOval func.
675  * @tc.type: FUNC
676  * @tc.require: AR000GTO5R
677  */
678 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddOval030, TestSize.Level1)
679 {
680     OH_Drawing_Path* path = OH_Drawing_PathCreate();
681     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
682     OH_Drawing_PathAddOval(nullptr, rect, PATH_DIRECTION_CW);
683     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
684     OH_Drawing_PathAddOval(path, nullptr, PATH_DIRECTION_CW);
685     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
686     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
687     OH_Drawing_PathClose(path);
688     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 500.0));
689     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 300.0));
690     OH_Drawing_PathDestroy(path);
691     OH_Drawing_RectDestroy(rect);
692 }
693 
694 /*
695  * @tc.name: NativeDrawingPathTest_PathAddPolygon031
696  * @tc.desc: test for Adds contour created from point array, adding (count - 1) line segments.
697  * @tc.type: FUNC
698  * @tc.require: AR000GTO5R
699  */
700 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddPolygon031, TestSize.Level1)
701 {
702     OH_Drawing_Path* path = OH_Drawing_PathCreate();
703     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
704     OH_Drawing_PathAddPolygon(path, nullptr, ADDPOLYGON_COUNT, true);
705     OH_Drawing_PathAddPolygon(nullptr, src, ADDPOLYGON_COUNT, true);
706     OH_Drawing_PathAddPolygon(nullptr, nullptr, ADDPOLYGON_COUNT, true);
707     OH_Drawing_PathAddPolygon(path, src, ADDPOLYGON_COUNT, true);
708     EXPECT_TRUE(reinterpret_cast<Path*>(path)->IsValid());
709     OH_Drawing_PathDestroy(path);
710 }
711 
712 /*
713  * @tc.name: NativeDrawingPathTest_PathAddCircle032
714  * @tc.desc: test for Adds a circle to the path, and wound in the specified direction.
715  * @tc.type: FUNC
716  * @tc.require: AR000GTO5R
717  */
718 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddCircle032, TestSize.Level1)
719 {
720     float x = 50.f;
721     float y = 50.f;
722     float radius = 100.f;
723     OH_Drawing_Path* path = OH_Drawing_PathCreate();
724     OH_Drawing_PathAddCircle(nullptr, x, y, radius, PATH_DIRECTION_CW);
725     OH_Drawing_PathAddCircle(path, x, y, radius, PATH_DIRECTION_CW);
726     OH_Drawing_PathClose(path);
727     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.f));
728     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.f));
729     OH_Drawing_PathDestroy(path);
730 }
731 
732 /*
733  * @tc.name: NativeDrawingPathTest_PathBuildFromSvgString033
734  * @tc.desc: test for Parses the svg path from the string.
735  * @tc.type: FUNC
736  * @tc.require: AR000GTO5R
737  */
738 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathBuildFromSvgString033, TestSize.Level1)
739 {
740     const char *str = "M150 0 L75 200 L225 200 Z";
741     OH_Drawing_Path* path = OH_Drawing_PathCreate();
742     EXPECT_FALSE(OH_Drawing_PathBuildFromSvgString(nullptr, nullptr));
743     EXPECT_FALSE(OH_Drawing_PathBuildFromSvgString(nullptr, str));
744     EXPECT_TRUE(OH_Drawing_PathBuildFromSvgString(path, str));
745     OH_Drawing_PathDestroy(path);
746 }
747 
748 /*
749  * @tc.name: NativeDrawingPathTest_PathGetBounds034
750  * @tc.desc: test for Gets the smallest bounding box that contains the path.
751  * @tc.type: FUNC
752  * @tc.require: AR000GTO5R
753  */
754 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetBounds034, TestSize.Level1)
755 {
756     OH_Drawing_Path* path = OH_Drawing_PathCreate();
757     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
758     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
759     OH_Drawing_PathClose(path);
760     OH_Drawing_PathGetBounds(nullptr, rect);
761     OH_Drawing_PathGetBounds(path, nullptr);
762     OH_Drawing_PathGetBounds(nullptr, nullptr);
763     OH_Drawing_PathGetBounds(path, rect);
764     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Rect*>(rect)->GetWidth(), 500.0));
765     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Rect*>(rect)->GetHeight(), 300.0));
766     OH_Drawing_PathDestroy(path);
767     OH_Drawing_RectDestroy(rect);
768 }
769 
770 /*
771  * @tc.name: NativeDrawingPathTest_PathIsClosed035
772  * @tc.desc: test for Determines whether the path current contour is closed.
773  * @tc.type: FUNC
774  * @tc.require: AR000GTO5R
775  */
776 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathIsClosed035, TestSize.Level1)
777 {
778     OH_Drawing_Path* path = OH_Drawing_PathCreate();
779     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
780     OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
781     OH_Drawing_PathAddRoundRect(path, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
782 
783     EXPECT_FALSE(OH_Drawing_PathIsClosed(nullptr, true));
784     EXPECT_TRUE(OH_Drawing_PathIsClosed(path, false));
785     EXPECT_TRUE(OH_Drawing_PathIsClosed(path, true));
786 
787     OH_Drawing_Path* pathLine = OH_Drawing_PathCreate();
788     OH_Drawing_PathLineTo(pathLine, 50, 40);
789     EXPECT_FALSE(OH_Drawing_PathIsClosed(pathLine, false));
790     EXPECT_TRUE(OH_Drawing_PathIsClosed(pathLine, true));
791 
792     OH_Drawing_RoundRectDestroy(roundRect);
793     OH_Drawing_RectDestroy(rect);
794     OH_Drawing_PathDestroy(path);
795     OH_Drawing_PathDestroy(pathLine);
796 }
797 
798 /*
799  * @tc.name: NativeDrawingPathTest_PathGetPositionTangent036
800  * @tc.desc: test for Gets the position and tangent of the distance from the starting position of the Path.
801  * @tc.type: FUNC
802  * @tc.require: AR000GTO5R
803  */
804 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetPositionTangent036, TestSize.Level1)
805 {
806     OH_Drawing_Path* path = OH_Drawing_PathCreate(); // test path add oval
807     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
808     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
809     float distance = 10.f; // 10.f is distance
810     OH_Drawing_Point2D position;
811     OH_Drawing_Point2D tangent;
812     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(nullptr, false, distance, nullptr, nullptr));
813     EXPECT_TRUE(OH_Drawing_PathGetPositionTangent(path, true, 0.f, &position, &tangent));
814     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(path, true, std::nanf(""), &position, &tangent));
815     EXPECT_TRUE(OH_Drawing_PathGetPositionTangent(path, true, distance, &position, &tangent));
816 
817     OH_Drawing_Path* pathNo = OH_Drawing_PathCreate(); // test no path
818     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(pathNo, true, distance, &position, &tangent));
819     OH_Drawing_PathDestroy(path);
820     OH_Drawing_PathDestroy(pathNo);
821     OH_Drawing_RectDestroy(rect);
822 }
823 
824 /*
825  * @tc.name: NativeDrawingPathTest_PathOp037
826  * @tc.desc: test for Combines two paths.
827  * @tc.type: FUNC
828  * @tc.require: AR000GTO5R
829  */
830 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathOp037, TestSize.Level1)
831 {
832     OH_Drawing_Path* path = OH_Drawing_PathCreate();
833     OH_Drawing_Path* srcPath = OH_Drawing_PathCreate();
834     EXPECT_FALSE(OH_Drawing_PathOp(nullptr, srcPath, PATH_OP_MODE_INTERSECT));
835     EXPECT_FALSE(OH_Drawing_PathOp(path, nullptr, PATH_OP_MODE_INTERSECT));
836     EXPECT_FALSE(OH_Drawing_PathOp(nullptr, nullptr, PATH_OP_MODE_INTERSECT));
837     EXPECT_TRUE(OH_Drawing_PathOp(path, srcPath, PATH_OP_MODE_INTERSECT));
838     OH_Drawing_PathDestroy(path);
839     OH_Drawing_PathDestroy(srcPath);
840 }
841 
842 /*
843  * @tc.name: NativeDrawingPathTest_PathGetMatrix038
844  * @tc.desc: test for Computes the corresponding matrix at the specified distance.
845  * @tc.type: FUNC
846  * @tc.require: AR000GTO5R
847  */
848 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetMatrix038, TestSize.Level1)
849 {
850     OH_Drawing_Path* path = OH_Drawing_PathCreate();
851     OH_Drawing_PathMoveTo(path, 100, 100);
852     OH_Drawing_PathRLineTo(path, 100, 100);
853     float distance = 0.f;
854     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(100, 100);
855     EXPECT_FALSE(OH_Drawing_PathGetMatrix(nullptr, false, distance, matrix, GET_POSITION_MATRIX));
856     EXPECT_FALSE(OH_Drawing_PathGetMatrix(path, false, distance, nullptr, GET_POSITION_MATRIX));
857     EXPECT_FALSE(OH_Drawing_PathGetMatrix(nullptr, false, distance, nullptr, GET_POSITION_MATRIX));
858     EXPECT_TRUE(OH_Drawing_PathGetMatrix(path, false, distance, matrix, GET_POSITION_MATRIX));
859     OH_Drawing_PathDestroy(path);
860     OH_Drawing_MatrixDestroy(matrix);
861 }
862 } // namespace Drawing
863 } // namespace Rosen
864 } // namespace OHOS
865