1 /*
2 * Copyright (c) 2022-2023 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, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "gtest/gtest.h"
17
18 #include "draw/path.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class PathTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp() override;
31 void TearDown() override;
32 };
33
SetUpTestCase()34 void PathTest::SetUpTestCase() {}
TearDownTestCase()35 void PathTest::TearDownTestCase() {}
SetUp()36 void PathTest::SetUp() {}
TearDown()37 void PathTest::TearDown() {}
38
39 /**
40 * @tc.name: CreateAndDestroy001
41 * @tc.desc:
42 * @tc.type: FUNC
43 * @tc.require: AR000GGNV3
44 * @tc.author:
45 */
HWTEST_F(PathTest, CreateAndDestroy001, TestSize.Level1)46 HWTEST_F(PathTest, CreateAndDestroy001, TestSize.Level1)
47 {
48 auto path = std::make_unique<Path>();
49 ASSERT_TRUE(path != nullptr);
50 }
51
52 /**
53 * @tc.name: BuildFromSVGString001
54 * @tc.desc: Test for Parsing the SVG format string and sets the Path.
55 * @tc.type: FUNC
56 * @tc.require: I715J0
57 */
HWTEST_F(PathTest, BuildFromSVGString001, TestSize.Level1)58 HWTEST_F(PathTest, BuildFromSVGString001, TestSize.Level1)
59 {
60 auto path = std::make_unique<Path>();
61 ASSERT_TRUE(path != nullptr);
62 std::string str;
63 EXPECT_TRUE(path->BuildFromSVGString(str));
64 }
65
66 /**
67 * @tc.name: BuildFromSVGString002
68 * @tc.desc: Test for Parsing the SVG format string and sets the Path.
69 * @tc.type: FUNC
70 * @tc.require: I715J0
71 */
HWTEST_F(PathTest, BuildFromSVGString002, TestSize.Level1)72 HWTEST_F(PathTest, BuildFromSVGString002, TestSize.Level1)
73 {
74 auto path = std::make_unique<Path>();
75 ASSERT_TRUE(path != nullptr);
76 std::string str = "string";
77 EXPECT_FALSE(path->BuildFromSVGString(str));
78 }
79
80 /**
81 * @tc.name: BuildFromSVGString003
82 * @tc.desc: Test for Parsing the SVG format string and sets the Path.
83 * @tc.type: FUNC
84 * @tc.require: I715J0
85 */
HWTEST_F(PathTest, BuildFromSVGString003, TestSize.Level1)86 HWTEST_F(PathTest, BuildFromSVGString003, TestSize.Level1)
87 {
88 auto path = std::make_unique<Path>();
89 ASSERT_TRUE(path != nullptr);
90 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
91 EXPECT_TRUE(path->BuildFromSVGString(path->ConvertToSVGString()));
92 }
93
94 /**
95 * @tc.name: ConvertToSVGString001
96 * @tc.desc: Test for Parsing into a string in SVG format that describes the Path.
97 * @tc.type: FUNC
98 * @tc.require: I715J0
99 */
HWTEST_F(PathTest, ConvertToSVGString001, TestSize.Level1)100 HWTEST_F(PathTest, ConvertToSVGString001, TestSize.Level1)
101 {
102 auto path = std::make_unique<Path>();
103 ASSERT_TRUE(path != nullptr);
104 EXPECT_EQ(path->ConvertToSVGString(), "");
105 }
106
107 /**
108 * @tc.name: ConvertToSVGString002
109 * @tc.desc: Test for Parsing into a string in SVG format that describes the Path.
110 * @tc.type: FUNC
111 * @tc.require: I715J0
112 */
HWTEST_F(PathTest, ConvertToSVGString002, TestSize.Level1)113 HWTEST_F(PathTest, ConvertToSVGString002, TestSize.Level1)
114 {
115 auto path = std::make_unique<Path>();
116 ASSERT_TRUE(path != nullptr);
117 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
118 EXPECT_TRUE(path->ConvertToSVGString() != "");
119 }
120
121 /**
122 * @tc.name: MoveTo001
123 * @tc.desc:
124 * @tc.type: FUNC
125 * @tc.require: AR000GGNV3
126 * @tc.author:
127 */
HWTEST_F(PathTest, MoveTo001, TestSize.Level1)128 HWTEST_F(PathTest, MoveTo001, TestSize.Level1)
129 {
130 auto path = std::make_unique<Path>();
131 ASSERT_TRUE(path != nullptr);
132 path->MoveTo(5.0f, 4.5f);
133 }
134
135 /**
136 * @tc.name: MoveTo002
137 * @tc.desc:
138 * @tc.type: FUNC
139 * @tc.require: AR000GGNV3
140 * @tc.author:
141 */
HWTEST_F(PathTest, MoveTo002, TestSize.Level1)142 HWTEST_F(PathTest, MoveTo002, TestSize.Level1)
143 {
144 auto path = std::make_unique<Path>();
145 ASSERT_TRUE(path != nullptr);
146 path->MoveTo(4.5f, 5.0f);
147 }
148
149 /**
150 * @tc.name: LineTo001
151 * @tc.desc:
152 * @tc.type: FUNC
153 * @tc.require: AR000GGNV3
154 * @tc.author:
155 */
HWTEST_F(PathTest, LineTo001, TestSize.Level1)156 HWTEST_F(PathTest, LineTo001, TestSize.Level1)
157 {
158 auto path = std::make_unique<Path>();
159 ASSERT_TRUE(path != nullptr);
160 path->LineTo(4.5f, 5.0f);
161 }
162
163 /**
164 * @tc.name: LineTo002
165 * @tc.desc:
166 * @tc.type: FUNC
167 * @tc.require: AR000GGNV3
168 * @tc.author:
169 */
HWTEST_F(PathTest, LineTo002, TestSize.Level1)170 HWTEST_F(PathTest, LineTo002, TestSize.Level1)
171 {
172 auto path = std::make_unique<Path>();
173 ASSERT_TRUE(path != nullptr);
174 path->LineTo(1.0f, 3.0f);
175 }
176
177 /**
178 * @tc.name: ArcTo001
179 * @tc.desc:
180 * @tc.type: FUNC
181 * @tc.require: AR000GGNV3
182 * @tc.author:
183 */
HWTEST_F(PathTest, ArcTo001, TestSize.Level1)184 HWTEST_F(PathTest, ArcTo001, TestSize.Level1)
185 {
186 auto path = std::make_unique<Path>();
187 ASSERT_TRUE(path != nullptr);
188 path->ArcTo(1.0f, 3.0f, 2.2f, 2.3f, 0.0f, 5.0f);
189 }
190
191 /**
192 * @tc.name: ArcTo002
193 * @tc.desc:
194 * @tc.type: FUNC
195 * @tc.require: AR000GGNV3
196 * @tc.author:
197 */
HWTEST_F(PathTest, ArcTo002, TestSize.Level1)198 HWTEST_F(PathTest, ArcTo002, TestSize.Level1)
199 {
200 auto path = std::make_unique<Path>();
201 ASSERT_TRUE(path != nullptr);
202 path->ArcTo(1.0f, 3.0f, 2.5f, 2.4f, 1.0f, 3.0f);
203 }
204
205 /**
206 * @tc.name: ArcTo003
207 * @tc.desc: Arc To Direction Test
208 * @tc.type: FUNC
209 * @tc.require: issuel#I6Q4ZH
210 */
HWTEST_F(PathTest, ArcTo003, TestSize.Level2)211 HWTEST_F(PathTest, ArcTo003, TestSize.Level2)
212 {
213 Path path;
214 path.ArcTo(1.0f, 3.0f, 2.5f, PathDirection::CCW_DIRECTION, 1.0f, 3.0f);
215 }
216
217 /**
218 * @tc.name: ArcToWith6001
219 * @tc.desc:
220 * @tc.type: FUNC
221 * @tc.require: AR000GGNV3
222 * @tc.author:
223 */
HWTEST_F(PathTest, ArcToWith6001, TestSize.Level1)224 HWTEST_F(PathTest, ArcToWith6001, TestSize.Level1)
225 {
226 auto path = std::make_unique<Path>();
227 ASSERT_TRUE(path != nullptr);
228 Point point1;
229 Point point2;
230 path->ArcTo(point1, point2, 2.5f, 2.4f);
231 }
232
233 /**
234 * @tc.name: ArcToWith6002
235 * @tc.desc:
236 * @tc.type: FUNC
237 * @tc.require: AR000GGNV3
238 * @tc.author:
239 */
HWTEST_F(PathTest, ArcToWith6002, TestSize.Level1)240 HWTEST_F(PathTest, ArcToWith6002, TestSize.Level1)
241 {
242 auto path = std::make_unique<Path>();
243 ASSERT_TRUE(path != nullptr);
244 Point point1;
245 Point point2;
246 path->ArcTo(point1, point2, 2.5f, 2.0f);
247 }
248
249 /**
250 * @tc.name: CubicTo001
251 * @tc.desc:
252 * @tc.type: FUNC
253 * @tc.require: AR000GGNV3
254 * @tc.author:
255 */
HWTEST_F(PathTest, CubicTo001, TestSize.Level1)256 HWTEST_F(PathTest, CubicTo001, TestSize.Level1)
257 {
258 auto path = std::make_unique<Path>();
259 ASSERT_TRUE(path != nullptr);
260 path->CubicTo(1.0f, 2.3f, 2.5f, 2.0f, 3.5f, 3.0f);
261 }
262
263 /**
264 * @tc.name: CubicTo002
265 * @tc.desc:
266 * @tc.type: FUNC
267 * @tc.require: AR000GGNV3
268 * @tc.author:
269 */
HWTEST_F(PathTest, CubicTo002, TestSize.Level1)270 HWTEST_F(PathTest, CubicTo002, TestSize.Level1)
271 {
272 auto path = std::make_unique<Path>();
273 ASSERT_TRUE(path != nullptr);
274 path->CubicTo(1.0f, 2.3f, 1.4f, 2.0f, 1.5f, 3.0f);
275 }
276
277 /**
278 * @tc.name: CubicTo2001
279 * @tc.desc:
280 * @tc.type: FUNC
281 * @tc.require: AR000GGNV3
282 * @tc.author:
283 */
HWTEST_F(PathTest, CubicTo2001, TestSize.Level1)284 HWTEST_F(PathTest, CubicTo2001, TestSize.Level1)
285 {
286 auto path = std::make_unique<Path>();
287 ASSERT_TRUE(path != nullptr);
288 Point point1;
289 Point point2;
290 Point endPoint(2.3f, 1.5f);
291 path->CubicTo(point1, point2, endPoint);
292 }
293
294 /**
295 * @tc.name: CubicTo2002
296 * @tc.desc:
297 * @tc.type: FUNC
298 * @tc.require: AR000GGNV3
299 * @tc.author:
300 */
HWTEST_F(PathTest, CubicTo2002, TestSize.Level1)301 HWTEST_F(PathTest, CubicTo2002, TestSize.Level1)
302 {
303 auto path = std::make_unique<Path>();
304 ASSERT_TRUE(path != nullptr);
305 Point point1(1.2f, 0.0f);
306 Point point2(1.3f, 1.0f);
307 Point endPoint(2.3f, 1.5f);
308 path->CubicTo(point1, point2, endPoint);
309 }
310
311 /**
312 * @tc.name: QuadTo2001
313 * @tc.desc:
314 * @tc.type: FUNC
315 * @tc.require: AR000GGNV3
316 * @tc.author:
317 */
HWTEST_F(PathTest, QuadTo2001, TestSize.Level1)318 HWTEST_F(PathTest, QuadTo2001, TestSize.Level1)
319 {
320 auto path = std::make_unique<Path>();
321 ASSERT_TRUE(path != nullptr);
322 Point point1(1.2f, 0.0f);
323 Point endPoint(2.3f, 1.5f);
324 path->QuadTo(point1, endPoint);
325 }
326
327 /**
328 * @tc.name: QuadTo2002
329 * @tc.desc:
330 * @tc.type: FUNC
331 * @tc.require: AR000GGNV3
332 * @tc.author:
333 */
HWTEST_F(PathTest, QuadTo2002, TestSize.Level1)334 HWTEST_F(PathTest, QuadTo2002, TestSize.Level1)
335 {
336 auto path = std::make_unique<Path>();
337 ASSERT_TRUE(path != nullptr);
338 Point point1(0.5f, 0.3f);
339 Point endPoint(3.5f, 3.3f);
340 path->QuadTo(point1, endPoint);
341 }
342
343 /**
344 * @tc.name: QuadTo4001
345 * @tc.desc:
346 * @tc.type: FUNC
347 * @tc.require: AR000GGNV3
348 * @tc.author:
349 */
HWTEST_F(PathTest, QuadTo4001, TestSize.Level1)350 HWTEST_F(PathTest, QuadTo4001, TestSize.Level1)
351 {
352 auto path = std::make_unique<Path>();
353 ASSERT_TRUE(path != nullptr);
354 path->QuadTo(1.0f, 1.5f, 3.3f, 4.5f);
355 }
356
357 /**
358 * @tc.name: QuadTo4002
359 * @tc.desc:
360 * @tc.type: FUNC
361 * @tc.require: AR000GGNV3
362 * @tc.author:
363 */
HWTEST_F(PathTest, QuadTo4002, TestSize.Level1)364 HWTEST_F(PathTest, QuadTo4002, TestSize.Level1)
365 {
366 auto path = std::make_unique<Path>();
367 ASSERT_TRUE(path != nullptr);
368 path->QuadTo(1.0f, 1.2f, 3.0f, 4.0f);
369 }
370
371 /**
372 * @tc.name: AddRect2001
373 * @tc.desc:
374 * @tc.type: FUNC
375 * @tc.require: AR000GGNV3
376 * @tc.author:
377 */
HWTEST_F(PathTest, AddRect2001, TestSize.Level1)378 HWTEST_F(PathTest, AddRect2001, TestSize.Level1)
379 {
380 auto path = std::make_unique<Path>();
381 ASSERT_TRUE(path != nullptr);
382 Rect rect;
383 path->AddRect(rect);
384 }
385
386 /**
387 * @tc.name: AddRect2002
388 * @tc.desc:
389 * @tc.type: FUNC
390 * @tc.require: AR000GGNV3
391 * @tc.author:
392 */
HWTEST_F(PathTest, AddRect2002, TestSize.Level1)393 HWTEST_F(PathTest, AddRect2002, TestSize.Level1)
394 {
395 auto path = std::make_unique<Path>();
396 ASSERT_TRUE(path != nullptr);
397 Rect rect;
398 path->AddRect(rect, PathDirection::CCW_DIRECTION);
399 }
400
401 /**
402 * @tc.name: AddRect5001
403 * @tc.desc:
404 * @tc.type: FUNC
405 * @tc.require: AR000GGNV3
406 * @tc.author:
407 */
HWTEST_F(PathTest, AddRect5001, TestSize.Level1)408 HWTEST_F(PathTest, AddRect5001, TestSize.Level1)
409 {
410 auto path = std::make_unique<Path>();
411 ASSERT_TRUE(path != nullptr);
412 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f, PathDirection::CCW_DIRECTION);
413 }
414
415 /**
416 * @tc.name: AddRect5002
417 * @tc.desc:
418 * @tc.type: FUNC
419 * @tc.require: AR000GGNV3
420 * @tc.author:
421 */
HWTEST_F(PathTest, AddRect5002, TestSize.Level1)422 HWTEST_F(PathTest, AddRect5002, TestSize.Level1)
423 {
424 auto path = std::make_unique<Path>();
425 ASSERT_TRUE(path != nullptr);
426 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
427 }
428
429 /**
430 * @tc.name: AddOval001
431 * @tc.desc:
432 * @tc.type: FUNC
433 * @tc.require: AR000GGNV3
434 * @tc.author:
435 */
HWTEST_F(PathTest, AddOval001, TestSize.Level1)436 HWTEST_F(PathTest, AddOval001, TestSize.Level1)
437 {
438 auto path = std::make_unique<Path>();
439 ASSERT_TRUE(path != nullptr);
440 Rect oval;
441 path->AddOval(oval, PathDirection::CCW_DIRECTION);
442 }
443
444 /**
445 * @tc.name: AddOval002
446 * @tc.desc:
447 * @tc.type: FUNC
448 * @tc.require: AR000GGNV3
449 * @tc.author:
450 */
HWTEST_F(PathTest, AddOval002, TestSize.Level1)451 HWTEST_F(PathTest, AddOval002, TestSize.Level1)
452 {
453 auto path = std::make_unique<Path>();
454 ASSERT_TRUE(path != nullptr);
455 Rect oval;
456 path->AddOval(oval);
457 }
458
459 /**
460 * @tc.name: AddArc001
461 * @tc.desc:
462 * @tc.type: FUNC
463 * @tc.require: AR000GGNV3
464 * @tc.author:
465 */
HWTEST_F(PathTest, AddArc001, TestSize.Level1)466 HWTEST_F(PathTest, AddArc001, TestSize.Level1)
467 {
468 auto path = std::make_unique<Path>();
469 ASSERT_TRUE(path != nullptr);
470 Rect rect;
471 path->AddArc(rect, 1.0f, 2.0f);
472 }
473
474 /**
475 * @tc.name: AddArc002
476 * @tc.desc:
477 * @tc.type: FUNC
478 * @tc.require: AR000GGNV3
479 * @tc.author:
480 */
HWTEST_F(PathTest, AddArc002, TestSize.Level1)481 HWTEST_F(PathTest, AddArc002, TestSize.Level1)
482 {
483 auto path = std::make_unique<Path>();
484 ASSERT_TRUE(path != nullptr);
485 Rect rect;
486 path->AddArc(rect, 2.0f, 1.0f);
487 }
488
489 /**
490 * @tc.name: AddPoly001
491 * @tc.desc:
492 * @tc.type: FUNC
493 * @tc.require: AR000GGNV3
494 * @tc.author:
495 */
HWTEST_F(PathTest, AddPoly001, TestSize.Level1)496 HWTEST_F(PathTest, AddPoly001, TestSize.Level1)
497 {
498 auto path = std::make_unique<Path>();
499 ASSERT_TRUE(path != nullptr);
500 std::vector<Point> points;
501 Point point1;
502 points.push_back(point1);
503 int size = points.size();
504 path->AddPoly(points, size, false);
505 }
506
507 /**
508 * @tc.name: AddPoly002
509 * @tc.desc:
510 * @tc.type: FUNC
511 * @tc.require: AR000GGNV3
512 * @tc.author:
513 */
HWTEST_F(PathTest, AddPoly002, TestSize.Level1)514 HWTEST_F(PathTest, AddPoly002, TestSize.Level1)
515 {
516 auto path = std::make_unique<Path>();
517 ASSERT_TRUE(path != nullptr);
518 std::vector<Point> points;
519 Point point1;
520 Point point2;
521 points.push_back(point1);
522 points.push_back(point2);
523 int size = points.size();
524 path->AddPoly(points, size, true);
525 }
526
527 /**
528 * @tc.name: AddCircle001
529 * @tc.desc:
530 * @tc.type: FUNC
531 * @tc.require: AR000GGNV3
532 * @tc.author:
533 */
HWTEST_F(PathTest, AddCircle001, TestSize.Level1)534 HWTEST_F(PathTest, AddCircle001, TestSize.Level1)
535 {
536 auto path = std::make_unique<Path>();
537 ASSERT_TRUE(path != nullptr);
538 path->AddCircle(1.0f, 0.5f, 0.5f);
539 }
540
541 /**
542 * @tc.name: AddCircle002
543 * @tc.desc:
544 * @tc.type: FUNC
545 * @tc.require: AR000GGNV3
546 * @tc.author:
547 */
HWTEST_F(PathTest, AddCircle002, TestSize.Level1)548 HWTEST_F(PathTest, AddCircle002, TestSize.Level1)
549 {
550 auto path = std::make_unique<Path>();
551 ASSERT_TRUE(path != nullptr);
552 path->AddCircle(1.0f, 0.5f, 0.5f, PathDirection::CCW_DIRECTION);
553 }
554
555 /**
556 * @tc.name: AddRoundRect001
557 * @tc.desc:
558 * @tc.type: FUNC
559 * @tc.require: AR000GGNV3
560 * @tc.author:
561 */
HWTEST_F(PathTest, AddRoundRect001, TestSize.Level1)562 HWTEST_F(PathTest, AddRoundRect001, TestSize.Level1)
563 {
564 auto path = std::make_unique<Path>();
565 ASSERT_TRUE(path != nullptr);
566 Rect rect;
567 path->AddRoundRect(rect, 0.5f, 0.5f, PathDirection::CCW_DIRECTION);
568 }
569
570 /**
571 * @tc.name: AddRoundRect002
572 * @tc.desc:
573 * @tc.type: FUNC
574 * @tc.require: AR000GGNV3
575 * @tc.author:
576 */
HWTEST_F(PathTest, AddRoundRect002, TestSize.Level1)577 HWTEST_F(PathTest, AddRoundRect002, TestSize.Level1)
578 {
579 auto path = std::make_unique<Path>();
580 ASSERT_TRUE(path != nullptr);
581 Rect rect;
582 path->AddRoundRect(rect, 0.5f, 0.5f);
583 }
584
585 /**
586 * @tc.name: AddRoundRect003
587 * @tc.desc: Test for adding the circle rectangle to the Path.
588 * @tc.type: FUNC
589 * @tc.require: I715J0
590 */
HWTEST_F(PathTest, AddRoundRect003, TestSize.Level1)591 HWTEST_F(PathTest, AddRoundRect003, TestSize.Level1)
592 {
593 auto path = std::make_unique<Path>();
594 ASSERT_TRUE(path != nullptr);
595 RoundRect roundRect;
596 path->AddRoundRect(roundRect, PathDirection::CCW_DIRECTION);
597 }
598
599 /**
600 * @tc.name: AddRoundRect004
601 * @tc.desc: Test for adding the circle rectangle to the Path.
602 * @tc.type: FUNC
603 * @tc.require: I715J0
604 */
HWTEST_F(PathTest, AddRoundRect004, TestSize.Level1)605 HWTEST_F(PathTest, AddRoundRect004, TestSize.Level1)
606 {
607 auto path = std::make_unique<Path>();
608 ASSERT_TRUE(path != nullptr);
609 RoundRect roundRect;
610 path->AddRoundRect(roundRect);
611 }
612
613 /**
614 * @tc.name: AddRoundRect005
615 * @tc.desc: Test for adding the circle rectangle to the Path.
616 * @tc.type: FUNC
617 * @tc.require: I715J0
618 */
HWTEST_F(PathTest, AddRoundRect005, TestSize.Level1)619 HWTEST_F(PathTest, AddRoundRect005, TestSize.Level1)
620 {
621 auto path = std::make_unique<Path>();
622 ASSERT_TRUE(path != nullptr);
623 Rect rect;
624 RoundRect roundRect(rect, 12.6f, 77.4f);
625 path->AddRoundRect(roundRect);
626 }
627
628 /**
629 * @tc.name: AddPath3001
630 * @tc.desc:
631 * @tc.type: FUNC
632 * @tc.require: AR000GGNV3
633 * @tc.author:
634 */
HWTEST_F(PathTest, AddPath3001, TestSize.Level1)635 HWTEST_F(PathTest, AddPath3001, TestSize.Level1)
636 {
637 auto path = std::make_unique<Path>();
638 ASSERT_TRUE(path != nullptr);
639 Path sourcePath;
640 path->AddPath(sourcePath, 0.5f, 0.5f);
641 }
642
643 /**
644 * @tc.name: AddPath3002
645 * @tc.desc:
646 * @tc.type: FUNC
647 * @tc.require: AR000GGNV3
648 * @tc.author:
649 */
HWTEST_F(PathTest, AddPath3002, TestSize.Level1)650 HWTEST_F(PathTest, AddPath3002, TestSize.Level1)
651 {
652 auto path = std::make_unique<Path>();
653 ASSERT_TRUE(path != nullptr);
654 Path sourcePath;
655 path->AddPath(sourcePath, 1.0f, 1.0f);
656 }
657
658 /**
659 * @tc.name: AddPath1001
660 * @tc.desc:
661 * @tc.type: FUNC
662 * @tc.require: AR000GGNV3
663 * @tc.author:
664 */
HWTEST_F(PathTest, AddPath1001, TestSize.Level1)665 HWTEST_F(PathTest, AddPath1001, TestSize.Level1)
666 {
667 auto path = std::make_unique<Path>();
668 ASSERT_TRUE(path != nullptr);
669 Path sourcePath;
670 path->AddPath(sourcePath);
671 }
672
673 /**
674 * @tc.name: AddPath2001
675 * @tc.desc:
676 * @tc.type: FUNC
677 * @tc.require: AR000GGNV3
678 * @tc.author:
679 */
HWTEST_F(PathTest, AddPath2001, TestSize.Level1)680 HWTEST_F(PathTest, AddPath2001, TestSize.Level1)
681 {
682 auto path = std::make_unique<Path>();
683 ASSERT_TRUE(path != nullptr);
684 Path path1;
685 Matrix matrix;
686 path->AddPath(path1, matrix);
687 }
688
689 /**
690 * @tc.name: AddPath2002
691 * @tc.desc:
692 * @tc.type: FUNC
693 * @tc.require: AR000GGNV3
694 * @tc.author:
695 */
HWTEST_F(PathTest, AddPath2002, TestSize.Level1)696 HWTEST_F(PathTest, AddPath2002, TestSize.Level1)
697 {
698 auto path = std::make_unique<Path>();
699 ASSERT_TRUE(path != nullptr);
700 Path path1;
701 Matrix matrix;
702 path->AddPath(path1, matrix);
703 }
704
705 /**
706 * @tc.name: ReverseAddPath001
707 * @tc.desc: Test for adding the src from back forward to the Path.
708 * @tc.type: FUNC
709 * @tc.require: I715J0
710 */
HWTEST_F(PathTest, ReverseAddPath001, TestSize.Level1)711 HWTEST_F(PathTest, ReverseAddPath001, TestSize.Level1)
712 {
713 auto path = std::make_unique<Path>();
714 ASSERT_TRUE(path != nullptr);
715 Path path1;
716 path->ReverseAddPath(path1);
717 }
718
719 /**
720 * @tc.name: ReverseAddPath002
721 * @tc.desc: Test for adding the src from back forward to the Path.
722 * @tc.type: FUNC
723 * @tc.require: I715J0
724 */
HWTEST_F(PathTest, ReverseAddPath002, TestSize.Level1)725 HWTEST_F(PathTest, ReverseAddPath002, TestSize.Level1)
726 {
727 auto path = std::make_unique<Path>();
728 ASSERT_TRUE(path != nullptr);
729 Path path2;
730 path2.AddRect(1.0f, 4.0f, 3.0f, 2.0f);
731 path->ReverseAddPath(path2);
732 }
733
734 /**
735 * @tc.name: GetBounds001
736 * @tc.desc:
737 * @tc.type: FUNC
738 * @tc.require: AR000GGNV3
739 * @tc.author:
740 */
HWTEST_F(PathTest, GetBounds001, TestSize.Level1)741 HWTEST_F(PathTest, GetBounds001, TestSize.Level1)
742 {
743 auto path = std::make_unique<Path>();
744 ASSERT_TRUE(path != nullptr);
745 auto rect = path->GetBounds();
746 }
747
748 /**
749 * @tc.name: SetFillStyle001
750 * @tc.desc:
751 * @tc.type: FUNC
752 * @tc.require: AR000GGNV3
753 * @tc.author:
754 */
HWTEST_F(PathTest, SetFillStyle001, TestSize.Level1)755 HWTEST_F(PathTest, SetFillStyle001, TestSize.Level1)
756 {
757 auto path = std::make_unique<Path>();
758 ASSERT_TRUE(path != nullptr);
759 path->SetFillStyle(PathFillType::WINDING);
760 }
761
762 /**
763 * @tc.name: SetFillStyle002
764 * @tc.desc:
765 * @tc.type: FUNC
766 * @tc.require: AR000GGNV3
767 * @tc.author:
768 */
HWTEST_F(PathTest, SetFillStyle002, TestSize.Level1)769 HWTEST_F(PathTest, SetFillStyle002, TestSize.Level1)
770 {
771 auto path = std::make_unique<Path>();
772 ASSERT_TRUE(path != nullptr);
773 path->SetFillStyle(PathFillType::INVERSE_WINDING);
774 }
775
776 /**
777 * @tc.name: Interpolate001
778 * @tc.desc:
779 * @tc.type: FUNC
780 * @tc.require: AR000GGNV3
781 * @tc.author:
782 */
HWTEST_F(PathTest, Interpolate001, TestSize.Level1)783 HWTEST_F(PathTest, Interpolate001, TestSize.Level1)
784 {
785 auto path = std::make_unique<Path>();
786 ASSERT_TRUE(path != nullptr);
787 Path ending;
788 Path out;
789 path->Interpolate(ending, 0.5f, out);
790 }
791
792 /**
793 * @tc.name: Interpolate002
794 * @tc.desc:
795 * @tc.type: FUNC
796 * @tc.require: AR000GGNV3
797 * @tc.author:
798 */
HWTEST_F(PathTest, Interpolate002, TestSize.Level1)799 HWTEST_F(PathTest, Interpolate002, TestSize.Level1)
800 {
801 auto path = std::make_unique<Path>();
802 ASSERT_TRUE(path != nullptr);
803 Path ending;
804 Path out;
805 path->Interpolate(ending, 0.2f, out);
806 }
807
808 /**
809 * @tc.name: Transform001
810 * @tc.desc:
811 * @tc.type: FUNC
812 * @tc.require: AR000GGNV3
813 * @tc.author:
814 */
HWTEST_F(PathTest, Transform001, TestSize.Level1)815 HWTEST_F(PathTest, Transform001, TestSize.Level1)
816 {
817 auto path = std::make_unique<Path>();
818 ASSERT_TRUE(path != nullptr);
819 Matrix matrix;
820 path->Transform(matrix);
821 }
822
823 /**
824 * @tc.name: Offset001
825 * @tc.desc:
826 * @tc.type: FUNC
827 * @tc.require: AR000GGNV3
828 * @tc.author:
829 */
HWTEST_F(PathTest, Offset001, TestSize.Level1)830 HWTEST_F(PathTest, Offset001, TestSize.Level1)
831 {
832 auto path = std::make_unique<Path>();
833 ASSERT_TRUE(path != nullptr);
834 path->Offset(1.0f, 2.3f);
835 }
836
837 /**
838 * @tc.name: Offset002
839 * @tc.desc:
840 * @tc.type: FUNC
841 * @tc.require: AR000GGNV3
842 * @tc.author:
843 */
HWTEST_F(PathTest, Offset002, TestSize.Level1)844 HWTEST_F(PathTest, Offset002, TestSize.Level1)
845 {
846 auto path = std::make_unique<Path>();
847 ASSERT_TRUE(path != nullptr);
848 path->Offset(2.3f, 1.0f);
849 }
850
851 /**
852 * @tc.name: Op001
853 * @tc.desc:
854 * @tc.type: FUNC
855 * @tc.require: AR000GGNV3
856 * @tc.author:
857 */
HWTEST_F(PathTest, Op001, TestSize.Level1)858 HWTEST_F(PathTest, Op001, TestSize.Level1)
859 {
860 auto path = std::make_unique<Path>();
861 ASSERT_TRUE(path != nullptr);
862 Path path1;
863 Path path2;
864 path->Op(path1, path2, PathOp::INTERSECT);
865 }
866
867 /**
868 * @tc.name: Op002
869 * @tc.desc:
870 * @tc.type: FUNC
871 * @tc.require: AR000GGNV3
872 * @tc.author:
873 */
HWTEST_F(PathTest, Op002, TestSize.Level1)874 HWTEST_F(PathTest, Op002, TestSize.Level1)
875 {
876 auto path = std::make_unique<Path>();
877 ASSERT_TRUE(path != nullptr);
878 Path path1;
879 Path path2;
880 path->Op(path1, path2, PathOp::UNION);
881 }
882
883 /**
884 * @tc.name: IsValid001
885 * @tc.desc: Test for Checking whether the Path is valid.
886 * @tc.type: FUNC
887 * @tc.require: I715J0
888 */
HWTEST_F(PathTest, IsValid001, TestSize.Level1)889 HWTEST_F(PathTest, IsValid001, TestSize.Level1)
890 {
891 auto path = std::make_unique<Path>();
892 ASSERT_TRUE(path != nullptr);
893 EXPECT_FALSE(path->IsValid());
894 }
895
896 /**
897 * @tc.name: IsValid002
898 * @tc.desc: Test for Checking whether the Path is valid.
899 * @tc.type: FUNC
900 * @tc.require: I715J0
901 */
HWTEST_F(PathTest, IsValid002, TestSize.Level1)902 HWTEST_F(PathTest, IsValid002, TestSize.Level1)
903 {
904 auto path = std::make_unique<Path>();
905 ASSERT_TRUE(path != nullptr);
906 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
907 EXPECT_TRUE(path->IsValid());
908 }
909
910 /**
911 * @tc.name: Reset001
912 * @tc.desc:
913 * @tc.type: FUNC
914 * @tc.require: AR000GGNV3
915 * @tc.author:
916 */
HWTEST_F(PathTest, Reset001, TestSize.Level1)917 HWTEST_F(PathTest, Reset001, TestSize.Level1)
918 {
919 auto path = std::make_unique<Path>();
920 ASSERT_TRUE(path != nullptr);
921 path->Reset();
922 }
923
924 /**
925 * @tc.name: Close001
926 * @tc.desc:
927 * @tc.type: FUNC
928 * @tc.require: AR000GGNV3
929 * @tc.author:
930 */
HWTEST_F(PathTest, Close001, TestSize.Level1)931 HWTEST_F(PathTest, Close001, TestSize.Level1)
932 {
933 auto path = std::make_unique<Path>();
934 ASSERT_TRUE(path != nullptr);
935 path->Close();
936 }
937
938 /**
939 * @tc.name: GetLength001
940 * @tc.desc: Test for geting the length of the current path object.
941 * @tc.type: FUNC
942 * @tc.require: I715J0
943 */
HWTEST_F(PathTest, GetLength001, TestSize.Level1)944 HWTEST_F(PathTest, GetLength001, TestSize.Level1)
945 {
946 auto path = std::make_unique<Path>();
947 ASSERT_TRUE(path != nullptr);
948 EXPECT_EQ(path->GetLength(false), 0);
949 }
950
951 /**
952 * @tc.name: GetLength002
953 * @tc.desc: Test for geting the length of the current path object.
954 * @tc.type: FUNC
955 * @tc.require: I715J0
956 */
HWTEST_F(PathTest, GetLength002, TestSize.Level1)957 HWTEST_F(PathTest, GetLength002, TestSize.Level1)
958 {
959 auto path = std::make_unique<Path>();
960 ASSERT_TRUE(path != nullptr);
961 EXPECT_EQ(path->GetLength(true), 0);
962 }
963
964 /**
965 * @tc.name: GetLength003
966 * @tc.desc: Test for geting the length of the current path object.
967 * @tc.type: FUNC
968 * @tc.require: I715J0
969 */
HWTEST_F(PathTest, GetLength003, TestSize.Level1)970 HWTEST_F(PathTest, GetLength003, TestSize.Level1)
971 {
972 auto path = std::make_unique<Path>();
973 ASSERT_TRUE(path != nullptr);
974 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
975 EXPECT_EQ(path->GetLength(true), 8);
976 }
977
978 /**
979 * @tc.name: GetPositionAndTangent001
980 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
981 * @tc.type: FUNC
982 * @tc.require: I715J0
983 */
HWTEST_F(PathTest, GetPositionAndTangent001, TestSize.Level1)984 HWTEST_F(PathTest, GetPositionAndTangent001, TestSize.Level1)
985 {
986 auto path = std::make_unique<Path>();
987 ASSERT_TRUE(path != nullptr);
988 Point point1;
989 Point point2;
990 EXPECT_FALSE(path->GetPositionAndTangent(0, point1, point2, false));
991 }
992
993 /**
994 * @tc.name: GetPositionAndTangent002
995 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
996 * @tc.type: FUNC
997 * @tc.require: I715J0
998 */
HWTEST_F(PathTest, GetPositionAndTangent002, TestSize.Level1)999 HWTEST_F(PathTest, GetPositionAndTangent002, TestSize.Level1)
1000 {
1001 auto path = std::make_unique<Path>();
1002 ASSERT_TRUE(path != nullptr);
1003 Point point1;
1004 Point point2;
1005 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
1006 EXPECT_TRUE(path->GetPositionAndTangent(10, point1, point2, true));
1007 }
1008
1009 /**
1010 * @tc.name: GetPositionAndTangent003
1011 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
1012 * @tc.type: FUNC
1013 * @tc.require: I715J0
1014 */
HWTEST_F(PathTest, GetPositionAndTangent003, TestSize.Level1)1015 HWTEST_F(PathTest, GetPositionAndTangent003, TestSize.Level1)
1016 {
1017 auto path = std::make_unique<Path>();
1018 ASSERT_TRUE(path != nullptr);
1019 Point point1(0.5f, 0.3f);
1020 Point point2(3.5f, 3.3f);
1021 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
1022 EXPECT_TRUE(path->GetPositionAndTangent(0.1f, point1, point2, false));
1023 }
1024
1025 /**
1026 * @tc.name: CopyConstruction001
1027 * @tc.desc: Bounds should be same by using copy construction
1028 * @tc.type: FUNC
1029 * @tc.require: issuelI6M9U9
1030 */
HWTEST_F(PathTest, CopyConstruction001, TestSize.Level1)1031 HWTEST_F(PathTest, CopyConstruction001, TestSize.Level1)
1032 {
1033 Path path1;
1034 path1.MoveTo(1.0f, 2.0f);
1035 path1.LineTo(3.0f, 4.0f);
1036 Path path2 = path1;
1037 ASSERT_TRUE(path1.GetBounds() == path2.GetBounds());
1038 }
1039
1040 /**
1041 * @tc.name: CopyConstruction002
1042 * @tc.desc: Deep clone by the copy construction should not modify the original object
1043 * @tc.type: FUNC
1044 * @tc.require: issuelI6M9U9
1045 */
HWTEST_F(PathTest, CopyConstruction002, TestSize.Level1)1046 HWTEST_F(PathTest, CopyConstruction002, TestSize.Level1)
1047 {
1048 Path path1;
1049 path1.MoveTo(1.0f, 2.0f);
1050 path1.LineTo(3.0f, 4.0f);
1051 Path path2 = path1;
1052 path2.LineTo(10.0f, 10.0f);
1053 ASSERT_TRUE(path1.GetBounds() != path2.GetBounds());
1054 }
1055
1056 /**
1057 * @tc.name: Assignment001
1058 * @tc.desc: Bounds should be same by using assignment method
1059 * @tc.type: FUNC
1060 * @tc.require: issuelI6M9U9
1061 */
HWTEST_F(PathTest, Assignment001, TestSize.Level1)1062 HWTEST_F(PathTest, Assignment001, TestSize.Level1)
1063 {
1064 Path path1;
1065 path1.MoveTo(1.0f, 2.0f);
1066 path1.LineTo(3.0f, 4.0f);
1067 Path path2;
1068 path2 = path1;
1069 ASSERT_TRUE(path1.GetBounds() == path2.GetBounds());
1070 }
1071
1072 /**
1073 * @tc.name: Assignment002
1074 * @tc.desc: Deep clone by the assignment method should not modify the original object
1075 * @tc.type: FUNC
1076 * @tc.require: issuelI6M9U9
1077 */
HWTEST_F(PathTest, Assignment002, TestSize.Level1)1078 HWTEST_F(PathTest, Assignment002, TestSize.Level1)
1079 {
1080 Path path1;
1081 path1.MoveTo(1.0f, 2.0f);
1082 path1.LineTo(3.0f, 4.0f);
1083 Path path2;
1084 path2 = path1;
1085 path2.LineTo(10.0f, 10.0f);
1086 ASSERT_TRUE(path1.GetBounds() != path2.GetBounds());
1087 }
1088
1089 /**
1090 * @tc.name: Dump001
1091 * @tc.desc: Dump Path
1092 * @tc.type: FUNC
1093 * @tc.require:
1094 */
HWTEST_F(PathTest, Dump001, TestSize.Level1)1095 HWTEST_F(PathTest, Dump001, TestSize.Level1)
1096 {
1097 Path path;
1098 path.MoveTo(1.0f, 2.0f);
1099 path.LineTo(3.0f, 4.0f);
1100 std::string out;
1101 EXPECT_TRUE(out.empty());
1102 path.Dump(out);
1103 EXPECT_FALSE(out.empty());
1104 }
1105 } // namespace Drawing
1106 } // namespace Rosen
1107 } // namespace OHOS
1108