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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 ASSERT_TRUE(path.IsValid());
216 }
217
218 /**
219 * @tc.name: ArcToWith6001
220 * @tc.desc:
221 * @tc.type: FUNC
222 * @tc.require: AR000GGNV3
223 * @tc.author:
224 */
225 HWTEST_F(PathTest, ArcToWith6001, TestSize.Level1)
226 {
227 auto path = std::make_unique<Path>();
228 ASSERT_TRUE(path != nullptr);
229 Point point1;
230 Point point2;
231 path->ArcTo(point1, point2, 2.5f, 2.4f);
232 }
233
234 /**
235 * @tc.name: ArcToWith6002
236 * @tc.desc:
237 * @tc.type: FUNC
238 * @tc.require: AR000GGNV3
239 * @tc.author:
240 */
241 HWTEST_F(PathTest, ArcToWith6002, TestSize.Level1)
242 {
243 auto path = std::make_unique<Path>();
244 ASSERT_TRUE(path != nullptr);
245 Point point1;
246 Point point2;
247 path->ArcTo(point1, point2, 2.5f, 2.0f);
248 }
249
250 /**
251 * @tc.name: CubicTo001
252 * @tc.desc:
253 * @tc.type: FUNC
254 * @tc.require: AR000GGNV3
255 * @tc.author:
256 */
257 HWTEST_F(PathTest, CubicTo001, TestSize.Level1)
258 {
259 auto path = std::make_unique<Path>();
260 ASSERT_TRUE(path != nullptr);
261 path->CubicTo(1.0f, 2.3f, 2.5f, 2.0f, 3.5f, 3.0f);
262 }
263
264 /**
265 * @tc.name: CubicTo002
266 * @tc.desc:
267 * @tc.type: FUNC
268 * @tc.require: AR000GGNV3
269 * @tc.author:
270 */
271 HWTEST_F(PathTest, CubicTo002, TestSize.Level1)
272 {
273 auto path = std::make_unique<Path>();
274 ASSERT_TRUE(path != nullptr);
275 path->CubicTo(1.0f, 2.3f, 1.4f, 2.0f, 1.5f, 3.0f);
276 }
277
278 /**
279 * @tc.name: CubicTo2001
280 * @tc.desc:
281 * @tc.type: FUNC
282 * @tc.require: AR000GGNV3
283 * @tc.author:
284 */
285 HWTEST_F(PathTest, CubicTo2001, TestSize.Level1)
286 {
287 auto path = std::make_unique<Path>();
288 ASSERT_TRUE(path != nullptr);
289 Point point1;
290 Point point2;
291 Point endPoint(2.3f, 1.5f);
292 path->CubicTo(point1, point2, endPoint);
293 }
294
295 /**
296 * @tc.name: CubicTo2002
297 * @tc.desc:
298 * @tc.type: FUNC
299 * @tc.require: AR000GGNV3
300 * @tc.author:
301 */
302 HWTEST_F(PathTest, CubicTo2002, TestSize.Level1)
303 {
304 auto path = std::make_unique<Path>();
305 ASSERT_TRUE(path != nullptr);
306 Point point1(1.2f, 0.0f);
307 Point point2(1.3f, 1.0f);
308 Point endPoint(2.3f, 1.5f);
309 path->CubicTo(point1, point2, endPoint);
310 }
311
312 /**
313 * @tc.name: QuadTo2001
314 * @tc.desc:
315 * @tc.type: FUNC
316 * @tc.require: AR000GGNV3
317 * @tc.author:
318 */
319 HWTEST_F(PathTest, QuadTo2001, TestSize.Level1)
320 {
321 auto path = std::make_unique<Path>();
322 ASSERT_TRUE(path != nullptr);
323 Point point1(1.2f, 0.0f);
324 Point endPoint(2.3f, 1.5f);
325 path->QuadTo(point1, endPoint);
326 }
327
328 /**
329 * @tc.name: QuadTo2002
330 * @tc.desc:
331 * @tc.type: FUNC
332 * @tc.require: AR000GGNV3
333 * @tc.author:
334 */
335 HWTEST_F(PathTest, QuadTo2002, TestSize.Level1)
336 {
337 auto path = std::make_unique<Path>();
338 ASSERT_TRUE(path != nullptr);
339 Point point1(0.5f, 0.3f);
340 Point endPoint(3.5f, 3.3f);
341 path->QuadTo(point1, endPoint);
342 }
343
344 /**
345 * @tc.name: QuadTo4001
346 * @tc.desc:
347 * @tc.type: FUNC
348 * @tc.require: AR000GGNV3
349 * @tc.author:
350 */
351 HWTEST_F(PathTest, QuadTo4001, TestSize.Level1)
352 {
353 auto path = std::make_unique<Path>();
354 ASSERT_TRUE(path != nullptr);
355 path->QuadTo(1.0f, 1.5f, 3.3f, 4.5f);
356 }
357
358 /**
359 * @tc.name: QuadTo4002
360 * @tc.desc:
361 * @tc.type: FUNC
362 * @tc.require: AR000GGNV3
363 * @tc.author:
364 */
365 HWTEST_F(PathTest, QuadTo4002, TestSize.Level1)
366 {
367 auto path = std::make_unique<Path>();
368 ASSERT_TRUE(path != nullptr);
369 path->QuadTo(1.0f, 1.2f, 3.0f, 4.0f);
370 }
371
372 /**
373 * @tc.name: AddRect2001
374 * @tc.desc:
375 * @tc.type: FUNC
376 * @tc.require: AR000GGNV3
377 * @tc.author:
378 */
379 HWTEST_F(PathTest, AddRect2001, TestSize.Level1)
380 {
381 auto path = std::make_unique<Path>();
382 ASSERT_TRUE(path != nullptr);
383 Rect rect;
384 path->AddRect(rect);
385 }
386
387 /**
388 * @tc.name: AddRect2002
389 * @tc.desc:
390 * @tc.type: FUNC
391 * @tc.require: AR000GGNV3
392 * @tc.author:
393 */
394 HWTEST_F(PathTest, AddRect2002, TestSize.Level1)
395 {
396 auto path = std::make_unique<Path>();
397 ASSERT_TRUE(path != nullptr);
398 Rect rect;
399 path->AddRect(rect, PathDirection::CCW_DIRECTION);
400 }
401
402 /**
403 * @tc.name: AddRect5001
404 * @tc.desc:
405 * @tc.type: FUNC
406 * @tc.require: AR000GGNV3
407 * @tc.author:
408 */
409 HWTEST_F(PathTest, AddRect5001, TestSize.Level1)
410 {
411 auto path = std::make_unique<Path>();
412 ASSERT_TRUE(path != nullptr);
413 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f, PathDirection::CCW_DIRECTION);
414 }
415
416 /**
417 * @tc.name: AddRect5002
418 * @tc.desc:
419 * @tc.type: FUNC
420 * @tc.require: AR000GGNV3
421 * @tc.author:
422 */
423 HWTEST_F(PathTest, AddRect5002, TestSize.Level1)
424 {
425 auto path = std::make_unique<Path>();
426 ASSERT_TRUE(path != nullptr);
427 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
428 }
429
430 /**
431 * @tc.name: AddOval001
432 * @tc.desc:
433 * @tc.type: FUNC
434 * @tc.require: AR000GGNV3
435 * @tc.author:
436 */
437 HWTEST_F(PathTest, AddOval001, TestSize.Level1)
438 {
439 auto path = std::make_unique<Path>();
440 ASSERT_TRUE(path != nullptr);
441 Rect oval;
442 path->AddOval(oval, PathDirection::CCW_DIRECTION);
443 }
444
445 /**
446 * @tc.name: AddOval002
447 * @tc.desc:
448 * @tc.type: FUNC
449 * @tc.require: AR000GGNV3
450 * @tc.author:
451 */
452 HWTEST_F(PathTest, AddOval002, TestSize.Level1)
453 {
454 auto path = std::make_unique<Path>();
455 ASSERT_TRUE(path != nullptr);
456 Rect oval;
457 path->AddOval(oval);
458 }
459
460 /**
461 * @tc.name: AddArc001
462 * @tc.desc:
463 * @tc.type: FUNC
464 * @tc.require: AR000GGNV3
465 * @tc.author:
466 */
467 HWTEST_F(PathTest, AddArc001, TestSize.Level1)
468 {
469 auto path = std::make_unique<Path>();
470 ASSERT_TRUE(path != nullptr);
471 Rect rect;
472 path->AddArc(rect, 1.0f, 2.0f);
473 }
474
475 /**
476 * @tc.name: AddArc002
477 * @tc.desc:
478 * @tc.type: FUNC
479 * @tc.require: AR000GGNV3
480 * @tc.author:
481 */
482 HWTEST_F(PathTest, AddArc002, TestSize.Level1)
483 {
484 auto path = std::make_unique<Path>();
485 ASSERT_TRUE(path != nullptr);
486 Rect rect;
487 path->AddArc(rect, 2.0f, 1.0f);
488 }
489
490 /**
491 * @tc.name: AddPoly001
492 * @tc.desc:
493 * @tc.type: FUNC
494 * @tc.require: AR000GGNV3
495 * @tc.author:
496 */
497 HWTEST_F(PathTest, AddPoly001, TestSize.Level1)
498 {
499 auto path = std::make_unique<Path>();
500 ASSERT_TRUE(path != nullptr);
501 std::vector<Point> points;
502 Point point1;
503 points.push_back(point1);
504 int size = points.size();
505 path->AddPoly(points, size, false);
506 }
507
508 /**
509 * @tc.name: AddPoly002
510 * @tc.desc:
511 * @tc.type: FUNC
512 * @tc.require: AR000GGNV3
513 * @tc.author:
514 */
515 HWTEST_F(PathTest, AddPoly002, TestSize.Level1)
516 {
517 auto path = std::make_unique<Path>();
518 ASSERT_TRUE(path != nullptr);
519 std::vector<Point> points;
520 Point point1;
521 Point point2;
522 points.push_back(point1);
523 points.push_back(point2);
524 int size = points.size();
525 path->AddPoly(points, size, true);
526 }
527
528 /**
529 * @tc.name: AddCircle001
530 * @tc.desc:
531 * @tc.type: FUNC
532 * @tc.require: AR000GGNV3
533 * @tc.author:
534 */
535 HWTEST_F(PathTest, AddCircle001, TestSize.Level1)
536 {
537 auto path = std::make_unique<Path>();
538 ASSERT_TRUE(path != nullptr);
539 path->AddCircle(1.0f, 0.5f, 0.5f);
540 }
541
542 /**
543 * @tc.name: AddCircle002
544 * @tc.desc:
545 * @tc.type: FUNC
546 * @tc.require: AR000GGNV3
547 * @tc.author:
548 */
549 HWTEST_F(PathTest, AddCircle002, TestSize.Level1)
550 {
551 auto path = std::make_unique<Path>();
552 ASSERT_TRUE(path != nullptr);
553 path->AddCircle(1.0f, 0.5f, 0.5f, PathDirection::CCW_DIRECTION);
554 }
555
556 /**
557 * @tc.name: AddRoundRect001
558 * @tc.desc:
559 * @tc.type: FUNC
560 * @tc.require: AR000GGNV3
561 * @tc.author:
562 */
563 HWTEST_F(PathTest, AddRoundRect001, TestSize.Level1)
564 {
565 auto path = std::make_unique<Path>();
566 ASSERT_TRUE(path != nullptr);
567 Rect rect;
568 path->AddRoundRect(rect, 0.5f, 0.5f, PathDirection::CCW_DIRECTION);
569 }
570
571 /**
572 * @tc.name: AddRoundRect002
573 * @tc.desc:
574 * @tc.type: FUNC
575 * @tc.require: AR000GGNV3
576 * @tc.author:
577 */
578 HWTEST_F(PathTest, AddRoundRect002, TestSize.Level1)
579 {
580 auto path = std::make_unique<Path>();
581 ASSERT_TRUE(path != nullptr);
582 Rect rect;
583 path->AddRoundRect(rect, 0.5f, 0.5f);
584 }
585
586 /**
587 * @tc.name: AddRoundRect003
588 * @tc.desc: Test for adding the circle rectangle to the Path.
589 * @tc.type: FUNC
590 * @tc.require: I715J0
591 */
592 HWTEST_F(PathTest, AddRoundRect003, TestSize.Level1)
593 {
594 auto path = std::make_unique<Path>();
595 ASSERT_TRUE(path != nullptr);
596 RoundRect roundRect;
597 path->AddRoundRect(roundRect, PathDirection::CCW_DIRECTION);
598 }
599
600 /**
601 * @tc.name: AddRoundRect004
602 * @tc.desc: Test for adding the circle rectangle to the Path.
603 * @tc.type: FUNC
604 * @tc.require: I715J0
605 */
606 HWTEST_F(PathTest, AddRoundRect004, TestSize.Level1)
607 {
608 auto path = std::make_unique<Path>();
609 ASSERT_TRUE(path != nullptr);
610 RoundRect roundRect;
611 path->AddRoundRect(roundRect);
612 }
613
614 /**
615 * @tc.name: AddRoundRect005
616 * @tc.desc: Test for adding the circle rectangle to the Path.
617 * @tc.type: FUNC
618 * @tc.require: I715J0
619 */
620 HWTEST_F(PathTest, AddRoundRect005, TestSize.Level1)
621 {
622 auto path = std::make_unique<Path>();
623 ASSERT_TRUE(path != nullptr);
624 Rect rect;
625 RoundRect roundRect(rect, 12.6f, 77.4f);
626 path->AddRoundRect(roundRect);
627 }
628
629 /**
630 * @tc.name: AddPath3001
631 * @tc.desc:
632 * @tc.type: FUNC
633 * @tc.require: AR000GGNV3
634 * @tc.author:
635 */
636 HWTEST_F(PathTest, AddPath3001, TestSize.Level1)
637 {
638 auto path = std::make_unique<Path>();
639 ASSERT_TRUE(path != nullptr);
640 Path sourcePath;
641 path->AddPath(sourcePath, 0.5f, 0.5f);
642 }
643
644 /**
645 * @tc.name: AddPath3002
646 * @tc.desc:
647 * @tc.type: FUNC
648 * @tc.require: AR000GGNV3
649 * @tc.author:
650 */
651 HWTEST_F(PathTest, AddPath3002, TestSize.Level1)
652 {
653 auto path = std::make_unique<Path>();
654 ASSERT_TRUE(path != nullptr);
655 Path sourcePath;
656 path->AddPath(sourcePath, 1.0f, 1.0f);
657 }
658
659 /**
660 * @tc.name: AddPath1001
661 * @tc.desc:
662 * @tc.type: FUNC
663 * @tc.require: AR000GGNV3
664 * @tc.author:
665 */
666 HWTEST_F(PathTest, AddPath1001, TestSize.Level1)
667 {
668 auto path = std::make_unique<Path>();
669 ASSERT_TRUE(path != nullptr);
670 Path sourcePath;
671 path->AddPath(sourcePath);
672 }
673
674 /**
675 * @tc.name: AddPath2001
676 * @tc.desc:
677 * @tc.type: FUNC
678 * @tc.require: AR000GGNV3
679 * @tc.author:
680 */
681 HWTEST_F(PathTest, AddPath2001, TestSize.Level1)
682 {
683 auto path = std::make_unique<Path>();
684 ASSERT_TRUE(path != nullptr);
685 Path path1;
686 Matrix matrix;
687 path->AddPath(path1, matrix);
688 }
689
690 /**
691 * @tc.name: AddPath2002
692 * @tc.desc:
693 * @tc.type: FUNC
694 * @tc.require: AR000GGNV3
695 * @tc.author:
696 */
697 HWTEST_F(PathTest, AddPath2002, TestSize.Level1)
698 {
699 auto path = std::make_unique<Path>();
700 ASSERT_TRUE(path != nullptr);
701 Path path1;
702 Matrix matrix;
703 path->AddPath(path1, matrix);
704 }
705
706 /**
707 * @tc.name: ReverseAddPath001
708 * @tc.desc: Test for adding the src from back forward to the Path.
709 * @tc.type: FUNC
710 * @tc.require: I715J0
711 */
712 HWTEST_F(PathTest, ReverseAddPath001, TestSize.Level1)
713 {
714 auto path = std::make_unique<Path>();
715 ASSERT_TRUE(path != nullptr);
716 Path path1;
717 path->ReverseAddPath(path1);
718 }
719
720 /**
721 * @tc.name: ReverseAddPath002
722 * @tc.desc: Test for adding the src from back forward to the Path.
723 * @tc.type: FUNC
724 * @tc.require: I715J0
725 */
726 HWTEST_F(PathTest, ReverseAddPath002, TestSize.Level1)
727 {
728 auto path = std::make_unique<Path>();
729 ASSERT_TRUE(path != nullptr);
730 Path path2;
731 path2.AddRect(1.0f, 4.0f, 3.0f, 2.0f);
732 path->ReverseAddPath(path2);
733 }
734
735 /**
736 * @tc.name: GetBounds001
737 * @tc.desc:
738 * @tc.type: FUNC
739 * @tc.require: AR000GGNV3
740 * @tc.author:
741 */
742 HWTEST_F(PathTest, GetBounds001, TestSize.Level1)
743 {
744 auto path = std::make_unique<Path>();
745 ASSERT_TRUE(path != nullptr);
746 auto rect = path->GetBounds();
747 }
748
749 /**
750 * @tc.name: SetFillStyle001
751 * @tc.desc:
752 * @tc.type: FUNC
753 * @tc.require: AR000GGNV3
754 * @tc.author:
755 */
756 HWTEST_F(PathTest, SetFillStyle001, TestSize.Level1)
757 {
758 auto path = std::make_unique<Path>();
759 ASSERT_TRUE(path != nullptr);
760 path->SetFillStyle(PathFillType::WINDING);
761 }
762
763 /**
764 * @tc.name: SetFillStyle002
765 * @tc.desc:
766 * @tc.type: FUNC
767 * @tc.require: AR000GGNV3
768 * @tc.author:
769 */
770 HWTEST_F(PathTest, SetFillStyle002, TestSize.Level1)
771 {
772 auto path = std::make_unique<Path>();
773 ASSERT_TRUE(path != nullptr);
774 path->SetFillStyle(PathFillType::INVERSE_WINDING);
775 }
776
777 /**
778 * @tc.name: GetFillStyle001
779 * @tc.desc: Test Path's GetFillStyle
780 * @tc.type: FUNC
781 * @tc.require: IB742Z
782 */
783 HWTEST_F(PathTest, GetFillStyle001, TestSize.Level1)
784 {
785 auto path = std::make_unique<Path>();
786 ASSERT_TRUE(path != nullptr);
787 path->SetFillStyle(PathFillType::WINDING);
788 EXPECT_TRUE(path->GetFillStyle() == PathFillType::WINDING);
789 path->SetFillStyle(PathFillType::INVERSE_WINDING);
790 EXPECT_TRUE(path->GetFillStyle() == PathFillType::INVERSE_WINDING);
791 }
792
793 /**
794 * @tc.name: Interpolate001
795 * @tc.desc:
796 * @tc.type: FUNC
797 * @tc.require: AR000GGNV3
798 * @tc.author:
799 */
800 HWTEST_F(PathTest, Interpolate001, TestSize.Level1)
801 {
802 auto path = std::make_unique<Path>();
803 ASSERT_TRUE(path != nullptr);
804 Path ending;
805 Path out;
806 path->Interpolate(ending, 0.5f, out);
807 }
808
809 /**
810 * @tc.name: Interpolate002
811 * @tc.desc:
812 * @tc.type: FUNC
813 * @tc.require: AR000GGNV3
814 * @tc.author:
815 */
816 HWTEST_F(PathTest, Interpolate002, TestSize.Level1)
817 {
818 auto path = std::make_unique<Path>();
819 ASSERT_TRUE(path != nullptr);
820 Path ending;
821 Path out;
822 path->Interpolate(ending, 0.2f, out);
823 }
824
825 /**
826 * @tc.name: Transform001
827 * @tc.desc:
828 * @tc.type: FUNC
829 * @tc.require: AR000GGNV3
830 * @tc.author:
831 */
832 HWTEST_F(PathTest, Transform001, TestSize.Level1)
833 {
834 auto path = std::make_unique<Path>();
835 ASSERT_TRUE(path != nullptr);
836 Matrix matrix;
837 path->Transform(matrix);
838 }
839
840 /**
841 * @tc.name: Offset001
842 * @tc.desc:
843 * @tc.type: FUNC
844 * @tc.require: AR000GGNV3
845 * @tc.author:
846 */
847 HWTEST_F(PathTest, Offset001, TestSize.Level1)
848 {
849 auto path = std::make_unique<Path>();
850 ASSERT_TRUE(path != nullptr);
851 path->Offset(1.0f, 2.3f);
852 }
853
854 /**
855 * @tc.name: Offset002
856 * @tc.desc:
857 * @tc.type: FUNC
858 * @tc.require: AR000GGNV3
859 * @tc.author:
860 */
861 HWTEST_F(PathTest, Offset002, TestSize.Level1)
862 {
863 auto path = std::make_unique<Path>();
864 ASSERT_TRUE(path != nullptr);
865 path->Offset(2.3f, 1.0f);
866 }
867
868 /**
869 * @tc.name: Op001
870 * @tc.desc:
871 * @tc.type: FUNC
872 * @tc.require: AR000GGNV3
873 * @tc.author:
874 */
875 HWTEST_F(PathTest, Op001, TestSize.Level1)
876 {
877 auto path = std::make_unique<Path>();
878 ASSERT_TRUE(path != nullptr);
879 Path path1;
880 Path path2;
881 path->Op(path1, path2, PathOp::INTERSECT);
882 }
883
884 /**
885 * @tc.name: Op002
886 * @tc.desc:
887 * @tc.type: FUNC
888 * @tc.require: AR000GGNV3
889 * @tc.author:
890 */
891 HWTEST_F(PathTest, Op002, TestSize.Level1)
892 {
893 auto path = std::make_unique<Path>();
894 ASSERT_TRUE(path != nullptr);
895 Path path1;
896 Path path2;
897 path->Op(path1, path2, PathOp::UNION);
898 }
899
900 /**
901 * @tc.name: IsValid001
902 * @tc.desc: Test for Checking whether the Path is valid.
903 * @tc.type: FUNC
904 * @tc.require: I715J0
905 */
906 HWTEST_F(PathTest, IsValid001, TestSize.Level1)
907 {
908 auto path = std::make_unique<Path>();
909 ASSERT_TRUE(path != nullptr);
910 EXPECT_FALSE(path->IsValid());
911 }
912
913 /**
914 * @tc.name: IsValid002
915 * @tc.desc: Test for Checking whether the Path is valid.
916 * @tc.type: FUNC
917 * @tc.require: I715J0
918 */
919 HWTEST_F(PathTest, IsValid002, TestSize.Level1)
920 {
921 auto path = std::make_unique<Path>();
922 ASSERT_TRUE(path != nullptr);
923 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
924 EXPECT_TRUE(path->IsValid());
925 }
926
927 /**
928 * @tc.name: Reset001
929 * @tc.desc:
930 * @tc.type: FUNC
931 * @tc.require: AR000GGNV3
932 * @tc.author:
933 */
934 HWTEST_F(PathTest, Reset001, TestSize.Level1)
935 {
936 auto path = std::make_unique<Path>();
937 ASSERT_TRUE(path != nullptr);
938 path->Reset();
939 }
940
941 /**
942 * @tc.name: Close001
943 * @tc.desc:
944 * @tc.type: FUNC
945 * @tc.require: AR000GGNV3
946 * @tc.author:
947 */
948 HWTEST_F(PathTest, Close001, TestSize.Level1)
949 {
950 auto path = std::make_unique<Path>();
951 ASSERT_TRUE(path != nullptr);
952 path->Close();
953 }
954
955 /**
956 * @tc.name: GetLength001
957 * @tc.desc: Test for geting the length of the current path object.
958 * @tc.type: FUNC
959 * @tc.require: I715J0
960 */
961 HWTEST_F(PathTest, GetLength001, TestSize.Level1)
962 {
963 auto path = std::make_unique<Path>();
964 ASSERT_TRUE(path != nullptr);
965 EXPECT_EQ(path->GetLength(false), 0);
966 }
967
968 /**
969 * @tc.name: GetLength002
970 * @tc.desc: Test for geting the length of the current path object.
971 * @tc.type: FUNC
972 * @tc.require: I715J0
973 */
974 HWTEST_F(PathTest, GetLength002, TestSize.Level1)
975 {
976 auto path = std::make_unique<Path>();
977 ASSERT_TRUE(path != nullptr);
978 EXPECT_EQ(path->GetLength(true), 0);
979 }
980
981 /**
982 * @tc.name: GetLength003
983 * @tc.desc: Test for geting the length of the current path object.
984 * @tc.type: FUNC
985 * @tc.require: I715J0
986 */
987 HWTEST_F(PathTest, GetLength003, TestSize.Level1)
988 {
989 auto path = std::make_unique<Path>();
990 ASSERT_TRUE(path != nullptr);
991 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
992 EXPECT_EQ(path->GetLength(true), 8);
993 }
994
995 /**
996 * @tc.name: GetPositionAndTangent001
997 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
998 * @tc.type: FUNC
999 * @tc.require: I715J0
1000 */
1001 HWTEST_F(PathTest, GetPositionAndTangent001, TestSize.Level1)
1002 {
1003 auto path = std::make_unique<Path>();
1004 ASSERT_TRUE(path != nullptr);
1005 Point point1;
1006 Point point2;
1007 EXPECT_FALSE(path->GetPositionAndTangent(0, point1, point2, false));
1008 }
1009
1010 /**
1011 * @tc.name: GetPositionAndTangent002
1012 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
1013 * @tc.type: FUNC
1014 * @tc.require: I715J0
1015 */
1016 HWTEST_F(PathTest, GetPositionAndTangent002, TestSize.Level1)
1017 {
1018 auto path = std::make_unique<Path>();
1019 ASSERT_TRUE(path != nullptr);
1020 Point point1;
1021 Point point2;
1022 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
1023 EXPECT_TRUE(path->GetPositionAndTangent(10, point1, point2, true));
1024 }
1025
1026 /**
1027 * @tc.name: GetPositionAndTangent003
1028 * @tc.desc: Test for geting the position and tangent of the distance from the starting position of the Path.
1029 * @tc.type: FUNC
1030 * @tc.require: I715J0
1031 */
1032 HWTEST_F(PathTest, GetPositionAndTangent003, TestSize.Level1)
1033 {
1034 auto path = std::make_unique<Path>();
1035 ASSERT_TRUE(path != nullptr);
1036 Point point1(0.5f, 0.3f);
1037 Point point2(3.5f, 3.3f);
1038 path->AddRect(1.0f, 4.0f, 3.0f, 2.0f);
1039 EXPECT_TRUE(path->GetPositionAndTangent(0.1f, point1, point2, false));
1040 }
1041
1042 /**
1043 * @tc.name: GetSegment001
1044 * @tc.desc: Test for Gets the path between the start and end points.
1045 * @tc.type: FUNC
1046 * @tc.require: I715J0
1047 */
1048 HWTEST_F(PathTest, GetSegment001, TestSize.Level1)
1049 {
1050 Path path;
1051 path.MoveTo(100, 100);
1052 path.LineTo(100, 200);
1053 path.LineTo(200, 200);
1054 Path newPath;
1055 EXPECT_EQ(path.GetSegment(120, 180, &newPath, false, false), true);
1056 EXPECT_EQ(path.GetSegment(120, 280, &newPath, false, true), true);
1057 EXPECT_EQ(path.GetSegment(-50, 999, &newPath, false, true), true);
1058 EXPECT_EQ(path.GetSegment(120, 180, &newPath, true, false), true);
1059 EXPECT_EQ(path.GetSegment(120, 280, &newPath, true, true), true);
1060 EXPECT_EQ(path.GetSegment(-50, 999, &newPath, true, true), true);
1061 EXPECT_EQ(path.GetSegment(120, 120, &newPath, false, true), true);
1062 EXPECT_EQ(path.GetSegment(130, 120, &newPath, false, true), false);
1063 EXPECT_EQ(path.GetSegment(130, 120, nullptr, false, true), false);
1064 }
1065
1066 /**
1067 * @tc.name: CopyConstruction001
1068 * @tc.desc: Bounds should be same by using copy construction
1069 * @tc.type: FUNC
1070 * @tc.require: issuelI6M9U9
1071 */
1072 HWTEST_F(PathTest, CopyConstruction001, TestSize.Level1)
1073 {
1074 Path path1;
1075 path1.MoveTo(1.0f, 2.0f);
1076 path1.LineTo(3.0f, 4.0f);
1077 Path path2 = path1;
1078 ASSERT_TRUE(path1.GetBounds() == path2.GetBounds());
1079 }
1080
1081 /**
1082 * @tc.name: CopyConstruction002
1083 * @tc.desc: Deep clone by the copy construction should not modify the original object
1084 * @tc.type: FUNC
1085 * @tc.require: issuelI6M9U9
1086 */
1087 HWTEST_F(PathTest, CopyConstruction002, TestSize.Level1)
1088 {
1089 Path path1;
1090 path1.MoveTo(1.0f, 2.0f);
1091 path1.LineTo(3.0f, 4.0f);
1092 Path path2 = path1;
1093 path2.LineTo(10.0f, 10.0f);
1094 ASSERT_TRUE(path1.GetBounds() != path2.GetBounds());
1095 }
1096
1097 /**
1098 * @tc.name: Assignment001
1099 * @tc.desc: Bounds should be same by using assignment method
1100 * @tc.type: FUNC
1101 * @tc.require: issuelI6M9U9
1102 */
1103 HWTEST_F(PathTest, Assignment001, TestSize.Level1)
1104 {
1105 Path path1;
1106 path1.MoveTo(1.0f, 2.0f);
1107 path1.LineTo(3.0f, 4.0f);
1108 Path path2;
1109 path2 = path1;
1110 ASSERT_TRUE(path1.GetBounds() == path2.GetBounds());
1111 }
1112
1113 /**
1114 * @tc.name: Assignment002
1115 * @tc.desc: Deep clone by the assignment method should not modify the original object
1116 * @tc.type: FUNC
1117 * @tc.require: issuelI6M9U9
1118 */
1119 HWTEST_F(PathTest, Assignment002, TestSize.Level1)
1120 {
1121 Path path1;
1122 path1.MoveTo(1.0f, 2.0f);
1123 path1.LineTo(3.0f, 4.0f);
1124 Path path2;
1125 path2 = path1;
1126 path2.LineTo(10.0f, 10.0f);
1127 ASSERT_TRUE(path1.GetBounds() != path2.GetBounds());
1128 }
1129
1130 /**
1131 * @tc.name: Dump001
1132 * @tc.desc: Dump Path
1133 * @tc.type: FUNC
1134 * @tc.require:
1135 */
1136 HWTEST_F(PathTest, Dump001, TestSize.Level1)
1137 {
1138 Path path;
1139 path.MoveTo(1.0f, 2.0f);
1140 path.LineTo(3.0f, 4.0f);
1141 std::string out;
1142 EXPECT_TRUE(out.empty());
1143 path.Dump(out);
1144 EXPECT_FALSE(out.empty());
1145 }
1146
1147 /**
1148 * @tc.name: Serialize001
1149 * @tc.desc: Data returned shouldn't be nullptr
1150 * @tc.type: FUNC
1151 * @tc.require: issuelI6M9U9
1152 */
1153 HWTEST_F(PathTest, Serialize001, TestSize.Level1)
1154 {
1155 Path path1;
1156 path1.MoveTo(1.0f, 2.0f);
1157 path1.LineTo(3.0f, 4.0f);
1158 auto data1 = path1.Serialize();
1159 ASSERT_TRUE(data1 != nullptr);
1160 Path path2;
1161 auto data2 = path2.Serialize();
1162 ASSERT_TRUE(data2 != nullptr);
1163 }
1164 } // namespace Drawing
1165 } // namespace Rosen
1166 } // namespace OHOS
1167