1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ci#include "gtest/gtest.h"
17f6603c60Sopenharmony_ci
18f6603c60Sopenharmony_ci#include "DrawingNativeCanvasCommon.h"
19f6603c60Sopenharmony_ci#include "drawing_bitmap.h"
20f6603c60Sopenharmony_ci#include "drawing_brush.h"
21f6603c60Sopenharmony_ci#include "drawing_canvas.h"
22f6603c60Sopenharmony_ci#include "drawing_color.h"
23f6603c60Sopenharmony_ci#include "drawing_color_filter.h"
24f6603c60Sopenharmony_ci#include "drawing_filter.h"
25f6603c60Sopenharmony_ci#include "drawing_font.h"
26f6603c60Sopenharmony_ci#include "drawing_image.h"
27f6603c60Sopenharmony_ci#include "drawing_mask_filter.h"
28f6603c60Sopenharmony_ci#include "drawing_matrix.h"
29f6603c60Sopenharmony_ci#include "drawing_memory_stream.h"
30f6603c60Sopenharmony_ci#include "drawing_path.h"
31f6603c60Sopenharmony_ci#include "drawing_pen.h"
32f6603c60Sopenharmony_ci#include "drawing_point.h"
33f6603c60Sopenharmony_ci#include "drawing_rect.h"
34f6603c60Sopenharmony_ci#include "drawing_region.h"
35f6603c60Sopenharmony_ci#include "drawing_round_rect.h"
36f6603c60Sopenharmony_ci#include "drawing_sampling_options.h"
37f6603c60Sopenharmony_ci#include "drawing_shader_effect.h"
38f6603c60Sopenharmony_ci#include "drawing_text_blob.h"
39f6603c60Sopenharmony_ci#include "drawing_typeface.h"
40f6603c60Sopenharmony_ci
41f6603c60Sopenharmony_ciusing namespace testing;
42f6603c60Sopenharmony_ciusing namespace testing::ext;
43f6603c60Sopenharmony_ci
44f6603c60Sopenharmony_cinamespace OHOS {
45f6603c60Sopenharmony_cinamespace Rosen {
46f6603c60Sopenharmony_cinamespace Drawing {
47f6603c60Sopenharmony_ci
48f6603c60Sopenharmony_ci/*
49f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2900
50f6603c60Sopenharmony_ci * @tc.name: testCanvasSkewNormal
51f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSkewNormal.
52f6603c60Sopenharmony_ci * @tc.size  : SmallTest
53f6603c60Sopenharmony_ci * @tc.type  : Function
54f6603c60Sopenharmony_ci * @tc.level : Level 0
55f6603c60Sopenharmony_ci */
56f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSkewNormal, TestSize.Level0) {
57f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
58f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
59f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasSkew with positive skew values on the x and y axes
60f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, 1.0, 1.0);
61f6603c60Sopenharmony_ci    // 3. Call drawing class interface
62f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect1 = OH_Drawing_RectCreate(0, 0, 100, 100);
63f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect1);
64f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasSkew with negative skew values on the x and y axes
65f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, -1.0, -1.0);
66f6603c60Sopenharmony_ci    // 5. Call drawing class interface
67f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 0, 100, 100);
68f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect2);
69f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasSkew with positive skew value on the x-axis and negative skew value on the y-axis
70f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, 1.0, -1.0);
71f6603c60Sopenharmony_ci    // 7. Call drawing class interface
72f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 0, 100, 100);
73f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect3);
74f6603c60Sopenharmony_ci    // 8. Free memory
75f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect1);
76f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect2);
77f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect3);
78f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
79f6603c60Sopenharmony_ci}
80f6603c60Sopenharmony_ci
81f6603c60Sopenharmony_ci/*
82f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2901
83f6603c60Sopenharmony_ci * @tc.name: testCanvasSkewNull
84f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSkewNull.
85f6603c60Sopenharmony_ci * @tc.size  : SmallTest
86f6603c60Sopenharmony_ci * @tc.type  : Function
87f6603c60Sopenharmony_ci * @tc.level : Level 3
88f6603c60Sopenharmony_ci */
89f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSkewNull, TestSize.Level3) {
90f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
91f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
92f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasSkew with the first parameter as null
93f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(nullptr, 2, 2);
94f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasSkew with the second parameter as 0
95f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, 0, 2);
96f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasSkew with the third parameter as 0
97f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, 2, 0);
98f6603c60Sopenharmony_ci    // 5. Free memory
99f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
100f6603c60Sopenharmony_ci}
101f6603c60Sopenharmony_ci
102f6603c60Sopenharmony_ci/*
103f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2903
104f6603c60Sopenharmony_ci * @tc.name: testCanvasSkewMaximum
105f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSkewMaximum.
106f6603c60Sopenharmony_ci * @tc.size  : SmallTest
107f6603c60Sopenharmony_ci * @tc.type  : Function
108f6603c60Sopenharmony_ci * @tc.level : Level 3
109f6603c60Sopenharmony_ci */
110f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSkewMaximum, TestSize.Level3) {
111f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
112f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
113f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasSkew with the skew amount sx on the x-axis as the maximum value
114f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, FLT_MAX, 1);
115f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasSkew with the skew amount sy on the y-axis as the maximum value
116f6603c60Sopenharmony_ci    OH_Drawing_CanvasSkew(canvas, 1, FLT_MAX);
117f6603c60Sopenharmony_ci    // 4. Free memory
118f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
119f6603c60Sopenharmony_ci}
120f6603c60Sopenharmony_ci
121f6603c60Sopenharmony_ci/*
122f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2904
123f6603c60Sopenharmony_ci * @tc.name: testCanvasSkewInputDestroyed
124f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSkewInputDestroyed.
125f6603c60Sopenharmony_ci * @tc.size  : SmallTest
126f6603c60Sopenharmony_ci * @tc.type  : Function
127f6603c60Sopenharmony_ci * @tc.level : Level 3
128f6603c60Sopenharmony_ci */
129f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSkewInputDestroyed, TestSize.Level3) {
130f6603c60Sopenharmony_ci    // Deprecated
131f6603c60Sopenharmony_ci}
132f6603c60Sopenharmony_ci
133f6603c60Sopenharmony_ci/*
134f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2905
135f6603c60Sopenharmony_ci * @tc.name: testCanvasSkewMultipleCalls
136f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSkewMultipleCalls.
137f6603c60Sopenharmony_ci * @tc.size  : SmallTest
138f6603c60Sopenharmony_ci * @tc.type  : Function
139f6603c60Sopenharmony_ci * @tc.level : Level 3
140f6603c60Sopenharmony_ci */
141f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSkewMultipleCalls, TestSize.Level3) {
142f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
143f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
144f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasSkew 10 times, each time with a different skew value
145f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
146f6603c60Sopenharmony_ci        float skew = i * 0.1;
147f6603c60Sopenharmony_ci        OH_Drawing_CanvasSkew(canvas, skew, skew);
148f6603c60Sopenharmony_ci    }
149f6603c60Sopenharmony_ci    // 3. Call drawing class interface
150f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
151f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
152f6603c60Sopenharmony_ci    // 4. Free memory
153f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
154f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
155f6603c60Sopenharmony_ci}
156f6603c60Sopenharmony_ci
157f6603c60Sopenharmony_ci/*
158f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3000
159f6603c60Sopenharmony_ci * @tc.name: testCanvasGetWidthtestCanvasGetHeightNormal
160f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetWidthtestCanvasGetHeightNormal.
161f6603c60Sopenharmony_ci * @tc.size  : SmallTest
162f6603c60Sopenharmony_ci * @tc.type  : Function
163f6603c60Sopenharmony_ci * @tc.level : Level 0
164f6603c60Sopenharmony_ci */
165f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetWidthtestCanvasGetHeightNormal, TestSize.Level0) {
166f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
167f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
168f6603c60Sopenharmony_ci    // 2. Switch the binding to a bitmap canvas using OH_Drawing_CanvasBind, and verify the canvas information by
169f6603c60Sopenharmony_ci    // calling OH_Drawing_CanvasGetHeight and OH_Drawing_CanvasGetWidth
170f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
171f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
172f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
173f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
174f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
175f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas, bitmap);
176f6603c60Sopenharmony_ci    int32_t canvasWidth = OH_Drawing_CanvasGetWidth(canvas);
177f6603c60Sopenharmony_ci    int32_t canvasHeight = OH_Drawing_CanvasGetHeight(canvas);
178f6603c60Sopenharmony_ci    EXPECT_EQ(canvasWidth, width);
179f6603c60Sopenharmony_ci    EXPECT_EQ(canvasHeight, height);
180f6603c60Sopenharmony_ci    // 3. Free memory
181f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
182f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
183f6603c60Sopenharmony_ci}
184f6603c60Sopenharmony_ci
185f6603c60Sopenharmony_ci/*
186f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3001
187f6603c60Sopenharmony_ci * @tc.name: testCanvasGetWidthtestCanvasGetHeightNull
188f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetWidthtestCanvasGetHeightNull.
189f6603c60Sopenharmony_ci * @tc.size  : SmallTest
190f6603c60Sopenharmony_ci * @tc.type  : Function
191f6603c60Sopenharmony_ci * @tc.level : Level 3
192f6603c60Sopenharmony_ci */
193f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetWidthtestCanvasGetHeightNull, TestSize.Level3) {
194f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
195f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
196f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasGetHeight with null input
197f6603c60Sopenharmony_ci    int32_t canvasHeight = OH_Drawing_CanvasGetHeight(nullptr);
198f6603c60Sopenharmony_ci    EXPECT_EQ(canvasHeight, 0);
199f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasGetWidth with null input
200f6603c60Sopenharmony_ci    int32_t canvasWidth = OH_Drawing_CanvasGetWidth(nullptr);
201f6603c60Sopenharmony_ci    EXPECT_EQ(canvasWidth, 0);
202f6603c60Sopenharmony_ci    // 4. Free memory
203f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
204f6603c60Sopenharmony_ci}
205f6603c60Sopenharmony_ci
206f6603c60Sopenharmony_ci/*
207f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3002
208f6603c60Sopenharmony_ci * @tc.name: testCanvasGetWidthtestCanvasGetHeightMultipleCalls
209f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetWidthtestCanvasGetHeightMultipleCalls.
210f6603c60Sopenharmony_ci * @tc.size  : SmallTest
211f6603c60Sopenharmony_ci * @tc.type  : Function
212f6603c60Sopenharmony_ci * @tc.level : Level 3
213f6603c60Sopenharmony_ci */
214f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetWidthtestCanvasGetHeightMultipleCalls, TestSize.Level3) {
215f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
216f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
217f6603c60Sopenharmony_ci    // 2. Switch the binding to a bitmap canvas with different widths and heights 10 times, and verify the canvas
218f6603c60Sopenharmony_ci    // information by calling OH_Drawing_CanvasGetHeight and OH_Drawing_CanvasGetWidth after each switch
219f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
220f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
221f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
222f6603c60Sopenharmony_ci        uint32_t width = 200 + i * 10;
223f6603c60Sopenharmony_ci        uint32_t height = 200 + i * 10;
224f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
225f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
226f6603c60Sopenharmony_ci        int32_t canvasWidth = OH_Drawing_CanvasGetWidth(canvas);
227f6603c60Sopenharmony_ci        int32_t canvasHeight = OH_Drawing_CanvasGetHeight(canvas);
228f6603c60Sopenharmony_ci        EXPECT_EQ(canvasWidth, width);
229f6603c60Sopenharmony_ci        EXPECT_EQ(canvasHeight, height);
230f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
231f6603c60Sopenharmony_ci    }
232f6603c60Sopenharmony_ci    // 3. Switch the binding to different widths and heights of bitmap canvas 10 times
233f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
234f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
235f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
236f6603c60Sopenharmony_ci        uint32_t width = 200 + i * 10;
237f6603c60Sopenharmony_ci        uint32_t height = 200 + i * 10;
238f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
239f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
240f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
241f6603c60Sopenharmony_ci    }
242f6603c60Sopenharmony_ci
243f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasGetHeight and OH_Drawing_CanvasGetWidth 10 times to verify the canvas
244f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
245f6603c60Sopenharmony_ci        int32_t canvasWidth = OH_Drawing_CanvasGetWidth(canvas);
246f6603c60Sopenharmony_ci        int32_t canvasHeight = OH_Drawing_CanvasGetHeight(canvas);
247f6603c60Sopenharmony_ci        EXPECT_EQ(canvasWidth, 200 + 90);
248f6603c60Sopenharmony_ci        EXPECT_EQ(canvasHeight, 200 + 90);
249f6603c60Sopenharmony_ci    }
250f6603c60Sopenharmony_ci
251f6603c60Sopenharmony_ci    // 5. Free memory
252f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
253f6603c60Sopenharmony_ci}
254f6603c60Sopenharmony_ci
255f6603c60Sopenharmony_ci/*
256f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3003
257f6603c60Sopenharmony_ci * @tc.name: testCanvasGetWidthtestCanvasGetHeightInputDestroyed
258f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetWidthtestCanvasGetHeightInputDestroyed.
259f6603c60Sopenharmony_ci * @tc.size  : SmallTest
260f6603c60Sopenharmony_ci * @tc.type  : Function
261f6603c60Sopenharmony_ci * @tc.level : Level 3
262f6603c60Sopenharmony_ci */
263f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetWidthtestCanvasGetHeightInputDestroyed, TestSize.Level3) {
264f6603c60Sopenharmony_ci    // Deprecated
265f6603c60Sopenharmony_ci}
266f6603c60Sopenharmony_ci
267f6603c60Sopenharmony_ci/*
268f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3004
269f6603c60Sopenharmony_ci * @tc.name: testCanvasGetWidthtestCanvasGetHeightMultipleCallsBoudary
270f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetWidthtestCanvasGetHeightMultipleCallsBoudary.
271f6603c60Sopenharmony_ci * @tc.size  : SmallTest
272f6603c60Sopenharmony_ci * @tc.type  : Function
273f6603c60Sopenharmony_ci * @tc.level : Level 3
274f6603c60Sopenharmony_ci */
275f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetWidthtestCanvasGetHeightMultipleCallsBoudary, TestSize.Level3) {
276f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
277f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
278f6603c60Sopenharmony_ci    // 2. Switch the binding to a bitmap canvas with different widths and heights 10 times, and verify the canvas
279f6603c60Sopenharmony_ci    // information by calling OH_Drawing_CanvasGetHeight and OH_Drawing_CanvasGetWidth after each switch
280f6603c60Sopenharmony_ci    constexpr uint32_t width = 4096;
281f6603c60Sopenharmony_ci    constexpr uint32_t height = 2160;
282f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
283f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
284f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
285f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
286f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
287f6603c60Sopenharmony_ci        int32_t canvasWidth = OH_Drawing_CanvasGetWidth(canvas);
288f6603c60Sopenharmony_ci        int32_t canvasHeight = OH_Drawing_CanvasGetHeight(canvas);
289f6603c60Sopenharmony_ci        EXPECT_EQ(canvasWidth, width);
290f6603c60Sopenharmony_ci        EXPECT_EQ(canvasHeight, height);
291f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
292f6603c60Sopenharmony_ci    }
293f6603c60Sopenharmony_ci    // 3. Switch the binding to different widths and heights of bitmap canvas 10 times
294f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
295f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
296f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
297f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
298f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
299f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
300f6603c60Sopenharmony_ci    }
301f6603c60Sopenharmony_ci
302f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasGetHeight and OH_Drawing_CanvasGetWidth 10 times to verify the canvas
303f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
304f6603c60Sopenharmony_ci        int32_t canvasWidth = OH_Drawing_CanvasGetWidth(canvas);
305f6603c60Sopenharmony_ci        int32_t canvasHeight = OH_Drawing_CanvasGetHeight(canvas);
306f6603c60Sopenharmony_ci        EXPECT_EQ(canvasWidth, width);
307f6603c60Sopenharmony_ci        EXPECT_EQ(canvasHeight, height);
308f6603c60Sopenharmony_ci    }
309f6603c60Sopenharmony_ci
310f6603c60Sopenharmony_ci    // 5. Free memory
311f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
312f6603c60Sopenharmony_ci}
313f6603c60Sopenharmony_ci
314f6603c60Sopenharmony_ci/*
315f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3100
316f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsNormal
317f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsNormal.
318f6603c60Sopenharmony_ci * @tc.size  : SmallTest
319f6603c60Sopenharmony_ci * @tc.type  : Function
320f6603c60Sopenharmony_ci * @tc.level : Level 0
321f6603c60Sopenharmony_ci */
322f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsNormal, TestSize.Level0) {
323f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
324f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
325f6603c60Sopenharmony_ci    // 2. OH_Drawing_RectCreate
326f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
327f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasGetLocalClipBounds
328f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
329f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawRect
330f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
331f6603c60Sopenharmony_ci    // 5. Free memory
332f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
333f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
334f6603c60Sopenharmony_ci}
335f6603c60Sopenharmony_ci
336f6603c60Sopenharmony_ci/*
337f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3101
338f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsNull
339f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsNull.
340f6603c60Sopenharmony_ci * @tc.size  : SmallTest
341f6603c60Sopenharmony_ci * @tc.type  : Function
342f6603c60Sopenharmony_ci * @tc.level : Level 3
343f6603c60Sopenharmony_ci */
344f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsNull, TestSize.Level3) {
345f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
346f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
347f6603c60Sopenharmony_ci    // 2. OH_Drawing_RectCreate
348f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
349f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasGetLocalClipBounds with the first parameter as null
350f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(nullptr, rect);
351f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasGetLocalClipBounds with the second parameter as null
352f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, nullptr);
353f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect created with left, top, right, bottom as 0
354f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(0, 100, 100, 100);
355f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
356f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 0, 100, 100);
357f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
358f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 100, 0, 100);
359f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
360f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 100, 100, 0);
361f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
362f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect created with all values as 0
363f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(0, 0, 0, 0);
364f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
365f6603c60Sopenharmony_ci    // 7. Free memory
366f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
367f6603c60Sopenharmony_ci}
368f6603c60Sopenharmony_ci
369f6603c60Sopenharmony_ci/*
370f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3102
371f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsAbnormal
372f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsAbnormal.
373f6603c60Sopenharmony_ci * @tc.size  : SmallTest
374f6603c60Sopenharmony_ci * @tc.type  : Function
375f6603c60Sopenharmony_ci * @tc.level : Level 3
376f6603c60Sopenharmony_ci */
377f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsAbnormal, TestSize.Level3) {
378f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
379f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
380f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect created with negative values for left, top, right,
381f6603c60Sopenharmony_ci    // and bottom
382f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect1 = OH_Drawing_RectCreate(-100, 100, 100, 100);
383f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect1);
384f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(100, -100, 100, 100);
385f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect2);
386f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(100, 100, -100, 100);
387f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect3);
388f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect4 = OH_Drawing_RectCreate(100, 100, 100, -100);
389f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect4);
390f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect src created with the top-left coordinate equal to the
391f6603c60Sopenharmony_ci    // bottom-right coordinate or the top-left coordinate equal to the bottom-right coordinate
392f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect5 = OH_Drawing_RectCreate(100, 200, 200, 200);
393f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect5);
394f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect6 = OH_Drawing_RectCreate(200, 100, 200, 200);
395f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect6);
396f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect src created with the top-left coordinate equal to the
397f6603c60Sopenharmony_ci    // bottom-right coordinate
398f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect7 = OH_Drawing_RectCreate(100, 100, 100, 100);
399f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect7);
400f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasGetLocalClipBounds with OH_Drawing_Rect src created with the top-left coordinate greater than
401f6603c60Sopenharmony_ci    // the bottom-right coordinate
402f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect8 = OH_Drawing_RectCreate(200, 200, 100, 100);
403f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetLocalClipBounds(canvas, rect8);
404f6603c60Sopenharmony_ci    // 6. Free memory
405f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect1);
406f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect2);
407f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect3);
408f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect4);
409f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect5);
410f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect6);
411f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect7);
412f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect8);
413f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
414f6603c60Sopenharmony_ci}
415f6603c60Sopenharmony_ci
416f6603c60Sopenharmony_ci/*
417f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3103
418f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsMultipleCalls
419f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsMultipleCalls.
420f6603c60Sopenharmony_ci * @tc.size  : SmallTest
421f6603c60Sopenharmony_ci * @tc.type  : Function
422f6603c60Sopenharmony_ci * @tc.level : Level 3
423f6603c60Sopenharmony_ci */
424f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsMultipleCalls, TestSize.Level3) {
425f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
426f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
427f6603c60Sopenharmony_ci    // 2. Switch the binding to a bitmap canvas with different widths and heights 10 times, and verify the canvas
428f6603c60Sopenharmony_ci    // information by calling OH_Drawing_CanvasGetLocalClipBounds after each switch
429f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
430f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
431f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
432f6603c60Sopenharmony_ci        uint32_t width = 200;
433f6603c60Sopenharmony_ci        uint32_t height = 200;
434f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
435f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
436f6603c60Sopenharmony_ci        OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, width, height);
437f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
438f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rect);
439f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
440f6603c60Sopenharmony_ci    }
441f6603c60Sopenharmony_ci    // 3. Switch the binding to different widths and heights of bitmap canvas 10 times
442f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
443f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
444f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
445f6603c60Sopenharmony_ci        uint32_t width = 200 + i * 10;
446f6603c60Sopenharmony_ci        uint32_t height = 200 + i * 10;
447f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
448f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
449f6603c60Sopenharmony_ci        OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, width, height);
450f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
451f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rect);
452f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
453f6603c60Sopenharmony_ci    }
454f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasGetLocalClipBounds 10 times to verify the canvas
455f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
456f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
457f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
458f6603c60Sopenharmony_ci    }
459f6603c60Sopenharmony_ci    // 5. Free memory
460f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
461f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
462f6603c60Sopenharmony_ci}
463f6603c60Sopenharmony_ci
464f6603c60Sopenharmony_ci/*
465f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3104
466f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsInputDestroyed
467f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsInputDestroyed.
468f6603c60Sopenharmony_ci * @tc.size  : SmallTest
469f6603c60Sopenharmony_ci * @tc.type  : Function
470f6603c60Sopenharmony_ci * @tc.level : Level 3
471f6603c60Sopenharmony_ci */
472f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsInputDestroyed, TestSize.Level3) {
473f6603c60Sopenharmony_ci    // Deprecated
474f6603c60Sopenharmony_ci}
475f6603c60Sopenharmony_ci
476f6603c60Sopenharmony_ci/*
477f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3105
478f6603c60Sopenharmony_ci * @tc.name: testCanvasGetLocalClipBoundsMultipleCallsBoundary
479f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetLocalClipBoundsMultipleCallsBoundary.
480f6603c60Sopenharmony_ci * @tc.size  : SmallTest
481f6603c60Sopenharmony_ci * @tc.type  : Function
482f6603c60Sopenharmony_ci * @tc.level : Level 3
483f6603c60Sopenharmony_ci */
484f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetLocalClipBoundsMultipleCallsBoundary, TestSize.Level3) {
485f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
486f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
487f6603c60Sopenharmony_ci    // 2. Switch the binding to a bitmap canvas with different widths and heights 10 times, and verify the canvas
488f6603c60Sopenharmony_ci    // information by calling OH_Drawing_CanvasGetLocalClipBounds after each switch
489f6603c60Sopenharmony_ci    uint32_t width = 4096;
490f6603c60Sopenharmony_ci    uint32_t height = 2160;
491f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
492f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
493f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
494f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
495f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
496f6603c60Sopenharmony_ci        OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, width, height);
497f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
498f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rect);
499f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
500f6603c60Sopenharmony_ci    }
501f6603c60Sopenharmony_ci    // 3. Switch the binding to different widths and heights of bitmap canvas 10 times
502f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
503f6603c60Sopenharmony_ci        OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
504f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
505f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
506f6603c60Sopenharmony_ci        OH_Drawing_CanvasBind(canvas, bitmap);
507f6603c60Sopenharmony_ci        OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, width, height);
508f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
509f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rect);
510f6603c60Sopenharmony_ci        OH_Drawing_BitmapDestroy(bitmap);
511f6603c60Sopenharmony_ci    }
512f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasGetLocalClipBounds 10 times to verify the canvas
513f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
514f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
515f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetLocalClipBounds(canvas, rect);
516f6603c60Sopenharmony_ci    }
517f6603c60Sopenharmony_ci    // 5. Free memory
518f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
519f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
520f6603c60Sopenharmony_ci}
521f6603c60Sopenharmony_ci
522f6603c60Sopenharmony_ci/*
523f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3200
524f6603c60Sopenharmony_ci * @tc.name: testCanvasConcatMatrixtestCanvasGetTotalMatrixNormal
525f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasConcatMatrixtestCanvasGetTotalMatrixNormal.
526f6603c60Sopenharmony_ci * @tc.size  : SmallTest
527f6603c60Sopenharmony_ci * @tc.type  : Function
528f6603c60Sopenharmony_ci * @tc.level : Level 0
529f6603c60Sopenharmony_ci */
530f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasConcatMatrixtestCanvasGetTotalMatrixNormal, TestSize.Level0) {
531f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
532f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
533f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
534f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
535f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
536f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasConcatMatrix to get the 3x3 matrix of the canvas by calling
537f6603c60Sopenharmony_ci    // OH_Drawing_CanvasGetTotalMatrix
538f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(canvas, matrix);
539f6603c60Sopenharmony_ci    OH_Drawing_Matrix *totalMatrix = OH_Drawing_MatrixCreate();
540f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix);
541f6603c60Sopenharmony_ci    EXPECT_NE(totalMatrix, nullptr);
542f6603c60Sopenharmony_ci    // 4. Free memory
543f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
544f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(totalMatrix);
545f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
546f6603c60Sopenharmony_ci}
547f6603c60Sopenharmony_ci
548f6603c60Sopenharmony_ci/*
549f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3201
550f6603c60Sopenharmony_ci * @tc.name: testCanvasConcatMatrixNull
551f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasConcatMatrixNull.
552f6603c60Sopenharmony_ci * @tc.size  : SmallTest
553f6603c60Sopenharmony_ci * @tc.type  : Function
554f6603c60Sopenharmony_ci * @tc.level : Level 3
555f6603c60Sopenharmony_ci */
556f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasConcatMatrixNull, TestSize.Level3) {
557f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
558f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
559f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
560f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
561f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
562f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasConcatMatrix with the first parameter as null
563f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(nullptr, matrix);
564f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasConcatMatrix with the second parameter as null
565f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(canvas, nullptr);
566f6603c60Sopenharmony_ci    // 5. Free memory
567f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
568f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
569f6603c60Sopenharmony_ci}
570f6603c60Sopenharmony_ci
571f6603c60Sopenharmony_ci/*
572f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3202
573f6603c60Sopenharmony_ci * @tc.name: testCanvasGetTotalMatrixNull
574f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetTotalMatrixNull.
575f6603c60Sopenharmony_ci * @tc.size  : SmallTest
576f6603c60Sopenharmony_ci * @tc.type  : Function
577f6603c60Sopenharmony_ci * @tc.level : Level 3
578f6603c60Sopenharmony_ci */
579f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetTotalMatrixNull, TestSize.Level3) {
580f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
581f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
582f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
583f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
584f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasGetTotalMatrix with the first parameter as null
585f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(nullptr, matrix);
586f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasGetTotalMatrix with the second parameter as null
587f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(canvas, nullptr);
588f6603c60Sopenharmony_ci    // 5. Free memory
589f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
590f6603c60Sopenharmony_ci}
591f6603c60Sopenharmony_ci
592f6603c60Sopenharmony_ci/*
593f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3203
594f6603c60Sopenharmony_ci * @tc.name: testCanvasConcatMatrixtestCanvasGetTotalMatrixMultipleCalls
595f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasConcatMatrixtestCanvasGetTotalMatrixMultipleCalls.
596f6603c60Sopenharmony_ci * @tc.size  : SmallTest
597f6603c60Sopenharmony_ci * @tc.type  : Function
598f6603c60Sopenharmony_ci * @tc.level : Level 3
599f6603c60Sopenharmony_ci */
600f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasConcatMatrixtestCanvasGetTotalMatrixMultipleCalls, TestSize.Level3) {
601f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
602f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
603f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateScale
604f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(10, 10, 10, 10);
605f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasConcatMatrix to get the 3x3 matrix of the canvas by calling
606f6603c60Sopenharmony_ci    // OH_Drawing_CanvasGetTotalMatrix
607f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(canvas, matrix);
608f6603c60Sopenharmony_ci    OH_Drawing_Matrix *totalMatrix = OH_Drawing_MatrixCreate();
609f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix);
610f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixCreateRotation
611f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateRotation(180, 1, 1);
612f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_CanvasConcatMatrix to get the 3x3 matrix of the canvas by calling
613f6603c60Sopenharmony_ci    // OH_Drawing_CanvasGetTotalMatrix
614f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(canvas, matrix2);
615f6603c60Sopenharmony_ci    OH_Drawing_Matrix *totalMatrix2 = OH_Drawing_MatrixCreate();
616f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix2);
617f6603c60Sopenharmony_ci    // 6. OH_Drawing_MatrixCreateTranslation
618f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateTranslation(10, 10);
619f6603c60Sopenharmony_ci    // 7. Call OH_Drawing_CanvasConcatMatrix to get the 3x3 matrix of the canvas by calling
620f6603c60Sopenharmony_ci    // OH_Drawing_CanvasGetTotalMatrix
621f6603c60Sopenharmony_ci    OH_Drawing_CanvasConcatMatrix(canvas, matrix3);
622f6603c60Sopenharmony_ci    OH_Drawing_Matrix *totalMatrix3 = OH_Drawing_MatrixCreate();
623f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix3);
624f6603c60Sopenharmony_ci    // 8. Repeat steps 2-7 10 times
625f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
626f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(10, 10, 10, 10);
627f6603c60Sopenharmony_ci        OH_Drawing_CanvasConcatMatrix(canvas, matrix);
628f6603c60Sopenharmony_ci        OH_Drawing_Matrix *totalMatrix = OH_Drawing_MatrixCreate();
629f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix);
630f6603c60Sopenharmony_ci
631f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateRotation(180, 1, 1);
632f6603c60Sopenharmony_ci        OH_Drawing_CanvasConcatMatrix(canvas, matrix2);
633f6603c60Sopenharmony_ci        OH_Drawing_Matrix *totalMatrix2 = OH_Drawing_MatrixCreate();
634f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix2);
635f6603c60Sopenharmony_ci
636f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateTranslation(10, 10);
637f6603c60Sopenharmony_ci        OH_Drawing_CanvasConcatMatrix(canvas, matrix3);
638f6603c60Sopenharmony_ci        OH_Drawing_Matrix *totalMatrix3 = OH_Drawing_MatrixCreate();
639f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetTotalMatrix(canvas, totalMatrix3);
640f6603c60Sopenharmony_ci
641f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
642f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix2);
643f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix3);
644f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(totalMatrix);
645f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(totalMatrix2);
646f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(totalMatrix3);
647f6603c60Sopenharmony_ci    }
648f6603c60Sopenharmony_ci    // 9. Call OH_Drawing_CanvasConcatMatrix 10 times
649f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
650f6603c60Sopenharmony_ci        OH_Drawing_CanvasConcatMatrix(canvas, matrix);
651f6603c60Sopenharmony_ci    }
652f6603c60Sopenharmony_ci
653f6603c60Sopenharmony_ci    // 10. Free memory
654f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
655f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
656f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
657f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(totalMatrix);
658f6603c60Sopenharmony_ci}
659f6603c60Sopenharmony_ci
660f6603c60Sopenharmony_ci/*
661f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3204
662f6603c60Sopenharmony_ci * @tc.name: testCanvasConcatMatrixtestCanvasGetTotalMatrixInputDestroyed
663f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasConcatMatrixtestCanvasGetTotalMatrixInputDestroyed.
664f6603c60Sopenharmony_ci * @tc.size  : SmallTest
665f6603c60Sopenharmony_ci * @tc.type  : Function
666f6603c60Sopenharmony_ci * @tc.level : Level 3
667f6603c60Sopenharmony_ci */
668f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasConcatMatrixtestCanvasGetTotalMatrixInputDestroyed, TestSize.Level3) {
669f6603c60Sopenharmony_ci    // Deprecated
670f6603c60Sopenharmony_ci}
671f6603c60Sopenharmony_ci
672f6603c60Sopenharmony_ci/*
673f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3300
674f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawShadowNormal
675f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawShadowNormal.
676f6603c60Sopenharmony_ci * @tc.size  : SmallTest
677f6603c60Sopenharmony_ci * @tc.type  : Function
678f6603c60Sopenharmony_ci * @tc.level : Level 0
679f6603c60Sopenharmony_ci */
680f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawShadowNormal, TestSize.Level0) {
681f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
682f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
683f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
684f6603c60Sopenharmony_ci    // 2. OH_Drawing_PathCreate
685f6603c60Sopenharmony_ci    OH_Drawing_Path *path = OH_Drawing_PathCreate();
686f6603c60Sopenharmony_ci    EXPECT_NE(path, nullptr);
687f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawShadow, iterate through the OH_Drawing_CanvasShadowFlags enumeration values
688f6603c60Sopenharmony_ci    OH_Drawing_CanvasShadowFlags flags[] = {
689f6603c60Sopenharmony_ci        SHADOW_FLAGS_NONE,
690f6603c60Sopenharmony_ci        SHADOW_FLAGS_TRANSPARENT_OCCLUDER,
691f6603c60Sopenharmony_ci        SHADOW_FLAGS_GEOMETRIC_ONLY,
692f6603c60Sopenharmony_ci        SHADOW_FLAGS_ALL,
693f6603c60Sopenharmony_ci    };
694f6603c60Sopenharmony_ci    OH_Drawing_Point3D p1{0.0, 0.0, 0.0};
695f6603c60Sopenharmony_ci    OH_Drawing_Point3D p2{10.0, 10.0, 10.0};
696f6603c60Sopenharmony_ci    for (int i = 0; i < 4; i++) {
697f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFF000000, 0xFF000000, flags[i]);
698f6603c60Sopenharmony_ci    }
699f6603c60Sopenharmony_ci    // 4. Free memory
700f6603c60Sopenharmony_ci    OH_Drawing_PathDestroy(path);
701f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
702f6603c60Sopenharmony_ci}
703f6603c60Sopenharmony_ci
704f6603c60Sopenharmony_ci/*
705f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3301
706f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawShadowNull
707f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawShadowNull.
708f6603c60Sopenharmony_ci * @tc.size  : SmallTest
709f6603c60Sopenharmony_ci * @tc.type  : Function
710f6603c60Sopenharmony_ci * @tc.level : Level 3
711f6603c60Sopenharmony_ci */
712f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawShadowNull, TestSize.Level3) {
713f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
714f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
715f6603c60Sopenharmony_ci    // 2. OH_Drawing_PathCreate
716f6603c60Sopenharmony_ci    OH_Drawing_Path *path = OH_Drawing_PathCreate();
717f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawShadow with the first parameter as null
718f6603c60Sopenharmony_ci    OH_Drawing_Point3D p1{0.0, 0.0, 0.0};
719f6603c60Sopenharmony_ci    OH_Drawing_Point3D p2{10.0, 10.0, 10.0};
720f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(nullptr, path, p1, p2, 10, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
721f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawShadow with the second parameter as null
722f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, nullptr, p1, p2, 10, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
723f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawShadow with the third parameter as null
724f6603c60Sopenharmony_ci    // Unable to test, compilation error
725f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawShadow with the fourth parameter as null
726f6603c60Sopenharmony_ci    // Unable to test, compilation error
727f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawShadow with the fifth parameter as 0
728f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 0, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
729f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawShadow with the sixth parameter as 0
730f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0, 0xFF000000, SHADOW_FLAGS_ALL);
731f6603c60Sopenharmony_ci    // 9. OH_Drawing_CanvasDrawShadow with the seventh parameter as 0
732f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFF000000, 0, SHADOW_FLAGS_ALL);
733f6603c60Sopenharmony_ci    // 10. Free memory
734f6603c60Sopenharmony_ci    OH_Drawing_PathDestroy(path);
735f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
736f6603c60Sopenharmony_ci}
737f6603c60Sopenharmony_ci
738f6603c60Sopenharmony_ci/*
739f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3302
740f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawShadowAbnormal
741f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawShadowAbnormal.
742f6603c60Sopenharmony_ci * @tc.size  : SmallTest
743f6603c60Sopenharmony_ci * @tc.type  : Function
744f6603c60Sopenharmony_ci * @tc.level : Level 3
745f6603c60Sopenharmony_ci */
746f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawShadowAbnormal, TestSize.Level3) {
747f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
748f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
749f6603c60Sopenharmony_ci    // 2. OH_Drawing_PathCreate
750f6603c60Sopenharmony_ci    OH_Drawing_Path *path = OH_Drawing_PathCreate();
751f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawShadow, the third parameter planeParams x, y, z are set to negative values
752f6603c60Sopenharmony_ci    OH_Drawing_Point3D p1{-1.0, -1.0, -1.0};
753f6603c60Sopenharmony_ci    OH_Drawing_Point3D p2{10.0, 10.0, 10.0};
754f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
755f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawShadow, the fourth parameter devLightPos x, y, z are set to negative values
756f6603c60Sopenharmony_ci    OH_Drawing_Point3D p3{0.0, 0.0, 0.0};
757f6603c60Sopenharmony_ci    OH_Drawing_Point3D p4{-10.0, -10.0, -10.0};
758f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p3, p4, 10, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
759f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawShadow, the fifth parameter lightRadius is set to a negative value
760f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p3, p4, -10, 0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
761f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawShadow, the sixth parameter ambientColor is set to a negative value
762f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p3, p4, 10, -0xFF000000, 0xFF000000, SHADOW_FLAGS_ALL);
763f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawShadow, the seventh parameter spotColor is set to a negative value
764f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p3, p4, 10, 0xFF000000, -0xFF000000, SHADOW_FLAGS_ALL);
765f6603c60Sopenharmony_ci    // 8. Free memory
766f6603c60Sopenharmony_ci    OH_Drawing_PathDestroy(path);
767f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
768f6603c60Sopenharmony_ci}
769f6603c60Sopenharmony_ci
770f6603c60Sopenharmony_ci/*
771f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3303
772f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawShadowMaximum
773f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawShadowMaximum.
774f6603c60Sopenharmony_ci * @tc.size  : SmallTest
775f6603c60Sopenharmony_ci * @tc.type  : Function
776f6603c60Sopenharmony_ci * @tc.level : Level 3
777f6603c60Sopenharmony_ci */
778f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawShadowMaximum, TestSize.Level3) {
779f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
780f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
781f6603c60Sopenharmony_ci    // 2. OH_Drawing_PathCreate
782f6603c60Sopenharmony_ci    OH_Drawing_Path *path = OH_Drawing_PathCreate();
783f6603c60Sopenharmony_ci    OH_Drawing_Point3D p1{1.0, 1.0, 1.0};
784f6603c60Sopenharmony_ci    OH_Drawing_Point3D p2{10.0, 10.0, 10.0};
785f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawShadow, set the x, y, z values in the planeParams parameter to maximum values
786f6603c60Sopenharmony_ci    p1 = {FLT_MAX, FLT_MAX, FLT_MAX};
787f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFFFFFFFF, 0xFFFFFFFF, SHADOW_FLAGS_ALL);
788f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawShadow, set the x, y, z values in the devLightPos parameter to maximum values
789f6603c60Sopenharmony_ci    p1 = {1.0, 1.0, 1.0};
790f6603c60Sopenharmony_ci    p2 = {FLT_MAX, FLT_MAX, FLT_MAX};
791f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFFFFFFFF, 0xFFFFFFFF, SHADOW_FLAGS_ALL);
792f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawShadow, set the lightRadius parameter to maximum value
793f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, FLT_MAX, 0xFFFFFFFF, 0xFFFFFFFF, SHADOW_FLAGS_ALL);
794f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawShadow, set the ambientColor parameter to maximum value
795f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFFFFFFFF, 0xFFFFFFFF, SHADOW_FLAGS_ALL);
796f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawShadow, set the spotColor parameter to maximum value
797f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawShadow(canvas, path, p1, p2, 10, 0xFFFFFFFF, 0xFFFFFFFF, SHADOW_FLAGS_ALL);
798f6603c60Sopenharmony_ci    // 8. Free memory
799f6603c60Sopenharmony_ci    OH_Drawing_PathDestroy(path);
800f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
801f6603c60Sopenharmony_ci}
802f6603c60Sopenharmony_ci
803f6603c60Sopenharmony_ci/*
804f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3304
805f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawShadowInputDestroyed
806f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawShadowInputDestroyed.
807f6603c60Sopenharmony_ci * @tc.size  : SmallTest
808f6603c60Sopenharmony_ci * @tc.type  : Function
809f6603c60Sopenharmony_ci * @tc.level : Level 3
810f6603c60Sopenharmony_ci */
811f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawShadowInputDestroyed, TestSize.Level3) {
812f6603c60Sopenharmony_ci    // Deprecated
813f6603c60Sopenharmony_ci}
814f6603c60Sopenharmony_ci
815f6603c60Sopenharmony_ci/*
816f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3400
817f6603c60Sopenharmony_ci * @tc.name: testCanvasClearNormal
818f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearNormal.
819f6603c60Sopenharmony_ci * @tc.size  : SmallTest
820f6603c60Sopenharmony_ci * @tc.type  : Function
821f6603c60Sopenharmony_ci * @tc.level : Level 0
822f6603c60Sopenharmony_ci */
823f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearNormal, TestSize.Level0) {
824f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
825f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
826f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasClear, covering the minimum value 0x00000000 and the maximum value 0xFFFFFFFF for color
827f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas, 0x00000000);
828f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas, 0xFFFFFFFF);
829f6603c60Sopenharmony_ci    // 3. Free memory
830f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
831f6603c60Sopenharmony_ci}
832f6603c60Sopenharmony_ci
833f6603c60Sopenharmony_ci/*
834f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3401
835f6603c60Sopenharmony_ci * @tc.name: testCanvasClearNull
836f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearNull.
837f6603c60Sopenharmony_ci * @tc.size  : SmallTest
838f6603c60Sopenharmony_ci * @tc.type  : Function
839f6603c60Sopenharmony_ci * @tc.level : Level 3
840f6603c60Sopenharmony_ci */
841f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearNull, TestSize.Level3) {
842f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
843f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
844f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasClear with the first parameter as null
845f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(nullptr, 0x00000000);
846f6603c60Sopenharmony_ci    // 3. Free memory
847f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
848f6603c60Sopenharmony_ci}
849f6603c60Sopenharmony_ci
850f6603c60Sopenharmony_ci/*
851f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3402
852f6603c60Sopenharmony_ci * @tc.name: testCanvasClearAbnormal
853f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearAbnormal.
854f6603c60Sopenharmony_ci * @tc.size  : SmallTest
855f6603c60Sopenharmony_ci * @tc.type  : Function
856f6603c60Sopenharmony_ci * @tc.level : Level 3
857f6603c60Sopenharmony_ci */
858f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearAbnormal, TestSize.Level3) {
859f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
860f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
861f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasClear with the parameter color set to a negative value
862f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas, -1);
863f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasClear with the parameter color set to a floating-point value
864f6603c60Sopenharmony_ci    // compile error, ignore
865f6603c60Sopenharmony_ci    // 4. Free memory
866f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
867f6603c60Sopenharmony_ci}
868f6603c60Sopenharmony_ci
869f6603c60Sopenharmony_ci/*
870f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3403
871f6603c60Sopenharmony_ci * @tc.name: testCanvasClearMultipleCalls
872f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearMultipleCalls.
873f6603c60Sopenharmony_ci * @tc.size  : SmallTest
874f6603c60Sopenharmony_ci * @tc.type  : Function
875f6603c60Sopenharmony_ci * @tc.level : Level 3
876f6603c60Sopenharmony_ci */
877f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearMultipleCalls, TestSize.Level3) {
878f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
879f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
880f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasClear 10 times, each time with a different color
881f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
882f6603c60Sopenharmony_ci        OH_Drawing_CanvasClear(canvas, 0x11111111 + i * 10);
883f6603c60Sopenharmony_ci    }
884f6603c60Sopenharmony_ci    // 3. Free memory
885f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
886f6603c60Sopenharmony_ci}
887f6603c60Sopenharmony_ci
888f6603c60Sopenharmony_ci/*
889f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3404
890f6603c60Sopenharmony_ci * @tc.name: testCanvasClearInputDestroyed
891f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearInputDestroyed.
892f6603c60Sopenharmony_ci * @tc.size  : SmallTest
893f6603c60Sopenharmony_ci * @tc.type  : Function
894f6603c60Sopenharmony_ci * @tc.level : Level 3
895f6603c60Sopenharmony_ci */
896f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearInputDestroyed, TestSize.Level3) {
897f6603c60Sopenharmony_ci    // Deprecated
898f6603c60Sopenharmony_ci}
899f6603c60Sopenharmony_ci
900f6603c60Sopenharmony_ci/*
901f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3405
902f6603c60Sopenharmony_ci * @tc.name: testCanvasClearMaximum
903f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClearMaximum.
904f6603c60Sopenharmony_ci * @tc.size  : SmallTest
905f6603c60Sopenharmony_ci * @tc.type  : Function
906f6603c60Sopenharmony_ci * @tc.level : Level 3
907f6603c60Sopenharmony_ci */
908f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClearMaximum, TestSize.Level3) {
909f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
910f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
911f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasClear with the parameter color set to the maximum value
912f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas, 0xFFFFFFFF);
913f6603c60Sopenharmony_ci    // 3. Free memory
914f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
915f6603c60Sopenharmony_ci}
916f6603c60Sopenharmony_ci
917f6603c60Sopenharmony_ci/*
918f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3500
919f6603c60Sopenharmony_ci * @tc.name: testCanvasSetMatrixNormal
920f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSetMatrixNormal.
921f6603c60Sopenharmony_ci * @tc.size  : SmallTest
922f6603c60Sopenharmony_ci * @tc.type  : Function
923f6603c60Sopenharmony_ci * @tc.level : Level 0
924f6603c60Sopenharmony_ci */
925f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSetMatrixNormal, TestSize.Level0) {
926f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
927f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
928f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
929f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
930f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
931f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasSetMatrix and use OH_Drawing_MatrixGetValue to get the matrix information
932f6603c60Sopenharmony_ci    OH_Drawing_CanvasSetMatrix(canvas, matrix);
933f6603c60Sopenharmony_ci    float val = OH_Drawing_MatrixGetValue(matrix, 0);
934f6603c60Sopenharmony_ci    EXPECT_EQ(val, 1);
935f6603c60Sopenharmony_ci
936f6603c60Sopenharmony_ci    // 4. Free memory
937f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
938f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
939f6603c60Sopenharmony_ci}
940f6603c60Sopenharmony_ci
941f6603c60Sopenharmony_ci/*
942f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3501
943f6603c60Sopenharmony_ci * @tc.name: testCanvasSetMatrixNull
944f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSetMatrixNull.
945f6603c60Sopenharmony_ci * @tc.size  : SmallTest
946f6603c60Sopenharmony_ci * @tc.type  : Function
947f6603c60Sopenharmony_ci * @tc.level : Level 3
948f6603c60Sopenharmony_ci */
949f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSetMatrixNull, TestSize.Level3) {
950f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
951f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
952f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
953f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
954f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
955f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasSetMatrix with the first parameter as null
956f6603c60Sopenharmony_ci    OH_Drawing_CanvasSetMatrix(nullptr, matrix);
957f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasSetMatrix with the second parameter as null
958f6603c60Sopenharmony_ci    OH_Drawing_CanvasSetMatrix(canvas, nullptr);
959f6603c60Sopenharmony_ci    // 5. Free memory
960f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
961f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
962f6603c60Sopenharmony_ci}
963f6603c60Sopenharmony_ci
964f6603c60Sopenharmony_ci/*
965f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3502
966f6603c60Sopenharmony_ci * @tc.name: testCanvasSetMatrixMultipleCalls
967f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSetMatrixMultipleCalls.
968f6603c60Sopenharmony_ci * @tc.size  : SmallTest
969f6603c60Sopenharmony_ci * @tc.type  : Function
970f6603c60Sopenharmony_ci * @tc.level : Level 3
971f6603c60Sopenharmony_ci */
972f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSetMatrixMultipleCalls, TestSize.Level3) {
973f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
974f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
975f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreate
976f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
977f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
978f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasSetMatrix 10 times, and after each call, call OH_Drawing_MatrixGetValue to get the
979f6603c60Sopenharmony_ci    // matrix information
980f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
981f6603c60Sopenharmony_ci        OH_Drawing_CanvasSetMatrix(canvas, matrix);
982f6603c60Sopenharmony_ci        float val = OH_Drawing_MatrixGetValue(matrix, 0);
983f6603c60Sopenharmony_ci        EXPECT_EQ(val, 1);
984f6603c60Sopenharmony_ci    }
985f6603c60Sopenharmony_ci    // 4. Free memory
986f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
987f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
988f6603c60Sopenharmony_ci}
989f6603c60Sopenharmony_ci
990f6603c60Sopenharmony_ci/*
991f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3503
992f6603c60Sopenharmony_ci * @tc.name: testCanvasSetMatrixInputDestroyed
993f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasSetMatrixInputDestroyed.
994f6603c60Sopenharmony_ci * @tc.size  : SmallTest
995f6603c60Sopenharmony_ci * @tc.type  : Function
996f6603c60Sopenharmony_ci * @tc.level : Level 3
997f6603c60Sopenharmony_ci */
998f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasSetMatrixInputDestroyed, TestSize.Level3) {
999f6603c60Sopenharmony_ci    // Deprecated
1000f6603c60Sopenharmony_ci}
1001f6603c60Sopenharmony_ci
1002f6603c60Sopenharmony_ci/*
1003f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3600
1004f6603c60Sopenharmony_ci * @tc.name: testCanvasResetMatrixNormal
1005f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasResetMatrixNormal.
1006f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1007f6603c60Sopenharmony_ci * @tc.type  : Function
1008f6603c60Sopenharmony_ci * @tc.level : Level 0
1009f6603c60Sopenharmony_ci */
1010f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasResetMatrixNormal, TestSize.Level0) {
1011f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasCreate to create a canvas object
1012f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1013f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasResetMatrix
1014f6603c60Sopenharmony_ci    OH_Drawing_CanvasResetMatrix(canvas);
1015f6603c60Sopenharmony_ci    // 3. Free memory
1016f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1017f6603c60Sopenharmony_ci}
1018f6603c60Sopenharmony_ci
1019f6603c60Sopenharmony_ci/*
1020f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3601
1021f6603c60Sopenharmony_ci * @tc.name: testCanvasResetMatrixNull
1022f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasResetMatrixNull.
1023f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1024f6603c60Sopenharmony_ci * @tc.type  : Function
1025f6603c60Sopenharmony_ci * @tc.level : Level 3
1026f6603c60Sopenharmony_ci */
1027f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasResetMatrixNull, TestSize.Level3) {
1028f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasResetMatrix with a null parameter
1029f6603c60Sopenharmony_ci    OH_Drawing_CanvasResetMatrix(nullptr);
1030f6603c60Sopenharmony_ci}
1031f6603c60Sopenharmony_ci
1032f6603c60Sopenharmony_ci/*
1033f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3603
1034f6603c60Sopenharmony_ci * @tc.name: testCanvasResetMatrixMultipleCalls
1035f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasResetMatrixMultipleCalls.
1036f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1037f6603c60Sopenharmony_ci * @tc.type  : Function
1038f6603c60Sopenharmony_ci * @tc.level : Level 3
1039f6603c60Sopenharmony_ci */
1040f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasResetMatrixMultipleCalls, TestSize.Level3) {
1041f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasCreate to create a canvas object
1042f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1043f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixCreate
1044f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1045f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
1046f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasSetMatrix 10 times, call OH_Drawing_CanvasResetMatrix 10 times, and get matrix
1047f6603c60Sopenharmony_ci    // information using OH_Drawing_MatrixGetValue
1048f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1049f6603c60Sopenharmony_ci        OH_Drawing_CanvasSetMatrix(canvas, matrix);
1050f6603c60Sopenharmony_ci    }
1051f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1052f6603c60Sopenharmony_ci        OH_Drawing_CanvasResetMatrix(canvas);
1053f6603c60Sopenharmony_ci    }
1054f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasSetMatrix, OH_Drawing_CanvasResetMatrix, and get matrix information using
1055f6603c60Sopenharmony_ci    // OH_Drawing_MatrixGetValue
1056f6603c60Sopenharmony_ci    OH_Drawing_CanvasSetMatrix(canvas, matrix);
1057f6603c60Sopenharmony_ci    OH_Drawing_CanvasResetMatrix(canvas);
1058f6603c60Sopenharmony_ci    float val = OH_Drawing_MatrixGetValue(matrix, 0);
1059f6603c60Sopenharmony_ci    EXPECT_EQ(val, 1);
1060f6603c60Sopenharmony_ci    // 5. Repeat steps 4 for 10 times
1061f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1062f6603c60Sopenharmony_ci        OH_Drawing_CanvasSetMatrix(canvas, matrix);
1063f6603c60Sopenharmony_ci        OH_Drawing_CanvasResetMatrix(canvas);
1064f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 0), 1);
1065f6603c60Sopenharmony_ci    }
1066f6603c60Sopenharmony_ci    // 6. Free memory
1067f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1068f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1069f6603c60Sopenharmony_ci}
1070f6603c60Sopenharmony_ci
1071f6603c60Sopenharmony_ci/*
1072f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3700
1073f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawImageRectWithSrcNormal
1074f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawImageRectWithSrcNormal.
1075f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1076f6603c60Sopenharmony_ci * @tc.type  : Function
1077f6603c60Sopenharmony_ci * @tc.level : Level 0
1078f6603c60Sopenharmony_ci */
1079f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawImageRectWithSrcNormal, TestSize.Level0) {
1080f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasCreate to create a canvas object
1081f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1082f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1083f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ImageCreate to create an image object
1084f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1085f6603c60Sopenharmony_ci    EXPECT_NE(image, nullptr);
1086f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectCreate to create a rectangle object
1087f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1088f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectCreate to create a rectangle object
1089f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 0, 100, 100);
1090f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_SamplingOptionsCreate to create a sampling options object
1091f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode::FILTER_MODE_NEAREST,
1092f6603c60Sopenharmony_ci                                                                           OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
1093f6603c60Sopenharmony_ci    EXPECT_NE(options, nullptr);
1094f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_CanvasDrawImageRectWithSrc with the sixth parameter iterating through the enumeration
1095f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, image, rect, rect2, options, STRICT_SRC_RECT_CONSTRAINT);
1096f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, image, rect, rect2, options, FAST_SRC_RECT_CONSTRAINT);
1097f6603c60Sopenharmony_ci    // 7. Free memory
1098f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1099f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect2);
1100f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1101f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1102f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1103f6603c60Sopenharmony_ci}
1104f6603c60Sopenharmony_ci
1105f6603c60Sopenharmony_ci/*
1106f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3701
1107f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawImageRectWithSrcNull
1108f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawImageRectWithSrcNull.
1109f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1110f6603c60Sopenharmony_ci * @tc.type  : Function
1111f6603c60Sopenharmony_ci * @tc.level : Level 3
1112f6603c60Sopenharmony_ci */
1113f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawImageRectWithSrcNull, TestSize.Level3) {
1114f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1115f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1116f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1117f6603c60Sopenharmony_ci    EXPECT_NE(image, nullptr);
1118f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1119f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 0, 100, 100);
1120f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode::FILTER_MODE_NEAREST,
1121f6603c60Sopenharmony_ci                                                                           OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
1122f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasDrawImageRectWithSrc with the first parameter being nullptr
1123f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(nullptr, image, rect, rect2, options, STRICT_SRC_RECT_CONSTRAINT);
1124f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasDrawImageRectWithSrc with the second parameter being nullptr
1125f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, nullptr, rect, rect2, options, STRICT_SRC_RECT_CONSTRAINT);
1126f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasDrawImageRectWithSrc with the third parameter being nullptr
1127f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, image, nullptr, rect2, options, STRICT_SRC_RECT_CONSTRAINT);
1128f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasDrawImageRectWithSrc with the fourth parameter being nullptr
1129f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, image, rect, nullptr, options, STRICT_SRC_RECT_CONSTRAINT);
1130f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_CanvasDrawImageRectWithSrc with the fifth parameter being nullptr
1131f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas, image, rect, rect2, nullptr, STRICT_SRC_RECT_CONSTRAINT);
1132f6603c60Sopenharmony_ci    // 6. Free memory
1133f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1134f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect2);
1135f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1136f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1137f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1138f6603c60Sopenharmony_ci}
1139f6603c60Sopenharmony_ci
1140f6603c60Sopenharmony_ci/*
1141f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3800
1142f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawImageRectNormal
1143f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawImageRectNormal.
1144f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1145f6603c60Sopenharmony_ci * @tc.type  : Function
1146f6603c60Sopenharmony_ci * @tc.level : Level 0
1147f6603c60Sopenharmony_ci */
1148f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawImageRectNormal, TestSize.Level0) {
1149f6603c60Sopenharmony_ci    // 1. Create a canvas object using OH_Drawing_CanvasCreate
1150f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1151f6603c60Sopenharmony_ci    // 2. Create an image object using OH_Drawing_ImageCreate
1152f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1153f6603c60Sopenharmony_ci    // 3. Create a rectangle object using OH_Drawing_RectCreate
1154f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1155f6603c60Sopenharmony_ci    // 4. Create a sampling options object using OH_Drawing_SamplingOptionsCreate
1156f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode::FILTER_MODE_NEAREST,
1157f6603c60Sopenharmony_ci                                                                           OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
1158f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_CanvasDrawImageRect
1159f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas, image, rect, options);
1160f6603c60Sopenharmony_ci    // 6. Free memory
1161f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1162f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1163f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1164f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1165f6603c60Sopenharmony_ci}
1166f6603c60Sopenharmony_ci
1167f6603c60Sopenharmony_ci/*
1168f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3801
1169f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawImageRectNull
1170f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawImageRectNull.
1171f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1172f6603c60Sopenharmony_ci * @tc.type  : Function
1173f6603c60Sopenharmony_ci * @tc.level : Level 3
1174f6603c60Sopenharmony_ci */
1175f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawImageRectNull, TestSize.Level3) {
1176f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1177f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1178f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1179f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode::FILTER_MODE_NEAREST,
1180f6603c60Sopenharmony_ci                                                                           OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
1181f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasDrawImageRect with the first parameter as null
1182f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(nullptr, image, rect, options);
1183f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasDrawImageRect with the second parameter as null
1184f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas, nullptr, rect, options);
1185f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasDrawImageRect with the third parameter as null
1186f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas, image, nullptr, options);
1187f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasDrawImageRect with the fourth parameter as null
1188f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas, image, rect, nullptr);
1189f6603c60Sopenharmony_ci    // 5. Free memory
1190f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1191f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1192f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1193f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1194f6603c60Sopenharmony_ci}
1195f6603c60Sopenharmony_ci
1196f6603c60Sopenharmony_ci/*
1197f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3900
1198f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawVerticesNormal
1199f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawVerticesNormal.
1200f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1201f6603c60Sopenharmony_ci * @tc.type  : Function
1202f6603c60Sopenharmony_ci * @tc.level : Level 0
1203f6603c60Sopenharmony_ci */
1204f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawVerticesNormal, TestSize.Level0) {
1205f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_one = {0, 0};
1206f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_two = {100, 100};
1207f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_three = {300, 100};
1208f6603c60Sopenharmony_ci    OH_Drawing_Point2D points_vertices[3] = {point_one, point_two, point_three};
1209f6603c60Sopenharmony_ci
1210f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_one = {0, 0};
1211f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_two = {1, 1};
1212f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_three = {2, 0};
1213f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_vertices[3] = {texs_one, texs_two, texs_three};
1214f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
1215f6603c60Sopenharmony_ci    uint16_t indices[3] = {0, 1, 2};
1216f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasCreate to create a canvas object
1217f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1218f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasDrawVertices with the second parameter iterating through the enum
1219f6603c60Sopenharmony_ci    OH_Drawing_VertexMode mode[] = {VERTEX_MODE_TRIANGLES, VERTEX_MODE_TRIANGLES_STRIP, VERTEX_MODE_TRIANGLE_FAN};
1220f6603c60Sopenharmony_ci    for (int i = 0; i < 3; i++) {
1221f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawVertices(canvas, mode[i], 3, points_vertices, texs_vertices, colors, 3, indices,
1222f6603c60Sopenharmony_ci                                      BLEND_MODE_COLOR);
1223f6603c60Sopenharmony_ci    }
1224f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasDrawVertices with the ninth parameter iterating through the enum
1225f6603c60Sopenharmony_ci    OH_Drawing_BlendMode blendMode[] = {
1226f6603c60Sopenharmony_ci        BLEND_MODE_CLEAR,      BLEND_MODE_SRC,        BLEND_MODE_DST,         BLEND_MODE_SRC_OVER,
1227f6603c60Sopenharmony_ci        BLEND_MODE_DST_OVER,   BLEND_MODE_SRC_IN,     BLEND_MODE_DST_IN,      BLEND_MODE_SRC_OUT,
1228f6603c60Sopenharmony_ci        BLEND_MODE_DST_OUT,    BLEND_MODE_SRC_ATOP,   BLEND_MODE_DST_ATOP,    BLEND_MODE_XOR,
1229f6603c60Sopenharmony_ci        BLEND_MODE_PLUS,       BLEND_MODE_MODULATE,   BLEND_MODE_SCREEN,      BLEND_MODE_OVERLAY,
1230f6603c60Sopenharmony_ci        BLEND_MODE_DARKEN,     BLEND_MODE_LIGHTEN,    BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN,
1231f6603c60Sopenharmony_ci        BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE,  BLEND_MODE_EXCLUSION,
1232f6603c60Sopenharmony_ci        BLEND_MODE_MULTIPLY,   BLEND_MODE_HUE,        BLEND_MODE_SATURATION,  BLEND_MODE_COLOR,
1233f6603c60Sopenharmony_ci        BLEND_MODE_LUMINOSITY,
1234f6603c60Sopenharmony_ci    };
1235f6603c60Sopenharmony_ci    for (int i = 0; i < 30; i++) {
1236f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, colors, 3,
1237f6603c60Sopenharmony_ci                                      indices, blendMode[i]);
1238f6603c60Sopenharmony_ci    }
1239f6603c60Sopenharmony_ci    // 4. Free memory
1240f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1241f6603c60Sopenharmony_ci}
1242f6603c60Sopenharmony_ci
1243f6603c60Sopenharmony_ci/*
1244f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3901
1245f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawVerticesNull
1246f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawVerticesNull.
1247f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1248f6603c60Sopenharmony_ci * @tc.type  : Function
1249f6603c60Sopenharmony_ci * @tc.level : Level 3
1250f6603c60Sopenharmony_ci */
1251f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawVerticesNull, TestSize.Level3) {
1252f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_one = {0, 0};
1253f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_two = {100, 100};
1254f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_three = {300, 100};
1255f6603c60Sopenharmony_ci    OH_Drawing_Point2D points_vertices[3] = {point_one, point_two, point_three};
1256f6603c60Sopenharmony_ci
1257f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_one = {0, 0};
1258f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_two = {1, 1};
1259f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_three = {2, 0};
1260f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_vertices[3] = {texs_one, texs_two, texs_three};
1261f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
1262f6603c60Sopenharmony_ci    uint16_t indices[3] = {0, 1, 2};
1263f6603c60Sopenharmony_ci
1264f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1265f6603c60Sopenharmony_ci
1266f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasDrawVertices with the first parameter as nullptr
1267f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(nullptr, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, colors, 3, indices,
1268f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1269f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasDrawVertices with the third parameter as 0
1270f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 0, points_vertices, texs_vertices, colors, 3, indices,
1271f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1272f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasDrawVertices with the fourth parameter as nullptr
1273f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, nullptr, texs_vertices, colors, 3, indices,
1274f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1275f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasDrawVertices with the fifth parameter as nullptr
1276f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, nullptr, colors, 3, indices,
1277f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1278f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_CanvasDrawVertices with the sixth parameter as nullptr
1279f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, nullptr, 3, indices,
1280f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1281f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_CanvasDrawVertices with the seventh parameter as 0
1282f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, colors, 0, indices,
1283f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1284f6603c60Sopenharmony_ci    // 7. Call OH_Drawing_CanvasDrawVertices with the eighth parameter as nullptr
1285f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, colors, 3, nullptr,
1286f6603c60Sopenharmony_ci                                  BLEND_MODE_COLOR);
1287f6603c60Sopenharmony_ci    // 8. Free memory
1288f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1289f6603c60Sopenharmony_ci}
1290f6603c60Sopenharmony_ci
1291f6603c60Sopenharmony_ci/*
1292f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3902
1293f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawVerticesAbnormal
1294f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawVerticesAbnormal.
1295f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1296f6603c60Sopenharmony_ci * @tc.type  : Function
1297f6603c60Sopenharmony_ci * @tc.level : Level 3
1298f6603c60Sopenharmony_ci */
1299f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawVerticesAbnormal, TestSize.Level3) {
1300f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1301f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1302f6603c60Sopenharmony_ci
1303f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasDrawVertices with a floating-point number as the third parameter
1304f6603c60Sopenharmony_ci    // Compilation error, cannot pass a floating-point number
1305f6603c60Sopenharmony_ci
1306f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasDrawVertices with a floating-point number as the seventh parameter
1307f6603c60Sopenharmony_ci    // Compilation error, cannot pass a floating-point number
1308f6603c60Sopenharmony_ci
1309f6603c60Sopenharmony_ci    // 4. Free memory
1310f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1311f6603c60Sopenharmony_ci}
1312f6603c60Sopenharmony_ci
1313f6603c60Sopenharmony_ci/*
1314f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_3903
1315f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawVerticesMaximum
1316f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawVerticesMaximum.
1317f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1318f6603c60Sopenharmony_ci * @tc.type  : Function
1319f6603c60Sopenharmony_ci * @tc.level : Level 3
1320f6603c60Sopenharmony_ci */
1321f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawVerticesMaximum, TestSize.Level3) {
1322f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1323f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_one = {0, 0};
1324f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_two = {100, 100};
1325f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_three = {300, 100};
1326f6603c60Sopenharmony_ci    OH_Drawing_Point2D points_vertices[3] = {point_one, point_two, point_three};
1327f6603c60Sopenharmony_ci
1328f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_one = {0, 0};
1329f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_two = {1, 1};
1330f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_three = {2, 0};
1331f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_vertices[3] = {texs_one, texs_two, texs_three};
1332f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
1333f6603c60Sopenharmony_ci    uint16_t indices[3] = {0, 1, 2};
1334f6603c60Sopenharmony_ci
1335f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1336f6603c60Sopenharmony_ci
1337f6603c60Sopenharmony_ci    if (0) {
1338f6603c60Sopenharmony_ci        // todo cpp crash
1339f6603c60Sopenharmony_ci        // 2. Call OH_Drawing_CanvasDrawVertices with the third parameter as the maximum value 0x7FFFFFFF
1340f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 0x7FFFFFFF, points_vertices, texs_vertices, colors,
1341f6603c60Sopenharmony_ci                                      3, indices, BLEND_MODE_COLOR);
1342f6603c60Sopenharmony_ci        // 3. Call OH_Drawing_CanvasDrawVertices with the seventh parameter as the maximum value 0x7FFFFFFF
1343f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawVertices(canvas, VERTEX_MODE_TRIANGLES, 3, points_vertices, texs_vertices, colors,
1344f6603c60Sopenharmony_ci                                      0x7FFFFFFF, indices, BLEND_MODE_COLOR);
1345f6603c60Sopenharmony_ci    }
1346f6603c60Sopenharmony_ci
1347f6603c60Sopenharmony_ci    // 4. Free memory
1348f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1349f6603c60Sopenharmony_ci}
1350f6603c60Sopenharmony_ci
1351f6603c60Sopenharmony_ci/*
1352f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4000
1353f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsNormal
1354f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsNormal.
1355f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1356f6603c60Sopenharmony_ci * @tc.type  : Function
1357f6603c60Sopenharmony_ci * @tc.level : Level 0
1358f6603c60Sopenharmony_ci */
1359f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsNormal, TestSize.Level0) {
1360f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1361f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1362f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixels
1363f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1364f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1365f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
1366f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
1367f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
1368f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1369f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
1370f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 0, 0);
1371f6603c60Sopenharmony_ci    // 3. Free memory
1372f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1373f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1374f6603c60Sopenharmony_ci}
1375f6603c60Sopenharmony_ci
1376f6603c60Sopenharmony_ci/*
1377f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4001
1378f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsNull
1379f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsNull.
1380f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1381f6603c60Sopenharmony_ci * @tc.type  : Function
1382f6603c60Sopenharmony_ci * @tc.level : Level 3
1383f6603c60Sopenharmony_ci */
1384f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsNull, TestSize.Level3) {
1385f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1386f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasReadPixels with the first parameter as nullptr
1387f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1388f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1389f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
1390f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
1391f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
1392f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1393f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
1394f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(nullptr, &imageInfo, pixels, 0, 0, 0);
1395f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixels with the second parameter as nullptr
1396f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, nullptr, pixels, 0, 0, 0);
1397f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixels with the third parameter as nullptr
1398f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, nullptr, 0, 0, 0);
1399f6603c60Sopenharmony_ci    // 4. Free memory
1400f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1401f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1402f6603c60Sopenharmony_ci}
1403f6603c60Sopenharmony_ci
1404f6603c60Sopenharmony_ci/*
1405f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4002
1406f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsMismatch
1407f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsMismatch.
1408f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1409f6603c60Sopenharmony_ci * @tc.type  : Function
1410f6603c60Sopenharmony_ci * @tc.level : Level 3
1411f6603c60Sopenharmony_ci */
1412f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsMismatch, TestSize.Level3) {
1413f6603c60Sopenharmony_ci    // Deprecated
1414f6603c60Sopenharmony_ci}
1415f6603c60Sopenharmony_ci
1416f6603c60Sopenharmony_ci/*
1417f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4003
1418f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsAbnormal
1419f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsAbnormal.
1420f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1421f6603c60Sopenharmony_ci * @tc.type  : Function
1422f6603c60Sopenharmony_ci * @tc.level : Level 3
1423f6603c60Sopenharmony_ci */
1424f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsAbnormal, TestSize.Level3) {
1425f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1426f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1427f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixels with the fourth parameter as a negative number or a floating-point number
1428f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1429f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1430f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
1431f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
1432f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
1433f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1434f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
1435f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, -1, 0, 0);
1436f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 1.0f, 0, 0);
1437f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixels with the fifth parameter as a floating-point number
1438f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 1.0f, 0);
1439f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasReadPixels with the sixth parameter as a floating-point number
1440f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 0, 1.0f);
1441f6603c60Sopenharmony_ci    // 5. Free memory
1442f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1443f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1444f6603c60Sopenharmony_ci}
1445f6603c60Sopenharmony_ci
1446f6603c60Sopenharmony_ci/*
1447f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4004
1448f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsMaximum
1449f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsMaximum.
1450f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1451f6603c60Sopenharmony_ci * @tc.type  : Function
1452f6603c60Sopenharmony_ci * @tc.level : Level 3
1453f6603c60Sopenharmony_ci */
1454f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsMaximum, TestSize.Level3) {
1455f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1456f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1457f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixels with the fourth parameter as the maximum value 0xFFFFFFFF
1458f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1459f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1460f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
1461f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
1462f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
1463f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1464f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
1465f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0xFFFFFFFF, 0, 0);
1466f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixels with the fifth parameter as the maximum value 0x7FFFFFFF
1467f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 0x7FFFFFFF, 0);
1468f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasReadPixels with the sixth parameter as the maximum value 0x7FFFFFFF
1469f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 0, 0x7FFFFFFF);
1470f6603c60Sopenharmony_ci    // 5. Free memory
1471f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1472f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1473f6603c60Sopenharmony_ci}
1474f6603c60Sopenharmony_ci
1475f6603c60Sopenharmony_ci/*
1476f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4005
1477f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsBoundary
1478f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsBoundary.
1479f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1480f6603c60Sopenharmony_ci * @tc.type  : Function
1481f6603c60Sopenharmony_ci * @tc.level : Level 0
1482f6603c60Sopenharmony_ci */
1483f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsBoundary, TestSize.Level0) {
1484f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1485f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1486f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixels
1487f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1488f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1489f6603c60Sopenharmony_ci    constexpr uint32_t width = 4096;
1490f6603c60Sopenharmony_ci    constexpr uint32_t height = 2160;
1491f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
1492f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1493f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
1494f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixels(canvas, &imageInfo, pixels, 0, 0, 0);
1495f6603c60Sopenharmony_ci    // 3. Free memory
1496f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1497f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1498f6603c60Sopenharmony_ci}
1499f6603c60Sopenharmony_ci
1500f6603c60Sopenharmony_ci/*
1501f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4100
1502f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsToBitmapNormal
1503f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsToBitmapNormal.
1504f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1505f6603c60Sopenharmony_ci * @tc.type  : Function
1506f6603c60Sopenharmony_ci * @tc.level : Level 0
1507f6603c60Sopenharmony_ci */
1508f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsToBitmapNormal, TestSize.Level0) {
1509f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1510f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1511f6603c60Sopenharmony_ci    // 2. Create a bitmap object by calling OH_Drawing_BitmapCreate
1512f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1513f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixelsToBitmap
1514f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 1, 1);
1515f6603c60Sopenharmony_ci    // 4. Free memory
1516f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1517f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1518f6603c60Sopenharmony_ci}
1519f6603c60Sopenharmony_ci
1520f6603c60Sopenharmony_ci/*
1521f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4101
1522f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsToBitmapNull
1523f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsToBitmapNull.
1524f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1525f6603c60Sopenharmony_ci * @tc.type  : Function
1526f6603c60Sopenharmony_ci * @tc.level : Level 3
1527f6603c60Sopenharmony_ci */
1528f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsToBitmapNull, TestSize.Level3) {
1529f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1530f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1531f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_CanvasReadPixelsToBitmap with the first parameter as null
1532f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(nullptr, bitmap, 1, 1);
1533f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_CanvasReadPixelsToBitmap with the second parameter as null
1534f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, nullptr, 1, 1);
1535f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixelsToBitmap with the third parameter as 0
1536f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 0, 1);
1537f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasReadPixelsToBitmap with the fourth parameter as 0
1538f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 1, 0);
1539f6603c60Sopenharmony_ci    // 5. Free memory
1540f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1541f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1542f6603c60Sopenharmony_ci}
1543f6603c60Sopenharmony_ci
1544f6603c60Sopenharmony_ci/*
1545f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4102
1546f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsToBitmapAbnormal
1547f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsToBitmapAbnormal.
1548f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1549f6603c60Sopenharmony_ci * @tc.type  : Function
1550f6603c60Sopenharmony_ci * @tc.level : Level 3
1551f6603c60Sopenharmony_ci */
1552f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsToBitmapAbnormal, TestSize.Level3) {
1553f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1554f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1555f6603c60Sopenharmony_ci    // 2. Create a bitmap object by calling OH_Drawing_BitmapCreate
1556f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1557f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixelsToBitmap with the third parameter as a floating-point number
1558f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 1.0f, 0);
1559f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasReadPixelsToBitmap with the fourth parameter as a floating-point number
1560f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 1, 1.0f);
1561f6603c60Sopenharmony_ci    // 5. Free memory
1562f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1563f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1564f6603c60Sopenharmony_ci}
1565f6603c60Sopenharmony_ci
1566f6603c60Sopenharmony_ci/*
1567f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4103
1568f6603c60Sopenharmony_ci * @tc.name: testCanvasReadPixelsToBitmapMaximum
1569f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasReadPixelsToBitmapMaximum.
1570f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1571f6603c60Sopenharmony_ci * @tc.type  : Function
1572f6603c60Sopenharmony_ci * @tc.level : Level 3
1573f6603c60Sopenharmony_ci */
1574f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasReadPixelsToBitmapMaximum, TestSize.Level3) {
1575f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1576f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1577f6603c60Sopenharmony_ci    // 2. Create a bitmap object by calling OH_Drawing_BitmapCreate
1578f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1579f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_CanvasReadPixelsToBitmap with the third parameter set to the maximum value 0x7FFFFFFF
1580f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 0x7FFFFFFF, 0);
1581f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_CanvasReadPixelsToBitmap with the fourth parameter set to the maximum value 0x7FFFFFFF
1582f6603c60Sopenharmony_ci    OH_Drawing_CanvasReadPixelsToBitmap(canvas, bitmap, 1, 0x7FFFFFFF);
1583f6603c60Sopenharmony_ci    // 5. Free memory
1584f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1585f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1586f6603c60Sopenharmony_ci}
1587f6603c60Sopenharmony_ci/*
1588f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4104
1589f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawSingleCharacter
1590f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawSingleCharacter.
1591f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1592f6603c60Sopenharmony_ci * @tc.type  : Function
1593f6603c60Sopenharmony_ci * @tc.level : Level 1
1594f6603c60Sopenharmony_ci */
1595f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawSingleCharacter, TestSize.Level1)
1596f6603c60Sopenharmony_ci{
1597f6603c60Sopenharmony_ci    // 1. Create a canvas object by calling OH_Drawing_CanvasCreate
1598f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1599f6603c60Sopenharmony_ci    const char* strOne = "a";
1600f6603c60Sopenharmony_ci    const char* strTwo = "你好";
1601f6603c60Sopenharmony_ci    OH_Drawing_Font *font = OH_Drawing_FontCreate();
1602f6603c60Sopenharmony_ci    EXPECT_NE(font, nullptr);
1603f6603c60Sopenharmony_ci    float x = 0.f;
1604f6603c60Sopenharmony_ci    float y = 0.f;
1605f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas, strOne, font, x, y), OH_DRAWING_SUCCESS);
1606f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas, strTwo, font, x, y), OH_DRAWING_SUCCESS);
1607f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(nullptr, strOne, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER);
1608f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas, nullptr, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER);
1609f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas, strOne, nullptr, x, y),
1610f6603c60Sopenharmony_ci        OH_DRAWING_ERROR_INVALID_PARAMETER);
1611f6603c60Sopenharmony_ci    const char* strThree = "";
1612f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasDrawSingleCharacter(canvas, strThree, font, x, y), OH_DRAWING_ERROR_INVALID_PARAMETER);
1613f6603c60Sopenharmony_ci    OH_Drawing_FontDestroy(font);
1614f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1615f6603c60Sopenharmony_ci}
1616f6603c60Sopenharmony_ci
1617f6603c60Sopenharmony_ci/*
1618f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4200
1619f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawSingleCharacterNormal
1620f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawSingleCharacterNormal.
1621f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1622f6603c60Sopenharmony_ci * @tc.type  : Function
1623f6603c60Sopenharmony_ci * @tc.level : Level 0
1624f6603c60Sopenharmony_ci */
1625f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawSingleCharacterNormal, TestSize.Level0) {
1626f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1627f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1628f6603c60Sopenharmony_ci    //2. OH_Drawing_BrushCreate
1629f6603c60Sopenharmony_ci    OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
1630f6603c60Sopenharmony_ci    //3. OH_Drawing_BrushSetColor
1631f6603c60Sopenharmony_ci    OH_Drawing_BrushSetColor(brush, 0xFFFFFFFF);
1632f6603c60Sopenharmony_ci    //4. OH_Drawing_FontCreate
1633f6603c60Sopenharmony_ci    OH_Drawing_Font *font = OH_Drawing_FontCreate();
1634f6603c60Sopenharmony_ci    //5. OH_Drawing_FontSetTextSize
1635f6603c60Sopenharmony_ci    const float textSize = 10.f;
1636f6603c60Sopenharmony_ci    OH_Drawing_FontSetTextSize(font, textSize);
1637f6603c60Sopenharmony_ci    //6. OH_Drawing_CanvasDrawSingleCharacter parameter is normal, where str is a single character,UTF-8 encoded, and
1638f6603c60Sopenharmony_ci    // Chinese/English characters are passed
1639f6603c60Sopenharmony_ci    float x = 0.f;
1640f6603c60Sopenharmony_ci    float y = 0.f;
1641f6603c60Sopenharmony_ci    const char* str = "a";
1642f6603c60Sopenharmony_ci    const char* str1 = "我";
1643f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str, font, x, y);
1644f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str1, font, x, y);
1645f6603c60Sopenharmony_ci    //7. OH_Drawing_CanvasDrawSingleCharacter parameters are entered normally, where str is a multi-character, UTF-8
1646f6603c60Sopenharmony_ci    // encoded, and English/Chinese characters are in
1647f6603c60Sopenharmony_ci    str = "abc";
1648f6603c60Sopenharmony_ci    str1 = "你是谁";
1649f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str, font, x, y);
1650f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str1, font, x, y);
1651f6603c60Sopenharmony_ci    //8. free memory
1652f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1653f6603c60Sopenharmony_ci    OH_Drawing_BrushDestroy(brush);
1654f6603c60Sopenharmony_ci    OH_Drawing_FontDestroy(font);
1655f6603c60Sopenharmony_ci}
1656f6603c60Sopenharmony_ci
1657f6603c60Sopenharmony_ci/*
1658f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4201
1659f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawSingleCharacterNull
1660f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawSingleCharacterNull.
1661f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1662f6603c60Sopenharmony_ci * @tc.type  : Function
1663f6603c60Sopenharmony_ci * @tc.level : Level 3
1664f6603c60Sopenharmony_ci */
1665f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawSingleCharacterNull, TestSize.Level3) {
1666f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1667f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1668f6603c60Sopenharmony_ci    //2. OH_Drawing_BrushCreate
1669f6603c60Sopenharmony_ci    OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
1670f6603c60Sopenharmony_ci    //3. OH_Drawing_BrushSetColor
1671f6603c60Sopenharmony_ci    OH_Drawing_BrushSetColor(brush, 0xFFFFFFFF);
1672f6603c60Sopenharmony_ci    //4. OH_Drawing_FontCreate
1673f6603c60Sopenharmony_ci    OH_Drawing_Font *font = OH_Drawing_FontCreate();
1674f6603c60Sopenharmony_ci    //5. OH_Drawing_FontSetTextSize
1675f6603c60Sopenharmony_ci    const float textSize = 10.f;
1676f6603c60Sopenharmony_ci    OH_Drawing_FontSetTextSize(font, textSize);
1677f6603c60Sopenharmony_ci    //6. OH_Drawing_CanvasDrawSingleCharacter parameter canvas is empty
1678f6603c60Sopenharmony_ci    float x = 0.f;
1679f6603c60Sopenharmony_ci    float y = 0.f;
1680f6603c60Sopenharmony_ci    const char *str = "a";
1681f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(nullptr, str, font, x, y);
1682f6603c60Sopenharmony_ci    //7. OH_Drawing_CanvasDrawSingleCharacter parameter str is empty
1683f6603c60Sopenharmony_ci    str = "";
1684f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str, font, x, y);
1685f6603c60Sopenharmony_ci    //8. OH_Drawing_CanvasDrawSingleCharacter parameter font is empty
1686f6603c60Sopenharmony_ci    str = "a";
1687f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str, nullptr, x, y);
1688f6603c60Sopenharmony_ci    //9. OH_Drawing_CanvasDrawSingleCharacter parameter str to 0 characters
1689f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawSingleCharacter(canvas, str, font, x, y);
1690f6603c60Sopenharmony_ci    //10.free memory
1691f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1692f6603c60Sopenharmony_ci    OH_Drawing_BrushDestroy(brush);
1693f6603c60Sopenharmony_ci    OH_Drawing_FontDestroy(font);
1694f6603c60Sopenharmony_ci}
1695f6603c60Sopenharmony_ci
1696f6603c60Sopenharmony_ci/*
1697f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4300
1698f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointNormal
1699f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointNormal.
1700f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1701f6603c60Sopenharmony_ci * @tc.type  : Function
1702f6603c60Sopenharmony_ci * @tc.level : Level 0
1703f6603c60Sopenharmony_ci */
1704f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointNormal, TestSize.Level0) {
1705f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1706f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1707f6603c60Sopenharmony_ci    //2. OH_Drawing_Point2D create an array of points
1708f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_one = {0.0f, 0.0f};
1709f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_two = {1.0f, 1.0f};
1710f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_three = {2.0f, 2.0f};
1711f6603c60Sopenharmony_ci    OH_Drawing_Point2D point_vertices[1] = {texs_one};
1712f6603c60Sopenharmony_ci    for (int i = 0; i < 1; i++) {
1713f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoint(canvas, &point_vertices[i]);
1714f6603c60Sopenharmony_ci    }
1715f6603c60Sopenharmony_ci    //3. OH_Drawing_Point2D create an array of multiple points
1716f6603c60Sopenharmony_ci    OH_Drawing_Point2D texs_vertices[3] = {texs_one, texs_two, texs_three};
1717f6603c60Sopenharmony_ci    for (int i = 0; i < 3; i++) {
1718f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoint(canvas, &texs_vertices[i]);
1719f6603c60Sopenharmony_ci    }
1720f6603c60Sopenharmony_ci    //4. free memory
1721f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1722f6603c60Sopenharmony_ci}
1723f6603c60Sopenharmony_ci
1724f6603c60Sopenharmony_ci/*
1725f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4301
1726f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointNull
1727f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointNull.
1728f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1729f6603c60Sopenharmony_ci * @tc.type  : Function
1730f6603c60Sopenharmony_ci * @tc.level : Level 3
1731f6603c60Sopenharmony_ci */
1732f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointNull, TestSize.Level3) {
1733f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1734f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1735f6603c60Sopenharmony_ci    //2. OH_Drawing_CanvasDrawPoint the first parameter is empty
1736f6603c60Sopenharmony_ci    const OH_Drawing_Point2D point = {0.0f, 0.0f};
1737f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoint(nullptr, &point);
1738f6603c60Sopenharmony_ci    //3. OH_Drawing_CanvasDrawPoint the second parameter is empty
1739f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoint(canvas, nullptr);
1740f6603c60Sopenharmony_ci    //4.free memory
1741f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1742f6603c60Sopenharmony_ci}
1743f6603c60Sopenharmony_ci
1744f6603c60Sopenharmony_ci/*
1745f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4302
1746f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointMultipleCalls
1747f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointMultipleCalls.
1748f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1749f6603c60Sopenharmony_ci * @tc.type  : Function
1750f6603c60Sopenharmony_ci * @tc.level : Level 3
1751f6603c60Sopenharmony_ci */
1752f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointMultipleCalls, TestSize.Level3) {
1753f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1754f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvases[10];
1755f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1756f6603c60Sopenharmony_ci        canvases[i]= OH_Drawing_CanvasCreate();
1757f6603c60Sopenharmony_ci    }
1758f6603c60Sopenharmony_ci    //2. Call OH_Drawing_CanvasDrawPoint 10 times
1759f6603c60Sopenharmony_ci    OH_Drawing_Point2D point1 = {0.0f, 0.0f};
1760f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1761f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoint(canvases[i], &point1);
1762f6603c60Sopenharmony_ci    }
1763f6603c60Sopenharmony_ci}
1764f6603c60Sopenharmony_ci
1765f6603c60Sopenharmony_ci/*
1766f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4400
1767f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawColorNormal
1768f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawColorNormal.
1769f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1770f6603c60Sopenharmony_ci * @tc.type  : Function
1771f6603c60Sopenharmony_ci * @tc.level : Level 0
1772f6603c60Sopenharmony_ci */
1773f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawColorNormal, TestSize.Level0) {
1774f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1775f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1776f6603c60Sopenharmony_ci    //2. OH_Drawing_CanvasDrawColor enumeration traversal
1777f6603c60Sopenharmony_ci    uint32_t color[3] = {0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
1778f6603c60Sopenharmony_ci    OH_Drawing_BlendMode blendMode[] = {
1779f6603c60Sopenharmony_ci        BLEND_MODE_CLEAR,      BLEND_MODE_SRC,        BLEND_MODE_DST,         BLEND_MODE_SRC_OVER,
1780f6603c60Sopenharmony_ci        BLEND_MODE_DST_OVER,   BLEND_MODE_SRC_IN,     BLEND_MODE_DST_IN,      BLEND_MODE_SRC_OUT,
1781f6603c60Sopenharmony_ci        BLEND_MODE_DST_OUT,    BLEND_MODE_SRC_ATOP,   BLEND_MODE_DST_ATOP,    BLEND_MODE_XOR,
1782f6603c60Sopenharmony_ci        BLEND_MODE_PLUS,       BLEND_MODE_MODULATE,   BLEND_MODE_SCREEN,      BLEND_MODE_OVERLAY,
1783f6603c60Sopenharmony_ci        BLEND_MODE_DARKEN,     BLEND_MODE_LIGHTEN,    BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN,
1784f6603c60Sopenharmony_ci        BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE,  BLEND_MODE_EXCLUSION,
1785f6603c60Sopenharmony_ci        BLEND_MODE_MULTIPLY,   BLEND_MODE_HUE,        BLEND_MODE_SATURATION,  BLEND_MODE_COLOR,
1786f6603c60Sopenharmony_ci        BLEND_MODE_LUMINOSITY,
1787f6603c60Sopenharmony_ci    };
1788f6603c60Sopenharmony_ci    for (int i = 0; i < 29; i++) {
1789f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
1790f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawColor(canvas, color[j], blendMode[i]);
1791f6603c60Sopenharmony_ci        }
1792f6603c60Sopenharmony_ci    }
1793f6603c60Sopenharmony_ci}
1794f6603c60Sopenharmony_ci
1795f6603c60Sopenharmony_ci/*
1796f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4401
1797f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawColorNull
1798f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawColorNull.
1799f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1800f6603c60Sopenharmony_ci * @tc.type  : Function
1801f6603c60Sopenharmony_ci * @tc.level : Level 3
1802f6603c60Sopenharmony_ci */
1803f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawColorNull, TestSize.Level3) {
1804f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1805f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1806f6603c60Sopenharmony_ci    //2. OH_Drawing_CanvasDrawColor with the first parameter as nullptr
1807f6603c60Sopenharmony_ci    OH_Drawing_BlendMode blendMode[] = {
1808f6603c60Sopenharmony_ci        BLEND_MODE_CLEAR,      BLEND_MODE_SRC,        BLEND_MODE_DST,         BLEND_MODE_SRC_OVER,
1809f6603c60Sopenharmony_ci        BLEND_MODE_DST_OVER,   BLEND_MODE_SRC_IN,     BLEND_MODE_DST_IN,      BLEND_MODE_SRC_OUT,
1810f6603c60Sopenharmony_ci        BLEND_MODE_DST_OUT,    BLEND_MODE_SRC_ATOP,   BLEND_MODE_DST_ATOP,    BLEND_MODE_XOR,
1811f6603c60Sopenharmony_ci        BLEND_MODE_PLUS,       BLEND_MODE_MODULATE,   BLEND_MODE_SCREEN,      BLEND_MODE_OVERLAY,
1812f6603c60Sopenharmony_ci        BLEND_MODE_DARKEN,     BLEND_MODE_LIGHTEN,    BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN,
1813f6603c60Sopenharmony_ci        BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE,  BLEND_MODE_EXCLUSION,
1814f6603c60Sopenharmony_ci        BLEND_MODE_MULTIPLY,   BLEND_MODE_HUE,        BLEND_MODE_SATURATION,  BLEND_MODE_COLOR,
1815f6603c60Sopenharmony_ci        BLEND_MODE_LUMINOSITY,
1816f6603c60Sopenharmony_ci    };
1817f6603c60Sopenharmony_ci    uint32_t color = 0xFFFF0000;
1818f6603c60Sopenharmony_ci    for (int i = 0; i < 29; i++) {
1819f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawColor(nullptr, color, blendMode[i]);
1820f6603c60Sopenharmony_ci    }
1821f6603c60Sopenharmony_ci    //3. OH_Drawing_CanvasDrawColor with the first parameter as 0
1822f6603c60Sopenharmony_ci    for (int i = 0; i < 29; i++) {
1823f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawColor(canvas, 0, blendMode[i]);
1824f6603c60Sopenharmony_ci    }
1825f6603c60Sopenharmony_ci    //4. free memory
1826f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1827f6603c60Sopenharmony_ci}
1828f6603c60Sopenharmony_ci
1829f6603c60Sopenharmony_ci/*
1830f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4402
1831f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawColorMaximum
1832f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawColorMaximum.
1833f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1834f6603c60Sopenharmony_ci * @tc.type  : Function
1835f6603c60Sopenharmony_ci * @tc.level : Level 3
1836f6603c60Sopenharmony_ci */
1837f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawColorMaximum, TestSize.Level3) {
1838f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1839f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1840f6603c60Sopenharmony_ci    //2. OH_Drawing_CanvasDrawColor with the second parameter set to the maximum value
1841f6603c60Sopenharmony_ci    OH_Drawing_BlendMode blendMode[] = {
1842f6603c60Sopenharmony_ci        BLEND_MODE_CLEAR,      BLEND_MODE_SRC,        BLEND_MODE_DST,         BLEND_MODE_SRC_OVER,
1843f6603c60Sopenharmony_ci        BLEND_MODE_DST_OVER,   BLEND_MODE_SRC_IN,     BLEND_MODE_DST_IN,      BLEND_MODE_SRC_OUT,
1844f6603c60Sopenharmony_ci        BLEND_MODE_DST_OUT,    BLEND_MODE_SRC_ATOP,   BLEND_MODE_DST_ATOP,    BLEND_MODE_XOR,
1845f6603c60Sopenharmony_ci        BLEND_MODE_PLUS,       BLEND_MODE_MODULATE,   BLEND_MODE_SCREEN,      BLEND_MODE_OVERLAY,
1846f6603c60Sopenharmony_ci        BLEND_MODE_DARKEN,     BLEND_MODE_LIGHTEN,    BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN,
1847f6603c60Sopenharmony_ci        BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE,  BLEND_MODE_EXCLUSION,
1848f6603c60Sopenharmony_ci        BLEND_MODE_MULTIPLY,   BLEND_MODE_HUE,        BLEND_MODE_SATURATION,  BLEND_MODE_COLOR,
1849f6603c60Sopenharmony_ci        BLEND_MODE_LUMINOSITY,
1850f6603c60Sopenharmony_ci    };
1851f6603c60Sopenharmony_ci    uint32_t color = 0x00000000;
1852f6603c60Sopenharmony_ci    for (int i = 0; i < 29; i++) {
1853f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawColor(nullptr, color, blendMode[i]);
1854f6603c60Sopenharmony_ci    }
1855f6603c60Sopenharmony_ci    //3. free memory
1856f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1857f6603c60Sopenharmony_ci}
1858f6603c60Sopenharmony_ci
1859f6603c60Sopenharmony_ci/*
1860f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4403
1861f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawColorMultipleCalls
1862f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawColorMultipleCalls.
1863f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1864f6603c60Sopenharmony_ci * @tc.type  : Function
1865f6603c60Sopenharmony_ci * @tc.level : Level 3
1866f6603c60Sopenharmony_ci */
1867f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawColorMultipleCalls, TestSize.Level3) {
1868f6603c60Sopenharmony_ci    //1. OH_Drawing_CanvasCreate
1869f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1870f6603c60Sopenharmony_ci    //2. Call OH_Drawing_CanvasDrawColor 10 times
1871f6603c60Sopenharmony_ci    uint32_t color = 0xFFFF0000;
1872f6603c60Sopenharmony_ci    OH_Drawing_BlendMode blendMode[] = {
1873f6603c60Sopenharmony_ci        BLEND_MODE_CLEAR,      BLEND_MODE_SRC,        BLEND_MODE_DST,         BLEND_MODE_SRC_OVER,
1874f6603c60Sopenharmony_ci        BLEND_MODE_DST_OVER,   BLEND_MODE_SRC_IN,     BLEND_MODE_DST_IN,      BLEND_MODE_SRC_OUT,
1875f6603c60Sopenharmony_ci        BLEND_MODE_DST_OUT,    BLEND_MODE_SRC_ATOP,
1876f6603c60Sopenharmony_ci    };
1877f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1878f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawColor(canvas, color, blendMode[i]);
1879f6603c60Sopenharmony_ci    }
1880f6603c60Sopenharmony_ci    //3. free memory
1881f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1882f6603c60Sopenharmony_ci}
1883f6603c60Sopenharmony_ci
1884f6603c60Sopenharmony_ci/*
1885f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4500
1886f6603c60Sopenharmony_ci * @tc.name: testCanvasIsClipEmptyNormal
1887f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasIsClipEmptyNormal.
1888f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1889f6603c60Sopenharmony_ci * @tc.type  : Function
1890f6603c60Sopenharmony_ci * @tc.level : Level 0
1891f6603c60Sopenharmony_ci */
1892f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasIsClipEmptyNormal, TestSize.Level0) {
1893f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
1894f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1895f6603c60Sopenharmony_ci    OH_Drawing_Rect  *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1896f6603c60Sopenharmony_ci    //2. OH_Drawing_RoundRectCreate
1897f6603c60Sopenharmony_ci    OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f);
1898f6603c60Sopenharmony_ci    //3. OH_Drawing_CanvasClipRoundRect with the parameter clipOp set DIFFERENCE
1899f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
1900f6603c60Sopenharmony_ci    bool doAntiAlias[] = {true, false};
1901f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1902f6603c60Sopenharmony_ci        OH_Drawing_CanvasClipRoundRect(canvas, roundRect, clipOp, doAntiAlias[i]);
1903f6603c60Sopenharmony_ci    }
1904f6603c60Sopenharmony_ci    //4. OH_Drawing_CanvasIsClipEmpty
1905f6603c60Sopenharmony_ci    bool isClipEmpty[] = {true, false};
1906f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1907f6603c60Sopenharmony_ci        OH_Drawing_CanvasIsClipEmpty(canvas, &isClipEmpty[i]);
1908f6603c60Sopenharmony_ci    }
1909f6603c60Sopenharmony_ci    //5. free memory
1910f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1911f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1912f6603c60Sopenharmony_ci    OH_Drawing_RoundRectDestroy(roundRect);
1913f6603c60Sopenharmony_ci}
1914f6603c60Sopenharmony_ci
1915f6603c60Sopenharmony_ci/*
1916f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4501
1917f6603c60Sopenharmony_ci * @tc.name: testCanvasIsClipEmptyNull
1918f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasIsClipEmptyNull.
1919f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1920f6603c60Sopenharmony_ci * @tc.type  : Function
1921f6603c60Sopenharmony_ci * @tc.level : Level 3
1922f6603c60Sopenharmony_ci */
1923f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasIsClipEmptyNull, TestSize.Level3) {
1924f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
1925f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1926f6603c60Sopenharmony_ci    OH_Drawing_Rect  *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1927f6603c60Sopenharmony_ci    //2. OH_Drawing_RoundRectCreate
1928f6603c60Sopenharmony_ci    OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f);
1929f6603c60Sopenharmony_ci    //3. OH_Drawing_CanvasClipRoundRect with the parameter clipOp set DIFFERENCE
1930f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
1931f6603c60Sopenharmony_ci    bool doAntiAlias[] = {true, false};
1932f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1933f6603c60Sopenharmony_ci        OH_Drawing_CanvasClipRoundRect(canvas, roundRect, clipOp, doAntiAlias[i]);
1934f6603c60Sopenharmony_ci    }
1935f6603c60Sopenharmony_ci    //4. OH_Drawing_CanvasIsClipEmpty with the first parameter as null
1936f6603c60Sopenharmony_ci    bool isClipEmpty[] = {true, false};
1937f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1938f6603c60Sopenharmony_ci        OH_Drawing_CanvasIsClipEmpty(nullptr, &isClipEmpty[i]);
1939f6603c60Sopenharmony_ci    }
1940f6603c60Sopenharmony_ci    //5. OH_Drawing_CanvasIsClipEmpty with the second parameter as null
1941f6603c60Sopenharmony_ci    OH_Drawing_CanvasIsClipEmpty(canvas, nullptr);
1942f6603c60Sopenharmony_ci    //6. free memory
1943f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1944f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1945f6603c60Sopenharmony_ci    OH_Drawing_RoundRectDestroy(roundRect);
1946f6603c60Sopenharmony_ci}
1947f6603c60Sopenharmony_ci
1948f6603c60Sopenharmony_ci/*
1949f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4502
1950f6603c60Sopenharmony_ci * @tc.name: testCanvasIsClipEmptyMultipleCalls
1951f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasIsClipEmptyMultipleCalls.
1952f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1953f6603c60Sopenharmony_ci * @tc.type  : Function
1954f6603c60Sopenharmony_ci * @tc.level : Level 3
1955f6603c60Sopenharmony_ci */
1956f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasIsClipEmptyMultipleCalls, TestSize.Level3) {
1957f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
1958f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1959f6603c60Sopenharmony_ci    OH_Drawing_Rect  *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
1960f6603c60Sopenharmony_ci    //2. OH_Drawing_RoundRectCreate
1961f6603c60Sopenharmony_ci    OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f);
1962f6603c60Sopenharmony_ci    //3. OH_Drawing_CanvasClipRoundRect with the parameter clipOp set DIFFERENCE
1963f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
1964f6603c60Sopenharmony_ci    bool doAntiAlias[] = {true, false};
1965f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1966f6603c60Sopenharmony_ci        OH_Drawing_CanvasClipRoundRect(canvas, roundRect, clipOp, doAntiAlias[i]);
1967f6603c60Sopenharmony_ci    }
1968f6603c60Sopenharmony_ci    //4. Call OH_Drawing_CanvasIsClipEmpty 10 times
1969f6603c60Sopenharmony_ci    bool isClipEmpty = true;
1970f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvases[10];
1971f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1972f6603c60Sopenharmony_ci        canvases[i]= OH_Drawing_CanvasCreate();
1973f6603c60Sopenharmony_ci    }
1974f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1975f6603c60Sopenharmony_ci        OH_Drawing_CanvasIsClipEmpty(canvases[i], &isClipEmpty);
1976f6603c60Sopenharmony_ci    }
1977f6603c60Sopenharmony_ci    //5. free memory
1978f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1979f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1980f6603c60Sopenharmony_ci        OH_Drawing_CanvasDestroy(canvases[i]);
1981f6603c60Sopenharmony_ci    }
1982f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1983f6603c60Sopenharmony_ci    OH_Drawing_RoundRectDestroy(roundRect);
1984f6603c60Sopenharmony_ci}
1985f6603c60Sopenharmony_ci
1986f6603c60Sopenharmony_ci/*
1987f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4600
1988f6603c60Sopenharmony_ci * @tc.name: testCanvasGetImageInfoNormal
1989f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetImageInfoNormal.
1990f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1991f6603c60Sopenharmony_ci * @tc.type  : Function
1992f6603c60Sopenharmony_ci * @tc.level : Level 0
1993f6603c60Sopenharmony_ci */
1994f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetImageInfoNormal, TestSize.Level0) {
1995f6603c60Sopenharmony_ci    //1. OH_Drawing_BitmapCreate
1996f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1997f6603c60Sopenharmony_ci    //2. OH_Drawing_BitmapGetPixels
1998f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
1999f6603c60Sopenharmony_ci    //3. OH_Drawing_BitmapBuild
2000f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
2001f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
2002f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
2003f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
2004f6603c60Sopenharmony_ci    //4. OH_Drawing_BitmapCreateFromPixels
2005f6603c60Sopenharmony_ci    const uint32_t bytesPerPixel = 3;
2006f6603c60Sopenharmony_ci    const uint32_t padding = 32;
2007f6603c60Sopenharmony_ci    const uint32_t rowBytes = width * bytesPerPixel + padding;
2008f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
2009f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *frompixels = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
2010f6603c60Sopenharmony_ci    //5. OH_Drawing_CanvasBind
2011f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
2012f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas, bitmap);
2013f6603c60Sopenharmony_ci    //6. OH_Drawing_CanvasGetImageInfo
2014f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetImageInfo(canvas, &imageInfo);
2015f6603c60Sopenharmony_ci    //7. free memory
2016f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
2017f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
2018f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(frompixels);
2019f6603c60Sopenharmony_ci}
2020f6603c60Sopenharmony_ci
2021f6603c60Sopenharmony_ci/*
2022f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4601
2023f6603c60Sopenharmony_ci * @tc.name: testCanvasGetImageInfoNull
2024f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetImageInfoNull.
2025f6603c60Sopenharmony_ci * @tc.size  : SmallTest
2026f6603c60Sopenharmony_ci * @tc.type  : Function
2027f6603c60Sopenharmony_ci * @tc.level : Level 3
2028f6603c60Sopenharmony_ci */
2029f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetImageInfoNull, TestSize.Level3) {
2030f6603c60Sopenharmony_ci    //1. OH_Drawing_BitmapCreate
2031f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
2032f6603c60Sopenharmony_ci    //2. OH_Drawing_BitmapGetPixels
2033f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
2034f6603c60Sopenharmony_ci    //3. OH_Drawing_BitmapBuild
2035f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
2036f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
2037f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
2038f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
2039f6603c60Sopenharmony_ci    //4. OH_Drawing_BitmapCreateFromPixels
2040f6603c60Sopenharmony_ci    const uint32_t bytesPerPixel = 3;
2041f6603c60Sopenharmony_ci    const uint32_t padding = 32;
2042f6603c60Sopenharmony_ci    const uint32_t rowBytes = width * bytesPerPixel + padding;
2043f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
2044f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *frompixels = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
2045f6603c60Sopenharmony_ci    //5. OH_Drawing_CanvasBind
2046f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
2047f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas, bitmap);
2048f6603c60Sopenharmony_ci    //6. OH_Drawing_CanvasGetImageInfo with the first parameter as null
2049f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetImageInfo(nullptr, &imageInfo);
2050f6603c60Sopenharmony_ci    //7. OH_Drawing_CanvasGetImageInfo with the second parameter as null
2051f6603c60Sopenharmony_ci    OH_Drawing_CanvasGetImageInfo(canvas, nullptr);
2052f6603c60Sopenharmony_ci    //8. free memory
2053f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
2054f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
2055f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(frompixels);
2056f6603c60Sopenharmony_ci}
2057f6603c60Sopenharmony_ci
2058f6603c60Sopenharmony_ci/*
2059f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4602
2060f6603c60Sopenharmony_ci * @tc.name: testCanvasGetImageInfoMultipleCalls
2061f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasGetImageInfoMultipleCalls.
2062f6603c60Sopenharmony_ci * @tc.size  : SmallTest
2063f6603c60Sopenharmony_ci * @tc.type  : Function
2064f6603c60Sopenharmony_ci * @tc.level : Level 3
2065f6603c60Sopenharmony_ci */
2066f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasGetImageInfoMultipleCalls, TestSize.Level3) {
2067f6603c60Sopenharmony_ci    //1. OH_Drawing_BitmapCreate
2068f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
2069f6603c60Sopenharmony_ci    //2. OH_Drawing_BitmapGetPixels
2070f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
2071f6603c60Sopenharmony_ci    //3. OH_Drawing_BitmapBuild
2072f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
2073f6603c60Sopenharmony_ci    constexpr uint32_t width = 200;
2074f6603c60Sopenharmony_ci    constexpr uint32_t height = 200;
2075f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
2076f6603c60Sopenharmony_ci    //4. OH_Drawing_BitmapCreateFromPixels
2077f6603c60Sopenharmony_ci    const uint32_t bytesPerPixel = 3;
2078f6603c60Sopenharmony_ci    const uint32_t padding = 32;
2079f6603c60Sopenharmony_ci    const uint32_t rowBytes = width * bytesPerPixel + padding;
2080f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
2081f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *frompixels = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
2082f6603c60Sopenharmony_ci    //5. OH_Drawing_CanvasBind
2083f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
2084f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas, bitmap);
2085f6603c60Sopenharmony_ci    //6. Call OH_Drawing_CanvasGetImageInfo 10 times
2086f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvases[10];
2087f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2088f6603c60Sopenharmony_ci        canvases[i]= OH_Drawing_CanvasCreate();
2089f6603c60Sopenharmony_ci    }
2090f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2091f6603c60Sopenharmony_ci        OH_Drawing_CanvasGetImageInfo(canvases[i], &imageInfo);
2092f6603c60Sopenharmony_ci    }
2093f6603c60Sopenharmony_ci    //7. free memory
2094f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
2095f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2096f6603c60Sopenharmony_ci        OH_Drawing_CanvasDestroy(canvases[i]);
2097f6603c60Sopenharmony_ci    }
2098f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
2099f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(frompixels);
2100f6603c60Sopenharmony_ci}
2101f6603c60Sopenharmony_ci
2102f6603c60Sopenharmony_ci/*
2103f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4700
2104f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRegionNormal
2105f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRegionNormal.
2106f6603c60Sopenharmony_ci * @tc.size  : SmallTest
2107f6603c60Sopenharmony_ci * @tc.type  : Function
2108f6603c60Sopenharmony_ci * @tc.level : Level 0
2109f6603c60Sopenharmony_ci */
2110f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRegionNormal, TestSize.Level0) {
2111f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
2112f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
2113f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
2114f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
2115f6603c60Sopenharmony_ci    //2. OH_Drawing_RegionCreate
2116f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
2117f6603c60Sopenharmony_ci    //3. OH_Drawing_RegionSetRect
2118f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
2119f6603c60Sopenharmony_ci    //4. OH_Drawing_CanvasClipRegion
2120f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipRegion(canvas, region, clipOp);
2121f6603c60Sopenharmony_ci    //5. free memory
2122f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
2123f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
2124f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
2125f6603c60Sopenharmony_ci}
2126f6603c60Sopenharmony_ci
2127f6603c60Sopenharmony_ci/*
2128f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4701
2129f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRegionNull
2130f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRegionNull.
2131f6603c60Sopenharmony_ci * @tc.size  : SmallTest
2132f6603c60Sopenharmony_ci * @tc.type  : Function
2133f6603c60Sopenharmony_ci * @tc.level : Level 3
2134f6603c60Sopenharmony_ci */
2135f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRegionNull, TestSize.Level3) {
2136f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
2137f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
2138f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
2139f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
2140f6603c60Sopenharmony_ci    //2. OH_Drawing_RegionCreate
2141f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
2142f6603c60Sopenharmony_ci    //3. OH_Drawing_RegionSetRect
2143f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
2144f6603c60Sopenharmony_ci    //4. OH_Drawing_CanvasClipRegion with the first parameter as nullptr
2145f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipRegion(nullptr, region, clipOp);
2146f6603c60Sopenharmony_ci    //5. OH_Drawing_CanvasClipRegion with the second parameter as nullptr
2147f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipRegion(canvas, nullptr, clipOp);
2148f6603c60Sopenharmony_ci    //6. free memory
2149f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
2150f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
2151f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
2152f6603c60Sopenharmony_ci}
2153f6603c60Sopenharmony_ci
2154f6603c60Sopenharmony_ci/*
2155f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_4702
2156f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRegionMultipleCalls
2157f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRegionMultipleCalls.
2158f6603c60Sopenharmony_ci * @tc.size  : SmallTest
2159f6603c60Sopenharmony_ci * @tc.type  : Function
2160f6603c60Sopenharmony_ci * @tc.level : Level 3
2161f6603c60Sopenharmony_ci */
2162f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRegionMultipleCalls, TestSize.Level3) {
2163f6603c60Sopenharmony_ci    //1. OH_Drawing_RectCreate
2164f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvases[10];
2165f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2166f6603c60Sopenharmony_ci        canvases[i]= OH_Drawing_CanvasCreate();
2167f6603c60Sopenharmony_ci    }
2168f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100);
2169f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipOp clipOp = {OH_Drawing_CanvasClipOp::DIFFERENCE};
2170f6603c60Sopenharmony_ci    //2. OH_Drawing_RegionCreate
2171f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
2172f6603c60Sopenharmony_ci    //3. OH_Drawing_RegionSetRect
2173f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
2174f6603c60Sopenharmony_ci    //4. Call OH_Drawing_CanvasClipRegion 10 times
2175f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2176f6603c60Sopenharmony_ci        OH_Drawing_CanvasClipRegion(canvases[i], region, clipOp);
2177f6603c60Sopenharmony_ci    }
2178f6603c60Sopenharmony_ci    //5. free memory
2179f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
2180f6603c60Sopenharmony_ci        OH_Drawing_CanvasDestroy(canvases[i]);
2181f6603c60Sopenharmony_ci    }
2182f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
2183f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
2184f6603c60Sopenharmony_ci}
2185f6603c60Sopenharmony_ci
2186f6603c60Sopenharmony_ci} // namespace Drawing
2187f6603c60Sopenharmony_ci} // namespace Rosen
2188f6603c60Sopenharmony_ci} // namespace OHOS