1/*
2 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 "drawing_color.h"
19#include "drawing_color_filter.h"
20#include "drawing_filter.h"
21#include "drawing_matrix.h"
22#include "drawing_path.h"
23#include "drawing_path_effect.h"
24#include "drawing_pen.h"
25#include "drawing_point.h"
26#include "drawing_rect.h"
27#include "drawing_shader_effect.h"
28#include "drawing_shadow_layer.h"
29
30using namespace testing;
31using namespace testing::ext;
32
33namespace OHOS {
34namespace Rosen {
35namespace Drawing {
36class DrawingNativePenTest : public testing::Test {};
37
38/*
39 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0100
40 * @tc.name: testPenCreateNormal
41 * @tc.desc: Test for testPenCreateNormal.
42 * @tc.size: SmallTest
43 * @tc.type: Function
44 * @tc.level: Level 0
45 */
46HWTEST_F(DrawingNativePenTest, testPenCreateNormal, TestSize.Level0) {
47    // 1. Create a pen object using OH_Drawing_PenCreate
48    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
49    // 2. Free the memory using OH_Drawing_PenDestroy
50    OH_Drawing_PenDestroy(pen);
51}
52
53/*
54 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0200
55 * @tc.name: testPenCopyNormal
56 * @tc.desc: Test for testPenCopyNormal.
57 * @tc.size: SmallTest
58 * @tc.type: Function
59 * @tc.level: Level 0
60 */
61HWTEST_F(DrawingNativePenTest, testPenCopyNormal, TestSize.Level0) {
62    // 1. Create a pen object 1 using OH_Drawing_PenCreate
63    OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate();
64    // 2. Set color for pen 1 using OH_Drawing_PenSetColor
65    OH_Drawing_PenSetColor(pen1, 0x00000000);
66    // 3. Copy pen 1 to pen 2 using OH_Drawing_PenCopy
67    OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(pen1);
68    // 4. Get color of pen 2 using OH_Drawing_PenGetColor
69    uint32_t color = OH_Drawing_PenGetColor(pen2);
70    EXPECT_EQ(color, 0x00000000);
71    // 5. Modify color of pen 1 using OH_Drawing_PenSetColor
72    OH_Drawing_PenSetColor(pen1, 0x00FF0000);
73    // 6. Get color of pen 2 using OH_Drawing_PenGetColor
74    uint32_t color2 = OH_Drawing_PenGetColor(pen2);
75    EXPECT_EQ(color2, 0x00000000);
76    // 7. Free the memory
77    OH_Drawing_PenDestroy(pen1);
78    OH_Drawing_PenDestroy(pen2);
79}
80
81/*
82 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0201
83 * @tc.name: testPenCopyNull
84 * @tc.desc: Test for testPenCopyNull.
85 * @tc.size: SmallTest
86 * @tc.type: Function
87 * @tc.level: Level 3
88 */
89HWTEST_F(DrawingNativePenTest, testPenCopyNull, TestSize.Level3) {
90    // 1. Create a pen object using OH_Drawing_PenCreate
91    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
92    // 2. Copy pen object with nullptr using OH_Drawing_PenCopy
93    OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(nullptr);
94    // 3. Free the memory
95    OH_Drawing_PenDestroy(pen);
96    OH_Drawing_PenDestroy(pen2);
97}
98
99/*
100 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0202
101 * @tc.name: testPenCopyInputDestroyed
102 * @tc.desc: Test for testPenCopyInputDestroyed.
103 * @tc.size: SmallTest
104 * @tc.type: Function
105 * @tc.level: Level 3
106 */
107HWTEST_F(DrawingNativePenTest, testPenCopyInputDestroyed, TestSize.Level3) {
108    // 1. Create a pen object 1 using OH_Drawing_PenCreate
109    OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate();
110    // 2. Copy pen 1 to pen 2 using OH_Drawing_PenCopy
111    OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(pen1);
112    // 3. Destroy pen 1 using OH_Drawing_PenDestroy
113    OH_Drawing_PenDestroy(pen1);
114    // 4. Set color for pen 2 using OH_Drawing_PenSetColor
115    OH_Drawing_PenSetColor(pen2, 0x00000000);
116    // 5. Get color of pen 2 using OH_Drawing_PenGetColor
117    uint32_t color = OH_Drawing_PenGetColor(pen2);
118    EXPECT_EQ(color, 0x00000000);
119    // 6. Free the memory
120    OH_Drawing_PenDestroy(pen2);
121}
122
123/*
124 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0300
125 * @tc.name: testPenDestroyNormal
126 * @tc.desc: Test for testPenDestroyNormal.
127 * @tc.size: SmallTest
128 * @tc.type: Function
129 * @tc.level: Level 0
130 */
131HWTEST_F(DrawingNativePenTest, testPenDestroyNormal, TestSize.Level0) {
132    // 1. Create a pen object using OH_Drawing_PenCreate
133    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
134    // 2. Destroy the object using OH_Drawing_PenDestroy
135    OH_Drawing_PenDestroy(pen);
136}
137
138/*
139 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0301
140 * @tc.name: testPenDestroyNull
141 * @tc.desc: Test for testPenDestroyNull.
142 * @tc.size: SmallTest
143 * @tc.type: Function
144 * @tc.level: Level 3
145 */
146HWTEST_F(DrawingNativePenTest, testPenDestroyNull, TestSize.Level3) {
147    // 1. Create a pen object using OH_Drawing_PenCreate
148    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
149    // 2. Destroy the object with nullptr using OH_Drawing_PenDestroy
150    OH_Drawing_PenDestroy(nullptr);
151    // 3. Free the memory
152    OH_Drawing_PenDestroy(pen);
153}
154
155/*
156 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0400
157 * @tc.name: testPenIsAntiAliasNormal
158 * @tc.desc: Test for testPenIsAntiAliasNormal.
159 * @tc.size: SmallTest
160 * @tc.type: Function
161 * @tc.level: Level 0
162 */
163HWTEST_F(DrawingNativePenTest, testPenIsAntiAliasNormal, TestSize.Level0) {
164    // 1. Create a pen object using OH_Drawing_PenCreate
165    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
166    // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias
167    OH_Drawing_PenSetAntiAlias(pen, true);
168    // 3. Get the anti-aliasing status of the pen using OH_Drawing_PenIsAntiAlias
169    bool isAntiAlias = OH_Drawing_PenIsAntiAlias(pen);
170    EXPECT_EQ(isAntiAlias, true);
171    // 4. Free the memory
172    OH_Drawing_PenDestroy(pen);
173}
174
175/*
176 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0401
177 * @tc.name: testPenIsAntiAliasNull
178 * @tc.desc: Test for testPenIsAntiAliasNull.
179 * @tc.size: SmallTest
180 * @tc.type: Function
181 * @tc.level: Level 3
182 */
183HWTEST_F(DrawingNativePenTest, testPenIsAntiAliasNull, TestSize.Level3) {
184    // 1. Create a pen object using OH_Drawing_PenCreate
185    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
186    // 2. Call OH_Drawing_PenIsAntiAlias with nullptr as parameter
187    bool isAntiAlias = OH_Drawing_PenIsAntiAlias(nullptr);
188    EXPECT_EQ(isAntiAlias, false);
189    // 3. Free the memory
190    OH_Drawing_PenDestroy(pen);
191}
192
193/*
194 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0500
195 * @tc.name: testPenSetAntiAliasNormal
196 * @tc.desc: Test for testPenSetAntiAliasNormal.
197 * @tc.size: SmallTest
198 * @tc.type: Function
199 * @tc.level: Level 0
200 */
201HWTEST_F(DrawingNativePenTest, testPenSetAntiAliasNormal, TestSize.Level0) {
202    // 1. Create a pen object using OH_Drawing_PenCreate
203    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
204    // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias
205    OH_Drawing_PenSetAntiAlias(pen, true);
206    // 3. Get the anti-aliasing status of the pen using OH_Drawing_PenIsAntiAlias
207    bool isAntiAlias = OH_Drawing_PenIsAntiAlias(pen);
208    EXPECT_EQ(isAntiAlias, true);
209    // 4. Free the memory
210    OH_Drawing_PenDestroy(pen);
211}
212
213/*
214 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0501
215 * @tc.name: testPenSetAntiAliasNull
216 * @tc.desc: Test for testPenSetAntiAliasNull.
217 * @tc.size: SmallTest
218 * @tc.type: Function
219 * @tc.level: Level 3
220 */
221HWTEST_F(DrawingNativePenTest, testPenSetAntiAliasNull, TestSize.Level3) {
222    // 1. Create a pen object using OH_Drawing_PenCreate
223    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
224    // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias
225    OH_Drawing_PenSetAntiAlias(nullptr, true);
226    // 3. Free the memory
227    OH_Drawing_PenDestroy(pen);
228}
229
230/*
231 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0600
232 * @tc.name: testPenGetColorNormal
233 * @tc.desc: Test for testPenGetColorNormal.
234 * @tc.size: SmallTest
235 * @tc.type: Function
236 * @tc.level: Level 0
237 */
238HWTEST_F(DrawingNativePenTest, testPenGetColorNormal, TestSize.Level0) {
239    // 1. Create a pen object using OH_Drawing_PenCreate
240    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
241    // 2. Set color for the pen using OH_Drawing_PenSetColor
242    OH_Drawing_PenSetColor(pen, 0x00000000);
243    // 3. Get color of the pen using OH_Drawing_PenGetColor
244    uint32_t color = OH_Drawing_PenGetColor(pen);
245    EXPECT_EQ(color, 0x00000000);
246    // 4. Free the memory
247    OH_Drawing_PenDestroy(pen);
248}
249
250/*
251 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0601
252 * @tc.name: testPenGetColorNull
253 * @tc.desc: Test for testPenGetColorNull.
254 * @tc.size: SmallTest
255 * @tc.type: Function
256 * @tc.level: Level 3
257 */
258HWTEST_F(DrawingNativePenTest, testPenGetColorNull, TestSize.Level3) {
259    // 1. Create a pen object using OH_Drawing_PenCreate
260    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
261    // 2. Call OH_Drawing_PenGetColor with nullptr as parameter
262    OH_Drawing_PenGetColor(nullptr);
263    // 3. Free the memory
264    OH_Drawing_PenDestroy(pen);
265}
266
267/*
268 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0700
269 * @tc.name: testPenSetColorNormal
270 * @tc.desc: Test for testPenSetColorNormal.
271 * @tc.size: SmallTest
272 * @tc.type: Function
273 * @tc.level: Level 0
274 */
275HWTEST_F(DrawingNativePenTest, testPenSetColorNormal, TestSize.Level0) {
276    // 1. Create a pen object using OH_Drawing_PenCreate
277    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
278    // 2. Set color for the pen using OH_Drawing_PenSetColor
279    OH_Drawing_PenSetColor(pen, 0x00000000);
280    // 3. Get color of the pen using OH_Drawing_PenGetColor
281    uint32_t color = OH_Drawing_PenGetColor(pen);
282    EXPECT_EQ(color, 0x00000000);
283    // 4. Free the memory
284    OH_Drawing_PenDestroy(pen);
285}
286
287/*
288 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0701
289 * @tc.name: testPenSetColorNull
290 * @tc.desc: Test for testPenSetColorNull.
291 * @tc.size: SmallTest
292 * @tc.type: Function
293 * @tc.level: Level 3
294 */
295HWTEST_F(DrawingNativePenTest, testPenSetColorNull, TestSize.Level3) {
296    // 1. Create a pen object using OH_Drawing_PenCreate
297    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
298    // 2. Set color for the pen using OH_Drawing_PenSetColor with nullptr as the first parameter
299    OH_Drawing_PenSetColor(nullptr, 0x00000000);
300    // 3. Set color for the pen using OH_Drawing_PenSetColor with 0x00000000 as the second parameter
301    OH_Drawing_PenSetColor(pen, 0x00000000);
302    // 4. Free the memory
303    OH_Drawing_PenDestroy(pen);
304}
305
306/*
307 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0702
308 * @tc.name: testPenSetColorAbnormal
309 * @tc.desc: Test for testPenSetColorAbnormal.
310 * @tc.size: SmallTest
311 * @tc.type: Function
312 * @tc.level: Level 3
313 */
314HWTEST_F(DrawingNativePenTest, testPenSetColorAbnormal, TestSize.Level3) {
315    // 1. Create a pen object using OH_Drawing_PenCreate
316    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
317    // 2. Set the second parameter of OH_Drawing_PenSetColor to a negative number or a floating-point number
318    OH_Drawing_PenSetColor(pen, -1);
319    // 3. Call OH_Drawing_PenGetColor
320    uint32_t color = OH_Drawing_PenGetColor(pen);
321    EXPECT_EQ(static_cast<uint32_t>(-1), color);
322    // 4. Free the memory
323    OH_Drawing_PenDestroy(pen);
324}
325
326/*
327 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0703
328 * @tc.name: testPenSetColorMaximum
329 * @tc.desc: Test for testPenSetColorMaximum.
330 * @tc.size: SmallTest
331 * @tc.type: Function
332 * @tc.level: Level 3
333 */
334HWTEST_F(DrawingNativePenTest, testPenSetColorMaximum, TestSize.Level3) {
335    // 1. Create a pen object using OH_Drawing_PenCreate
336    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
337    // 2. Set the second parameter of OH_Drawing_PenSetColor to a maximum value of 0xFFFFFFFF + 1
338    OH_Drawing_PenSetColor(pen, 0xFFFFFFFF + 1);
339    // 3. Get the color of the pen using OH_Drawing_PenGetColor
340    uint32_t color = OH_Drawing_PenGetColor(pen);
341    EXPECT_EQ(0xFFFFFFFF + 1, color);
342    // 4. Free the memory
343    OH_Drawing_PenDestroy(pen);
344}
345
346/*
347 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0800
348 * @tc.name: testPenGetAlphaNormal
349 * @tc.desc: Test for testPenGetAlphaNormal.
350 * @tc.size: SmallTest
351 * @tc.type: Function
352 * @tc.level: Level 0
353 */
354HWTEST_F(DrawingNativePenTest, testPenGetAlphaNormal, TestSize.Level0) {
355    // 1. Create a pen object using OH_Drawing_PenCreate
356    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
357    // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha
358    OH_Drawing_PenSetAlpha(pen, 0x00);
359    // 3. Get the alpha value of the pen using OH_Drawing_PenGetAlpha
360    uint8_t alpha = OH_Drawing_PenGetAlpha(pen);
361    EXPECT_EQ(alpha, 0x00);
362    // 4. Free the memory
363    OH_Drawing_PenDestroy(pen);
364}
365
366/*
367 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0801
368 * @tc.name: testPenGetAlphaNull
369 * @tc.desc: Test for testPenGetAlphaNull.
370 * @tc.size: SmallTest
371 * @tc.type: Function
372 * @tc.level: Level 3
373 */
374HWTEST_F(DrawingNativePenTest, testPenGetAlphaNull, TestSize.Level3) {
375    // 1. Create a pen object using OH_Drawing_PenCreate
376    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
377    // 2. Call OH_Drawing_PenGetAlpha with nullptr as parameter
378    OH_Drawing_PenGetAlpha(nullptr);
379    // 3. Free the memory
380    OH_Drawing_PenDestroy(pen);
381}
382
383/*
384 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0900
385 * @tc.name: testPenSetAlphaNormal
386 * @tc.desc: Test for testPenSetAlphaNormal.
387 * @tc.size: SmallTest
388 * @tc.type: Function
389 * @tc.level: Level 0
390 */
391HWTEST_F(DrawingNativePenTest, testPenSetAlphaNormal, TestSize.Level0) {
392    // 1. Create a pen object using OH_Drawing_PenCreate
393    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
394    // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha
395    OH_Drawing_PenSetAlpha(pen, 0x00);
396    // 3. Get the alpha value of the pen using OH_Drawing_PenGetAlpha
397    uint8_t alpha = OH_Drawing_PenGetAlpha(pen);
398    EXPECT_EQ(alpha, 0x00);
399    // 4. Free the memory
400    OH_Drawing_PenDestroy(pen);
401}
402
403/*
404 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0901
405 * @tc.name: testPenSetAlphaNull
406 * @tc.desc: Test for testPenSetAlphaNull.
407 * @tc.size: SmallTest
408 * @tc.type: Function
409 * @tc.level: Level 3
410 */
411HWTEST_F(DrawingNativePenTest, testPenSetAlphaNull, TestSize.Level3) {
412    // 1. Create a pen object using OH_Drawing_PenCreate
413    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
414    // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha with nullptr as the first parameter
415    OH_Drawing_PenSetAlpha(nullptr, 0xff);
416    // 3. Set the alpha value for the pen using OH_Drawing_PenSetAlpha with 0x00 as the second parameter
417    OH_Drawing_PenSetAlpha(pen, 0x00);
418    // 4. Free the memory
419    OH_Drawing_PenDestroy(pen);
420}
421
422/*
423 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0902
424 * @tc.name: testPenSetAlphaAbnormal
425 * @tc.desc: Test for testPenSetAlphaAbnormal.
426 * @tc.size: SmallTest
427 * @tc.type: Function
428 * @tc.level: Level 3
429 */
430HWTEST_F(DrawingNativePenTest, testPenSetAlphaAbnormal, TestSize.Level3) {
431    // 1. Create a pen object using OH_Drawing_PenCreate
432    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
433    // 2. Set the second parameter of OH_Drawing_PenSetAlpha to a negative number or a floating-point number
434    OH_Drawing_PenSetAlpha(pen, -1);
435    // 3. Call OH_Drawing_PenGetAlpha
436    uint8_t alpha = OH_Drawing_PenGetAlpha(pen);
437    EXPECT_EQ(static_cast<uint8_t>(-1), alpha);
438    // 4. Free the memory
439    OH_Drawing_PenDestroy(pen);
440}
441
442/*
443 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0903
444 * @tc.name: testPenSetAlphaMaximum
445 * @tc.desc: Test for testPenSetAlphaMaximum.
446 * @tc.size: SmallTest
447 * @tc.type: Function
448 * @tc.level: Level 3
449 */
450HWTEST_F(DrawingNativePenTest, testPenSetAlphaMaximum, TestSize.Level3) {
451    // 1. Create a pen object using OH_Drawing_PenCreate
452    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
453    // 2. Set the second parameter of OH_Drawing_PenSetAlpha to a maximum value of 0xFF + 1
454    uint8_t alpha1 = 0xFF;
455    OH_Drawing_PenSetAlpha(pen, alpha1 + 1);
456    // 3. Call OH_Drawing_PenGetAlpha
457    uint8_t alpha2 = OH_Drawing_PenGetAlpha(pen);
458    EXPECT_EQ(alpha2, 0);
459    // 4. Free the memory
460    OH_Drawing_PenDestroy(pen);
461}
462
463/*
464 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1000
465 * @tc.name: testPenGetWidthNormal
466 * @tc.desc: Test for testPenGetWidthNormal.
467 * @tc.size: SmallTest
468 * @tc.type: Function
469 * @tc.level: Level 0
470 */
471HWTEST_F(DrawingNativePenTest, testPenGetWidthNormal, TestSize.Level0) {
472    // 1. Create a pen object using OH_Drawing_PenCreate
473    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
474    // 2. Set the pen width using OH_Drawing_PenSetWidth
475    OH_Drawing_PenSetWidth(pen, 1.0);
476    // 3. Get the pen width using OH_Drawing_PenGetWidth
477    float width = OH_Drawing_PenGetWidth(pen);
478    EXPECT_EQ(width, 1.0);
479    // 4. Free the memory
480    OH_Drawing_PenDestroy(pen);
481}
482
483/*
484 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1001
485 * @tc.name: testPenGetWidthNull
486 * @tc.desc: Test for testPenGetWidthNull.
487 * @tc.size: SmallTest
488 * @tc.type: Function
489 * @tc.level: Level 3
490 */
491HWTEST_F(DrawingNativePenTest, testPenGetWidthNull, TestSize.Level3) {
492    // 1. Create a pen object using OH_Drawing_PenCreate
493    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
494    // 2. Call OH_Drawing_PenGetWidth with nullptr as parameter
495    OH_Drawing_PenGetWidth(nullptr);
496    // 3. Free the memory
497    OH_Drawing_PenDestroy(pen);
498}
499
500/*
501 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1002
502 * @tc.name: testPenGetWidthBoundary
503 * @tc.desc: Test for testPenGetWidthBoundary.
504 * @tc.size: SmallTest
505 * @tc.type: Function
506 * @tc.level: Level 0
507 */
508HWTEST_F(DrawingNativePenTest, testPenGetWidthBoundary, TestSize.Level0) {
509    // 1. Create a pen object using OH_Drawing_PenCreate
510    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
511    // 2. Set the pen width using OH_Drawing_PenSetWidth
512    float width = 4096.0;
513    OH_Drawing_PenSetWidth(pen, width);
514    // 3. Get the pen width using OH_Drawing_PenGetWidth
515    float getWidth = OH_Drawing_PenGetWidth(pen);
516    EXPECT_EQ(width, getWidth);
517    // 4. Free the memory
518    OH_Drawing_PenDestroy(pen);
519}
520
521/*
522 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1100
523 * @tc.name: testPenSetWidthNormal
524 * @tc.desc: Test for testPenSetWidthNormal.
525 * @tc.size: SmallTest
526 * @tc.type: Function
527 * @tc.level: Level 0
528 */
529HWTEST_F(DrawingNativePenTest, testPenSetWidthNormal, TestSize.Level0) {
530    // 1. Create a pen object using OH_Drawing_PenCreate
531    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
532    // 2. Set the pen width using OH_Drawing_PenSetWidth
533    OH_Drawing_PenSetWidth(pen, 1.0);
534    // 3. Get the pen width using OH_Drawing_PenGetWidth
535    float width = OH_Drawing_PenGetWidth(pen);
536    EXPECT_EQ(width, 1.0);
537    // 4. Free the memory
538    OH_Drawing_PenDestroy(pen);
539}
540
541/*
542 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1101
543 * @tc.name: testPenSetWidthNull
544 * @tc.desc: Test for testPenSetWidthNull.
545 * @tc.size: SmallTest
546 * @tc.type: Function
547 * @tc.level: Level 3
548 */
549HWTEST_F(DrawingNativePenTest, testPenSetWidthNull, TestSize.Level3) {
550    // 1. Create a pen object using OH_Drawing_PenCreate
551    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
552    // 2. Call OH_Drawing_PenSetWidth with nullptr as the first parameter
553    OH_Drawing_PenSetWidth(nullptr, 1.00);
554    // 3. Call OH_Drawing_PenSetWidth with 0.00 as the second parameter
555    OH_Drawing_PenSetWidth(pen, 0.00);
556    // 4. Free the memory
557    OH_Drawing_PenDestroy(pen);
558}
559
560/*
561 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1102
562 * @tc.name: testPenSetWidthAbnormal
563 * @tc.desc: Test for testPenSetWidthAbnormal.
564 * @tc.size: SmallTest
565 * @tc.type: Function
566 * @tc.level: Level 3
567 */
568HWTEST_F(DrawingNativePenTest, testPenSetWidthAbnormal, TestSize.Level3) {
569    // 1. Create a pen object using OH_Drawing_PenCreate
570    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
571    // 2. Set the pen width using OH_Drawing_PenSetWidth with an integer or character data as the second parameter
572    int width = 1;
573    OH_Drawing_PenSetWidth(pen, width);
574    // 3. Get the pen width using OH_Drawing_PenGetWidth
575    float width2 = OH_Drawing_PenGetWidth(pen);
576    EXPECT_EQ(static_cast<float>(1), width2);
577    // 4. Free the memory
578    OH_Drawing_PenDestroy(pen);
579}
580
581/*
582 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1103
583 * @tc.name: testPenSetWidthMultipleCalls
584 * @tc.desc: Test for testPenSetWidthMultipleCalls.
585 * @tc.size: SmallTest
586 * @tc.type: Function
587 * @tc.level: Level 3
588 */
589HWTEST_F(DrawingNativePenTest, testPenSetWidthMultipleCalls, TestSize.Level3) {
590    // 1. Create a pen object using OH_Drawing_PenCreate
591    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
592    // 2. Loop through 10 times and set the pen width using OH_Drawing_PenSetWidth
593    for (int i = 0; i < 10; i++) {
594        OH_Drawing_PenSetWidth(pen, 1.0);
595    }
596    // 3. Loop through 10 times and get the pen width using OH_Drawing_PenGetWidth
597    for (int i = 0; i < 10; i++) {
598        float width = OH_Drawing_PenGetWidth(pen);
599        EXPECT_EQ(width, 1.0);
600    }
601    // 4. Free the memory
602    OH_Drawing_PenDestroy(pen);
603}
604
605/*
606 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1104
607 * @tc.name: testPenSetWidthMultipleCallsBoundary
608 * @tc.desc: Test for testPenSetWidthMultipleCallsBoundary.
609 * @tc.size: SmallTest
610 * @tc.type: Function
611 * @tc.level: Level 3
612 */
613HWTEST_F(DrawingNativePenTest, testPenSetWidthMultipleCallsBoundary, TestSize.Level3) {
614    // 1. Create a pen object using OH_Drawing_PenCreate
615    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
616    // 2. Loop through 10 times and set the pen width using OH_Drawing_PenSetWidth
617    for (int i = 0; i < 10; i++) {
618        OH_Drawing_PenSetWidth(pen, 4096.0);
619    }
620    // 3. Loop through 10 times and get the pen width using OH_Drawing_PenGetWidth
621    for (int i = 0; i < 10; i++) {
622        float width = OH_Drawing_PenGetWidth(pen);
623        EXPECT_EQ(width, 4096.0);
624    }
625    // 4. Free the memory
626    OH_Drawing_PenDestroy(pen);
627}
628
629/*
630 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1200
631 * @tc.name: testPenGetMiterLimitNormal
632 * @tc.desc: Test for testPenGetMiterLimitNormal.
633 * @tc.size: SmallTest
634 * @tc.type: Function
635 * @tc.level: Level 0
636 */
637HWTEST_F(DrawingNativePenTest, testPenGetMiterLimitNormal, TestSize.Level0) {
638    // 1. Create a pen object using OH_Drawing_PenCreate
639    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
640    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit
641    OH_Drawing_PenSetMiterLimit(pen, 1.0);
642    // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit
643    float miterLimit = OH_Drawing_PenGetMiterLimit(pen);
644    EXPECT_EQ(miterLimit, 1.0);
645    // 4. Free the memory
646    OH_Drawing_PenDestroy(pen);
647}
648
649/*
650 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1201
651 * @tc.name: testPenGetMiterLimitNull
652 * @tc.desc: Test for testPenGetMiterLimitNull.
653 * @tc.size: SmallTest
654 * @tc.type: Function
655 * @tc.level: Level 3
656 */
657HWTEST_F(DrawingNativePenTest, testPenGetMiterLimitNull, TestSize.Level3) {
658    // 1. Create a pen object using OH_Drawing_PenCreate
659    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
660    // 2. Call OH_Drawing_PenGetMiterLimit with nullptr as parameter
661    OH_Drawing_PenGetMiterLimit(nullptr);
662    // 3. Free the memory
663    OH_Drawing_PenDestroy(pen);
664}
665
666/*
667 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1300
668 * @tc.name: testPenSetMiterLimitNormal
669 * @tc.desc: Test for testPenSetMiterLimitNormal.
670 * @tc.size: SmallTest
671 * @tc.type: Function
672 * @tc.level: Level 0
673 */
674HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitNormal, TestSize.Level0) {
675    // 1. Create a pen object using OH_Drawing_PenCreate
676    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
677    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit
678    OH_Drawing_PenSetMiterLimit(pen, 1.0);
679    // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit
680    float miterLimit = OH_Drawing_PenGetMiterLimit(pen);
681    EXPECT_EQ(miterLimit, 1.0);
682    // 4. Free the memory
683    OH_Drawing_PenDestroy(pen);
684}
685
686/*
687 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1301
688 * @tc.name: testPenSetMiterLimitNull
689 * @tc.desc: Test for testPenSetMiterLimitNull.
690 * @tc.size: SmallTest
691 * @tc.type: Function
692 * @tc.level: Level 3
693 */
694HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitNull, TestSize.Level3) {
695    // 1. Create a pen object using OH_Drawing_PenCreate
696    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
697    // 2. Call OH_Drawing_PenSetMiterLimit with nullptr as the first parameter
698    OH_Drawing_PenSetMiterLimit(nullptr, 1.0);
699    // 3. Call OH_Drawing_PenSetMiterLimit with 0.0 as the second parameter
700    OH_Drawing_PenSetMiterLimit(pen, 0.0);
701    // 4. Free the memory
702    OH_Drawing_PenDestroy(pen);
703}
704
705/*
706 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1302
707 * @tc.name: testPenSetMiterLimitAbnormal
708 * @tc.desc: Test for testPenSetMiterLimitAbnormal.
709 * @tc.size: SmallTest
710 * @tc.type: Function
711 * @tc.level: Level 3
712 */
713HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitAbnormal, TestSize.Level3) {
714    // 1. Create a pen object using OH_Drawing_PenCreate
715    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
716    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit with an integer or character data as the
717    // second parameter
718    int miterLimit = 1;
719    OH_Drawing_PenSetMiterLimit(pen, miterLimit);
720    // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit
721    float miterLimit2 = OH_Drawing_PenGetMiterLimit(pen);
722    EXPECT_EQ(static_cast<float>(1), miterLimit2);
723    // 4. Free the memory
724    OH_Drawing_PenDestroy(pen);
725}
726
727/*
728 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1303
729 * @tc.name: testPenSetMiterLimitMultipleCalls
730 * @tc.desc: Test for testPenSetMiterLimitMultipleCalls.
731 * @tc.size: SmallTest
732 * @tc.type: Function
733 * @tc.level: Level 3
734 */
735HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitMultipleCalls, TestSize.Level3) {
736    // 1. Create a pen object using OH_Drawing_PenCreate
737    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
738    // 2. Loop through 10 times and set the miter limit for the pen using OH_Drawing_PenSetMiterLimit
739    for (int i = 0; i < 10; i++) {
740        OH_Drawing_PenSetMiterLimit(pen, 1.0);
741    }
742    // 3. Loop through 10 times and get the miter limit using OH_Drawing_PenGetMiterLimit
743    for (int i = 0; i < 10; i++) {
744        OH_Drawing_PenGetMiterLimit(pen);
745    }
746    // 4. Free the memory
747    OH_Drawing_PenDestroy(pen);
748}
749
750/*
751 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1400
752 * @tc.name: testPenGetCapNormal
753 * @tc.desc: Test for testPenGetCapNormal.
754 * @tc.size: SmallTest
755 * @tc.type: Function
756 * @tc.level: Level 0
757 */
758HWTEST_F(DrawingNativePenTest, testPenGetCapNormal, TestSize.Level0) {
759    // 1. Create a pen object using OH_Drawing_PenCreate
760    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
761    // 2. Set the pen cap style using OH_Drawing_PenSetCap
762    OH_Drawing_PenSetCap(pen, LINE_FLAT_CAP);
763    // 3. Get the pen cap style using OH_Drawing_PenGetCap
764    OH_Drawing_PenLineCapStyle cap = OH_Drawing_PenGetCap(pen);
765    EXPECT_EQ(cap, LINE_FLAT_CAP);
766    // 4. Free the memory
767    OH_Drawing_PenDestroy(pen);
768}
769
770/*
771 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1401
772 * @tc.name: testPenGetCapNull
773 * @tc.desc: Test for testPenGetCapNull.
774 * @tc.size: SmallTest
775 * @tc.type: Function
776 * @tc.level: Level 3
777 */
778HWTEST_F(DrawingNativePenTest, testPenGetCapNull, TestSize.Level3) {
779    // 1. Create a pen object using OH_Drawing_PenCreate
780    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
781    // 2. Call OH_Drawing_PenGetCap with nullptr as parameter
782    OH_Drawing_PenGetCap(nullptr);
783    // 3. Free the memory
784    OH_Drawing_PenDestroy(pen);
785}
786
787/*
788 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1500
789 * @tc.name: testPenSetCapNormal
790 * @tc.desc: Test for testPenSetCapNormal.
791 * @tc.size: SmallTest
792 * @tc.type: Function
793 * @tc.level: Level 0
794 */
795HWTEST_F(DrawingNativePenTest, testPenSetCapNormal, TestSize.Level0) {
796    // 1. Create a pen object using OH_Drawing_PenCreate
797    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
798    // 2. Call OH_Drawing_PenSetCap with the second parameter as an enumeration by looping through the styles array
799    OH_Drawing_PenLineCapStyle styles[] = {LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP};
800    for (int i = 0; i < 3; i++) {
801        OH_Drawing_PenSetCap(pen, styles[i]);
802        // 3. Get the pen cap style using OH_Drawing_PenGetCap
803        OH_Drawing_PenLineCapStyle cap = OH_Drawing_PenGetCap(pen);
804        EXPECT_EQ(cap, styles[i]);
805    }
806    // 4. Free the memory
807    OH_Drawing_PenDestroy(pen);
808}
809
810/*
811 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1501
812 * @tc.name: testPenSetCapNull
813 * @tc.desc: Test for testPenSetCapNull.
814 * @tc.size: SmallTest
815 * @tc.type: Function
816 * @tc.level: Level 3
817 */
818HWTEST_F(DrawingNativePenTest, testPenSetCapNull, TestSize.Level3) {
819    // 1. Create a pen object using OH_Drawing_PenCreate
820    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
821    // 2. Call OH_Drawing_PenSetCap with nullptr as the first parameter
822    OH_Drawing_PenSetCap(nullptr, LINE_FLAT_CAP);
823    // 3. Free the memory
824    OH_Drawing_PenDestroy(pen);
825}
826
827/*
828 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1502
829 * @tc.name: testPenSetCapMultipleCalls
830 * @tc.desc: Test for testPenSetCapMultipleCalls.
831 * @tc.size: SmallTest
832 * @tc.type: Function
833 * @tc.level: Level 3
834 */
835HWTEST_F(DrawingNativePenTest, testPenSetCapMultipleCalls, TestSize.Level3) {
836    // 1. Create a pen object using OH_Drawing_PenCreate
837    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
838    // 2. Loop through 10 times and set the pen cap style using OH_Drawing_PenSetCap
839    for (int i = 0; i < 10; i++) {
840        OH_Drawing_PenSetCap(pen, LINE_FLAT_CAP);
841    }
842    // 3. Loop through 10 times and get the pen cap style using OH_Drawing_PenGetCap
843    for (int i = 0; i < 10; i++) {
844        OH_Drawing_PenGetCap(pen);
845    }
846    // 4. Free the memory
847    OH_Drawing_PenDestroy(pen);
848}
849
850/*
851 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1600
852 * @tc.name: testPenGetJoinNormal
853 * @tc.desc: Test for testPenGetJoinNormal.
854 * @tc.size: SmallTest
855 * @tc.type: Function
856 * @tc.level: Level 0
857 */
858HWTEST_F(DrawingNativePenTest, testPenGetJoinNormal, TestSize.Level0) {
859    // 1. Create a pen object using OH_Drawing_PenCreate
860    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
861    // 2. Set the join style for the pen using OH_Drawing_PenSetJoin
862    OH_Drawing_PenSetJoin(pen, LINE_MITER_JOIN);
863    // 3. Get the join style using OH_Drawing_PenGetJoin
864    OH_Drawing_PenLineJoinStyle join = OH_Drawing_PenGetJoin(pen);
865    EXPECT_EQ(join, LINE_MITER_JOIN);
866    // 4. Free the memory
867    OH_Drawing_PenDestroy(pen);
868}
869
870/*
871 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1601
872 * @tc.name: testPenGetJoinNull
873 * @tc.desc: Test for testPenGetJoinNull.
874 * @tc.size: SmallTest
875 * @tc.type: Function
876 * @tc.level: Level 3
877 */
878HWTEST_F(DrawingNativePenTest, testPenGetJoinNull, TestSize.Level3) {
879    // 1. Create a pen object using OH_Drawing_PenCreate
880    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
881    // 2. Call OH_Drawing_PenGetJoin with nullptr as parameter
882    OH_Drawing_PenGetJoin(nullptr);
883    // 3. Free the memory
884    OH_Drawing_PenDestroy(pen);
885}
886
887/*
888 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1700
889 * @tc.name: testPenSetJoinNormal
890 * @tc.desc: test for testPenSetJoinNormal.
891 * @tc.size  : SmallTest
892 * @tc.type  : Function
893 * @tc.level : Level 0
894 */
895HWTEST_F(DrawingNativePenTest, testPenSetJoinNormal, TestSize.Level0) {
896    // 1. Create a pen object using OH_Drawing_PenCreate
897    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
898    // 2. Call OH_Drawing_PenSetJoin with the second parameter as an enumeration by looping through the styles array
899    OH_Drawing_PenLineJoinStyle styles[] = {LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN};
900    for (int i = 0; i < 3; i++) {
901        OH_Drawing_PenSetJoin(pen, styles[i]);
902        // 3. Get the join style using OH_Drawing_PenGetJoin
903        OH_Drawing_PenLineJoinStyle join = OH_Drawing_PenGetJoin(pen);
904        EXPECT_EQ(join, styles[i]);
905    }
906    // 4. Free the memory
907    OH_Drawing_PenDestroy(pen);
908}
909
910/*
911 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1701
912 * @tc.name: testPenSetJoinNull
913 * @tc.desc: test for testPenSetJoinNull.
914 * @tc.size  : SmallTest
915 * @tc.type  : Function
916 * @tc.level : Level 3
917 */
918HWTEST_F(DrawingNativePenTest, testPenSetJoinNull, TestSize.Level3) {
919    // 1. Create a pen object using OH_Drawing_PenCreate
920    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
921    // 2. Call OH_Drawing_PenSetJoin with nullptr as the first parameter
922    OH_Drawing_PenSetJoin(nullptr, LINE_MITER_JOIN);
923    // 3. Free the memory
924    OH_Drawing_PenDestroy(pen);
925}
926
927/*
928 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1702
929 * @tc.name: testPenSetJoinMultipleCalls
930 * @tc.desc: test for testPenSetJoinMultipleCalls.
931 * @tc.size  : SmallTest
932 * @tc.type  : Function
933 * @tc.level : Level 3
934 */
935HWTEST_F(DrawingNativePenTest, testPenSetJoinMultipleCalls, TestSize.Level3) {
936    // 1. Create a pen object using OH_Drawing_PenCreate
937    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
938    // 2. Loop through 10 times and set the pen join style using OH_Drawing_PenSetJoin
939    for (int i = 0; i < 10; i++) {
940        OH_Drawing_PenSetJoin(pen, LINE_MITER_JOIN);
941    }
942    // 3. Loop through 10 times and get the pen join style using OH_Drawing_PenGetJoin
943    for (int i = 0; i < 10; i++) {
944        OH_Drawing_PenGetJoin(pen);
945    }
946    // 4. Free the memory
947    OH_Drawing_PenDestroy(pen);
948}
949
950/*
951 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1800
952 * @tc.name: testPenSetShaderEffectNormal
953 * @tc.desc: test for testPenSetShaderEffectNormal.
954 * @tc.size  : SmallTest
955 * @tc.type  : Function
956 * @tc.level : Level 0
957 */
958HWTEST_F(DrawingNativePenTest, testPenSetShaderEffectNormal, TestSize.Level0) {
959    // 1. Create a pen object using OH_Drawing_PenCreate
960    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
961    // 2. Create a shader object using OH_Drawing_ShaderEffectCreate
962    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400);
963    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500);
964    uint32_t color[] = {0xffff0000, 0xff00ff00};
965    float pos[] = {0., 1.0};
966    OH_Drawing_ShaderEffect *linearGradient =
967        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP);
968    // 3. Set the shader effect for the pen using OH_Drawing_PenSetShaderEffect
969    OH_Drawing_PenSetShaderEffect(pen, linearGradient);
970    // 4. Free the memory
971    OH_Drawing_PointDestroy(startPt);
972    OH_Drawing_PointDestroy(endPt);
973    OH_Drawing_ShaderEffectDestroy(linearGradient);
974    OH_Drawing_PenDestroy(pen);
975}
976
977/*
978 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1801
979 * @tc.name: testPenSetShaderEffectNull
980 * @tc.desc: test for testPenSetShaderEffectNull.
981 * @tc.size  : SmallTest
982 * @tc.type  : Function
983 * @tc.level : Level 3
984 */
985HWTEST_F(DrawingNativePenTest, testPenSetShaderEffectNull, TestSize.Level3) {
986    // 1. Create a pen object using OH_Drawing_PenCreate
987    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
988    // 2. Create a shader object using OH_Drawing_ShaderEffectCreate
989    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400);
990    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500);
991    uint32_t color[] = {0xffff0000, 0xff00ff00};
992    float pos[] = {0., 1.0};
993    OH_Drawing_ShaderEffect *linearGradient =
994        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP);
995    // 3. Call OH_Drawing_PenSetShaderEffect with nullptr as the first parameter
996    OH_Drawing_PenSetShaderEffect(nullptr, linearGradient);
997    // 4. Call OH_Drawing_PenSetShaderEffect with nullptr as the second parameter
998    OH_Drawing_PenSetShaderEffect(pen, nullptr);
999    // 5. Free the memory
1000    OH_Drawing_PointDestroy(startPt);
1001    OH_Drawing_PointDestroy(endPt);
1002    OH_Drawing_ShaderEffectDestroy(linearGradient);
1003    OH_Drawing_PenDestroy(pen);
1004}
1005
1006/*
1007 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1900
1008 * @tc.name: testPenSetShadowLayerNormal
1009 * @tc.desc: test for testPenSetShadowLayerNormal.
1010 * @tc.size  : SmallTest
1011 * @tc.type  : Function
1012 * @tc.level : Level 0
1013 */
1014HWTEST_F(DrawingNativePenTest, testPenSetShadowLayerNormal, TestSize.Level0) {
1015    // 1. Create a pen object using OH_Drawing_PenCreate
1016    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1017    // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate
1018    OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000);
1019    // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer
1020    OH_Drawing_PenSetShadowLayer(pen, shadowLayer);
1021    // 4. Free the memory
1022    OH_Drawing_ShadowLayerDestroy(shadowLayer);
1023    OH_Drawing_PenDestroy(pen);
1024}
1025
1026/*
1027 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1901
1028 * @tc.name: testPenSetShadowLayerNull
1029 * @tc.desc: test for testPenSetShadowLayerNull.
1030 * @tc.size  : SmallTest
1031 * @tc.type  : Function
1032 * @tc.level : Level 3
1033 */
1034HWTEST_F(DrawingNativePenTest, testPenSetShadowLayerNull, TestSize.Level3) {
1035    // 1. Create a pen object using OH_Drawing_PenCreate
1036    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1037    // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate
1038    OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000);
1039    // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer with nullptr as the first parameter
1040    OH_Drawing_PenSetShadowLayer(nullptr, shadowLayer);
1041    // 4. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer with nullptr as the second parameter
1042    OH_Drawing_PenSetShadowLayer(pen, nullptr);
1043    // 5. Free the memory
1044    OH_Drawing_ShadowLayerDestroy(shadowLayer);
1045    OH_Drawing_PenDestroy(pen);
1046}
1047
1048/*
1049 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2000
1050 * @tc.name: testPenSetPathEffectNormal
1051 * @tc.desc: test for testPenSetPathEffectNormal.
1052 * @tc.size  : SmallTest
1053 * @tc.type  : Function
1054 * @tc.level : Level 0
1055 */
1056HWTEST_F(DrawingNativePenTest, testPenSetPathEffectNormal, TestSize.Level0) {
1057    // 1. Create a pen object using OH_Drawing_PenCreate
1058    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1059    // 2. Create a path effect object using OH_Drawing_PathEffectCreate
1060    float intervals[] = {1, 1, 1};
1061    OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, 3, 0.0);
1062    // 3. Set the path effect for the pen using OH_Drawing_PenSetPathEffect
1063    OH_Drawing_PenSetPathEffect(pen, pathEffect);
1064    // 4. Free the memory
1065    OH_Drawing_PathEffectDestroy(pathEffect);
1066    OH_Drawing_PenDestroy(pen);
1067}
1068
1069/*
1070 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2001
1071 * @tc.name: testPenSetPathEffectNull
1072 * @tc.desc: test for testPenSetPathEffectNull.
1073 * @tc.size  : SmallTest
1074 * @tc.type  : Function
1075 * @tc.level : Level 3
1076 */
1077HWTEST_F(DrawingNativePenTest, testPenSetPathEffectNull, TestSize.Level3) {
1078    // 1. Create a pen object using OH_Drawing_PenCreate
1079    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1080    // 2. Create a path effect object using OH_Drawing_PathEffectCreate
1081    float intervals[] = {1, 1, 1};
1082    OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, 3, 0.0);
1083    // 3. Set the path effect for the pen with nullptr as the first parameter
1084    OH_Drawing_PenSetPathEffect(nullptr, pathEffect);
1085    // 4. Set the path effect for the pen with nullptr as the second parameter
1086    OH_Drawing_PenSetPathEffect(pen, nullptr);
1087    // 5. Free the memory
1088    OH_Drawing_PathEffectDestroy(pathEffect);
1089    OH_Drawing_PenDestroy(pen);
1090}
1091
1092/*
1093 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2100
1094 * @tc.name: testPenSetFilterNormal
1095 * @tc.desc: test for testPenSetFilterNormal.
1096 * @tc.size  : SmallTest
1097 * @tc.type  : Function
1098 * @tc.level : Level 0
1099 */
1100HWTEST_F(DrawingNativePenTest, testPenSetFilterNormal, TestSize.Level0) {
1101    // 1. Create a pen object using OH_Drawing_PenCreate
1102    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1103    // 2. Create a filter object using OH_Drawing_FilterCreate
1104    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
1105    // 3. Set the filter effect for the pen using OH_Drawing_PenSetFilter
1106    OH_Drawing_PenSetFilter(pen, filter);
1107    // 4. Get the filter effect for the pen using OH_Drawing_PenGetFilter
1108    OH_Drawing_Filter *filter2 = OH_Drawing_FilterCreate();
1109    OH_Drawing_PenGetFilter(pen, filter2);
1110    // 5. Free the memory
1111    OH_Drawing_FilterDestroy(filter);
1112    OH_Drawing_FilterDestroy(filter2);
1113    OH_Drawing_PenDestroy(pen);
1114}
1115
1116/*
1117 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2101
1118 * @tc.name: testPenSetFilterNull
1119 * @tc.desc: test for testPenSetFilterNull.
1120 * @tc.size  : SmallTest
1121 * @tc.type  : Function
1122 * @tc.level : Level 3
1123 */
1124HWTEST_F(DrawingNativePenTest, testPenSetFilterNull, TestSize.Level3) {
1125    // 1. Create a pen object using OH_Drawing_PenCreate
1126    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1127    // 2. Create a filter object using OH_Drawing_FilterCreate
1128    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
1129    // 3. Call OH_Drawing_PenSetFilter with nullptr as the first parameter
1130    OH_Drawing_PenSetFilter(nullptr, filter);
1131    // 4. Call OH_Drawing_PenSetFilter with nullptr as the second parameter
1132    OH_Drawing_PenSetFilter(pen, nullptr);
1133    // 5. Free the memory
1134    OH_Drawing_FilterDestroy(filter);
1135    OH_Drawing_PenDestroy(pen);
1136}
1137
1138/*
1139 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2200
1140 * @tc.name: testPenGetFilterNormal
1141 * @tc.desc: test for testPenGetFilterNormal.
1142 * @tc.size  : SmallTest
1143 * @tc.type  : Function
1144 * @tc.level : Level 0
1145 */
1146HWTEST_F(DrawingNativePenTest, testPenGetFilterNormal, TestSize.Level0) {
1147    // 1. Create a pen object using OH_Drawing_PenCreate
1148    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1149    // 2. Create a filter object using OH_Drawing_FilterCreate
1150    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
1151    // 3. Set the filter effect for the pen using OH_Drawing_PenSetFilter
1152    OH_Drawing_PenSetFilter(pen, filter);
1153    // 4. Get the filter effect for the pen using OH_Drawing_PenGetFilter
1154    OH_Drawing_Filter *filter2 = OH_Drawing_FilterCreate();
1155    OH_Drawing_PenGetFilter(pen, filter2);
1156    // 5. Free the memory
1157    OH_Drawing_FilterDestroy(filter);
1158    OH_Drawing_FilterDestroy(filter2);
1159    OH_Drawing_PenDestroy(pen);
1160}
1161
1162/*
1163 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2201
1164 * @tc.name: testPenGetFilterNull
1165 * @tc.desc: test for testPenGetFilterNull.
1166 * @tc.size  : SmallTest
1167 * @tc.type  : Function
1168 * @tc.level : Level 3
1169 */
1170HWTEST_F(DrawingNativePenTest, testPenGetFilterNull, TestSize.Level3) {
1171    // 1. Create a pen object using OH_Drawing_PenCreate
1172    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1173    // 2. Create a filter object using OH_Drawing_FilterCreate
1174    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
1175    // 3. Call OH_Drawing_PenGetFilter with nullptr as the first parameter
1176    OH_Drawing_PenGetFilter(nullptr, filter);
1177    // 4. Call OH_Drawing_PenGetFilter with nullptr as the second parameter
1178    OH_Drawing_PenGetFilter(pen, nullptr);
1179    // 5. Free the memory
1180    OH_Drawing_FilterDestroy(filter);
1181    OH_Drawing_PenDestroy(pen);
1182}
1183
1184/*
1185 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2300
1186 * @tc.name: testPenSetBlendModeNormal
1187 * @tc.desc: test for testPenSetBlendModeNormal.
1188 * @tc.size  : SmallTest
1189 * @tc.type  : Function
1190 * @tc.level : Level 0
1191 */
1192HWTEST_F(DrawingNativePenTest, testPenSetBlendModeNormal, TestSize.Level0) {
1193    // 1. Create a pen object using OH_Drawing_PenCreate
1194    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1195    // 2. Use a loop to iterate through the enum values of OH_Drawing_BlendMode and call OH_Drawing_PenSetBlendMode with
1196    // the second parameter
1197    OH_Drawing_BlendMode modes[] = {BLEND_MODE_CLEAR, BLEND_MODE_SRC, BLEND_MODE_DST};
1198    for (int i = 0; i < 3; i++) {
1199        OH_Drawing_PenSetBlendMode(pen, modes[i]);
1200    }
1201    // 3. Free the memory
1202    OH_Drawing_PenDestroy(pen);
1203}
1204
1205/*
1206 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2301
1207 * @tc.name: testPenSetBlendModeNull
1208 * @tc.desc: test for testPenSetBlendModeNull.
1209 * @tc.size  : SmallTest
1210 * @tc.type  : Function
1211 * @tc.level : Level 3
1212 */
1213HWTEST_F(DrawingNativePenTest, testPenSetBlendModeNull, TestSize.Level3) {
1214    // 1. Create a pen object using OH_Drawing_PenCreate
1215    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1216    // 2. Call OH_Drawing_PenSetBlendMode with nullptr as the first parameter
1217    OH_Drawing_PenSetBlendMode(nullptr, BLEND_MODE_CLEAR);
1218    // 3. Free the memory
1219    OH_Drawing_PenDestroy(pen);
1220}
1221
1222/*
1223 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2400
1224 * @tc.name: testPenGetFillPathNormal
1225 * @tc.desc: test for testPenGetFillPathNormal.
1226 * @tc.size  : SmallTest
1227 * @tc.type  : Function
1228 * @tc.level : Level 0
1229 */
1230HWTEST_F(DrawingNativePenTest, testPenGetFillPathNormal, TestSize.Level0) {
1231    // 1. Create a pen object using OH_Drawing_PenCreate
1232    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1233    // 2. Create a source path object using OH_Drawing_PathCreate
1234    OH_Drawing_Path *srcPath = OH_Drawing_PathCreate();
1235    // 3. Create a destination path object using OH_Drawing_PathCreate
1236    OH_Drawing_Path *dstPath = OH_Drawing_PathCreate();
1237    // 4. Create a rectangle object using OH_Drawing_RectCreate
1238    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200);
1239    // 5. Create a matrix object using OH_Drawing_MatrixCreate
1240    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1241    // 6. Call OH_Drawing_PenGetFillPath
1242    OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, matrix);
1243    // 7. Free the memory
1244    OH_Drawing_PathDestroy(srcPath);
1245    OH_Drawing_PathDestroy(dstPath);
1246    OH_Drawing_RectDestroy(rect);
1247    OH_Drawing_MatrixDestroy(matrix);
1248    OH_Drawing_PenDestroy(pen);
1249}
1250
1251/*
1252 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2401
1253 * @tc.name: testPenGetFillPathNull
1254 * @tc.desc: test for testPenGetFillPathNull.
1255 * @tc.size  : SmallTest
1256 * @tc.type  : Function
1257 * @tc.level : Level 3
1258 */
1259HWTEST_F(DrawingNativePenTest, testPenGetFillPathNull, TestSize.Level3) {
1260    // 1. Create a pen object using OH_Drawing_PenCreate
1261    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1262    // 2. Create a source path object using OH_Drawing_PathCreate
1263    OH_Drawing_Path *srcPath = OH_Drawing_PathCreate();
1264    // 3. Create a destination path object using OH_Drawing_PathCreate
1265    OH_Drawing_Path *dstPath = OH_Drawing_PathCreate();
1266    // 4. Create a rectangle object using OH_Drawing_RectCreate
1267    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200);
1268    // 5. Create a matrix object using OH_Drawing_MatrixCreate
1269    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1270    // 6. Call OH_Drawing_PenGetFillPath with nullptr as the first parameter
1271    OH_Drawing_PenGetFillPath(nullptr, srcPath, dstPath, rect, matrix);
1272    // 7. Call OH_Drawing_PenGetFillPath with nullptr as the second parameter
1273    OH_Drawing_PenGetFillPath(pen, nullptr, dstPath, rect, matrix);
1274    // 8. Call OH_Drawing_PenGetFillPath with nullptr as the third parameter
1275    OH_Drawing_PenGetFillPath(pen, srcPath, nullptr, rect, matrix);
1276    // 9. Call OH_Drawing_PenGetFillPath with nullptr as the fourth parameter
1277    OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, nullptr, matrix);
1278    // 10. Call OH_Drawing_PenGetFillPath with nullptr as the fifth parameter
1279    OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, nullptr);
1280    // 11. Free the memory
1281    OH_Drawing_PathDestroy(srcPath);
1282    OH_Drawing_PathDestroy(dstPath);
1283    OH_Drawing_RectDestroy(rect);
1284    OH_Drawing_MatrixDestroy(matrix);
1285    OH_Drawing_PenDestroy(pen);
1286}
1287
1288/*
1289 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2500
1290 * @tc.name: testPenResetNormal
1291 * @tc.desc: test for testPenResetNormal.
1292 * @tc.size  : SmallTest
1293 * @tc.type  : Function
1294 * @tc.level : Level 0
1295 */
1296HWTEST_F(DrawingNativePenTest, testPenResetNormal, TestSize.Level0) {
1297    // 1. Create a pen object using OH_Drawing_PenCreate
1298    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1299    // 2. Set the pen color using OH_Drawing_PenSetColor
1300    OH_Drawing_PenSetColor(pen, 0xff0000ff);
1301    // 3. Get the pen color using OH_Drawing_PenGetColor
1302    uint32_t color = OH_Drawing_PenGetColor(pen);
1303    EXPECT_EQ(0xff0000ff, color);
1304    // 4. Reset the pen state using OH_Drawing_PenReset
1305    OH_Drawing_PenReset(pen);
1306    // 5. Get the pen color using OH_Drawing_PenGetColor
1307    color = OH_Drawing_PenGetColor(pen);
1308    OH_Drawing_Pen *pen2 = OH_Drawing_PenCreate();
1309    uint32_t color2 = OH_Drawing_PenGetColor(pen2);
1310    EXPECT_EQ(color2, color);
1311    // 6. Free the memory
1312    OH_Drawing_PenDestroy(pen);
1313}
1314
1315/*
1316 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2501
1317 * @tc.name: testPenResetNull
1318 * @tc.desc: test for testPenResetNull.
1319 * @tc.size  : SmallTest
1320 * @tc.type  : Function
1321 * @tc.level : Level 3
1322 */
1323HWTEST_F(DrawingNativePenTest, testPenResetNull, TestSize.Level3) {
1324    // 1. Create a pen object using OH_Drawing_PenCreate
1325    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1326    // 2. Call OH_Drawing_PenReset with nullptr as the parameter
1327    OH_Drawing_PenReset(nullptr);
1328    // 3. Free the memory
1329    OH_Drawing_PenDestroy(pen);
1330}
1331
1332/*
1333 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2502
1334 * @tc.name: testPenResetMultipleCalls
1335 * @tc.desc: test for testPenResetMultipleCalls.
1336 * @tc.size  : SmallTest
1337 * @tc.type  : Function
1338 * @tc.level : Level 3
1339 */
1340HWTEST_F(DrawingNativePenTest, testPenResetMultipleCalls, TestSize.Level3) {
1341    // 1. Create a pen object using OH_Drawing_PenCreate
1342    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
1343    // 2. Use a loop to call OH_Drawing_PenSetColor and set the pen color 10 times
1344    for (int i = 0; i < 10; i++) {
1345        OH_Drawing_PenSetColor(pen, 0xff0000ff);
1346    }
1347    // 3. Use a loop to call OH_Drawing_PenGetColor and get the pen color 10 times
1348    for (int i = 0; i < 10; i++) {
1349        OH_Drawing_PenGetColor(pen);
1350    }
1351    // 4. Use a loop to call OH_Drawing_PenReset and reset the pen state 10 times
1352    for (int i = 0; i < 10; i++) {
1353        OH_Drawing_PenReset(pen);
1354    }
1355    // 5. Use a loop to call OH_Drawing_PenGetColor and get the pen color 10 times
1356    for (int i = 0; i < 10; i++) {
1357        OH_Drawing_PenGetColor(pen);
1358    }
1359    // 6. Free the memory
1360    OH_Drawing_PenDestroy(pen);
1361}
1362
1363} // namespace Drawing
1364} // namespace Rosen
1365} // namespace OHOS