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, 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 <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_canvas.h"
19 #include "draw/core_canvas.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class SkiaCanvasTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 };
34
SetUpTestCase()35 void SkiaCanvasTest::SetUpTestCase() {}
TearDownTestCase()36 void SkiaCanvasTest::TearDownTestCase() {}
SetUp()37 void SkiaCanvasTest::SetUp() {}
TearDown()38 void SkiaCanvasTest::TearDown() {}
39
40 /**
41 * @tc.name: Bind001
42 * @tc.desc:
43 * @tc.type: FUNC
44 * @tc.author:
45 */
46 HWTEST_F(SkiaCanvasTest, Bind001, TestSize.Level1)
47 {
48 Bitmap bitmap;
49 SkiaCanvas skiaCanvas;
50 skiaCanvas.Bind(bitmap);
51 }
52
53 /**
54 * @tc.name: DrawPoint001
55 * @tc.desc:
56 * @tc.type: FUNC
57 * @tc.author:
58 */
59 HWTEST_F(SkiaCanvasTest, DrawPoint001, TestSize.Level1)
60 {
61 Point point;
62 SkiaCanvas skiaCanvas;
63 skiaCanvas.DrawPoint(point);
64 }
65
66 /**
67 * @tc.name: DrawLine001
68 * @tc.desc:
69 * @tc.type: FUNC
70 * @tc.author:
71 */
72 HWTEST_F(SkiaCanvasTest, DrawLine001, TestSize.Level1)
73 {
74 Point startPt;
75 Point endPt;
76 SkiaCanvas skiaCanvas;
77 skiaCanvas.DrawLine(startPt, endPt);
78 }
79
80 /**
81 * @tc.name: DrawRect001
82 * @tc.desc:
83 * @tc.type: FUNC
84 * @tc.author:
85 */
86 HWTEST_F(SkiaCanvasTest, DrawRect001, TestSize.Level1)
87 {
88 Rect rect;
89 SkiaCanvas skiaCanvas;
90 skiaCanvas.DrawRect(rect);
91 }
92
93 /**
94 * @tc.name: DrawRoundRect001
95 * @tc.desc:
96 * @tc.type: FUNC
97 * @tc.author:
98 */
99 HWTEST_F(SkiaCanvasTest, DrawRoundRect001, TestSize.Level1)
100 {
101 RoundRect roundRect;
102 SkiaCanvas skiaCanvas;
103 skiaCanvas.DrawRoundRect(roundRect);
104 }
105
106 /**
107 * @tc.name: DrawNestedRoundRect001
108 * @tc.desc:
109 * @tc.type: FUNC
110 * @tc.author:
111 */
112 HWTEST_F(SkiaCanvasTest, DrawNestedRoundRect001, TestSize.Level1)
113 {
114 RoundRect outer;
115 RoundRect inner;
116 SkiaCanvas skiaCanvas;
117 skiaCanvas.DrawNestedRoundRect(outer, inner);
118 }
119
120 /**
121 * @tc.name: DrawArc001
122 * @tc.desc:
123 * @tc.type: FUNC
124 * @tc.author:
125 */
126 HWTEST_F(SkiaCanvasTest, DrawArc001, TestSize.Level1)
127 {
128 Rect oval;
129 scalar startAngle = 30.0f;
130 scalar sweepAngle = 45.0f;
131 SkiaCanvas skiaCanvas;
132 skiaCanvas.DrawArc(oval, startAngle, sweepAngle);
133 }
134
135 /**
136 * @tc.name: DrawPie001
137 * @tc.desc:
138 * @tc.type: FUNC
139 * @tc.author:
140 */
141 HWTEST_F(SkiaCanvasTest, DrawPie001, TestSize.Level1)
142 {
143 Rect oval;
144 scalar startAngle = 45.0f;
145 scalar sweepAngle = 60.0f;
146 SkiaCanvas skiaCanvas;
147 skiaCanvas.DrawPie(oval, startAngle, sweepAngle);
148 }
149
150 /**
151 * @tc.name: DrawOval001
152 * @tc.desc:
153 * @tc.type: FUNC
154 * @tc.author:
155 */
156 HWTEST_F(SkiaCanvasTest, DrawOval001, TestSize.Level1)
157 {
158 Rect oval;
159 SkiaCanvas skiaCanvas;
160 skiaCanvas.DrawOval(oval);
161 }
162
163 /**
164 * @tc.name: DrawCircle001
165 * @tc.desc:
166 * @tc.type: FUNC
167 * @tc.author:
168 */
169 HWTEST_F(SkiaCanvasTest, DrawCircle001, TestSize.Level1)
170 {
171 Point centerPt;
172 scalar radius = 20.0f;
173 SkiaCanvas skiaCanvas;
174 skiaCanvas.DrawCircle(centerPt, radius);
175 }
176
177 /**
178 * @tc.name: DrawPath001
179 * @tc.desc:
180 * @tc.type: FUNC
181 * @tc.author:
182 */
183 HWTEST_F(SkiaCanvasTest, DrawPath001, TestSize.Level1)
184 {
185 Path path;
186 SkiaCanvas skiaCanvas;
187 skiaCanvas.DrawPath(path);
188 }
189
190 /**
191 * @tc.name: DrawBitmap001
192 * @tc.desc:
193 * @tc.type: FUNC
194 * @tc.author:
195 */
196 HWTEST_F(SkiaCanvasTest, DrawBitmap001, TestSize.Level1)
197 {
198 Bitmap bitmap;
199 scalar px = 60.0f;
200 scalar py = 30.0f;
201 SkiaCanvas skiaCanvas;
202 skiaCanvas.DrawBitmap(bitmap, px, py);
203 }
204
205 /**
206 * @tc.name: DrawImage001
207 * @tc.desc:
208 * @tc.type: FUNC
209 * @tc.author:
210 */
211 HWTEST_F(SkiaCanvasTest, DrawImage001, TestSize.Level1)
212 {
213 Image image;
214 scalar px = 30.0f;
215 scalar py = 65.0f;
216 SamplingOptions sampling;
217 SkiaCanvas skiaCanvas;
218 skiaCanvas.DrawImage(image, px, py, sampling);
219 }
220
221 /**
222 * @tc.name: DrawImageRect001
223 * @tc.desc:
224 * @tc.type: FUNC
225 * @tc.author:
226 */
227 HWTEST_F(SkiaCanvasTest, DrawImageRect001, TestSize.Level1)
228 {
229 Image image;
230 Rect src;
231 Rect dst;
232 SamplingOptions sampling;
233 SkiaCanvas skiaCanvas;
234 skiaCanvas.DrawImageRect(image, src, dst, sampling, SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT);
235 }
236
237 /**
238 * @tc.name: DrawImageRect002
239 * @tc.desc:
240 * @tc.type: FUNC
241 * @tc.author:
242 */
243 HWTEST_F(SkiaCanvasTest, DrawImageRect002, TestSize.Level1)
244 {
245 Image image;
246 Rect dst;
247 SamplingOptions sampling;
248 SkiaCanvas skiaCanvas;
249 skiaCanvas.DrawImageRect(image, dst, sampling);
250 }
251
252 /**
253 * @tc.name: DrawPicture001
254 * @tc.desc:
255 * @tc.type: FUNC
256 * @tc.author:
257 */
258 HWTEST_F(SkiaCanvasTest, DrawPicture001, TestSize.Level1)
259 {
260 Picture picture;
261 SkiaCanvas skiaCanvas;
262 skiaCanvas.DrawPicture(picture);
263 }
264
265 /**
266 * @tc.name: ClipPath001
267 * @tc.desc:
268 * @tc.type: FUNC
269 * @tc.author:
270 */
271 HWTEST_F(SkiaCanvasTest, ClipPath001, TestSize.Level1)
272 {
273 Path path;
274 SkiaCanvas skiaCanvas;
275 skiaCanvas.ClipPath(path, ClipOp::DIFFERENCE);
276 }
277
278 /**
279 * @tc.name: SetMatrix001
280 * @tc.desc:
281 * @tc.type: FUNC
282 * @tc.author:
283 */
284 HWTEST_F(SkiaCanvasTest, SetMatrix001, TestSize.Level1)
285 {
286 Matrix matrix;
287 SkiaCanvas skiaCanvas;
288 skiaCanvas.SetMatrix(matrix);
289 }
290
291 /**
292 * @tc.name: ConcatMatrix001
293 * @tc.desc:
294 * @tc.type: FUNC
295 * @tc.author:
296 */
297 HWTEST_F(SkiaCanvasTest, ConcatMatrix001, TestSize.Level1)
298 {
299 Matrix matrix;
300 SkiaCanvas skiaCanvas;
301 skiaCanvas.ConcatMatrix(matrix);
302 }
303
304 } // namespace Drawing
305 } // namespace Rosen
306 } // namespace OHOS