example: remove a resouce that may have a license.
[platform/core/uifw/lottie-player.git] / test / testsgregion.cpp
1 #include <gtest/gtest.h>
2 #include"vregion.h"
3 #include"vdebug.h"
4 #include"vpoint.h"
5 class VRegionTest : public ::testing::Test {
6 public:
7     VRegionTest():rgn1(-10, -10, 20, 20)
8     {
9     }
10     void SetUp()
11     {
12         rect1 = VRect(-10, -10, 20, 20);
13         rect2 = VRect(-15, 5, 10, 10);
14         rgn2 += rect2;
15         rgn3 = rgn1;
16     }
17     void TearDown()
18     {
19
20     }
21 public:
22     VRegion emptyRgn;
23     VRegion rgn1;
24     VRegion rgn2;
25     VRegion rgn3;
26     VRect rect1;
27     VRect rect2;
28     VRect rect3;
29
30 };
31
32 TEST_F(VRegionTest, constructor) {
33     ASSERT_EQ(rgn1.rectCount() , 1);
34     ASSERT_TRUE(rgn1.rectAt(0) == rect1);
35     ASSERT_TRUE(rgn1==rgn3);
36     ASSERT_TRUE(rgn1!=rgn2);
37 }
38
39 TEST_F(VRegionTest, moveSemantics) {
40     // move assignment
41
42     rgn1 = rect1;
43     VRegion tmp;
44     tmp = std::move(rgn1);
45     ASSERT_TRUE(rgn1.empty());
46
47     // move construction
48     rgn1 = rect1;
49     VRegion mvrgn = std::move(rgn1);
50     ASSERT_TRUE(rgn1.empty());
51     ASSERT_TRUE(mvrgn == rect1);
52 }
53 TEST_F(VRegionTest, isEmpty) {
54     ASSERT_TRUE(emptyRgn.empty());
55     ASSERT_TRUE(emptyRgn == VRegion());
56     ASSERT_TRUE(emptyRgn.rectCount() == 0);
57     ASSERT_TRUE(emptyRgn.boundingRect() == VRect());
58 }
59
60 TEST_F(VRegionTest, boundingRect) {
61     {
62         VRect rect;
63         VRegion region(rect);
64         ASSERT_TRUE(region.boundingRect() == rect);
65     }
66     {
67         VRect rect(10, -20, 30, 40);
68         VRegion region(rect);
69         ASSERT_TRUE(region.boundingRect() == rect);
70     }
71     {
72         VRect rect(15,25,10,10);
73         VRegion region(rect);
74         ASSERT_TRUE(region.boundingRect() == rect);
75     }
76 }
77
78 TEST_F(VRegionTest, swap) {
79     VRegion r1(VRect(0, 0,10,10));
80     VRegion r2(VRect(10,10,10,10));
81     std::swap(r1 ,r2);
82     ASSERT_TRUE(r1.rectAt(0) == VRect(10,10,10,10));
83     ASSERT_TRUE(r2.rectAt(0) == VRect(0, 0,10,10));
84 }
85
86 TEST_F(VRegionTest, substracted) {
87     VRegion r1(VRect(0, 0,20,20));
88     VRegion r2 = r1.subtracted(VRect(5,5,5,5));
89     VRegion expected;
90     expected += VRect(0,0,20,5);
91     expected += VRect(0,5,5,5);
92     expected += VRect(10,5,10,5);
93     expected += VRect(0,10,20,10);
94     ASSERT_TRUE(r2.rectCount() == expected.rectCount());
95     ASSERT_TRUE(r2 == expected);
96     r2 += VRect(5,5,5,5);
97     ASSERT_TRUE(r2 == r1);
98 }
99
100 TEST_F(VRegionTest, translate) {
101     VRegion r1(VRect(0, 0,20,20));
102     VPoint offset(10,10);
103     VRegion r2 =  r1.translated(offset);
104     r1.translate(offset);
105     ASSERT_TRUE(r2 == r2);
106 }
107
108 TEST_F(VRegionTest, intersects) {
109     VRegion r1(VRect(0, 0,20,20));
110     VRegion r2(VRect(20, 20,10,10));
111     ASSERT_FALSE(r1.intersects(r2));
112     r2 += VRect(5, 0,20,20);
113     ASSERT_TRUE(r1.intersects(r2));
114 }
115
116 TEST_F(VRegionTest, contains) {
117     VRegion r1(VRect(0, 0,20,20));
118     ASSERT_TRUE(r1.contains(VRect(5,5,10,10)));
119     ASSERT_FALSE(r1.contains(VRect(11,5,10,10)));
120 }