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 "DrawingNativeCanvasCommon.h"
17f6603c60Sopenharmony_ci#include "drawing_bitmap.h"
18f6603c60Sopenharmony_ci#include "drawing_brush.h"
19f6603c60Sopenharmony_ci#include "drawing_canvas.h"
20f6603c60Sopenharmony_ci#include "drawing_color.h"
21f6603c60Sopenharmony_ci#include "drawing_color_filter.h"
22f6603c60Sopenharmony_ci#include "drawing_error_code.h"
23f6603c60Sopenharmony_ci#include "drawing_filter.h"
24f6603c60Sopenharmony_ci#include "drawing_font.h"
25f6603c60Sopenharmony_ci#include "drawing_image.h"
26f6603c60Sopenharmony_ci#include "drawing_mask_filter.h"
27f6603c60Sopenharmony_ci#include "drawing_matrix.h"
28f6603c60Sopenharmony_ci#include "drawing_memory_stream.h"
29f6603c60Sopenharmony_ci#include "drawing_path.h"
30f6603c60Sopenharmony_ci#include "drawing_pen.h"
31f6603c60Sopenharmony_ci#include "drawing_pixel_map.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#include "image/pixelmap_native.h"
41f6603c60Sopenharmony_ci#include "gtest/gtest.h"
42f6603c60Sopenharmony_ci
43f6603c60Sopenharmony_ciusing namespace testing;
44f6603c60Sopenharmony_ciusing namespace testing::ext;
45f6603c60Sopenharmony_ci
46f6603c60Sopenharmony_cinamespace OHOS {
47f6603c60Sopenharmony_cinamespace Rosen {
48f6603c60Sopenharmony_cinamespace Drawing {
49f6603c60Sopenharmony_ci/*
50f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1100
51f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRectNormal
52f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRectNormal.
53f6603c60Sopenharmony_ci * @tc.size  : SmallTest
54f6603c60Sopenharmony_ci * @tc.type  : Function
55f6603c60Sopenharmony_ci * @tc.level : Level 0
56f6603c60Sopenharmony_ci */
57f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRectNormal, TestSize.Level0)
58f6603c60Sopenharmony_ci{
59f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
60f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
61f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
62f6603c60Sopenharmony_ci
63f6603c60Sopenharmony_ci    // 2. Obtain OH_Drawing_PixelMap from OH_Drawing_PixelMapGetFromNativePixelMap()
64f6603c60Sopenharmony_ci
65f6603c60Sopenharmony_ci    // 3. Create src and dst using OH_Drawing_RectCreate
66f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
67f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
68f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
69f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
70f6603c60Sopenharmony_ci
71f6603c60Sopenharmony_ci    // 4. Obtain OH_Drawing_PixelMap from OH_Drawing_PixelMapGetFromOhPixelMapNative
72f6603c60Sopenharmony_ci    OH_PixelmapNative *pixelMap = GET_OH_PixelmapNative();
73f6603c60Sopenharmony_ci    OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
74f6603c60Sopenharmony_ci    EXPECT_NE(drPixelMap, nullptr);
75f6603c60Sopenharmony_ci
76f6603c60Sopenharmony_ci    // 5. Iterate through OH_Drawing_FilterMode and OH_Drawing_MipmapMode to construct OH_Drawing_SamplingOptions for
77f6603c60Sopenharmony_ci    OH_Drawing_FilterMode filterMode[] = {FILTER_MODE_NEAREST, FILTER_MODE_LINEAR};
78f6603c60Sopenharmony_ci    OH_Drawing_MipmapMode mode[] = {MIPMAP_MODE_NEAREST, MIPMAP_MODE_LINEAR, MIPMAP_MODE_NONE};
79f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
80f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
81f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(filterMode[i], mode[j]);
82f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, options);
83f6603c60Sopenharmony_ci        }
84f6603c60Sopenharmony_ci    }
85f6603c60Sopenharmony_ci
86f6603c60Sopenharmony_ci    // 6. Free the memory.
87f6603c60Sopenharmony_ci    OH_Drawing_PixelMapDissolve(drPixelMap);
88f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
89f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
90f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
91f6603c60Sopenharmony_ci}
92f6603c60Sopenharmony_ci
93f6603c60Sopenharmony_ci/*
94f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1101
95f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRectNull
96f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRectNull.
97f6603c60Sopenharmony_ci * @tc.size  : SmallTest
98f6603c60Sopenharmony_ci * @tc.type  : Function
99f6603c60Sopenharmony_ci * @tc.level : Level 3
100f6603c60Sopenharmony_ci */
101f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRectNull, TestSize.Level3)
102f6603c60Sopenharmony_ci{
103f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
104f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
105f6603c60Sopenharmony_ci    OH_PixelmapNative *pixelMap = GET_OH_PixelmapNative();
106f6603c60Sopenharmony_ci    OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
107f6603c60Sopenharmony_ci    EXPECT_NE(drPixelMap, nullptr);
108f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
109f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
110f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
111f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
112f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *sampleOptions =
113f6603c60Sopenharmony_ci        OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_NEAREST);
114f6603c60Sopenharmony_ci
115f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(nullptr, drPixelMap, src, dst, sampleOptions);
116f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, nullptr, src, dst, sampleOptions);
117f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, nullptr, dst, sampleOptions);
118f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, nullptr, sampleOptions);
119f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, nullptr);
120f6603c60Sopenharmony_ci    OH_Drawing_PixelMapGetFromNativePixelMap(nullptr);
121f6603c60Sopenharmony_ci
122f6603c60Sopenharmony_ci    float rectParams[][4] = {
123f6603c60Sopenharmony_ci        {0, 1, 1, 1}, {1, 0, 1, 1}, {1, 1, 0, 1}, {1, 1, 1, 0}, {0, 0, 0, 0},
124f6603c60Sopenharmony_ci    };
125f6603c60Sopenharmony_ci    for (int i = 0; i < sizeof(rectParams) / sizeof(rectParams[0]); ++i) {
126f6603c60Sopenharmony_ci        OH_Drawing_Rect *src =
127f6603c60Sopenharmony_ci            OH_Drawing_RectCreate(rectParams[i][0], rectParams[i][1], rectParams[i][2], rectParams[i][3]);
128f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, sampleOptions);
129f6603c60Sopenharmony_ci
130f6603c60Sopenharmony_ci        OH_Drawing_Rect *dst =
131f6603c60Sopenharmony_ci            OH_Drawing_RectCreate(rectParams[i][0], rectParams[i][1], rectParams[i][2], rectParams[i][3]);
132f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, sampleOptions);
133f6603c60Sopenharmony_ci
134f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(src);
135f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(dst);
136f6603c60Sopenharmony_ci    }
137f6603c60Sopenharmony_ci
138f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
139f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
140f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(sampleOptions);
141f6603c60Sopenharmony_ci    OH_Drawing_PixelMapDissolve(drPixelMap);
142f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
143f6603c60Sopenharmony_ci}
144f6603c60Sopenharmony_ci
145f6603c60Sopenharmony_ci/*
146f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1102
147f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRectAbnormal
148f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRectAbnormal.
149f6603c60Sopenharmony_ci * @tc.size  : SmallTest
150f6603c60Sopenharmony_ci * @tc.type  : Function
151f6603c60Sopenharmony_ci * @tc.level : Level 3
152f6603c60Sopenharmony_ci */
153f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRectAbnormal, TestSize.Level3)
154f6603c60Sopenharmony_ci{
155f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
156f6603c60Sopenharmony_ci    OH_PixelmapNative *pixelMap = GET_OH_PixelmapNative();
157f6603c60Sopenharmony_ci    OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
158f6603c60Sopenharmony_ci    EXPECT_NE(drPixelMap, nullptr);
159f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
160f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
161f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
162f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
163f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *sampleOptions =
164f6603c60Sopenharmony_ci        OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_NEAREST);
165f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(nullptr, drPixelMap, src, dst, sampleOptions);
166f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, nullptr, src, dst, sampleOptions);
167f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, nullptr, dst, sampleOptions);
168f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, nullptr, sampleOptions);
169f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, nullptr);
170f6603c60Sopenharmony_ci    OH_Drawing_PixelMapGetFromNativePixelMap(nullptr);
171f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
172f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
173f6603c60Sopenharmony_ci    // Define parameter arrays for source and destination rectangles
174f6603c60Sopenharmony_ci    int srcRects[][4] = {
175f6603c60Sopenharmony_ci        {-1, 1, 1, 1},        {1, -1, 1, 1},        {1, 1, -1, 1},        {1, 1, 1, -1},    {100, 100, 100, 200},
176f6603c60Sopenharmony_ci        {100, 200, 200, 200}, {100, 100, 100, 100}, {200, 200, 100, 100}, {0, 0, 100, 100},
177f6603c60Sopenharmony_ci    };
178f6603c60Sopenharmony_ci    // Loop to draw the first 7 src rectangles
179f6603c60Sopenharmony_ci    for (int i = 0; i < 8; i++) {
180f6603c60Sopenharmony_ci        src = OH_Drawing_RectCreate(srcRects[i][0], srcRects[i][1], srcRects[i][2], srcRects[i][3]);
181f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, sampleOptions);
182f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(src);
183f6603c60Sopenharmony_ci    }
184f6603c60Sopenharmony_ci    src = OH_Drawing_RectCreate(0, 0, 100, 100);
185f6603c60Sopenharmony_ci    int dstRects[][4] = {
186f6603c60Sopenharmony_ci        {100, 100, 100, 200},
187f6603c60Sopenharmony_ci        {100, 200, 200, 200},
188f6603c60Sopenharmony_ci        {100, 100, 100, 100},
189f6603c60Sopenharmony_ci        {200, 200, 100, 100},
190f6603c60Sopenharmony_ci    };
191f6603c60Sopenharmony_ci    // Loop to draw all dst rectangles using the last src rectangle
192f6603c60Sopenharmony_ci    for (int i = 0; i < 4; i++) {
193f6603c60Sopenharmony_ci        dst = OH_Drawing_RectCreate(dstRects[i][0], dstRects[i][1], dstRects[i][2], dstRects[i][3]);
194f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst, sampleOptions);
195f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(dst);
196f6603c60Sopenharmony_ci    }
197f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
198f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(sampleOptions);
199f6603c60Sopenharmony_ci    OH_Drawing_PixelMapDissolve(drPixelMap);
200f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
201f6603c60Sopenharmony_ci}
202f6603c60Sopenharmony_ci
203f6603c60Sopenharmony_ci/*
204f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1103
205f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRectMaximum
206f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRectMaximum.
207f6603c60Sopenharmony_ci * @tc.size  : SmallTest
208f6603c60Sopenharmony_ci * @tc.type  : Function
209f6603c60Sopenharmony_ci * @tc.level : Level 3
210f6603c60Sopenharmony_ci */
211f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRectMaximum, TestSize.Level3)
212f6603c60Sopenharmony_ci{
213f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
214f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
215f6603c60Sopenharmony_ci
216f6603c60Sopenharmony_ci    OH_PixelmapNative *pixelMap = GET_OH_PixelmapNative();
217f6603c60Sopenharmony_ci    OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
218f6603c60Sopenharmony_ci    EXPECT_NE(drPixelMap, nullptr);
219f6603c60Sopenharmony_ci
220f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
221f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
222f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
223f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
224f6603c60Sopenharmony_ci
225f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *sampleOptions =
226f6603c60Sopenharmony_ci        OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_NEAREST);
227f6603c60Sopenharmony_ci    // 2
228f6603c60Sopenharmony_ci    OH_Drawing_Rect *src1 = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 100, 100);
229f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src1, dst, sampleOptions);
230f6603c60Sopenharmony_ci    // 3
231f6603c60Sopenharmony_ci    OH_Drawing_Rect *src2 = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
232f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src2, dst, sampleOptions);
233f6603c60Sopenharmony_ci    // 4
234f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst1 = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 100, 100);
235f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst1, sampleOptions);
236f6603c60Sopenharmony_ci    // 5
237f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst2 = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
238f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst2, sampleOptions);
239f6603c60Sopenharmony_ci    // 6
240f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src1);
241f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src2);
242f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst1);
243f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst2);
244f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
245f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
246f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(sampleOptions);
247f6603c60Sopenharmony_ci    OH_Drawing_PixelMapDissolve(drPixelMap);
248f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
249f6603c60Sopenharmony_ci}
250f6603c60Sopenharmony_ci
251f6603c60Sopenharmony_ci/*
252f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1103
253f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRect4KBoundary
254f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRect4KBoundary.
255f6603c60Sopenharmony_ci * @tc.size  : SmallTest
256f6603c60Sopenharmony_ci * @tc.type  : Function
257f6603c60Sopenharmony_ci * @tc.level : Level 3
258f6603c60Sopenharmony_ci */
259f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRect4KBoundary, TestSize.Level3)
260f6603c60Sopenharmony_ci{
261f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
262f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
263f6603c60Sopenharmony_ci
264f6603c60Sopenharmony_ci    OH_PixelmapNative *pixelMap = GET_OH_PixelmapNative4KBoundary();
265f6603c60Sopenharmony_ci    OH_Drawing_PixelMap *drPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
266f6603c60Sopenharmony_ci    EXPECT_NE(drPixelMap, nullptr);
267f6603c60Sopenharmony_ci
268f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
269f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
270f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
271f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
272f6603c60Sopenharmony_ci
273f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *sampleOptions =
274f6603c60Sopenharmony_ci        OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_NEAREST);
275f6603c60Sopenharmony_ci    // 2
276f6603c60Sopenharmony_ci    OH_Drawing_Rect *src1 = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 100, 100);
277f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src1, dst, sampleOptions);
278f6603c60Sopenharmony_ci    // 3
279f6603c60Sopenharmony_ci    OH_Drawing_Rect *src2 = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
280f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src2, dst, sampleOptions);
281f6603c60Sopenharmony_ci    // 4
282f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst1 = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 100, 100);
283f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst1, sampleOptions);
284f6603c60Sopenharmony_ci    // 5
285f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst2 = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
286f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPixelMapRect(canvas, drPixelMap, src, dst2, sampleOptions);
287f6603c60Sopenharmony_ci    // 6
288f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src1);
289f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src2);
290f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst1);
291f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst2);
292f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
293f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
294f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(sampleOptions);
295f6603c60Sopenharmony_ci    OH_Drawing_PixelMapDissolve(drPixelMap);
296f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
297f6603c60Sopenharmony_ci}
298f6603c60Sopenharmony_ci
299f6603c60Sopenharmony_ci/*
300f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1104
301f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPixelMapRectInputDestroyed
302f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPixelMapRectInputDestroyed.
303f6603c60Sopenharmony_ci * @tc.size  : SmallTest
304f6603c60Sopenharmony_ci * @tc.type  : Function
305f6603c60Sopenharmony_ci * @tc.level : Level 3
306f6603c60Sopenharmony_ci */
307f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPixelMapRectInputDestroyed, TestSize.Level3)
308f6603c60Sopenharmony_ci{
309f6603c60Sopenharmony_ci    // Deprecated
310f6603c60Sopenharmony_ci}
311f6603c60Sopenharmony_ci
312f6603c60Sopenharmony_ci/*
313f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1200
314f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBackgroundNormal
315f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBackgroundNormal.
316f6603c60Sopenharmony_ci * @tc.size  : SmallTest
317f6603c60Sopenharmony_ci * @tc.type  : Function
318f6603c60Sopenharmony_ci * @tc.level : Level 0
319f6603c60Sopenharmony_ci */
320f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBackgroundNormal, TestSize.Level0)
321f6603c60Sopenharmony_ci{
322f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
323f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
324f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
325f6603c60Sopenharmony_ci
326f6603c60Sopenharmony_ci    // 2. OH_Drawing_BrushCreate
327f6603c60Sopenharmony_ci    OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
328f6603c60Sopenharmony_ci    EXPECT_NE(brush, nullptr);
329f6603c60Sopenharmony_ci
330f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBackground
331f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBackground(canvas, brush);
332f6603c60Sopenharmony_ci
333f6603c60Sopenharmony_ci    // 4. Free the memory.
334f6603c60Sopenharmony_ci    OH_Drawing_BrushDestroy(brush);
335f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
336f6603c60Sopenharmony_ci}
337f6603c60Sopenharmony_ci
338f6603c60Sopenharmony_ci/*
339f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1201
340f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBackgroundNull
341f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBackgroundNull.
342f6603c60Sopenharmony_ci * @tc.size  : SmallTest
343f6603c60Sopenharmony_ci * @tc.type  : Function
344f6603c60Sopenharmony_ci * @tc.level : Level 3
345f6603c60Sopenharmony_ci */
346f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBackgroundNull, TestSize.Level3)
347f6603c60Sopenharmony_ci{
348f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
349f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
350f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
351f6603c60Sopenharmony_ci
352f6603c60Sopenharmony_ci    // 2. OH_Drawing_BrushCreate
353f6603c60Sopenharmony_ci    OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
354f6603c60Sopenharmony_ci    EXPECT_NE(brush, nullptr);
355f6603c60Sopenharmony_ci
356f6603c60Sopenharmony_ci    // 3. Pass an empty value as the first argument for OH_Drawing_CanvasDrawBackground.
357f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBackground(nullptr, brush);
358f6603c60Sopenharmony_ci
359f6603c60Sopenharmony_ci    // 4. Pass an empty value as the second argument for OH_Drawing_CanvasDrawBackground.
360f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBackground(canvas, nullptr);
361f6603c60Sopenharmony_ci
362f6603c60Sopenharmony_ci    // 5. Free the memory.
363f6603c60Sopenharmony_ci    OH_Drawing_BrushDestroy(brush);
364f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
365f6603c60Sopenharmony_ci}
366f6603c60Sopenharmony_ci
367f6603c60Sopenharmony_ci/*
368f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1202
369f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBackgroundInputDestroyed
370f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBackgroundInputDestroyed.
371f6603c60Sopenharmony_ci * @tc.size  : SmallTest
372f6603c60Sopenharmony_ci * @tc.type  : Function
373f6603c60Sopenharmony_ci * @tc.level : Level 3
374f6603c60Sopenharmony_ci */
375f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBackgroundInputDestroyed, TestSize.Level3)
376f6603c60Sopenharmony_ci{
377f6603c60Sopenharmony_ci    // Deprecated
378f6603c60Sopenharmony_ci}
379f6603c60Sopenharmony_ci
380f6603c60Sopenharmony_ci/*
381f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1203
382f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBackgroundMultipleCalls
383f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBackgroundMultipleCalls.
384f6603c60Sopenharmony_ci * @tc.size  : SmallTest
385f6603c60Sopenharmony_ci * @tc.type  : Function
386f6603c60Sopenharmony_ci * @tc.level : Level 3
387f6603c60Sopenharmony_ci */
388f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBackgroundMultipleCalls, TestSize.Level3)
389f6603c60Sopenharmony_ci{
390f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
391f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
392f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
393f6603c60Sopenharmony_ci
394f6603c60Sopenharmony_ci    // 2. OH_Drawing_BrushCreate
395f6603c60Sopenharmony_ci    OH_Drawing_Brush *brush = OH_Drawing_BrushCreate();
396f6603c60Sopenharmony_ci    EXPECT_NE(brush, nullptr);
397f6603c60Sopenharmony_ci
398f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBackground, 10 times.
399f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
400f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawBackground(canvas, brush);
401f6603c60Sopenharmony_ci    }
402f6603c60Sopenharmony_ci
403f6603c60Sopenharmony_ci    // 4. Free the memory.
404f6603c60Sopenharmony_ci    OH_Drawing_BrushDestroy(brush);
405f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
406f6603c60Sopenharmony_ci}
407f6603c60Sopenharmony_ci
408f6603c60Sopenharmony_ci/*
409f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1300
410f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRegionNormal
411f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRegionNormal.
412f6603c60Sopenharmony_ci * @tc.size  : SmallTest
413f6603c60Sopenharmony_ci * @tc.type  : Function
414f6603c60Sopenharmony_ci * @tc.level : Level 0
415f6603c60Sopenharmony_ci */
416f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRegionNormal, TestSize.Level0)
417f6603c60Sopenharmony_ci{
418f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
419f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
420f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
421f6603c60Sopenharmony_ci
422f6603c60Sopenharmony_ci    // 2. OH_Drawing_RegionCreate
423f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
424f6603c60Sopenharmony_ci    EXPECT_NE(region, nullptr);
425f6603c60Sopenharmony_ci
426f6603c60Sopenharmony_ci    // 3. OH_Drawing_RegionSetRect
427f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 256.0f, 256.0f);
428f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
429f6603c60Sopenharmony_ci
430f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawRegion
431f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRegion(canvas, region);
432f6603c60Sopenharmony_ci
433f6603c60Sopenharmony_ci    // 5. Free the memory.
434f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
435f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
436f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
437f6603c60Sopenharmony_ci}
438f6603c60Sopenharmony_ci
439f6603c60Sopenharmony_ci/*
440f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1301
441f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRegionNull
442f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRegionNull.
443f6603c60Sopenharmony_ci * @tc.size  : SmallTest
444f6603c60Sopenharmony_ci * @tc.type  : Function
445f6603c60Sopenharmony_ci * @tc.level : Level 3
446f6603c60Sopenharmony_ci */
447f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRegionNull, TestSize.Level3)
448f6603c60Sopenharmony_ci{
449f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
450f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
451f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
452f6603c60Sopenharmony_ci
453f6603c60Sopenharmony_ci    // 2. OH_Drawing_RegionCreate
454f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
455f6603c60Sopenharmony_ci    EXPECT_NE(region, nullptr);
456f6603c60Sopenharmony_ci
457f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawRegion, first parameter is nullptr
458f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 256.0f, 256.0f);
459f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
460f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRegion(nullptr, region);
461f6603c60Sopenharmony_ci
462f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawRegion, second parameter is nullptr
463f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRegion(canvas, nullptr);
464f6603c60Sopenharmony_ci
465f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawRegion, region is empty
466f6603c60Sopenharmony_ci    OH_Drawing_Region *region2 = OH_Drawing_RegionCreate();
467f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRegion(canvas, region2);
468f6603c60Sopenharmony_ci
469f6603c60Sopenharmony_ci    // 6. Free the memory.
470f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
471f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
472f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region2);
473f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
474f6603c60Sopenharmony_ci}
475f6603c60Sopenharmony_ci
476f6603c60Sopenharmony_ci/*
477f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1302
478f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRegionInputDestroyed
479f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRegionInputDestroyed.
480f6603c60Sopenharmony_ci * @tc.size  : SmallTest
481f6603c60Sopenharmony_ci * @tc.type  : Function
482f6603c60Sopenharmony_ci * @tc.level : Level 3
483f6603c60Sopenharmony_ci */
484f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRegionInputDestroyed, TestSize.Level3)
485f6603c60Sopenharmony_ci{
486f6603c60Sopenharmony_ci    // Deprecated
487f6603c60Sopenharmony_ci}
488f6603c60Sopenharmony_ci
489f6603c60Sopenharmony_ci/*
490f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1400
491f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsNormal
492f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsNormal.
493f6603c60Sopenharmony_ci * @tc.size  : SmallTest
494f6603c60Sopenharmony_ci * @tc.type  : Function
495f6603c60Sopenharmony_ci * @tc.level : Level 0
496f6603c60Sopenharmony_ci */
497f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsNormal, TestSize.Level0)
498f6603c60Sopenharmony_ci{
499f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
500f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
501f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
502f6603c60Sopenharmony_ci
503f6603c60Sopenharmony_ci    // 2. OH_Drawing_Point2D creates an array of points.
504f6603c60Sopenharmony_ci    OH_Drawing_Point2D point = {250, 500};
505f6603c60Sopenharmony_ci    OH_Drawing_Point2D points1[1] = {point};
506f6603c60Sopenharmony_ci
507f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawPoints iterates through the enum values OH_Drawing_PointMode, with count set to the
508f6603c60Sopenharmony_ci    // length of the corresponding value.
509f6603c60Sopenharmony_ci    OH_Drawing_PointMode modeArray[3] = {POINT_MODE_POINTS, POINT_MODE_LINES, POINT_MODE_POLYGON};
510f6603c60Sopenharmony_ci    for (int i = 0; i < 3; i++) {
511f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoints(canvas, modeArray[i], 1, points1);
512f6603c60Sopenharmony_ci    }
513f6603c60Sopenharmony_ci
514f6603c60Sopenharmony_ci    // 4. OH_Drawing_Point2D creates an array of multiple points.
515f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne = {250, 500};
516f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointTwo = {200, 500};
517f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointThree = {500, 700};
518f6603c60Sopenharmony_ci    OH_Drawing_Point2D points2[3] = {pointOne, pointTwo, pointThree};
519f6603c60Sopenharmony_ci
520f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawPoints iterates through the enum values OH_Drawing_PointMode, with count set to the
521f6603c60Sopenharmony_ci    // length of the corresponding value.
522f6603c60Sopenharmony_ci    for (int i = 0; i < 3; i++) {
523f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoints(canvas, modeArray[i], 3, points2);
524f6603c60Sopenharmony_ci    }
525f6603c60Sopenharmony_ci
526f6603c60Sopenharmony_ci    // 6. Free the memory.
527f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
528f6603c60Sopenharmony_ci}
529f6603c60Sopenharmony_ci
530f6603c60Sopenharmony_ci/*
531f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1401
532f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsNull
533f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsNull.
534f6603c60Sopenharmony_ci * @tc.size  : SmallTest
535f6603c60Sopenharmony_ci * @tc.type  : Function
536f6603c60Sopenharmony_ci * @tc.level : Level 3
537f6603c60Sopenharmony_ci */
538f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsNull, TestSize.Level3)
539f6603c60Sopenharmony_ci{
540f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
541f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
542f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
543f6603c60Sopenharmony_ci
544f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne = {250, 500};
545f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointTwo = {200, 500};
546f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointThree = {500, 700};
547f6603c60Sopenharmony_ci    OH_Drawing_Point2D points[3] = {pointOne, pointTwo, pointThree};
548f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointsEmpty[0] = {};
549f6603c60Sopenharmony_ci
550f6603c60Sopenharmony_ci    // 2. Pass an empty value as the first argument for OH_Drawing_CanvasDrawPoints.
551f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(nullptr, POINT_MODE_LINES, 3, points);
552f6603c60Sopenharmony_ci
553f6603c60Sopenharmony_ci    // 3. Set the third argument of OH_Drawing_CanvasDrawPoints to 0.
554f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 0, points);
555f6603c60Sopenharmony_ci
556f6603c60Sopenharmony_ci    // 4. Pass an empty array as the fourth argument for OH_Drawing_CanvasDrawPoints.
557f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 3, pointsEmpty);
558f6603c60Sopenharmony_ci
559f6603c60Sopenharmony_ci    // 5. Free the memory.
560f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
561f6603c60Sopenharmony_ci}
562f6603c60Sopenharmony_ci
563f6603c60Sopenharmony_ci/*
564f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1402
565f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsAbnormal
566f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsAbnormal.
567f6603c60Sopenharmony_ci * @tc.size  : SmallTest
568f6603c60Sopenharmony_ci * @tc.type  : Function
569f6603c60Sopenharmony_ci * @tc.level : Level 3
570f6603c60Sopenharmony_ci */
571f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsAbnormal, TestSize.Level3)
572f6603c60Sopenharmony_ci{
573f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
574f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
575f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
576f6603c60Sopenharmony_ci
577f6603c60Sopenharmony_ci    // 2. Pass a negative value for the count parameter in OH_Drawing_CanvasDrawPoints.
578f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne = {250, 500};
579f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointTwo = {200, 500};
580f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointThree = {500, 700};
581f6603c60Sopenharmony_ci    OH_Drawing_Point2D points[3] = {pointOne, pointTwo, pointThree};
582f6603c60Sopenharmony_ci
583f6603c60Sopenharmony_ci    if (0) {
584f6603c60Sopenharmony_ci        // todo cpp crash
585f6603c60Sopenharmony_ci        // libc++abi: terminating due to uncaught exception of type std::bad_alloc: std::bad_alloc
586f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, -1, points);
587f6603c60Sopenharmony_ci    }
588f6603c60Sopenharmony_ci
589f6603c60Sopenharmony_ci    // 3. Pass a floating-point value for the count parameter in OH_Drawing_CanvasDrawPoints.
590f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1.0f, points);
591f6603c60Sopenharmony_ci
592f6603c60Sopenharmony_ci    // 4. Set the x-coordinate of the point in OH_Drawing_Point2D parameter to a negative number in
593f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
594f6603c60Sopenharmony_ci    OH_Drawing_Point2D point1 = {-250, 500};
595f6603c60Sopenharmony_ci    OH_Drawing_Point2D points1[1] = {point1};
596f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points1);
597f6603c60Sopenharmony_ci
598f6603c60Sopenharmony_ci    // 5. Set the y-coordinate of the point in OH_Drawing_Point2D parameter to a negative number in
599f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
600f6603c60Sopenharmony_ci    OH_Drawing_Point2D point2 = {250, -500};
601f6603c60Sopenharmony_ci    OH_Drawing_Point2D points2[1] = {point2};
602f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points2);
603f6603c60Sopenharmony_ci
604f6603c60Sopenharmony_ci    // 6. Set both the x and y coordinates of the point in OH_Drawing_Point2D parameter to negative numbers in
605f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
606f6603c60Sopenharmony_ci    OH_Drawing_Point2D point3 = {-250, -500};
607f6603c60Sopenharmony_ci    OH_Drawing_Point2D points3[1] = {point3};
608f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points3);
609f6603c60Sopenharmony_ci
610f6603c60Sopenharmony_ci    // 7. Free the memory.
611f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
612f6603c60Sopenharmony_ci}
613f6603c60Sopenharmony_ci
614f6603c60Sopenharmony_ci/*
615f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1403
616f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsMismatch
617f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsMismatch.
618f6603c60Sopenharmony_ci * @tc.size  : SmallTest
619f6603c60Sopenharmony_ci * @tc.type  : Function
620f6603c60Sopenharmony_ci * @tc.level : Level 3
621f6603c60Sopenharmony_ci */
622f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsMismatch, TestSize.Level3)
623f6603c60Sopenharmony_ci{
624f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
625f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
626f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
627f6603c60Sopenharmony_ci
628f6603c60Sopenharmony_ci    // 2. Pass an array of OH_Drawing_Point2D with a length of 1 and pass 2 as the count parameter in
629f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
630f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne = {250, 500};
631f6603c60Sopenharmony_ci    OH_Drawing_Point2D points1[1] = {pointOne};
632f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 2, points1);
633f6603c60Sopenharmony_ci
634f6603c60Sopenharmony_ci    // 3. Pass an array of OH_Drawing_Point2D with a length of 3 and pass 1 as the count parameter in
635f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
636f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne1 = {250, 500};
637f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointTwo1 = {200, 500};
638f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointThree1 = {500, 700};
639f6603c60Sopenharmony_ci    OH_Drawing_Point2D points2[3] = {pointOne1, pointTwo1, pointThree1};
640f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points2);
641f6603c60Sopenharmony_ci
642f6603c60Sopenharmony_ci    // 4. Free the memory.
643f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
644f6603c60Sopenharmony_ci}
645f6603c60Sopenharmony_ci
646f6603c60Sopenharmony_ci/*
647f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1404
648f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsMaximum
649f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsMaximum.
650f6603c60Sopenharmony_ci * @tc.size  : SmallTest
651f6603c60Sopenharmony_ci * @tc.type  : Function
652f6603c60Sopenharmony_ci * @tc.level : Level 3
653f6603c60Sopenharmony_ci */
654f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsMaximum, TestSize.Level3)
655f6603c60Sopenharmony_ci{
656f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
657f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
658f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
659f6603c60Sopenharmony_ci
660f6603c60Sopenharmony_ci    // 2. Pass an extremely large value for the count parameter in OH_Drawing_CanvasDrawPoints.
661f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointOne = {250, 500};
662f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointTwo = {200, 500};
663f6603c60Sopenharmony_ci    OH_Drawing_Point2D pointThree = {500, 700};
664f6603c60Sopenharmony_ci    OH_Drawing_Point2D points[3] = {pointOne, pointTwo, pointThree};
665f6603c60Sopenharmony_ci    if (0) {
666f6603c60Sopenharmony_ci        // todo cpp crash
667f6603c60Sopenharmony_ci        // libc++abi: terminating due to uncaught exception of type std::bad_alloc: std::bad_alloc
668f6603c60Sopenharmony_ci        OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, INT32_MAX, points);
669f6603c60Sopenharmony_ci    }
670f6603c60Sopenharmony_ci
671f6603c60Sopenharmony_ci    // 3. Set the x-coordinate of the point in OH_Drawing_Point2D parameter to an extremely large value in
672f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
673f6603c60Sopenharmony_ci    OH_Drawing_Point2D point1 = {INT32_MAX, 500};
674f6603c60Sopenharmony_ci    OH_Drawing_Point2D points1[1] = {point1};
675f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points1);
676f6603c60Sopenharmony_ci
677f6603c60Sopenharmony_ci    // 4. Set the y-coordinate of the point in OH_Drawing_Point2D parameter to an extremely large value in
678f6603c60Sopenharmony_ci    // OH_Drawing_CanvasDrawPoints.
679f6603c60Sopenharmony_ci    OH_Drawing_Point2D point2 = {250, INT32_MAX};
680f6603c60Sopenharmony_ci    OH_Drawing_Point2D points2[1] = {point2};
681f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPoints(canvas, POINT_MODE_LINES, 1, points2);
682f6603c60Sopenharmony_ci
683f6603c60Sopenharmony_ci    // 5. Free the memory.
684f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
685f6603c60Sopenharmony_ci}
686f6603c60Sopenharmony_ci
687f6603c60Sopenharmony_ci/*
688f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1405
689f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawPointsInputDestroyed
690f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawPointsInputDestroyed.
691f6603c60Sopenharmony_ci * @tc.size  : SmallTest
692f6603c60Sopenharmony_ci * @tc.type  : Function
693f6603c60Sopenharmony_ci * @tc.level : Level 3
694f6603c60Sopenharmony_ci */
695f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawPointsInputDestroyed, TestSize.Level3)
696f6603c60Sopenharmony_ci{
697f6603c60Sopenharmony_ci    // Deprecated
698f6603c60Sopenharmony_ci}
699f6603c60Sopenharmony_ci
700f6603c60Sopenharmony_ci/*
701f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1500
702f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapNormal
703f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapNormal.
704f6603c60Sopenharmony_ci * @tc.size  : SmallTest
705f6603c60Sopenharmony_ci * @tc.type  : Function
706f6603c60Sopenharmony_ci * @tc.level : Level 0
707f6603c60Sopenharmony_ci */
708f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapNormal, TestSize.Level0)
709f6603c60Sopenharmony_ci{
710f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
711f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
712f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
713f6603c60Sopenharmony_ci
714f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
715f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
716f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
717f6603c60Sopenharmony_ci
718f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBitmap
719f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
720f6603c60Sopenharmony_ci
721f6603c60Sopenharmony_ci    // 4. OH_Drawing_BitmapCreateFromPixels, iterate through OH_Drawing_ColorFormat and OH_Drawing_AlphaFormat to
722f6603c60Sopenharmony_ci    // construct OH_Drawing_Image_Info.
723f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
724f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
725f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
726f6603c60Sopenharmony_ci    };
727f6603c60Sopenharmony_ci
728f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
729f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
730f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
731f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
732f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
733f6603c60Sopenharmony_ci    };
734f6603c60Sopenharmony_ci
735f6603c60Sopenharmony_ci    for (int i = 0; i < 6; i++) {
736f6603c60Sopenharmony_ci        for (int j = 0; j < 4; j++) {
737f6603c60Sopenharmony_ci            int width = 500;
738f6603c60Sopenharmony_ci            int height = 500;
739f6603c60Sopenharmony_ci            int rowBytes = width * height * 4;
740f6603c60Sopenharmony_ci            OH_Drawing_Image_Info imageInfo = {width, height, formats[i], alphaFormats[j]};
741f6603c60Sopenharmony_ci            OH_Drawing_BitmapFormat cFormat{formats[i], alphaFormats[j]};
742f6603c60Sopenharmony_ci            OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
743f6603c60Sopenharmony_ci            void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
744f6603c60Sopenharmony_ci            bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
745f6603c60Sopenharmony_ci            // 5. OH_Drawing_CanvasDrawBitmap
746f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
747f6603c60Sopenharmony_ci            OH_Drawing_BitmapDestroy(bitmap);
748f6603c60Sopenharmony_ci        }
749f6603c60Sopenharmony_ci    }
750f6603c60Sopenharmony_ci
751f6603c60Sopenharmony_ci    // 6. OH_Drawing_BitmapCreateFromPixels, initialize the Bitmap with rowBytes greater than the image.
752f6603c60Sopenharmony_ci    int width = 500;
753f6603c60Sopenharmony_ci    int height = 500;
754f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
755f6603c60Sopenharmony_ci    int rowBytes = 600 * 600 * 4;
756f6603c60Sopenharmony_ci    void *pixels = new int[width * height];
757f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
758f6603c60Sopenharmony_ci
759f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawBitmap
760f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
761f6603c60Sopenharmony_ci
762f6603c60Sopenharmony_ci    // 8. Free the memory.
763f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
764f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
765f6603c60Sopenharmony_ci}
766f6603c60Sopenharmony_ci
767f6603c60Sopenharmony_ci/*
768f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1501
769f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapNull
770f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapNull.
771f6603c60Sopenharmony_ci * @tc.size  : SmallTest
772f6603c60Sopenharmony_ci * @tc.type  : Function
773f6603c60Sopenharmony_ci * @tc.level : Level 3
774f6603c60Sopenharmony_ci */
775f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapNull, TestSize.Level3)
776f6603c60Sopenharmony_ci{
777f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
778f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
779f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
780f6603c60Sopenharmony_ci
781f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
782f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
783f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
784f6603c60Sopenharmony_ci
785f6603c60Sopenharmony_ci    // 3. The first parameter in OH_Drawing_CanvasDrawBitmap is empty.
786f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(nullptr, bitmap, 0, 0);
787f6603c60Sopenharmony_ci
788f6603c60Sopenharmony_ci    // 4. The second parameter in OH_Drawing_CanvasDrawBitmap is empty.
789f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, nullptr, 0, 0);
790f6603c60Sopenharmony_ci
791f6603c60Sopenharmony_ci    // 5. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, and allocate memory for pixels
792f6603c60Sopenharmony_ci    // as 47*48.
793f6603c60Sopenharmony_ci    int width = 48;
794f6603c60Sopenharmony_ci    int height = 48;
795f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
796f6603c60Sopenharmony_ci    int rowBytes = width * height * 4;
797f6603c60Sopenharmony_ci    void *pixels = new int[47 * 48];
798f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
799f6603c60Sopenharmony_ci
800f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmap
801f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
802f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
803f6603c60Sopenharmony_ci
804f6603c60Sopenharmony_ci    // 7. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, and allocate memory for pixels
805f6603c60Sopenharmony_ci    // as 48*47.
806f6603c60Sopenharmony_ci    width = 48;
807f6603c60Sopenharmony_ci    height = 48;
808f6603c60Sopenharmony_ci    imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
809f6603c60Sopenharmony_ci    rowBytes = width * height * 4;
810f6603c60Sopenharmony_ci    pixels = new int[48 * 47];
811f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
812f6603c60Sopenharmony_ci
813f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawBitmap
814f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
815f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
816f6603c60Sopenharmony_ci
817f6603c60Sopenharmony_ci    // 9. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, allocate memory for pixels as
818f6603c60Sopenharmony_ci    // 48*48, and set rowBytes as 47.
819f6603c60Sopenharmony_ci    width = 48;
820f6603c60Sopenharmony_ci    height = 48;
821f6603c60Sopenharmony_ci    imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
822f6603c60Sopenharmony_ci    rowBytes = 47;
823f6603c60Sopenharmony_ci    pixels = new int[48 * 48];
824f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
825f6603c60Sopenharmony_ci
826f6603c60Sopenharmony_ci    // 10. OH_Drawing_CanvasDrawBitmap
827f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
828f6603c60Sopenharmony_ci
829f6603c60Sopenharmony_ci    // 11. The third parameter in OH_Drawing_CanvasDrawBitmap is 0.
830f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
831f6603c60Sopenharmony_ci
832f6603c60Sopenharmony_ci    // 12. The fourth parameter in OH_Drawing_CanvasDrawBitmap is 0.
833f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
834f6603c60Sopenharmony_ci
835f6603c60Sopenharmony_ci    // 13. Free the memory.
836f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
837f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
838f6603c60Sopenharmony_ci}
839f6603c60Sopenharmony_ci
840f6603c60Sopenharmony_ci/*
841f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1502
842f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapAbnormal
843f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapAbnormal.
844f6603c60Sopenharmony_ci * @tc.size  : SmallTest
845f6603c60Sopenharmony_ci * @tc.type  : Function
846f6603c60Sopenharmony_ci * @tc.level : Level 3
847f6603c60Sopenharmony_ci */
848f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapAbnormal, TestSize.Level3)
849f6603c60Sopenharmony_ci{
850f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
851f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
852f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
853f6603c60Sopenharmony_ci
854f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
855f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
856f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
857f6603c60Sopenharmony_ci
858f6603c60Sopenharmony_ci    // 3. The x-coordinate of the top-left corner of the bitmap object in OH_Drawing_CanvasDrawBitmap is negative.
859f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, -1, 0);
860f6603c60Sopenharmony_ci
861f6603c60Sopenharmony_ci    // 4. The y-coordinate of the top-left corner of the bitmap object in OH_Drawing_CanvasDrawBitmap is negative.
862f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, -1);
863f6603c60Sopenharmony_ci
864f6603c60Sopenharmony_ci    // 5. Free the memory.
865f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
866f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
867f6603c60Sopenharmony_ci}
868f6603c60Sopenharmony_ci
869f6603c60Sopenharmony_ci/*
870f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1503
871f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapMaximum
872f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapMaximum.
873f6603c60Sopenharmony_ci * @tc.size  : SmallTest
874f6603c60Sopenharmony_ci * @tc.type  : Function
875f6603c60Sopenharmony_ci * @tc.level : Level 3
876f6603c60Sopenharmony_ci */
877f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapMaximum, TestSize.Level3)
878f6603c60Sopenharmony_ci{
879f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
880f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
881f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
882f6603c60Sopenharmony_ci
883f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
884f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
885f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
886f6603c60Sopenharmony_ci
887f6603c60Sopenharmony_ci    // 3. The x-coordinate of the top-left corner of the bitmap object in OH_Drawing_CanvasDrawBitmap is set to a very
888f6603c60Sopenharmony_ci    // large value.
889f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, FLT_MAX, 0);
890f6603c60Sopenharmony_ci
891f6603c60Sopenharmony_ci    // 4. The y-coordinate of the top-left corner of the bitmap object in OH_Drawing_CanvasDrawBitmap is set to a very
892f6603c60Sopenharmony_ci    // large value.
893f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, FLT_MAX);
894f6603c60Sopenharmony_ci
895f6603c60Sopenharmony_ci    // 5. Free the memory.
896f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
897f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
898f6603c60Sopenharmony_ci}
899f6603c60Sopenharmony_ci
900f6603c60Sopenharmony_ci/*
901f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1504
902f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapInputDestroyed
903f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapInputDestroyed.
904f6603c60Sopenharmony_ci * @tc.size  : SmallTest
905f6603c60Sopenharmony_ci * @tc.type  : Function
906f6603c60Sopenharmony_ci * @tc.level : Level 3
907f6603c60Sopenharmony_ci */
908f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapInputDestroyed, TestSize.Level3)
909f6603c60Sopenharmony_ci{
910f6603c60Sopenharmony_ci    // Deprecated
911f6603c60Sopenharmony_ci}
912f6603c60Sopenharmony_ci
913f6603c60Sopenharmony_ci/*
914f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1505
915f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapBoundary
916f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapBoundary.
917f6603c60Sopenharmony_ci * @tc.size  : SmallTest
918f6603c60Sopenharmony_ci * @tc.type  : Function
919f6603c60Sopenharmony_ci * @tc.level : Level 0
920f6603c60Sopenharmony_ci */
921f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapBoundary, TestSize.Level0)
922f6603c60Sopenharmony_ci{
923f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
924f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
925f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
926f6603c60Sopenharmony_ci
927f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
928f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
929f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
930f6603c60Sopenharmony_ci
931f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBitmap
932f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
933f6603c60Sopenharmony_ci
934f6603c60Sopenharmony_ci    // 4. OH_Drawing_BitmapCreateFromPixels, iterate through OH_Drawing_ColorFormat and OH_Drawing_AlphaFormat to
935f6603c60Sopenharmony_ci    // construct OH_Drawing_Image_Info.
936f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
937f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
938f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
939f6603c60Sopenharmony_ci    };
940f6603c60Sopenharmony_ci
941f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
942f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
943f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
944f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
945f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
946f6603c60Sopenharmony_ci    };
947f6603c60Sopenharmony_ci
948f6603c60Sopenharmony_ci    int width = 4096;
949f6603c60Sopenharmony_ci    int height = 2160;
950f6603c60Sopenharmony_ci    for (int i = 0; i < 6; i++) {
951f6603c60Sopenharmony_ci        for (int j = 0; j < 4; j++) {
952f6603c60Sopenharmony_ci            int rowBytes = width * height * 4;
953f6603c60Sopenharmony_ci            OH_Drawing_Image_Info imageInfo = {width, height, formats[i], alphaFormats[j]};
954f6603c60Sopenharmony_ci            OH_Drawing_BitmapFormat cFormat{formats[i], alphaFormats[j]};
955f6603c60Sopenharmony_ci            OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
956f6603c60Sopenharmony_ci            void *pixels = OH_Drawing_BitmapGetPixels(bitmap);
957f6603c60Sopenharmony_ci            bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
958f6603c60Sopenharmony_ci            // 5. OH_Drawing_CanvasDrawBitmap
959f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
960f6603c60Sopenharmony_ci            OH_Drawing_BitmapDestroy(bitmap);
961f6603c60Sopenharmony_ci        }
962f6603c60Sopenharmony_ci    }
963f6603c60Sopenharmony_ci
964f6603c60Sopenharmony_ci    // 6. OH_Drawing_BitmapCreateFromPixels, initialize the Bitmap with rowBytes greater than the image.
965f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
966f6603c60Sopenharmony_ci    int rowBytes = 600 * 600 * 4;
967f6603c60Sopenharmony_ci    void *pixels = new int[width * height];
968f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
969f6603c60Sopenharmony_ci
970f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawBitmap
971f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
972f6603c60Sopenharmony_ci
973f6603c60Sopenharmony_ci    // 8. Free the memory.
974f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
975f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
976f6603c60Sopenharmony_ci}
977f6603c60Sopenharmony_ci
978f6603c60Sopenharmony_ci/*
979f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1600
980f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectNormal
981f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectNormal.
982f6603c60Sopenharmony_ci * @tc.size  : SmallTest
983f6603c60Sopenharmony_ci * @tc.type  : Function
984f6603c60Sopenharmony_ci * @tc.level : Level 0
985f6603c60Sopenharmony_ci */
986f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectNormal, TestSize.Level0)
987f6603c60Sopenharmony_ci{
988f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
989f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
990f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
991f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
992f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
993f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
994f6603c60Sopenharmony_ci    // 3. OH_Drawing_RectCreate src and dst
995f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
996f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
997f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawBitmap
998f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
999f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawBitmapRect, iterate through OH_Drawing_FilterMode and OH_Drawing_MipmapMode to construct
1000f6603c60Sopenharmony_ci    // OH_Drawing_SamplingOptions
1001f6603c60Sopenharmony_ci    OH_Drawing_FilterMode filterMode[] = {FILTER_MODE_NEAREST, FILTER_MODE_LINEAR};
1002f6603c60Sopenharmony_ci    OH_Drawing_MipmapMode mode[] = {MIPMAP_MODE_NEAREST, MIPMAP_MODE_LINEAR, MIPMAP_MODE_NONE};
1003f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1004f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
1005f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(filterMode[i], mode[j]);
1006f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1007f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptionsDestroy(options);
1008f6603c60Sopenharmony_ci        }
1009f6603c60Sopenharmony_ci    }
1010f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmap
1011f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
1012f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1013f6603c60Sopenharmony_ci    // 7. OH_Drawing_BitmapCreateFromPixels, initialize Bitmap with a rowBytes larger than the image
1014f6603c60Sopenharmony_ci    int width = 500;
1015f6603c60Sopenharmony_ci    int height = 500;
1016f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
1017f6603c60Sopenharmony_ci    int rowBytes = 600 * 600 * 4;
1018f6603c60Sopenharmony_ci    void *pixels = new int[width * height];
1019f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
1020f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawBitmapRect, iterate through OH_Drawing_FilterMode and OH_Drawing_MipmapMode to construct
1021f6603c60Sopenharmony_ci    // OH_Drawing_SamplingOptions
1022f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1023f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
1024f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(filterMode[i], mode[j]);
1025f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1026f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptionsDestroy(options);
1027f6603c60Sopenharmony_ci        }
1028f6603c60Sopenharmony_ci    }
1029f6603c60Sopenharmony_ci    // 9. CanvasDrawBitmapRect with src parameter set to nullptr
1030f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_LINEAR);
1031f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, nullptr, dst, options);
1032f6603c60Sopenharmony_ci    // 10. Free memory
1033f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
1034f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
1035f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1036f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1037f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1038f6603c60Sopenharmony_ci}
1039f6603c60Sopenharmony_ci
1040f6603c60Sopenharmony_ci/*
1041f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1601
1042f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectNull
1043f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectNull.
1044f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1045f6603c60Sopenharmony_ci * @tc.type  : Function
1046f6603c60Sopenharmony_ci * @tc.level : Level 3
1047f6603c60Sopenharmony_ci */
1048f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectNull, TestSize.Level3)
1049f6603c60Sopenharmony_ci{
1050f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1051f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1052f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1053f6603c60Sopenharmony_ci
1054f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate, OH_Drawing_SamplingOptionsCreate
1055f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1056f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
1057f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_LINEAR);
1058f6603c60Sopenharmony_ci
1059f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBitmapRect with the first parameter set to nullptr
1060f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 200, 200);
1061f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1062f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 200, 200);
1063f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1064f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(nullptr, bitmap, src, dst, options);
1065f6603c60Sopenharmony_ci
1066f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawBitmapRect with the second parameter set to nullptr
1067f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, nullptr, src, dst, options);
1068f6603c60Sopenharmony_ci
1069f6603c60Sopenharmony_ci    // 5. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, and allocate memory for pixels
1070f6603c60Sopenharmony_ci    // as 47*48.
1071f6603c60Sopenharmony_ci    int width = 48;
1072f6603c60Sopenharmony_ci    int height = 48;
1073f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
1074f6603c60Sopenharmony_ci    int rowBytes = width * height * 4;
1075f6603c60Sopenharmony_ci    void *pixels = new int[47 * 48];
1076f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1077f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
1078f6603c60Sopenharmony_ci
1079f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmapRect
1080f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1081f6603c60Sopenharmony_ci
1082f6603c60Sopenharmony_ci    // 7. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, and allocate memory for pixels
1083f6603c60Sopenharmony_ci    // as 48*47.
1084f6603c60Sopenharmony_ci    width = 48;
1085f6603c60Sopenharmony_ci    height = 48;
1086f6603c60Sopenharmony_ci    imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
1087f6603c60Sopenharmony_ci    rowBytes = width * height * 4;
1088f6603c60Sopenharmony_ci    pixels = new int[48 * 47];
1089f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1090f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
1091f6603c60Sopenharmony_ci
1092f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawBitmapRect
1093f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1094f6603c60Sopenharmony_ci
1095f6603c60Sopenharmony_ci    // 9. OH_Drawing_BitmapCreateFromPixels, initialize the image with a size of 48*48, allocate memory for pixels as
1096f6603c60Sopenharmony_ci    // 48*48, and set rowBytes as 47.
1097f6603c60Sopenharmony_ci    width = 48;
1098f6603c60Sopenharmony_ci    height = 48;
1099f6603c60Sopenharmony_ci    imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
1100f6603c60Sopenharmony_ci    rowBytes = 47;
1101f6603c60Sopenharmony_ci    pixels = new int[48 * 48];
1102f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1103f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
1104f6603c60Sopenharmony_ci
1105f6603c60Sopenharmony_ci    // 10. OH_Drawing_CanvasDrawBitmapRect
1106f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1107f6603c60Sopenharmony_ci
1108f6603c60Sopenharmony_ci    // 11. OH_Drawing_CanvasDrawBitmapRect with the fourth parameter set to nullptr
1109f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, nullptr);
1110f6603c60Sopenharmony_ci
1111f6603c60Sopenharmony_ci    // 12. OH_Drawing_CanvasDrawBitmapRect with the fifth parameter set to nullptr
1112f6603c60Sopenharmony_ci    // error: no matching function for call to 'OH_Drawing_CanvasDrawBitmapRect'
1113f6603c60Sopenharmony_ci
1114f6603c60Sopenharmony_ci    // 13. Free memory
1115f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1116f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1117f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
1118f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
1119f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1120f6603c60Sopenharmony_ci}
1121f6603c60Sopenharmony_ci
1122f6603c60Sopenharmony_ci/*
1123f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1602
1124f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectAbnormal
1125f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectAbnormal.
1126f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1127f6603c60Sopenharmony_ci * @tc.type  : Function
1128f6603c60Sopenharmony_ci * @tc.level : Level 3
1129f6603c60Sopenharmony_ci */
1130f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectAbnormal, TestSize.Level3)
1131f6603c60Sopenharmony_ci{
1132f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1133f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1134f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1135f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate, OH_Drawing_SamplingOptionsCreate
1136f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1137f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
1138f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_LINEAR);
1139f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect created with negative values for left, top, right, bottom
1140f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(-100, -100, -50, -50);
1141f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1142f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(-100, -100, -50, -50);
1143f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1144f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1145f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect src created with the top-left coordinate equal to the
1146f6603c60Sopenharmony_ci    // bottom-right coordinate
1147f6603c60Sopenharmony_ci    src = OH_Drawing_RectCreate(100, 100, 100, 100);
1148f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1149f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1150f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect src created with the top-left coordinate greater than the
1151f6603c60Sopenharmony_ci    // bottom-right coordinate
1152f6603c60Sopenharmony_ci    src = OH_Drawing_RectCreate(200, 200, 100, 100);
1153f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1154f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1155f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with the top-left coordinate equal to the
1156f6603c60Sopenharmony_ci    // bottom-right coordinate
1157f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(100, 100, 100, 100);
1158f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1159f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1160f6603c60Sopenharmony_ci    // 7. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with the top-left coordinate greater than the
1161f6603c60Sopenharmony_ci    // bottom-right coordinate
1162f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(200, 200, 100, 100);
1163f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1164f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1165f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with the top-left coordinate equal to the
1166f6603c60Sopenharmony_ci    // bottom-right coordinate
1167f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(100, 100, 100, 100);
1168f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1169f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1170f6603c60Sopenharmony_ci    // 9. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with the top-left coordinate greater than the
1171f6603c60Sopenharmony_ci    // bottom-right coordinate
1172f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(200, 200, 100, 100);
1173f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1174f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1175f6603c60Sopenharmony_ci    // 10. Free memory
1176f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1177f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1178f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
1179f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
1180f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1181f6603c60Sopenharmony_ci}
1182f6603c60Sopenharmony_ci
1183f6603c60Sopenharmony_ci/*
1184f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1603
1185f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectMaximum
1186f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectMaximum.
1187f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1188f6603c60Sopenharmony_ci * @tc.type  : Function
1189f6603c60Sopenharmony_ci * @tc.level : Level 3
1190f6603c60Sopenharmony_ci */
1191f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectMaximum, TestSize.Level3)
1192f6603c60Sopenharmony_ci{
1193f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1194f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1195f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1196f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate, OH_Drawing_SamplingOptionsCreate
1197f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1198f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
1199f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_LINEAR);
1200f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect src created with maximum values for the top-left
1201f6603c60Sopenharmony_ci    // coordinate
1202f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 200, 200);
1203f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1204f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 200, 200);
1205f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1206f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1207f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect src created with maximum values for the top-right
1208f6603c60Sopenharmony_ci    // coordinate
1209f6603c60Sopenharmony_ci    src = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
1210f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
1211f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1212f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with maximum values for the top-left
1213f6603c60Sopenharmony_ci    // coordinate
1214f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(FLT_MAX, FLT_MAX, 200, 200);
1215f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1216f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1217f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmapRect with OH_Drawing_Rect dst created with maximum values for the top-right
1218f6603c60Sopenharmony_ci    // coordinate
1219f6603c60Sopenharmony_ci    dst = OH_Drawing_RectCreate(0, 0, FLT_MAX, FLT_MAX);
1220f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
1221f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1222f6603c60Sopenharmony_ci    // 7. Free memory
1223f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1224f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1225f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
1226f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
1227f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1228f6603c60Sopenharmony_ci}
1229f6603c60Sopenharmony_ci
1230f6603c60Sopenharmony_ci/*
1231f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1604
1232f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectInputDestroyed
1233f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectInputDestroyed.
1234f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1235f6603c60Sopenharmony_ci * @tc.type  : Function
1236f6603c60Sopenharmony_ci * @tc.level : Level 3
1237f6603c60Sopenharmony_ci */
1238f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectInputDestroyed, TestSize.Level3)
1239f6603c60Sopenharmony_ci{
1240f6603c60Sopenharmony_ci    // Deprecated
1241f6603c60Sopenharmony_ci}
1242f6603c60Sopenharmony_ci
1243f6603c60Sopenharmony_ci/*
1244f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1605
1245f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawBitmapRectBoundary
1246f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawBitmapRectBoundary.
1247f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1248f6603c60Sopenharmony_ci * @tc.type  : Function
1249f6603c60Sopenharmony_ci * @tc.level : Level 0
1250f6603c60Sopenharmony_ci */
1251f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawBitmapRectBoundary, TestSize.Level0)
1252f6603c60Sopenharmony_ci{
1253f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1254f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1255f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1256f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreate
1257f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
1258f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
1259f6603c60Sopenharmony_ci    // 3. OH_Drawing_RectCreate src and dst
1260f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
1261f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
1262f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawBitmap
1263f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
1264f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawBitmapRect, iterate through OH_Drawing_FilterMode and OH_Drawing_MipmapMode to construct
1265f6603c60Sopenharmony_ci    // OH_Drawing_SamplingOptions
1266f6603c60Sopenharmony_ci    OH_Drawing_FilterMode filterMode[] = {FILTER_MODE_NEAREST, FILTER_MODE_LINEAR};
1267f6603c60Sopenharmony_ci    OH_Drawing_MipmapMode mode[] = {MIPMAP_MODE_NEAREST, MIPMAP_MODE_LINEAR, MIPMAP_MODE_NONE};
1268f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1269f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
1270f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(filterMode[i], mode[j]);
1271f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1272f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptionsDestroy(options);
1273f6603c60Sopenharmony_ci        }
1274f6603c60Sopenharmony_ci    }
1275f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawBitmap
1276f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0);
1277f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1278f6603c60Sopenharmony_ci    // 7. OH_Drawing_BitmapCreateFromPixels, initialize Bitmap with a rowBytes larger than the image
1279f6603c60Sopenharmony_ci    int width = 4096;
1280f6603c60Sopenharmony_ci    int height = 2160;
1281f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_UNKNOWN, ALPHA_FORMAT_UNKNOWN};
1282f6603c60Sopenharmony_ci    int rowBytes = 600 * 600 * 4;
1283f6603c60Sopenharmony_ci    void *pixels = new int[width * height];
1284f6603c60Sopenharmony_ci    bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
1285f6603c60Sopenharmony_ci    // 8. OH_Drawing_CanvasDrawBitmapRect, iterate through OH_Drawing_FilterMode and OH_Drawing_MipmapMode to construct
1286f6603c60Sopenharmony_ci    // OH_Drawing_SamplingOptions
1287f6603c60Sopenharmony_ci    for (int i = 0; i < 2; i++) {
1288f6603c60Sopenharmony_ci        for (int j = 0; j < 3; j++) {
1289f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(filterMode[i], mode[j]);
1290f6603c60Sopenharmony_ci            OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, src, dst, options);
1291f6603c60Sopenharmony_ci            OH_Drawing_SamplingOptionsDestroy(options);
1292f6603c60Sopenharmony_ci        }
1293f6603c60Sopenharmony_ci    }
1294f6603c60Sopenharmony_ci    // 9. CanvasDrawBitmapRect with src parameter set to nullptr
1295f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_LINEAR);
1296f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas, bitmap, nullptr, dst, options);
1297f6603c60Sopenharmony_ci    // 10. Free memory
1298f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
1299f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
1300f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
1301f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1302f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1303f6603c60Sopenharmony_ci}
1304f6603c60Sopenharmony_ci
1305f6603c60Sopenharmony_ci/*
1306f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1700
1307f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRectNormal
1308f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRectNormal.
1309f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1310f6603c60Sopenharmony_ci * @tc.type  : Function
1311f6603c60Sopenharmony_ci * @tc.level : Level 0
1312f6603c60Sopenharmony_ci */
1313f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRectNormal, TestSize.Level0)
1314f6603c60Sopenharmony_ci{
1315f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1316f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1317f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1318f6603c60Sopenharmony_ci    // 2. OH_Drawing_RectCreate
1319f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
1320f6603c60Sopenharmony_ci    EXPECT_NE(rect, nullptr);
1321f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawRect
1322f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1323f6603c60Sopenharmony_ci    // 4. Free memory
1324f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1325f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1326f6603c60Sopenharmony_ci}
1327f6603c60Sopenharmony_ci
1328f6603c60Sopenharmony_ci/*
1329f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1701
1330f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRectNull
1331f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRectNull.
1332f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1333f6603c60Sopenharmony_ci * @tc.type  : Function
1334f6603c60Sopenharmony_ci * @tc.level : Level 3
1335f6603c60Sopenharmony_ci */
1336f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRectNull, TestSize.Level3)
1337f6603c60Sopenharmony_ci{
1338f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1339f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1340f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1341f6603c60Sopenharmony_ci    // 2. OH_Drawing_RectCreate
1342f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
1343f6603c60Sopenharmony_ci    EXPECT_NE(rect, nullptr);
1344f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawRect with the first parameter being null
1345f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, nullptr);
1346f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawRect with the second parameter being null
1347f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(nullptr, rect);
1348f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawRect with the second parameter OH_Drawing_Rect created with left, top, right, bottom
1349f6603c60Sopenharmony_ci    // respectively set to 0
1350f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(0, 200, 200, 200);
1351f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1352f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 0, 200, 200);
1353f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1354f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 0, 200);
1355f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1356f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 200, 0);
1357f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1358f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawRect with the second parameter OH_Drawing_Rect created with all values set to 0
1359f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(0, 0, 0, 0);
1360f6603c60Sopenharmony_ci    EXPECT_NE(rect, nullptr);
1361f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1362f6603c60Sopenharmony_ci    // 7. Free memory
1363f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1364f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1365f6603c60Sopenharmony_ci}
1366f6603c60Sopenharmony_ci
1367f6603c60Sopenharmony_ci/*
1368f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1702
1369f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRectAbnormal
1370f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRectAbnormal.
1371f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1372f6603c60Sopenharmony_ci * @tc.type  : Function
1373f6603c60Sopenharmony_ci * @tc.level : Level 3
1374f6603c60Sopenharmony_ci */
1375f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRectAbnormal, TestSize.Level3)
1376f6603c60Sopenharmony_ci{
1377f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1378f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1379f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1380f6603c60Sopenharmony_ci
1381f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasDrawRect with OH_Drawing_Rect created with left, top, right, bottom being negative numbers
1382f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-100, 100, 50, 50);
1383f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1384f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, -100, 50, 50);
1385f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1386f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 100, -50, 50);
1387f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1388f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 100, 50, -50);
1389f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1390f6603c60Sopenharmony_ci
1391f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawRect with OH_Drawing_Rect created with the top-left coordinate equal to the bottom-right
1392f6603c60Sopenharmony_ci    // coordinate
1393f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(100, 100, 100, 100);
1394f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1395f6603c60Sopenharmony_ci
1396f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 200, 200);
1397f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1398f6603c60Sopenharmony_ci
1399f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawRect with OH_Drawing_Rect created with the top-left coordinate equal to the bottom-right
1400f6603c60Sopenharmony_ci    // coordinate
1401f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 200, 200);
1402f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1403f6603c60Sopenharmony_ci
1404f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawRect with OH_Drawing_Rect created with the top-left coordinate greater than the
1405f6603c60Sopenharmony_ci    // bottom-right coordinate
1406f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 100, 100);
1407f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1408f6603c60Sopenharmony_ci
1409f6603c60Sopenharmony_ci    // 6. Free memory
1410f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1411f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
1412f6603c60Sopenharmony_ci}
1413f6603c60Sopenharmony_ci
1414f6603c60Sopenharmony_ci/*
1415f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1703
1416f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRectMaximum
1417f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRectMaximum.
1418f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1419f6603c60Sopenharmony_ci * @tc.type  : Function
1420f6603c60Sopenharmony_ci * @tc.level : Level 3
1421f6603c60Sopenharmony_ci */
1422f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRectMaximum, TestSize.Level3)
1423f6603c60Sopenharmony_ci{
1424f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1425f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1426f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1427f6603c60Sopenharmony_ci
1428f6603c60Sopenharmony_ci    // 2. OH_Drawing_CanvasDrawRect with OH_Drawing_Rect created with left, top, right, bottom set to maximum values
1429f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 200, 200, 200);
1430f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1431f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, FLT_MAX, 200, 200);
1432f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1433f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, FLT_MAX, 200);
1434f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1435f6603c60Sopenharmony_ci    rect = OH_Drawing_RectCreate(200, 200, 200, FLT_MAX);
1436f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawRect(canvas, rect);
1437f6603c60Sopenharmony_ci
1438f6603c60Sopenharmony_ci    // 3. Free memory
1439f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1440f6603c60Sopenharmony_ci}
1441f6603c60Sopenharmony_ci
1442f6603c60Sopenharmony_ci/*
1443f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1704
1444f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRectInputDestroyed
1445f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRectInputDestroyed.
1446f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1447f6603c60Sopenharmony_ci * @tc.type  : Function
1448f6603c60Sopenharmony_ci * @tc.level : Level 3
1449f6603c60Sopenharmony_ci */
1450f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRectInputDestroyed, TestSize.Level3)
1451f6603c60Sopenharmony_ci{
1452f6603c60Sopenharmony_ci    // Deprecated
1453f6603c60Sopenharmony_ci}
1454f6603c60Sopenharmony_ci
1455f6603c60Sopenharmony_ci/*
1456f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1800
1457f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawCircleNormal
1458f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawCircleNormal.
1459f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1460f6603c60Sopenharmony_ci * @tc.type  : Function
1461f6603c60Sopenharmony_ci * @tc.level : Level 0
1462f6603c60Sopenharmony_ci */
1463f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawCircleNormal, TestSize.Level0)
1464f6603c60Sopenharmony_ci{
1465f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1466f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1467f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1468f6603c60Sopenharmony_ci    // 2. OH_Drawing_PointCreate
1469f6603c60Sopenharmony_ci    OH_Drawing_Point *center = OH_Drawing_PointCreate(100, 100);
1470f6603c60Sopenharmony_ci    EXPECT_NE(center, nullptr);
1471f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawCircle
1472f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 50);
1473f6603c60Sopenharmony_ci    // 4. Free memory
1474f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1475f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(center);
1476f6603c60Sopenharmony_ci}
1477f6603c60Sopenharmony_ci
1478f6603c60Sopenharmony_ci/*
1479f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1801
1480f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawCircleNull
1481f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawCircleNull.
1482f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1483f6603c60Sopenharmony_ci * @tc.type  : Function
1484f6603c60Sopenharmony_ci * @tc.level : Level 3
1485f6603c60Sopenharmony_ci */
1486f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawCircleNull, TestSize.Level3)
1487f6603c60Sopenharmony_ci{
1488f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1489f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1490f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1491f6603c60Sopenharmony_ci    // 2. OH_Drawing_PointCreate
1492f6603c60Sopenharmony_ci    OH_Drawing_Point *center = OH_Drawing_PointCreate(100, 100);
1493f6603c60Sopenharmony_ci    EXPECT_NE(center, nullptr);
1494f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawCircle with the first parameter being null
1495f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(nullptr, center, 50);
1496f6603c60Sopenharmony_ci    // 4. OH_Drawing_CanvasDrawCircle with the second parameter being null
1497f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, nullptr, 50);
1498f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawCircle with the third parameter being 0
1499f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 0);
1500f6603c60Sopenharmony_ci    // 6. Free memory
1501f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1502f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(center);
1503f6603c60Sopenharmony_ci}
1504f6603c60Sopenharmony_ci
1505f6603c60Sopenharmony_ci/*
1506f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1802
1507f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawCircleAbnormal
1508f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawCircleAbnormal.
1509f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1510f6603c60Sopenharmony_ci * @tc.type  : Function
1511f6603c60Sopenharmony_ci * @tc.level : Level 3
1512f6603c60Sopenharmony_ci */
1513f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawCircleAbnormal, TestSize.Level3)
1514f6603c60Sopenharmony_ci{
1515f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1516f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1517f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1518f6603c60Sopenharmony_ci    // 2. OH_Drawing_PointCreate with x parameter being negative
1519f6603c60Sopenharmony_ci    OH_Drawing_Point *center = OH_Drawing_PointCreate(-100, 100);
1520f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawCircle
1521f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 50);
1522f6603c60Sopenharmony_ci    // 4. OH_Drawing_PointCreate with y parameter being negative
1523f6603c60Sopenharmony_ci    center = OH_Drawing_PointCreate(100, -100);
1524f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 50);
1525f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawCircle with radius parameter being negative
1526f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, -50);
1527f6603c60Sopenharmony_ci    // 6. Free memory
1528f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1529f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(center);
1530f6603c60Sopenharmony_ci}
1531f6603c60Sopenharmony_ci
1532f6603c60Sopenharmony_ci/*
1533f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1803
1534f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawCircleMaximum
1535f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawCircleMaximum.
1536f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1537f6603c60Sopenharmony_ci * @tc.type  : Function
1538f6603c60Sopenharmony_ci * @tc.level : Level 3
1539f6603c60Sopenharmony_ci */
1540f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawCircleMaximum, TestSize.Level3)
1541f6603c60Sopenharmony_ci{
1542f6603c60Sopenharmony_ci    // 1. OH_Drawing_CanvasCreate
1543f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate();
1544f6603c60Sopenharmony_ci    EXPECT_NE(canvas, nullptr);
1545f6603c60Sopenharmony_ci    // 2. OH_Drawing_PointCreate with x parameter set to the maximum value
1546f6603c60Sopenharmony_ci    OH_Drawing_Point *center = OH_Drawing_PointCreate(FLT_MAX, 100);
1547f6603c60Sopenharmony_ci    EXPECT_NE(center, nullptr);
1548f6603c60Sopenharmony_ci    // 3. OH_Drawing_CanvasDrawCircle
1549f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 50);
1550f6603c60Sopenharmony_ci    // 4. OH_Drawing_PointCreate with y parameter set to the maximum value
1551f6603c60Sopenharmony_ci    center = OH_Drawing_PointCreate(100, FLT_MAX);
1552f6603c60Sopenharmony_ci    EXPECT_NE(center, nullptr);
1553f6603c60Sopenharmony_ci    // 5. OH_Drawing_CanvasDrawCircle
1554f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, 50);
1555f6603c60Sopenharmony_ci    // 6. OH_Drawing_CanvasDrawCircle with radius parameter set to the maximum value
1556f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawCircle(canvas, center, FLT_MAX);
1557f6603c60Sopenharmony_ci    // 7. Free memory
1558f6603c60Sopenharmony_ci    OH_Drawing_CanvasDestroy(canvas);
1559f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(center);
1560f6603c60Sopenharmony_ci}
1561f6603c60Sopenharmony_ci
1562f6603c60Sopenharmony_ci/*
1563f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1804
1564f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawCircleInputDestroyed
1565f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawCircleInputDestroyed.
1566f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1567f6603c60Sopenharmony_ci * @tc.type  : Function
1568f6603c60Sopenharmony_ci * @tc.level : Level 3
1569f6603c60Sopenharmony_ci */
1570f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawCircleInputDestroyed, TestSize.Level3)
1571f6603c60Sopenharmony_ci{
1572f6603c60Sopenharmony_ci    // Deprecated
1573f6603c60Sopenharmony_ci}
1574f6603c60Sopenharmony_ci
1575f6603c60Sopenharmony_ci} // namespace Drawing
1576f6603c60Sopenharmony_ci} // namespace Rosen
1577f6603c60Sopenharmony_ci} // namespace OHOS