• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 #ifdef RS_ENABLE_VK
28 #include "platform/ohos/backend/rs_vulkan_context.h"
29 #endif
30 
31 using namespace testing;
32 using namespace testing::ext;
33 
34 namespace OHOS {
35 namespace Rosen {
36 namespace Drawing {
37 class NativeDrawingPathTest : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp() override;
42     void TearDown() override;
43 };
44 
45 constexpr uint32_t INTNUM_TEN = 10;
46 constexpr int32_t NEGATIVE_ONE = -1;
47 constexpr uint32_t ADDPOLYGON_COUNT = 1;
48 
SetUpTestCase()49 void NativeDrawingPathTest::SetUpTestCase()
50 {
51 #ifdef RS_ENABLE_VK
52     RsVulkanContext::SetRecyclable(false);
53 #endif
54 }
TearDownTestCase()55 void NativeDrawingPathTest::TearDownTestCase() {}
SetUp()56 void NativeDrawingPathTest::SetUp() {}
TearDown()57 void NativeDrawingPathTest::TearDown() {}
58 
59 /*
60  * @tc.name: NativeDrawingPathTest_pathCreate001
61  * @tc.desc: test for create drawing_path.
62  * @tc.type: FUNC
63  * @tc.require: AR000GTO5R
64  */
65 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCreate001, TestSize.Level1)
66 {
67     OH_Drawing_Path* path = OH_Drawing_PathCreate();
68     EXPECT_EQ(path == nullptr, false);
69     OH_Drawing_PathDestroy(path);
70 }
71 
72 /*
73  * @tc.name: NativeDrawingPathTest_pathMoveTo002
74  * @tc.desc: test for PathMoveTo func.
75  * @tc.type: FUNC
76  * @tc.require: AR000GTO5R
77  */
78 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathMoveTo002, TestSize.Level1)
79 {
80     OH_Drawing_Path* path1 = OH_Drawing_PathCreate();
81     OH_Drawing_PathMoveTo(nullptr, 0, 0);
82     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
83     OH_Drawing_PathMoveTo(path1, 20, 20);
84     OH_Drawing_PathMoveTo(path1, -1, 21.5);
85     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path1)->GetBounds().GetWidth(), 21.0));
86     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path1)->GetBounds().GetHeight(), 1.5));
87     OH_Drawing_PathDestroy(path1);
88 }
89 
90 /*
91  * @tc.name: NativeDrawingPathTest_pathLineTo003
92  * @tc.desc: test for PathLineTo func.
93  * @tc.type: FUNC
94  * @tc.require: AR000GTO5R
95  */
96 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathLineTo003, TestSize.Level1)
97 {
98     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
99     OH_Drawing_PathLineTo(nullptr, 0, 0);
100     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
101     OH_Drawing_PathLineTo(path2, 50, 40);
102     OH_Drawing_PathLineTo(path2, -50, 10.2);
103     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 100.0));
104     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 40.0));
105     OH_Drawing_PathDestroy(path2);
106 }
107 
108 /*
109  * @tc.name: NativeDrawingPathTest_pathReset004
110  * @tc.desc: test for PathReset func.
111  * @tc.type: FUNC
112  * @tc.require: AR000GTO5R
113  */
114 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathReset004, TestSize.Level1)
115 {
116     OH_Drawing_Path* path3 = OH_Drawing_PathCreate();
117     OH_Drawing_PathMoveTo(path3, 20, 20);
118     OH_Drawing_PathReset(nullptr);
119     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
120     OH_Drawing_PathReset(path3);
121     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path3)->GetBounds().GetWidth(), 0.0));
122     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path3)->GetBounds().GetHeight(), 0.0));
123     OH_Drawing_PathDestroy(path3);
124 }
125 
126 /*
127  * @tc.name: NativeDrawingPathTest_pathArcTo005
128  * @tc.desc: test for PathArcTo func.
129  * @tc.type: FUNC
130  * @tc.require: AR000GTO5R
131  */
132 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathArcTo005, TestSize.Level1)
133 {
134     OH_Drawing_Path* path4 = OH_Drawing_PathCreate();
135     OH_Drawing_PathArcTo(nullptr, 0, 0, 0, 0, 0, 0);
136     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
137     OH_Drawing_PathArcTo(path4, 10, 10, 20, 0, 0, 90);
138     OH_Drawing_PathArcTo(path4, -10, 10, 10, -10, 0, 90);
139     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path4)->GetBounds().GetWidth(), 0.0));
140     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path4)->GetBounds().GetHeight(), 0.0));
141     OH_Drawing_PathDestroy(path4);
142 }
143 
144 /*
145  * @tc.name: NativeDrawingPathTest_pathQuadTo006
146  * @tc.desc: test for PathQuadTo func.
147  * @tc.type: FUNC
148  * @tc.require: AR000GTO5R
149  */
150 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathQuadTo006, TestSize.Level1)
151 {
152     OH_Drawing_Path* path5 = OH_Drawing_PathCreate();
153     OH_Drawing_PathQuadTo(nullptr, 0, 0, 0, 0);
154     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
155     OH_Drawing_PathQuadTo(path5, 0, 0, 30, 30);
156     OH_Drawing_PathQuadTo(path5, -20.5f, -20.5f, 30, 0);
157     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path5)->GetBounds().GetWidth(), 50.5));
158     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path5)->GetBounds().GetHeight(), 50.5));
159     OH_Drawing_PathDestroy(path5);
160 }
161 
162 /*
163  * @tc.name: NativeDrawingPathTest_pathCubicTo007
164  * @tc.desc: test for PathCubicTo func.
165  * @tc.type: FUNC
166  * @tc.require: AR000GTO5R
167  */
168 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCubicTo007, TestSize.Level1)
169 {
170     OH_Drawing_Path* path6 = OH_Drawing_PathCreate();
171     OH_Drawing_PathCubicTo(nullptr, 0, 0, 0, 0, 0, 0);
172     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
173     OH_Drawing_PathCubicTo(path6, 30, 40, 60, 0, 50, 20);
174     OH_Drawing_PathCubicTo(path6, -30, 40, 60, -30.6f, 50, -20);
175     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path6)->GetBounds().GetWidth(), 90.0));
176     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path6)->GetBounds().GetHeight(), 70.6));
177     OH_Drawing_PathDestroy(path6);
178 }
179 
180 /*
181  * @tc.name: NativeDrawingPathTest_pathClose008
182  * @tc.desc: test for PathClose func.
183  * @tc.type: FUNC
184  * @tc.require: AR000GTO5R
185  */
186 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathClose008, TestSize.Level1)
187 {
188     OH_Drawing_Path* path = OH_Drawing_PathCreate();
189     OH_Drawing_PathLineTo(path, 50, 40);
190     OH_Drawing_PathClose(nullptr);
191     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
192     OH_Drawing_PathClose(path);
193     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.0));
194     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 40.0));
195     OH_Drawing_PathDestroy(path);
196 }
197 
198 /*
199  * @tc.name: NativeDrawingPathTest_pathCopy009
200  * @tc.desc: test for PathCopy func.
201  * @tc.type: FUNC
202  * @tc.require: SR000S9F0C
203  */
204 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathCopy009, TestSize.Level1)
205 {
206     OH_Drawing_Path* path = OH_Drawing_PathCreate();
207     // line point x = 50, y = 40
208     OH_Drawing_PathLineTo(path, 50, 40);
209     OH_Drawing_PathClose(path);
210     EXPECT_EQ(OH_Drawing_PathCopy(nullptr), nullptr);
211     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
212     OH_Drawing_Path* pathCopy = OH_Drawing_PathCopy(path);
213     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetWidth(), 50.0));
214     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetHeight(), 40.0));
215     OH_Drawing_PathDestroy(path);
216     OH_Drawing_PathDestroy(pathCopy);
217 }
218 
219 /*
220  * @tc.name: NativeDrawingPathTest_pathAddRect010
221  * @tc.desc: test for PathAddRect func.
222  * @tc.type: FUNC
223  * @tc.require: SR000S9F0C
224  */
225 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRect010, TestSize.Level1)
226 {
227     OH_Drawing_Path* path = OH_Drawing_PathCreate();
228     // rect left[50], top[50],right[250], bottom[250]
229     OH_Drawing_PathAddRect(nullptr, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
230     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
231     OH_Drawing_PathAddRect(path, 0, 0, 0, 0, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE));
232     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
233     OH_Drawing_PathAddRect(path, 0, 0, 0, 0, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN));
234     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
235     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
236     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
237     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.0));
238     OH_Drawing_PathDestroy(path);
239 }
240 
241 /*
242  * @tc.name: NativeDrawingPathTest_pathAddRoundRect011
243  * @tc.desc: test for PathAddRoundRect func.
244  * @tc.type: FUNC
245  * @tc.require: SR000S9F0C
246  */
247 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRoundRect011, TestSize.Level1)
248 {
249     OH_Drawing_Path* path = OH_Drawing_PathCreate();
250     // rect left[50], top[50],right[250], bottom[250]
251     OH_Drawing_PathAddRect(nullptr, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
252     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
253     OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
254     OH_Drawing_PathAddRoundRect(nullptr, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
255     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
256     OH_Drawing_PathAddRoundRect(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
257     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
258     OH_Drawing_PathAddRoundRect(path, roundRect, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE));
259     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
260     OH_Drawing_PathAddRoundRect(path, roundRect, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN));
261     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
262     OH_Drawing_PathAddRoundRect(path, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
263     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
264     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.0));
265     OH_Drawing_PathDestroy(path);
266     OH_Drawing_RoundRectDestroy(roundRect);
267     OH_Drawing_RectDestroy(rect);
268 }
269 
270 /*
271  * @tc.name: NativeDrawingPathTest_pathAddArc012
272  * @tc.desc: test for PathAddArc func.
273  * @tc.type: FUNC
274  * @tc.require: SR000S9F0C
275  */
276 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddArc012, TestSize.Level1)
277 {
278     OH_Drawing_Path* path = OH_Drawing_PathCreate();
279     // rect left[50], top[50],right[250], bottom[250]
280     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
281     OH_Drawing_PathAddArc(nullptr, rect, 0, 180);
282     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
283     OH_Drawing_PathAddArc(path, nullptr, 0, 180);
284     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
285     OH_Drawing_PathAddArc(path, rect, 0, 180);
286     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
287     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 100.0));
288     OH_Drawing_PathDestroy(path);
289     OH_Drawing_RectDestroy(rect);
290 }
291 
292 /*
293  * @tc.name: NativeDrawingPathTest_pathContains013
294  * @tc.desc: test for PathContains func.
295  * @tc.type: FUNC
296  * @tc.require: SR000S9F0C
297  */
298 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathContains013, TestSize.Level1)
299 {
300     OH_Drawing_Path* path = OH_Drawing_PathCreate();
301     // rect left[50], top[50],right[250], bottom[250]
302     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
303     OH_Drawing_PathContains(nullptr, 0, 0);
304     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
305     bool ret = OH_Drawing_PathContains(path, 0, 0);
306     EXPECT_EQ(ret, false);
307     ret = OH_Drawing_PathContains(path, 60, 60);
308     EXPECT_EQ(ret, true);
309     OH_Drawing_PathDestroy(path);
310 }
311 
312 /*
313  * @tc.name: NativeDrawingPathTest_pathTransform014
314  * @tc.desc: test for PathTransform func.
315  * @tc.type: FUNC
316  * @tc.require: SR000S9F0C
317  */
318 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathTransform014, TestSize.Level1)
319 {
320     OH_Drawing_Path* path = OH_Drawing_PathCreate();
321     // rect left[50], top[50],right[250], bottom[250]
322     OH_Drawing_PathAddRect(path, 50, 50, 250, 250, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
323     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(1, 1);
324     OH_Drawing_PathTransform(nullptr, matrix);
325     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
326     OH_Drawing_PathTransform(path, nullptr);
327     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
328 
329     bool ret = OH_Drawing_PathContains(path, 50, 50);
330     EXPECT_EQ(ret, true);
331     OH_Drawing_PathTransform(path, matrix);
332     ret = OH_Drawing_PathContains(path, 50, 50);
333     EXPECT_EQ(ret, false);
334     OH_Drawing_PathDestroy(path);
335 }
336 
337 /*
338  * @tc.name: NativeDrawingPathTest_pathSetFilltype015
339  * @tc.desc: test for PathSetFillType func.
340  * @tc.type: FUNC
341  * @tc.require: SR000S9F0C
342  */
343 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathSetFilltype015, TestSize.Level1)
344 {
345     OH_Drawing_Path* path = OH_Drawing_PathCreate();
346     OH_Drawing_PathSetFillType(nullptr, PATH_FILL_TYPE_WINDING);
347     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
348     OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(NEGATIVE_ONE));
349     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
350     OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(INTNUM_TEN));
351     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
352     OH_Drawing_PathSetFillType(path, PATH_FILL_TYPE_WINDING);
353     // line point x = 50, y = 40
354     OH_Drawing_PathLineTo(path, 50, 40);
355     OH_Drawing_PathClose(path);
356     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.0));
357     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 40.0));
358     float ret = OH_Drawing_PathGetLength(path, true);
359     EXPECT_TRUE(IsScalarAlmostEqual(ret, 128.062485)); // 128.062485 is length of path
360     OH_Drawing_PathDestroy(path);
361 }
362 
363 /*
364  * @tc.name: NativeDrawingPathTest_pathConicTo016
365  * @tc.desc: test for PathConicTo func.
366  * @tc.type: FUNC
367  * @tc.require: AR000GTO5R
368  */
369 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathConicTo016, TestSize.Level1)
370 {
371     OH_Drawing_Path* path = OH_Drawing_PathCreate();
372     OH_Drawing_PathConicTo(nullptr, 0, 0, 0, 0, 1);
373     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
374     OH_Drawing_PathConicTo(path, 0, 0, 30, 30, 1);
375     OH_Drawing_PathConicTo(path, -20.5f, -20.5f, 30, 0, 1);
376     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 50.5));
377     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 50.5));
378     OH_Drawing_PathDestroy(path);
379 }
380 
381 /*
382  * @tc.name: NativeDrawingPathTest_pathAddRectWithInitialCorner017
383  * @tc.desc: test for PathAddRectWithInitialCorner func.
384  * @tc.type: FUNC
385  * @tc.require: AR000GTO5R
386  */
387 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddRectWithInitialCorner017, TestSize.Level1)
388 {
389     OH_Drawing_Path* path = OH_Drawing_PathCreate();
390     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
391     OH_Drawing_PathAddRectWithInitialCorner(nullptr, rect, PATH_DIRECTION_CW, 0);
392     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
393     OH_Drawing_PathAddRectWithInitialCorner(path, nullptr, PATH_DIRECTION_CW, 0);
394     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
395     OH_Drawing_PathAddRectWithInitialCorner(path, rect, static_cast<OH_Drawing_PathDirection>(NEGATIVE_ONE), 0);
396     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
397     OH_Drawing_PathAddRectWithInitialCorner(path, rect, static_cast<OH_Drawing_PathDirection>(INTNUM_TEN), 0);
398     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
399     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
400     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.0));
401     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 300.0));
402     OH_Drawing_PathClose(path);
403     OH_Drawing_PathDestroy(path);
404     OH_Drawing_RectDestroy(rect);
405 }
406 
407 /*
408  * @tc.name: NativeDrawingPathTest_pathAddPathWithMode018
409  * @tc.desc: test for PathAddPathWithMode func.
410  * @tc.type: FUNC
411  * @tc.require: AR000GTO5R
412  */
413 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithMode018, TestSize.Level1)
414 {
415     OH_Drawing_Path* path = OH_Drawing_PathCreate();
416     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
417     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
418     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
419     OH_Drawing_PathAddPathWithMode(nullptr, path, PATH_ADD_MODE_APPEND);
420     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
421     OH_Drawing_PathAddPathWithMode(path2, nullptr, PATH_ADD_MODE_APPEND);
422     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
423     OH_Drawing_PathAddPathWithMode(path2, path, PATH_ADD_MODE_APPEND);
424     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
425     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
426     OH_Drawing_PathDestroy(path);
427     OH_Drawing_RectDestroy(rect);
428     OH_Drawing_PathDestroy(path2);
429 }
430 
431 /*
432  * @tc.name: NativeDrawingPathTest_pathAddPathWithOffsetAndMode019
433  * @tc.desc: test for PathAddPathWithOffsetAndMode func.
434  * @tc.type: FUNC
435  * @tc.require: AR000GTO5R
436  */
437 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithOffsetAndMode019, TestSize.Level1)
438 {
439     OH_Drawing_Path* path = OH_Drawing_PathCreate();
440     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
441     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
442     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
443     OH_Drawing_PathAddPathWithOffsetAndMode(nullptr, path, 0, 0, PATH_ADD_MODE_APPEND);
444     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
445     OH_Drawing_PathAddPathWithOffsetAndMode(path2, nullptr, 0, 0, PATH_ADD_MODE_APPEND);
446     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
447     OH_Drawing_PathAddPathWithOffsetAndMode(path2, path, 0, 0, PATH_ADD_MODE_APPEND);
448     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
449     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
450     OH_Drawing_PathDestroy(path);
451     OH_Drawing_RectDestroy(rect);
452     OH_Drawing_PathDestroy(path2);
453 }
454 
455 /*
456  * @tc.name: NativeDrawingPathTest_pathAddPathWithMatrixAndMode020
457  * @tc.desc: test for PathAddPathWithMatrixAndMode func.
458  * @tc.type: FUNC
459  * @tc.require: AR000GTO5R
460  */
461 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPathWithMatrixAndMode020, TestSize.Level1)
462 {
463     OH_Drawing_Path* path = OH_Drawing_PathCreate();
464     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 200.0f, 300.0f);
465     OH_Drawing_PathAddRectWithInitialCorner(path, rect, PATH_DIRECTION_CW, 0);
466     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
467     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
468 
469     OH_Drawing_PathAddPathWithMatrixAndMode(nullptr, path, matrix, PATH_ADD_MODE_APPEND);
470     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
471     OH_Drawing_PathAddPathWithMatrixAndMode(path2, nullptr, matrix, PATH_ADD_MODE_APPEND);
472     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
473     OH_Drawing_PathAddPathWithMatrixAndMode(path2, path, matrix, PATH_ADD_MODE_APPEND);
474     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetWidth(), 200.0));
475     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path2)->GetBounds().GetHeight(), 300.0));
476 
477     OH_Drawing_Path* pathRect = OH_Drawing_PathCreate();
478     OH_Drawing_PathAddRect(pathRect, 0.0f, 0.0f, 200.0f, 300.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
479     OH_Drawing_MatrixSetMatrix(
480         matrix,
481         5, 4, 0,
482         0, -1, 0,
483         0, 0, 1);
484     OH_Drawing_PathAddPath(pathRect, pathRect, nullptr);
485     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetWidth(), 200.0));
486     OH_Drawing_PathAddPath(pathRect, pathRect, matrix);
487     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetWidth(), 2200.0));
488     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathRect)->GetBounds().GetHeight(), 600.0));
489     OH_Drawing_PathAddPath(nullptr, pathRect, matrix);
490     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
491     OH_Drawing_PathAddPath(pathRect, nullptr, matrix);
492     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
493     OH_Drawing_PathDestroy(path);
494     OH_Drawing_RectDestroy(rect);
495     OH_Drawing_PathDestroy(path2);
496     OH_Drawing_PathDestroy(pathRect);
497     OH_Drawing_MatrixDestroy(matrix);
498 }
499 
500 /*
501  * @tc.name: NativeDrawingPathTest_pathOffset021
502  * @tc.desc: test for PathOffset func.
503  * @tc.type: FUNC
504  * @tc.require: AR000GTO5R
505  */
506 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathOffset021, TestSize.Level1)
507 {
508     OH_Drawing_Path* path = OH_Drawing_PathCreate();
509     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
510     OH_Drawing_PathOffset(nullptr, path2, 0, 0);
511     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
512     OH_Drawing_PathOffset(path, path2, 50, 40);
513     OH_Drawing_PathReset(path);
514     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 0.0));
515     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 0.0));
516     OH_Drawing_PathDestroy(path);
517     OH_Drawing_PathDestroy(path2);
518 }
519 
520 /*
521  * @tc.name: NativeDrawingPathTest_pathAddOvalWithInitialPoint022
522  * @tc.desc: test for PathAddOvalWithInitialPoint func.
523  * @tc.type: FUNC
524  * @tc.require: AR000GTO5R
525  */
526 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddOvalWithInitialPoint022, TestSize.Level1)
527 {
528     OH_Drawing_Path* path9 = OH_Drawing_PathCreate();
529     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
530     OH_Drawing_PathAddOvalWithInitialPoint(nullptr, rect, 0, PATH_DIRECTION_CW);
531     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
532     OH_Drawing_PathAddOvalWithInitialPoint(path9, nullptr, 0, PATH_DIRECTION_CW);
533     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
534     OH_Drawing_PathAddOvalWithInitialPoint(path9, rect, 10, PATH_DIRECTION_CW);
535     OH_Drawing_PathClose(path9);
536     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path9)->GetBounds().GetWidth(), 500.0));
537     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path9)->GetBounds().GetHeight(), 300.0));
538     OH_Drawing_PathDestroy(path9);
539     OH_Drawing_RectDestroy(rect);
540 }
541 
542 /*
543  * @tc.name: NativeDrawingPathTest_pathRMoveTo023
544  * @tc.desc: test for PathRMoveTo func.
545  * @tc.type: FUNC
546  * @tc.require: AR000GTO5R
547  */
548 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRMoveTo023, TestSize.Level1)
549 {
550     OH_Drawing_Path* path10 = OH_Drawing_PathCreate();
551     OH_Drawing_PathRMoveTo(nullptr, 0, 0);
552     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
553     OH_Drawing_PathRMoveTo(path10, 100, 100);
554     OH_Drawing_PathLineTo(path10, 300, 300);
555     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path10)->GetBounds().GetWidth(), 200.0));
556     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path10)->GetBounds().GetHeight(), 200.0));
557     OH_Drawing_PathDestroy(path10);
558 }
559 
560 /*
561  * @tc.name: NativeDrawingPathTest_pathRLineTo024
562  * @tc.desc: test for PathRLineTo func.
563  * @tc.type: FUNC
564  * @tc.require: AR000GTO5R
565  */
566 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRLineTo024, TestSize.Level1)
567 {
568     OH_Drawing_Path* path11 = OH_Drawing_PathCreate();
569     OH_Drawing_PathMoveTo(path11, 100, 100);
570     OH_Drawing_PathRLineTo(nullptr, 0, 0);
571     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
572     OH_Drawing_PathRLineTo(path11, 300, 300);
573     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path11)->GetBounds().GetWidth(), 300.0));
574     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path11)->GetBounds().GetHeight(), 300.0));
575     OH_Drawing_PathDestroy(path11);
576 }
577 
578 /*
579  * @tc.name: NativeDrawingPathTest_pathRQuadTo025
580  * @tc.desc: test for PathRQuadTo func.
581  * @tc.type: FUNC
582  * @tc.require: AR000GTO5R
583  */
584 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRQuadTo025, TestSize.Level1)
585 {
586     OH_Drawing_Path* path12 = OH_Drawing_PathCreate();
587     OH_Drawing_PathQuadTo(path12, 0, 0, 30, 30);
588     OH_Drawing_PathRQuadTo(nullptr, 0, 0, 0, 0);
589     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
590     OH_Drawing_PathRQuadTo(path12, 100, 100, 100, 300);
591     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path12)->GetBounds().GetWidth(), 130.0));
592     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path12)->GetBounds().GetHeight(), 330.0));
593     OH_Drawing_PathDestroy(path12);
594 }
595 
596 /*
597  * @tc.name: NativeDrawingPathTest_pathRConicTo026
598  * @tc.desc: test for PathRConicTo func.
599  * @tc.type: FUNC
600  * @tc.require: AR000GTO5R
601  */
602 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRConicTo026, TestSize.Level1)
603 {
604     OH_Drawing_Path* path13 = OH_Drawing_PathCreate();
605     OH_Drawing_PathRConicTo(nullptr, 0, 0, 0, 0, 1);
606     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
607     OH_Drawing_PathRConicTo(path13, 100, 100, 100, 300, 5);
608     OH_Drawing_PathRConicTo(path13, 100, 100, 100, 300, 5);
609     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path13)->GetBounds().GetWidth(), 200.0));
610     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path13)->GetBounds().GetHeight(), 600.0));
611     OH_Drawing_PathDestroy(path13);
612 }
613 
614 /*
615  * @tc.name: NativeDrawingPathTest_pathRCubicTo027
616  * @tc.desc: test for PathRCubicTo func.
617  * @tc.type: FUNC
618  * @tc.require: AR000GTO5R
619  */
620 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathRCubicTo027, TestSize.Level1)
621 {
622     OH_Drawing_Path* path14 = OH_Drawing_PathCreate();
623     OH_Drawing_PathCubicTo(path14, 30, 40, 60, 0, 50, 20);
624     OH_Drawing_PathRCubicTo(nullptr, 0, 0, 0, 0, 0, 0);
625     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
626     OH_Drawing_PathRCubicTo(path14, 30, 40, 60, 0, 50, 20);
627     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path14)->GetBounds().GetWidth(), 110.0));
628     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path14)->GetBounds().GetHeight(), 60.0));
629     OH_Drawing_PathDestroy(path14);
630 }
631 
632 /*
633  * @tc.name: NativeDrawingPathTest_pathTransformWithPerspectiveClip028
634  * @tc.desc: test for PathTransformWithPerspectiveClip func.
635  * @tc.type: FUNC
636  * @tc.require: AR000GTO5R
637  */
638 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathTransformWithPerspectiveClip028, TestSize.Level1)
639 {
640     OH_Drawing_Path* path15 = OH_Drawing_PathCreate();
641     OH_Drawing_PathAddRect(path15, 100, 500, 500, 100, PATH_DIRECTION_CW);
642     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(100, 100);
643     OH_Drawing_PathTransformWithPerspectiveClip(nullptr, matrix, path15, true);
644     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
645     OH_Drawing_PathTransformWithPerspectiveClip(path15, nullptr, path15, true);
646     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
647     OH_Drawing_PathTransformWithPerspectiveClip(path15, matrix, path15, true);
648     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path15)->GetBounds().GetWidth(), 400.0));
649     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path15)->GetBounds().GetHeight(), 400.0));
650     OH_Drawing_PathDestroy(path15);
651     OH_Drawing_MatrixDestroy(matrix);
652 }
653 
654 /*
655  * @tc.name: NativeDrawingPathTest_pathAddPath029
656  * @tc.desc: test for PathAddPath func.
657  * @tc.type: FUNC
658  * @tc.require: AR000GTO5R
659  */
660 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_pathAddPath029, TestSize.Level1)
661 {
662     OH_Drawing_Path* path16 = OH_Drawing_PathCreate();
663     OH_Drawing_PathAddRect(path16, 100, 500, 500, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
664     OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
665     OH_Drawing_MatrixSetMatrix(
666         matrix,
667         1, 0, 0,
668         0, -1, 0,
669         0, 0, 1);
670     OH_Drawing_PathAddPath(nullptr, path16, matrix);
671     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
672     OH_Drawing_PathAddPath(path16, nullptr, matrix);
673     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
674     OH_Drawing_PathAddPath(path16, path16, matrix);
675     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path16)->GetBounds().GetWidth(), 400.0));
676     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path16)->GetBounds().GetHeight(), 1000.0));
677     OH_Drawing_PathDestroy(path16);
678     OH_Drawing_MatrixDestroy(matrix);
679 }
680 
681 /*
682  * @tc.name: NativeDrawingPathTest_PathAddOval030
683  * @tc.desc: test for PathAddOval func.
684  * @tc.type: FUNC
685  * @tc.require: AR000GTO5R
686  */
687 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddOval030, TestSize.Level1)
688 {
689     OH_Drawing_Path* path = OH_Drawing_PathCreate();
690     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
691     OH_Drawing_PathAddOval(nullptr, rect, PATH_DIRECTION_CW);
692     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
693     OH_Drawing_PathAddOval(path, nullptr, PATH_DIRECTION_CW);
694     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
695     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
696     OH_Drawing_PathClose(path);
697     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 500.0));
698     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 300.0));
699     OH_Drawing_PathDestroy(path);
700     OH_Drawing_RectDestroy(rect);
701 }
702 
703 /*
704  * @tc.name: NativeDrawingPathTest_PathAddPolygon031
705  * @tc.desc: test for Adds contour created from point array, adding (count - 1) line segments.
706  * @tc.type: FUNC
707  * @tc.require: AR000GTO5R
708  */
709 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddPolygon031, TestSize.Level1)
710 {
711     OH_Drawing_Path* path = OH_Drawing_PathCreate();
712     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
713     OH_Drawing_PathAddPolygon(path, nullptr, ADDPOLYGON_COUNT, true);
714     OH_Drawing_PathAddPolygon(nullptr, src, ADDPOLYGON_COUNT, true);
715     OH_Drawing_PathAddPolygon(nullptr, nullptr, ADDPOLYGON_COUNT, true);
716     OH_Drawing_PathAddPolygon(path, src, ADDPOLYGON_COUNT, true);
717     EXPECT_TRUE(reinterpret_cast<Path*>(path)->IsValid());
718     OH_Drawing_PathDestroy(path);
719 }
720 
721 /*
722  * @tc.name: NativeDrawingPathTest_PathAddCircle032
723  * @tc.desc: test for Adds a circle to the path, and wound in the specified direction.
724  * @tc.type: FUNC
725  * @tc.require: AR000GTO5R
726  */
727 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathAddCircle032, TestSize.Level1)
728 {
729     float x = 50.f;
730     float y = 50.f;
731     float radius = 100.f;
732     OH_Drawing_Path* path = OH_Drawing_PathCreate();
733     OH_Drawing_PathAddCircle(nullptr, x, y, radius, PATH_DIRECTION_CW);
734     OH_Drawing_PathAddCircle(path, x, y, radius, PATH_DIRECTION_CW);
735     OH_Drawing_PathClose(path);
736     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 200.f));
737     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 200.f));
738     OH_Drawing_PathDestroy(path);
739 }
740 
741 /*
742  * @tc.name: NativeDrawingPathTest_PathBuildFromSvgString033
743  * @tc.desc: test for Parses the svg path from the string.
744  * @tc.type: FUNC
745  * @tc.require: AR000GTO5R
746  */
747 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathBuildFromSvgString033, TestSize.Level1)
748 {
749     const char *str = "M150 0 L75 200 L225 200 Z";
750     OH_Drawing_Path* path = OH_Drawing_PathCreate();
751     EXPECT_FALSE(OH_Drawing_PathBuildFromSvgString(nullptr, nullptr));
752     EXPECT_FALSE(OH_Drawing_PathBuildFromSvgString(nullptr, str));
753     EXPECT_TRUE(OH_Drawing_PathBuildFromSvgString(path, str));
754     OH_Drawing_PathDestroy(path);
755 }
756 
757 /*
758  * @tc.name: NativeDrawingPathTest_PathGetBounds034
759  * @tc.desc: test for Gets the smallest bounding box that contains the path.
760  * @tc.type: FUNC
761  * @tc.require: AR000GTO5R
762  */
763 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetBounds034, TestSize.Level1)
764 {
765     OH_Drawing_Path* path = OH_Drawing_PathCreate();
766     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
767     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
768     OH_Drawing_PathClose(path);
769     OH_Drawing_PathGetBounds(nullptr, rect);
770     OH_Drawing_PathGetBounds(path, nullptr);
771     OH_Drawing_PathGetBounds(nullptr, nullptr);
772     OH_Drawing_PathGetBounds(path, rect);
773     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Rect*>(rect)->GetWidth(), 500.0));
774     EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Rect*>(rect)->GetHeight(), 300.0));
775     OH_Drawing_PathDestroy(path);
776     OH_Drawing_RectDestroy(rect);
777 }
778 
779 /*
780  * @tc.name: NativeDrawingPathTest_PathIsClosed035
781  * @tc.desc: test for Determines whether the path current contour is closed.
782  * @tc.type: FUNC
783  * @tc.require: AR000GTO5R
784  */
785 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathIsClosed035, TestSize.Level1)
786 {
787     OH_Drawing_Path* path = OH_Drawing_PathCreate();
788     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 250, 250);
789     OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
790     OH_Drawing_PathAddRoundRect(path, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
791 
792     EXPECT_FALSE(OH_Drawing_PathIsClosed(nullptr, true));
793     EXPECT_TRUE(OH_Drawing_PathIsClosed(path, false));
794     EXPECT_TRUE(OH_Drawing_PathIsClosed(path, true));
795 
796     OH_Drawing_Path* pathLine = OH_Drawing_PathCreate();
797     OH_Drawing_PathLineTo(pathLine, 50, 40);
798     EXPECT_FALSE(OH_Drawing_PathIsClosed(pathLine, false));
799     EXPECT_TRUE(OH_Drawing_PathIsClosed(pathLine, true));
800 
801     OH_Drawing_RoundRectDestroy(roundRect);
802     OH_Drawing_RectDestroy(rect);
803     OH_Drawing_PathDestroy(path);
804     OH_Drawing_PathDestroy(pathLine);
805 }
806 
807 /*
808  * @tc.name: NativeDrawingPathTest_PathGetPositionTangent036
809  * @tc.desc: test for Gets the position and tangent of the distance from the starting position of the Path.
810  * @tc.type: FUNC
811  * @tc.require: AR000GTO5R
812  */
813 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetPositionTangent036, TestSize.Level1)
814 {
815     OH_Drawing_Path* path = OH_Drawing_PathCreate(); // test path add oval
816     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 100, 500, 400);
817     OH_Drawing_PathAddOval(path, rect, PATH_DIRECTION_CW);
818     float distance = 10.f; // 10.f is distance
819     OH_Drawing_Point2D position;
820     OH_Drawing_Point2D tangent;
821     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(nullptr, false, distance, nullptr, nullptr));
822     EXPECT_TRUE(OH_Drawing_PathGetPositionTangent(path, true, 0.f, &position, &tangent));
823     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(path, true, std::nanf(""), &position, &tangent));
824     EXPECT_TRUE(OH_Drawing_PathGetPositionTangent(path, true, distance, &position, &tangent));
825 
826     OH_Drawing_Path* pathNo = OH_Drawing_PathCreate(); // test no path
827     EXPECT_FALSE(OH_Drawing_PathGetPositionTangent(pathNo, true, distance, &position, &tangent));
828     OH_Drawing_PathDestroy(path);
829     OH_Drawing_PathDestroy(pathNo);
830     OH_Drawing_RectDestroy(rect);
831 }
832 
833 /*
834  * @tc.name: NativeDrawingPathTest_PathOp037
835  * @tc.desc: test for Combines two paths.
836  * @tc.type: FUNC
837  * @tc.require: AR000GTO5R
838  */
839 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathOp037, TestSize.Level1)
840 {
841     OH_Drawing_Path* path = OH_Drawing_PathCreate();
842     OH_Drawing_Path* srcPath = OH_Drawing_PathCreate();
843     EXPECT_FALSE(OH_Drawing_PathOp(nullptr, srcPath, PATH_OP_MODE_INTERSECT));
844     EXPECT_FALSE(OH_Drawing_PathOp(path, nullptr, PATH_OP_MODE_INTERSECT));
845     EXPECT_FALSE(OH_Drawing_PathOp(nullptr, nullptr, PATH_OP_MODE_INTERSECT));
846     EXPECT_TRUE(OH_Drawing_PathOp(path, srcPath, PATH_OP_MODE_INTERSECT));
847     OH_Drawing_PathDestroy(path);
848     OH_Drawing_PathDestroy(srcPath);
849 }
850 
851 /*
852  * @tc.name: NativeDrawingPathTest_PathGetMatrix038
853  * @tc.desc: test for Computes the corresponding matrix at the specified distance.
854  * @tc.type: FUNC
855  * @tc.require: AR000GTO5R
856  */
857 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetMatrix038, TestSize.Level1)
858 {
859     OH_Drawing_Path* path = OH_Drawing_PathCreate();
860     OH_Drawing_PathMoveTo(path, 100, 100);
861     OH_Drawing_PathRLineTo(path, 100, 100);
862     float distance = 0.f;
863     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(100, 100);
864     EXPECT_FALSE(OH_Drawing_PathGetMatrix(nullptr, false, distance, matrix, GET_POSITION_MATRIX));
865     EXPECT_FALSE(OH_Drawing_PathGetMatrix(path, false, distance, nullptr, GET_POSITION_MATRIX));
866     EXPECT_FALSE(OH_Drawing_PathGetMatrix(nullptr, false, distance, nullptr, GET_POSITION_MATRIX));
867     EXPECT_TRUE(OH_Drawing_PathGetMatrix(path, false, distance, matrix, GET_POSITION_MATRIX));
868     OH_Drawing_PathDestroy(path);
869     OH_Drawing_MatrixDestroy(matrix);
870 }
871 
872 /*
873  * @tc.name: NativeDrawingPathTest_PathGetSegment039
874  * @tc.desc: test for Gets the path between the start and end points.
875  * @tc.type: FUNC
876  * @tc.require: AR000GTO5R
877  */
878 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathGetSegment039, TestSize.Level1)
879 {
880     OH_Drawing_Path* path = OH_Drawing_PathCreate();
881     OH_Drawing_PathMoveTo(path, 100, 100);
882     OH_Drawing_PathLineTo(path, 100, 200);
883     OH_Drawing_PathLineTo(path, 200, 200);
884     OH_Drawing_Path* newPath = OH_Drawing_PathCreate();
885     bool result = false;
886 
887     EXPECT_EQ(OH_Drawing_PathGetSegment(path, false, 120, 180, false, newPath, &result), OH_DRAWING_SUCCESS);
888     EXPECT_EQ(result, true);
889 
890     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 120, 280, false, newPath, &result), OH_DRAWING_SUCCESS);
891     EXPECT_EQ(result, true);
892 
893     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, -50, 999, false, newPath, &result), OH_DRAWING_SUCCESS);
894     EXPECT_EQ(result, true);
895 
896     EXPECT_EQ(OH_Drawing_PathGetSegment(path, false, 120, 180, true, newPath, &result), OH_DRAWING_SUCCESS);
897     EXPECT_EQ(result, true);
898 
899     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 120, 280, true, newPath, &result), OH_DRAWING_SUCCESS);
900     EXPECT_EQ(result, true);
901 
902     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, -50, 999, true, newPath, &result), OH_DRAWING_SUCCESS);
903     EXPECT_EQ(result, true);
904 
905     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 120, 120, false, newPath, &result), OH_DRAWING_SUCCESS);
906     EXPECT_EQ(result, false);
907 
908     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 130, 120, false, newPath, &result), OH_DRAWING_SUCCESS);
909     EXPECT_EQ(result, false);
910 
911     EXPECT_EQ(OH_Drawing_PathGetSegment(nullptr, true, 120, 180, false, newPath, &result),
912         OH_DRAWING_ERROR_INVALID_PARAMETER);
913 
914     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 130, 120, false, nullptr, &result),
915         OH_DRAWING_ERROR_INVALID_PARAMETER);
916 
917     EXPECT_EQ(OH_Drawing_PathGetSegment(path, true, 130, 120, false, newPath, nullptr),
918         OH_DRAWING_ERROR_INVALID_PARAMETER);
919 
920     OH_Drawing_PathDestroy(newPath);
921     OH_Drawing_PathDestroy(path);
922 }
923 
924 /*
925  * @tc.name: NativeDrawingPathTest_SetPath040
926  * @tc.desc: test for Set Path.
927  * @tc.type: FUNC
928  * @tc.require: AR000GTO5R
929  */
930 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_OH_Drawing_PathSetPath040, TestSize.Level1)
931 {
932     OH_Drawing_Path* path = OH_Drawing_PathCreate();
933     ASSERT_TRUE(path != nullptr);
934     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
935     OH_Drawing_ErrorCode code = OH_Drawing_PathSetPath(path, path2);
936     EXPECT_EQ(code, OH_DRAWING_SUCCESS);
937     EXPECT_EQ(OH_Drawing_PathSetPath(path, nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
938     OH_Drawing_PathDestroy(path);
939     OH_Drawing_PathDestroy(path2);
940 }
941 
942 /*
943  * @tc.name: NativeDrawingPathTest_OH_Drawing_PathIsEmpty041
944  * @tc.desc: test for if path is empty.
945  * @tc.type: FUNC
946  * @tc.require: AR000GTO5R
947  */
948 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_OH_Drawing_PathIsEmpty041, TestSize.Level1)
949 {
950     OH_Drawing_Path* path = OH_Drawing_PathCreate();
951     ASSERT_TRUE(path != nullptr);
952     bool isEmpty = false;
953     OH_Drawing_ErrorCode code = OH_Drawing_PathIsEmpty(path, &isEmpty);
954     ASSERT_TRUE(isEmpty == true);
955     EXPECT_EQ(code, OH_DRAWING_SUCCESS);
956     OH_Drawing_ErrorCode code2 = OH_Drawing_PathIsEmpty(nullptr, &isEmpty);
957     EXPECT_EQ(code2, OH_DRAWING_ERROR_INVALID_PARAMETER);
958     OH_Drawing_ErrorCode code3 = OH_Drawing_PathIsEmpty(nullptr, nullptr);
959     EXPECT_EQ(code3, OH_DRAWING_ERROR_INVALID_PARAMETER);
960     OH_Drawing_ErrorCode code4 = OH_Drawing_PathIsEmpty(path, nullptr);
961     EXPECT_EQ(code4, OH_DRAWING_ERROR_INVALID_PARAMETER);
962     OH_Drawing_PathDestroy(path);
963 }
964 
965 /*
966  * @tc.name: NativeDrawingPathTest_OH_Drawing_PathIsRect042
967  * @tc.desc: test for if path is rect.
968  * @tc.type: FUNC
969  * @tc.require: AR000GTO5R
970  */
971 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_OH_Drawing_PathIsRect042, TestSize.Level1)
972 {
973     OH_Drawing_Path* path = OH_Drawing_PathCreate();
974     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 20, 20);
975     ASSERT_TRUE(path != nullptr);
976     ASSERT_TRUE(rect != nullptr);
977     bool isRect = false;
978     bool isEmpty = false;
979     OH_Drawing_ErrorCode code = OH_Drawing_PathIsRect(path, rect, &isRect);
980     ASSERT_TRUE(isRect == false);
981     EXPECT_EQ(code, OH_DRAWING_SUCCESS);
982     OH_Drawing_ErrorCode code2 = OH_Drawing_PathIsRect(nullptr, rect, &isEmpty);
983     EXPECT_EQ(code2, OH_DRAWING_ERROR_INVALID_PARAMETER);
984     OH_Drawing_ErrorCode code3 = OH_Drawing_PathIsRect(nullptr, nullptr, &isEmpty);
985     EXPECT_EQ(code3, OH_DRAWING_ERROR_INVALID_PARAMETER);
986     OH_Drawing_ErrorCode code4 = OH_Drawing_PathIsRect(path, nullptr, nullptr);
987     EXPECT_EQ(code4, OH_DRAWING_ERROR_INVALID_PARAMETER);
988     OH_Drawing_ErrorCode code5 = OH_Drawing_PathIsRect(path, nullptr, nullptr);
989     EXPECT_EQ(code5, OH_DRAWING_ERROR_INVALID_PARAMETER);
990     OH_Drawing_ErrorCode code6 = OH_Drawing_PathIsRect(nullptr, nullptr, nullptr);
991     EXPECT_EQ(code6, OH_DRAWING_ERROR_INVALID_PARAMETER);
992     OH_Drawing_ErrorCode code7 = OH_Drawing_PathIsRect(path, nullptr, &isEmpty);
993     EXPECT_EQ(code7, OH_DRAWING_SUCCESS);
994     OH_Drawing_ErrorCode code8 = OH_Drawing_PathIsRect(path, rect, nullptr);
995     EXPECT_EQ(code8, OH_DRAWING_ERROR_INVALID_PARAMETER);
996     OH_Drawing_PathDestroy(path);
997     OH_Drawing_RectDestroy(rect);
998 }
999 
1000 /*
1001  * @tc.name: NativeDrawingPathTest_OH_Drawing_PathGetFillType043
1002  * @tc.desc: test for gets Filltype.
1003  * @tc.type: FUNC
1004  * @tc.require: AR000GTO5R
1005  */
1006 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_OH_Drawing_PathGetFillType043, TestSize.Level1)
1007 {
1008     OH_Drawing_Path* path = OH_Drawing_PathCreate();
1009     ASSERT_TRUE(path != nullptr);
1010     OH_Drawing_PathFillType type;
1011     OH_Drawing_PathSetFillType(path, PATH_FILL_TYPE_WINDING);
1012     OH_Drawing_ErrorCode code = OH_Drawing_PathGetFillType(path, &type);
1013     EXPECT_EQ(code, OH_DRAWING_SUCCESS);
1014     EXPECT_EQ(type, PATH_FILL_TYPE_WINDING);
1015     OH_Drawing_ErrorCode code2 = OH_Drawing_PathGetFillType(nullptr, &type);
1016     EXPECT_EQ(code2, OH_DRAWING_ERROR_INVALID_PARAMETER);
1017     OH_Drawing_ErrorCode code3 = OH_Drawing_PathGetFillType(path, nullptr);
1018     EXPECT_EQ(code3, OH_DRAWING_ERROR_INVALID_PARAMETER);
1019     OH_Drawing_ErrorCode code4 = OH_Drawing_PathGetFillType(nullptr, nullptr);
1020     EXPECT_EQ(code4, OH_DRAWING_ERROR_INVALID_PARAMETER);
1021     OH_Drawing_PathDestroy(path);
1022 }
1023 
1024 /*
1025  * @tc.name: NativeDrawingPathTest_PathApproximate044
1026  * @tc.desc: test for OH_Drawing_PathApproximate.
1027  * @tc.type: FUNC
1028  * @tc.require: ICAWXU
1029  */
1030 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathApproximate044, TestSize.Level1)
1031 {
1032     OH_Drawing_Path* path = OH_Drawing_PathCreate();
1033     EXPECT_NE(path, nullptr);
1034     float acceptableError = 0.5f; // 0.5f is acceptableError
1035     uint32_t count = 0;
1036     EXPECT_EQ(OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count), OH_DRAWING_SUCCESS);
1037     EXPECT_EQ(count, 6); // 6 for the test
1038     float* points = new float[count];
1039     EXPECT_EQ(OH_Drawing_PathApproximate(nullptr, acceptableError, points, &count), OH_DRAWING_ERROR_INVALID_PARAMETER);
1040     EXPECT_EQ(OH_Drawing_PathApproximate(path, -1.0f, points, &count), OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
1041     EXPECT_EQ(OH_Drawing_PathApproximate(path, acceptableError, points, nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
1042     EXPECT_EQ(OH_Drawing_PathApproximate(path, acceptableError, points, &count), OH_DRAWING_SUCCESS);
1043     for (uint32_t i = 0; i < count; i += 3) { // 3 three values for each point
1044         scalar fraction = points[i];
1045         EXPECT_GE(fraction, 0.0f);
1046         EXPECT_LE(fraction, 1.0f);
1047         EXPECT_EQ(points[i + 1], 0.0f);
1048         EXPECT_EQ(points[i + 2], 0.0f); // 2 is the y value
1049     }
1050     if (points != nullptr) {
1051         delete[] points;
1052     }
1053     OH_Drawing_PathReset(path);
1054     uint32_t count2 = 0;
1055     OH_Drawing_PathMoveTo(path, 0, 0);
1056     OH_Drawing_PathLineTo(path, 5, 5);             // 5, 5 is the end point
1057     OH_Drawing_PathQuadTo(path, 10, 50, 100, 100); // 10, 50 is control point, 100, 100 is the end point
1058     // 150, 200 is control point, 250, 350 is the end point, 0.5f is the weight
1059     OH_Drawing_PathConicTo(path, 150, 200, 250, 350, 0.5f);
1060     // 350, 450, 450, 550 is the control point, 650, 750 is the end point
1061     OH_Drawing_PathCubicTo(path, 350, 450, 450, 550, 550, 650);
1062     OH_Drawing_PathClose(path);
1063     EXPECT_EQ(OH_Drawing_PathApproximate(path, acceptableError, nullptr, &count2), OH_DRAWING_SUCCESS);
1064     EXPECT_EQ(count2, 75);    // 75 for the test
1065     EXPECT_EQ(count2 % 3, 0); // 3 three values for each point
1066     float* points2 = new float[count2];
1067     EXPECT_EQ(OH_Drawing_PathApproximate(path, acceptableError, points2, &count2), OH_DRAWING_SUCCESS);
1068     for (uint32_t i = 0; i < count2; i += 3) { // 3 three values for each point
1069         scalar fraction = points2[i];
1070         EXPECT_GE(fraction, 0.0f);
1071         EXPECT_LE(fraction, 1.0f);
1072     }
1073     if (points2 != nullptr) {
1074         delete[] points2;
1075     }
1076     OH_Drawing_PathDestroy(path);
1077 }
1078 
1079 /*
1080  * @tc.name: NativeDrawingPathTest_PathInterpolate045
1081  * @tc.desc: test for OH_Drawing_PathInterpolate.
1082  * @tc.type: FUNC
1083  * @tc.require: ICAWXU
1084  */
1085 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathInterpolate045, TestSize.Level1)
1086 {
1087     OH_Drawing_Path* path = OH_Drawing_PathCreate();
1088     OH_Drawing_PathMoveTo(path, 50, 50); // 50, 50 is the start point
1089     OH_Drawing_PathLineTo(path, 100, 100); // 100, 100 is the control point
1090     OH_Drawing_PathLineTo(path, 200, 200); // 200, 200 is the end point
1091     OH_Drawing_Path* otherPath1 = OH_Drawing_PathCreate();
1092     OH_Drawing_PathMoveTo(otherPath1, 80, 200); // 80, 200 is the start point
1093     OH_Drawing_PathLineTo(otherPath1, 300, 300); // 300, 300 is the control point
1094     OH_Drawing_Path* otherPath2 = OH_Drawing_PathCreate();
1095     OH_Drawing_PathMoveTo(otherPath2, 100, 50); // 100, 50 is the start point
1096     OH_Drawing_PathLineTo(otherPath2, 200, 300); // 200, 300 is the control point
1097     OH_Drawing_PathLineTo(otherPath2, 300, 400); // 300, 400 is the end point
1098     OH_Drawing_Path* interpolatedPath = OH_Drawing_PathCreate();
1099     bool result = false;
1100     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 2.0, &result, interpolatedPath),
1101         OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); // 2.0 is weight
1102     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, -1.0, &result, interpolatedPath),
1103         OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); // -1.0 is weight
1104     EXPECT_EQ(OH_Drawing_PathInterpolate(nullptr, otherPath2, 0.5, &result, interpolatedPath),
1105         OH_DRAWING_ERROR_INVALID_PARAMETER); // 0.5 is weight
1106     EXPECT_EQ(OH_Drawing_PathInterpolate(path, nullptr, 0.5, &result, interpolatedPath),
1107         OH_DRAWING_ERROR_INVALID_PARAMETER); // 0.5 is weight
1108     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 0.5, nullptr, interpolatedPath),
1109         OH_DRAWING_ERROR_INVALID_PARAMETER); // 0.5 is weight
1110     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 0.5, &result, nullptr),
1111         OH_DRAWING_ERROR_INVALID_PARAMETER); // 0.5 is weight
1112     EXPECT_EQ(result, false);
1113     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath1, 0.0, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1114     EXPECT_EQ(result, false);
1115     // 0.5 is weight
1116     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath1, 0.5, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1117     EXPECT_EQ(result, false);
1118     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath1, 1.0, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1119     EXPECT_EQ(result, false);
1120     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 0.0, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1121     EXPECT_EQ(result, true);
1122     // 0.5 is weight
1123     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 0.5, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1124     EXPECT_EQ(result, true);
1125     EXPECT_EQ(OH_Drawing_PathInterpolate(path, otherPath2, 1.0, &result, interpolatedPath), OH_DRAWING_SUCCESS);
1126     EXPECT_EQ(result, true);
1127     OH_Drawing_PathDestroy(path);
1128     OH_Drawing_PathDestroy(otherPath1);
1129     OH_Drawing_PathDestroy(otherPath2);
1130     OH_Drawing_PathDestroy(interpolatedPath);
1131 }
1132 
1133 /*
1134  * @tc.name: NativeDrawingPathTest_PathIsInterpolate046
1135  * @tc.desc: test for OH_Drawing_PathIsInterpolate.
1136  * @tc.type: FUNC
1137  * @tc.require: ICAWXU
1138  */
1139 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_PathIsInterpolate046, TestSize.Level1)
1140 {
1141     OH_Drawing_Path* path1 = OH_Drawing_PathCreate();
1142     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
1143     bool result = false;
1144 
1145     EXPECT_EQ(OH_Drawing_PathIsInterpolate(nullptr, path2, &result), OH_DRAWING_ERROR_INVALID_PARAMETER);
1146     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, nullptr, &result), OH_DRAWING_ERROR_INVALID_PARAMETER);
1147     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
1148 
1149     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, &result), OH_DRAWING_SUCCESS);
1150     EXPECT_EQ(result, true);
1151 
1152     OH_Drawing_PathMoveTo(path1, 0, 0);
1153     OH_Drawing_PathLineTo(path1, 100, 100); // 100, 100 is the end point
1154     OH_Drawing_PathMoveTo(path2, 50, 50); // 50, 50 is the start point
1155     OH_Drawing_PathQuadTo(path2, 75, 75, 100, 100); // 75, 75 is the control point, 100, 100 is the end point
1156     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, &result), OH_DRAWING_SUCCESS);
1157     EXPECT_EQ(result, false);
1158 
1159     OH_Drawing_PathReset(path2);
1160     OH_Drawing_PathMoveTo(path2, 0, 1);
1161     OH_Drawing_PathLineTo(path2, 200, 200); // 200, 200 is the end point
1162     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, &result), OH_DRAWING_SUCCESS);
1163     EXPECT_EQ(result, true);
1164 
1165     OH_Drawing_PathConicTo(path1, 150, 150, 200, 200, 0.5f); // 150,150 is control, 200,200 is end, 0.5f is weight
1166     OH_Drawing_PathConicTo(path2, 150, 150, 200, 200, 0.5f); // 150,150 is control, 200,200 is end, 0.5f is weight
1167     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, &result), OH_DRAWING_SUCCESS);
1168     EXPECT_EQ(result, true);
1169 
1170     OH_Drawing_PathReset(path2);
1171     OH_Drawing_PathMoveTo(path2, 0, 0);
1172     OH_Drawing_PathLineTo(path2, 100, 100); // 100, 100 is the end point
1173     OH_Drawing_PathConicTo(path2, 150, 150, 200, 200, 0.8f); // 150,150 is control, 200,200 is end, 0.8f is weight
1174     EXPECT_EQ(OH_Drawing_PathIsInterpolate(path1, path2, &result), OH_DRAWING_SUCCESS);
1175     EXPECT_EQ(result, false);
1176 
1177     OH_Drawing_PathDestroy(path1);
1178     OH_Drawing_PathDestroy(path2);
1179 }
1180 } // namespace Drawing
1181 } // namespace Rosen
1182 } // namespace OHOS
1183