1 /*
2  * Copyright (c) 2022 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 "gtest/gtest.h"
17 
18 #include "effect/path_effect.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class PathEffectTest : 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 PathEffectTest::SetUpTestCase() {}
TearDownTestCase()35 void PathEffectTest::TearDownTestCase() {}
SetUp()36 void PathEffectTest::SetUp() {}
TearDown()37 void PathEffectTest::TearDown() {}
38 
39 /**
40  * @tc.name: CreateDashPathEffect001
41  * @tc.desc:
42  * @tc.type: FUNC
43  * @tc.require: AR000GGNV3
44  * @tc.author:
45  */
46 HWTEST_F(PathEffectTest, CreateDashPathEffect001, TestSize.Level1)
47 {
48     scalar intervals[] = { 1.0f, 2.0f, 1.5f, 3.0f };
49     auto pathEffect = PathEffect::CreateDashPathEffect(intervals, 4, 2.2f);
50     EXPECT_TRUE(pathEffect != nullptr);
51 }
52 
53 /**
54  * @tc.name: CreateDashPathEffect002
55  * @tc.desc:
56  * @tc.type: FUNC
57  * @tc.require: AR000GGNV3
58  * @tc.author:
59  */
60 HWTEST_F(PathEffectTest, CreateDashPathEffect002, TestSize.Level1)
61 {
62     scalar intervals[] = { 1.0f, 2.0f, 1.5f, 3.0f };
63     auto pathEffect = PathEffect::CreateDashPathEffect(intervals, 4, 1.5f);
64     EXPECT_TRUE(pathEffect != nullptr);
65 }
66 
67 /**
68  * @tc.name: CreatePathDashEffect003
69  * @tc.desc:
70  * @tc.type: FUNC
71  * @tc.require: AR000GGNV3
72  * @tc.author:
73  */
74 HWTEST_F(PathEffectTest, CreatePathDashEffect003, TestSize.Level1)
75 {
76     Path path;
77     auto pathEffect = PathEffect::CreatePathDashEffect(path, 1.1f, 1.5f, PathDashStyle::TRANSLATE);
78     EXPECT_TRUE(pathEffect != nullptr);
79 }
80 
81 /**
82  * @tc.name: CreatePathDashEffect004
83  * @tc.desc:
84  * @tc.type: FUNC
85  * @tc.require: AR000GGNV3
86  * @tc.author:
87  */
88 HWTEST_F(PathEffectTest, CreatePathDashEffect004, TestSize.Level1)
89 {
90     Path path;
91     auto pathEffect = PathEffect::CreatePathDashEffect(path, 1.5f, 1.0f, PathDashStyle::TRANSLATE);
92     EXPECT_TRUE(pathEffect != nullptr);
93 }
94 
95 /**
96  * @tc.name: CreateCornerPathEffect001
97  * @tc.desc:
98  * @tc.type: FUNC
99  * @tc.require: AR000GGNV3
100  * @tc.author:
101  */
102 HWTEST_F(PathEffectTest, CreateCornerPathEffect001, TestSize.Level1)
103 {
104     auto pathEffect = PathEffect::CreateCornerPathEffect(0.5f);
105     EXPECT_TRUE(pathEffect != nullptr);
106 }
107 
108 /**
109  * @tc.name: CreateCornerPathEffect002
110  * @tc.desc:
111  * @tc.type: FUNC
112  * @tc.require: AR000GGNV3
113  * @tc.author:
114  */
115 HWTEST_F(PathEffectTest, CreateCornerPathEffect002, TestSize.Level1)
116 {
117     auto pathEffect = PathEffect::CreateCornerPathEffect(0.2f);
118     EXPECT_TRUE(pathEffect != nullptr);
119 }
120 
121 /**
122  * @tc.name: CreateSumPathEffect001
123  * @tc.desc:
124  * @tc.type: FUNC
125  * @tc.require: AR000GGNV3
126  * @tc.author:
127  */
128 HWTEST_F(PathEffectTest, CreateSumPathEffect001, TestSize.Level1)
129 {
130     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 0.5f);
131     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 0.4f);
132     auto pathEffect = PathEffect::CreateSumPathEffect(pathEffect1, pathEffect2);
133     EXPECT_TRUE(pathEffect != nullptr);
134 }
135 
136 /**
137  * @tc.name: CreateSumPathEffect002
138  * @tc.desc:
139  * @tc.type: FUNC
140  * @tc.require: AR000GGNV3
141  * @tc.author:
142  */
143 HWTEST_F(PathEffectTest, CreateSumPathEffect002, TestSize.Level1)
144 {
145     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 5.5f);
146     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 7.4f);
147     auto pathEffect = PathEffect::CreateSumPathEffect(pathEffect1, pathEffect2);
148     EXPECT_TRUE(pathEffect != nullptr);
149 }
150 
151 /**
152  * @tc.name: CreateComposePathEffect001
153  * @tc.desc:
154  * @tc.type: FUNC
155  * @tc.require: AR000GGNV3
156  * @tc.author:
157  */
158 HWTEST_F(PathEffectTest, CreateComposePathEffect001, TestSize.Level1)
159 {
160     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 0.5f);
161     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 0.4f);
162     auto pathEffect = PathEffect::CreateComposePathEffect(pathEffect1, pathEffect2);
163     EXPECT_TRUE(pathEffect != nullptr);
164 }
165 
166 /**
167  * @tc.name: CreateComposePathEffect002
168  * @tc.desc:
169  * @tc.type: FUNC
170  * @tc.require: AR000GGNV3
171  * @tc.author:
172  */
173 HWTEST_F(PathEffectTest, CreateComposePathEffect002, TestSize.Level1)
174 {
175     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 6.5f);
176     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 99.4f);
177     auto pathEffect = PathEffect::CreateComposePathEffect(pathEffect1, pathEffect2);
178     EXPECT_TRUE(pathEffect != nullptr);
179 }
180 
181 /**
182  * @tc.name: ArgsConstructor001
183  * @tc.desc:
184  * @tc.type: FUNC
185  * @tc.require: AR000GGNV3
186  * @tc.author:
187  */
188 HWTEST_F(PathEffectTest, ArgsConstructor001, TestSize.Level1)
189 {
190     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::COMPOSE;
191     scalar intervals[] = { 1.0f, 2.0f, 1.5f, 3.0f };
192     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, intervals, 4, 1.0f);
193     ASSERT_TRUE(pathEffect != nullptr);
194     auto type = pathEffect->GetType();
195     EXPECT_TRUE(type == pathEffectType);
196 }
197 
198 /**
199  * @tc.name: ArgsConstructor002
200  * @tc.desc:
201  * @tc.type: FUNC
202  * @tc.require: AR000GGNV3
203  * @tc.author:
204  */
205 HWTEST_F(PathEffectTest, ArgsConstructor002, TestSize.Level1)
206 {
207     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::COMPOSE;
208     scalar intervals[] = { 15.0f, 25.0f, 15.5f, 35.0f };
209     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, intervals, 45, 15.0f);
210     ASSERT_TRUE(pathEffect != nullptr);
211     auto type = pathEffect->GetType();
212     EXPECT_TRUE(type == pathEffectType);
213 }
214 
215 /**
216  * @tc.name: ArgsConstructor003
217  * @tc.desc:
218  * @tc.type: FUNC
219  * @tc.require: AR000GGNV3
220  * @tc.author:
221  */
222 HWTEST_F(PathEffectTest, ArgsConstructor003, TestSize.Level1)
223 {
224     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::PATH_DASH;
225     Path path;
226     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, path, 21.0f, 21.5f, PathDashStyle::TRANSLATE);
227     ASSERT_TRUE(pathEffect != nullptr);
228     auto type = pathEffect->GetType();
229     EXPECT_TRUE(type == pathEffectType);
230 }
231 
232 /**
233  * @tc.name: ArgsConstructor004
234  * @tc.desc:
235  * @tc.type: FUNC
236  * @tc.require: AR000GGNV3
237  * @tc.author:
238  */
239 HWTEST_F(PathEffectTest, ArgsConstructor004, TestSize.Level1)
240 {
241     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::CORNER;
242     Path path;
243     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, path, 1.0f, 1.5f, PathDashStyle::ROTATE);
244     ASSERT_TRUE(pathEffect != nullptr);
245     auto type = pathEffect->GetType();
246     EXPECT_TRUE(type == pathEffectType);
247 }
248 
249 /**
250  * @tc.name: ArgsConstructor005
251  * @tc.desc:
252  * @tc.type: FUNC
253  * @tc.require: AR000GGNV3
254  * @tc.author:
255  */
256 HWTEST_F(PathEffectTest, ArgsConstructor005, TestSize.Level1)
257 {
258     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::SUM;
259     Path path;
260     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, 0.2f);
261     ASSERT_TRUE(pathEffect != nullptr);
262     auto type = pathEffect->GetType();
263     EXPECT_TRUE(type == pathEffectType);
264 }
265 
266 /**
267  * @tc.name: ArgsConstructor006
268  * @tc.desc:
269  * @tc.type: FUNC
270  * @tc.require: AR000GGNV3
271  * @tc.author:
272  */
273 HWTEST_F(PathEffectTest, ArgsConstructor006, TestSize.Level1)
274 {
275     PathEffect::PathEffectType pathEffectType = PathEffect::PathEffectType::SUM;
276     Path path;
277     auto pathEffect = std::make_unique<PathEffect>(pathEffectType, 0.5f);
278     ASSERT_TRUE(pathEffect != nullptr);
279     auto type = pathEffect->GetType();
280     EXPECT_TRUE(type == pathEffectType);
281 }
282 
283 /**
284  * @tc.name: ArgsConstructor007
285  * @tc.desc:
286  * @tc.type: FUNC
287  * @tc.require: AR000GGNV3
288  * @tc.author:
289  */
290 HWTEST_F(PathEffectTest, ArgsConstructor007, TestSize.Level1)
291 {
292     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 0.5f);
293     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 0.4f);
294     auto pathEffect = std::make_unique<PathEffect>(PathEffect::PathEffectType::PATH_DASH, pathEffect1, pathEffect2);
295     ASSERT_TRUE(pathEffect != nullptr);
296 }
297 
298 /**
299  * @tc.name: ArgsConstructor008
300  * @tc.desc:
301  * @tc.type: FUNC
302  * @tc.require: AR000GGNV3
303  * @tc.author:
304  */
305 HWTEST_F(PathEffectTest, ArgsConstructor008, TestSize.Level1)
306 {
307     PathEffect pathEffect1(PathEffect::PathEffectType::PATH_DASH, 0.1f);
308     PathEffect pathEffect2(PathEffect::PathEffectType::PATH_DASH, 0.2f);
309     auto pathEffect = std::make_unique<PathEffect>(PathEffect::PathEffectType::SUM, pathEffect1, pathEffect2);
310     ASSERT_TRUE(pathEffect != nullptr);
311 }
312 } // namespace Drawing
313 } // namespace Rosen
314 } // namespace OHOS
315