1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ci#include "gtest/gtest.h"
17f6603c60Sopenharmony_ci
18f6603c60Sopenharmony_ci#include "drawing_bitmap.h"
19f6603c60Sopenharmony_ci#include "drawing_brush.h"
20f6603c60Sopenharmony_ci#include "drawing_canvas.h"
21f6603c60Sopenharmony_ci#include "drawing_color.h"
22f6603c60Sopenharmony_ci#include "drawing_color_filter.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_point.h"
32f6603c60Sopenharmony_ci#include "drawing_rect.h"
33f6603c60Sopenharmony_ci#include "drawing_region.h"
34f6603c60Sopenharmony_ci#include "drawing_round_rect.h"
35f6603c60Sopenharmony_ci#include "drawing_sampling_options.h"
36f6603c60Sopenharmony_ci#include "drawing_shader_effect.h"
37f6603c60Sopenharmony_ci#include "drawing_text_blob.h"
38f6603c60Sopenharmony_ci#include "drawing_typeface.h"
39f6603c60Sopenharmony_ci
40f6603c60Sopenharmony_ciusing namespace testing;
41f6603c60Sopenharmony_ciusing namespace testing::ext;
42f6603c60Sopenharmony_ci
43f6603c60Sopenharmony_cinamespace OHOS {
44f6603c60Sopenharmony_cinamespace Rosen {
45f6603c60Sopenharmony_cinamespace Drawing {
46f6603c60Sopenharmony_ciclass DrawingNativeBitmapTest : public testing::Test {};
47f6603c60Sopenharmony_ci
48f6603c60Sopenharmony_ci/*
49f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0100
50f6603c60Sopenharmony_ci * @tc.name: testBitmapDestroyNormal
51f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapDestroyNormal.
52f6603c60Sopenharmony_ci * @tc.size  : SmallTest
53f6603c60Sopenharmony_ci * @tc.type  : Function
54f6603c60Sopenharmony_ci * @tc.level : Level 0
55f6603c60Sopenharmony_ci */
56f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapDestroyNormal, TestSize.Level0) {
57f6603c60Sopenharmony_ci    // step 1
58f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *cBitmap = OH_Drawing_BitmapCreate();
59f6603c60Sopenharmony_ci    EXPECT_NE(cBitmap, nullptr);
60f6603c60Sopenharmony_ci    // step 2
61f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(cBitmap);
62f6603c60Sopenharmony_ci}
63f6603c60Sopenharmony_ci
64f6603c60Sopenharmony_ci/*
65f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0101
66f6603c60Sopenharmony_ci * @tc.name: testBitmapDestroyNull
67f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapDestroyNull.
68f6603c60Sopenharmony_ci * @tc.size  : SmallTest
69f6603c60Sopenharmony_ci * @tc.type  : Function
70f6603c60Sopenharmony_ci * @tc.level : Level 3
71f6603c60Sopenharmony_ci */
72f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapDestroyNull, TestSize.Level3) { OH_Drawing_BitmapDestroy(nullptr); }
73f6603c60Sopenharmony_ci
74f6603c60Sopenharmony_ci/*
75f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0200
76f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsNormal
77f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsNormal.
78f6603c60Sopenharmony_ci * @tc.size  : SmallTest
79f6603c60Sopenharmony_ci * @tc.type  : Function
80f6603c60Sopenharmony_ci * @tc.level : Level 0
81f6603c60Sopenharmony_ci */
82f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsNormal, TestSize.Level0) {
83f6603c60Sopenharmony_ci    // 1. Construct OH_Drawing_Image_Info by iterating through OH_Drawing_ColorFormat and OH_Drawing_AlphaFormat
84f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
85f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
86f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
87f6603c60Sopenharmony_ci    };
88f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
89f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
90f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
91f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
92f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
93f6603c60Sopenharmony_ci    };
94f6603c60Sopenharmony_ci    for (OH_Drawing_ColorFormat format : formats) {
95f6603c60Sopenharmony_ci        for (OH_Drawing_AlphaFormat alphaFormat : alphaFormats) {
96f6603c60Sopenharmony_ci            int width = 100;
97f6603c60Sopenharmony_ci            int height = 100;
98f6603c60Sopenharmony_ci            int rowBytes = width * 4;
99f6603c60Sopenharmony_ci            OH_Drawing_Bitmap *bitmap1 = OH_Drawing_BitmapCreate();
100f6603c60Sopenharmony_ci            EXPECT_NE(bitmap1, nullptr);
101f6603c60Sopenharmony_ci            OH_Drawing_BitmapFormat cFormat{format, alphaFormat};
102f6603c60Sopenharmony_ci            OH_Drawing_BitmapBuild(bitmap1, width, height, &cFormat);
103f6603c60Sopenharmony_ci            void *pixels = OH_Drawing_BitmapGetPixels(bitmap1);
104f6603c60Sopenharmony_ci            if (pixels != nullptr) {
105f6603c60Sopenharmony_ci                OH_Drawing_Image_Info imageInfo;
106f6603c60Sopenharmony_ci                OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
107f6603c60Sopenharmony_ci                // 2. OH_Drawing_BitmapCreateFromPixels
108f6603c60Sopenharmony_ci                // Initialize the Bitmap with matching image information and call OH_Drawing_BitmapGet related
109f6603c60Sopenharmony_ci                // interfaces Verify that the parameters match the initialization parameters
110f6603c60Sopenharmony_ci                uint32_t height_ = OH_Drawing_BitmapGetHeight(bitmap);
111f6603c60Sopenharmony_ci                uint32_t width_ = OH_Drawing_BitmapGetWidth(bitmap);
112f6603c60Sopenharmony_ci                OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(bitmap);
113f6603c60Sopenharmony_ci                OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
114f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
115f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
116f6603c60Sopenharmony_ci                EXPECT_TRUE(colorFormat_ == format || colorFormat_ == 0);
117f6603c60Sopenharmony_ci                EXPECT_TRUE(alphaFormat_ == alphaFormat || alphaFormat_ == 0);
118f6603c60Sopenharmony_ci                // 3. OH_Drawing_BitmapCreateFromPixels
119f6603c60Sopenharmony_ci                // Initialize the Bitmap with rowBytes larger than the image, call OH_Drawing_BitmapGet related
120f6603c60Sopenharmony_ci                // interfaces (OH_Drawing_BitmapGetHeight, OH_Drawing_BitmapGetWidth), Verify that the parameters match
121f6603c60Sopenharmony_ci                // the initialization parameters
122f6603c60Sopenharmony_ci                int rowBytes2 = width * 4 + 1;
123f6603c60Sopenharmony_ci                bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes2);
124f6603c60Sopenharmony_ci                height_ = OH_Drawing_BitmapGetHeight(bitmap);
125f6603c60Sopenharmony_ci                width_ = OH_Drawing_BitmapGetWidth(bitmap);
126f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
127f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
128f6603c60Sopenharmony_ci                // 4. Free memory
129f6603c60Sopenharmony_ci                OH_Drawing_BitmapDestroy(bitmap);
130f6603c60Sopenharmony_ci            }
131f6603c60Sopenharmony_ci        }
132f6603c60Sopenharmony_ci    }
133f6603c60Sopenharmony_ci}
134f6603c60Sopenharmony_ci
135f6603c60Sopenharmony_ci/*
136f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0201
137f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsNull
138f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsNull.
139f6603c60Sopenharmony_ci * @tc.size  : SmallTest
140f6603c60Sopenharmony_ci * @tc.type  : Function
141f6603c60Sopenharmony_ci * @tc.level : Level 3
142f6603c60Sopenharmony_ci */
143f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsNull, TestSize.Level3) {
144f6603c60Sopenharmony_ci    int width = 100;
145f6603c60Sopenharmony_ci    int height = 100;
146f6603c60Sopenharmony_ci    int rowBytes = width * 4;
147f6603c60Sopenharmony_ci    uint8_t *pixels = new uint8_t[width * height * 4];
148f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_UNKNOWN};
149f6603c60Sopenharmony_ci    // 1. OH_Drawing_BitmapCreateFromPixels the first parameter OH_Drawing_Image_Info is empty
150f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap1 = OH_Drawing_BitmapCreateFromPixels(nullptr, pixels, rowBytes);
151f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap1, nullptr);
152f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreateFromPixels the second parameter pixels is empty
153f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap2 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, nullptr, rowBytes);
154f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap2, nullptr);
155f6603c60Sopenharmony_ci    // 3. OH_Drawing_BitmapCreateFromPixels the third parameter rowBytes is 0
156f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap3 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, 0);
157f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap3, nullptr);
158f6603c60Sopenharmony_ci    // 4. OH_Drawing_BitmapCreateFromPixels the width of the first parameter OH_Drawing_Image_Info is 0
159f6603c60Sopenharmony_ci    imageInfo.width = 0;
160f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap4 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
161f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap4, nullptr);
162f6603c60Sopenharmony_ci    // 5. OH_Drawing_BitmapCreateFromPixels the height of the first parameter OH_Drawing_Image_Info is 0
163f6603c60Sopenharmony_ci    imageInfo.width = width;
164f6603c60Sopenharmony_ci    imageInfo.height = 0;
165f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap5 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
166f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap5, nullptr);
167f6603c60Sopenharmony_ci    // 6. Free memory
168f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap1);
169f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap2);
170f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap3);
171f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap4);
172f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap5);
173f6603c60Sopenharmony_ci    delete[] pixels;
174f6603c60Sopenharmony_ci}
175f6603c60Sopenharmony_ci
176f6603c60Sopenharmony_ci/*
177f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0202
178f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsMismatch
179f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsMismatch.
180f6603c60Sopenharmony_ci * @tc.size  : SmallTest
181f6603c60Sopenharmony_ci * @tc.type  : Function
182f6603c60Sopenharmony_ci * @tc.level : Level 3
183f6603c60Sopenharmony_ci */
184f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsMismatch, TestSize.Level3) {
185f6603c60Sopenharmony_ci    int width = 48;
186f6603c60Sopenharmony_ci    int height = 48;
187f6603c60Sopenharmony_ci    int rowBytes = width * 4;
188f6603c60Sopenharmony_ci    uint8_t *pixels = new uint8_t[width * height * 4];
189f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_UNKNOWN};
190f6603c60Sopenharmony_ci    // 1. OH_Drawing_BitmapCreateFromPixels initializes a 48*48 image, but the memory allocated for pixels is 47*48
191f6603c60Sopenharmony_ci    uint8_t *pixels1 = new uint8_t[47 * height * 4];
192f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap1 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels1, rowBytes);
193f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap1, nullptr);
194f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreateFromPixels initializes a 48*48 image, but the memory allocated for pixels is 48*47
195f6603c60Sopenharmony_ci    uint8_t *pixels2 = new uint8_t[width * 47 * 4];
196f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap2 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels2, rowBytes);
197f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap2, nullptr);
198f6603c60Sopenharmony_ci    // 3. OH_Drawing_BitmapCreateFromPixels initializes a 48*48 image, but the memory allocated for pixels is 48*48 and
199f6603c60Sopenharmony_ci    // rowBytes is 47
200f6603c60Sopenharmony_ci    rowBytes = 47;
201f6603c60Sopenharmony_ci    uint8_t *pixels3 = new uint8_t[width * height * 4];
202f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap3 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels3, rowBytes);
203f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap3, nullptr);
204f6603c60Sopenharmony_ci    // 4. Free memory
205f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap1);
206f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap2);
207f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap3);
208f6603c60Sopenharmony_ci    delete[] pixels;
209f6603c60Sopenharmony_ci    delete[] pixels1;
210f6603c60Sopenharmony_ci    delete[] pixels2;
211f6603c60Sopenharmony_ci    delete[] pixels3;
212f6603c60Sopenharmony_ci}
213f6603c60Sopenharmony_ci
214f6603c60Sopenharmony_ci/*
215f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0203
216f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsAbnormal
217f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsAbnormal.
218f6603c60Sopenharmony_ci * @tc.size  : SmallTest
219f6603c60Sopenharmony_ci * @tc.type  : Function
220f6603c60Sopenharmony_ci * @tc.level : Level 3
221f6603c60Sopenharmony_ci */
222f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsAbnormal, TestSize.Level3) {
223f6603c60Sopenharmony_ci    int width = 48;
224f6603c60Sopenharmony_ci    int height = 48;
225f6603c60Sopenharmony_ci    int rowBytes = width * 4;
226f6603c60Sopenharmony_ci    uint8_t *pixels = new uint8_t[width * height * 4];
227f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_UNKNOWN};
228f6603c60Sopenharmony_ci    // 1. After constructing OH_Drawing_Image_Info, modify the byte value to an abnormal value
229f6603c60Sopenharmony_ci    imageInfo.width = -1;
230f6603c60Sopenharmony_ci    // 2. OH_Drawing_BitmapCreateFromPixels
231f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
232f6603c60Sopenharmony_ci    EXPECT_EQ(bitmap, nullptr);
233f6603c60Sopenharmony_ci    // 3. Free memory
234f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
235f6603c60Sopenharmony_ci    delete[] pixels;
236f6603c60Sopenharmony_ci}
237f6603c60Sopenharmony_ci
238f6603c60Sopenharmony_ci/*
239f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0204
240f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsVeryBig
241f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsVeryBig.
242f6603c60Sopenharmony_ci * @tc.size  : SmallTest
243f6603c60Sopenharmony_ci * @tc.type  : Function
244f6603c60Sopenharmony_ci * @tc.level : Level 3
245f6603c60Sopenharmony_ci */
246f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsVeryBig, TestSize.Level3) {
247f6603c60Sopenharmony_ci    // 1. Construct OH_Drawing_Image_Info by iterating through OH_Drawing_ColorFormat and OH_Drawing_AlphaFormat
248f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
249f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
250f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
251f6603c60Sopenharmony_ci    };
252f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
253f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
254f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
255f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
256f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
257f6603c60Sopenharmony_ci    };
258f6603c60Sopenharmony_ci    for (OH_Drawing_ColorFormat format : formats) {
259f6603c60Sopenharmony_ci        for (OH_Drawing_AlphaFormat alphaFormat : alphaFormats) {
260f6603c60Sopenharmony_ci            int width = 1000000;
261f6603c60Sopenharmony_ci            int height = 1000000;
262f6603c60Sopenharmony_ci            int rowBytes = width * 4;
263f6603c60Sopenharmony_ci            OH_Drawing_Bitmap *bitmap1 = OH_Drawing_BitmapCreate();
264f6603c60Sopenharmony_ci            EXPECT_NE(bitmap1, nullptr);
265f6603c60Sopenharmony_ci            OH_Drawing_BitmapFormat cFormat{format, alphaFormat};
266f6603c60Sopenharmony_ci            OH_Drawing_BitmapBuild(bitmap1, width, height, &cFormat);
267f6603c60Sopenharmony_ci            void *pixels = OH_Drawing_BitmapGetPixels(bitmap1);
268f6603c60Sopenharmony_ci            if (pixels != nullptr) {
269f6603c60Sopenharmony_ci                OH_Drawing_Image_Info imageInfo;
270f6603c60Sopenharmony_ci                OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
271f6603c60Sopenharmony_ci                // 2. OH_Drawing_BitmapCreateFromPixels
272f6603c60Sopenharmony_ci                // Initialize the Bitmap with matching image information and call OH_Drawing_BitmapGet related
273f6603c60Sopenharmony_ci                // interfaces Verify that the parameters match the initialization parameters
274f6603c60Sopenharmony_ci                uint32_t height_ = OH_Drawing_BitmapGetHeight(bitmap);
275f6603c60Sopenharmony_ci                uint32_t width_ = OH_Drawing_BitmapGetWidth(bitmap);
276f6603c60Sopenharmony_ci                OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(bitmap);
277f6603c60Sopenharmony_ci                OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
278f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
279f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
280f6603c60Sopenharmony_ci                EXPECT_TRUE(colorFormat_ == format || colorFormat_ == 0);
281f6603c60Sopenharmony_ci                EXPECT_TRUE(alphaFormat_ == alphaFormat || alphaFormat_ == 0);
282f6603c60Sopenharmony_ci                // 3. OH_Drawing_BitmapCreateFromPixels
283f6603c60Sopenharmony_ci                // Initialize the Bitmap with rowBytes larger than the image, call OH_Drawing_BitmapGet related
284f6603c60Sopenharmony_ci                // interfaces (OH_Drawing_BitmapGetHeight, OH_Drawing_BitmapGetWidth), Verify that the parameters match
285f6603c60Sopenharmony_ci                // the initialization parameters
286f6603c60Sopenharmony_ci                int rowBytes2 = width * 4 + 1;
287f6603c60Sopenharmony_ci                bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes2);
288f6603c60Sopenharmony_ci                height_ = OH_Drawing_BitmapGetHeight(bitmap);
289f6603c60Sopenharmony_ci                width_ = OH_Drawing_BitmapGetWidth(bitmap);
290f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
291f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
292f6603c60Sopenharmony_ci                // 4. Free memory
293f6603c60Sopenharmony_ci                OH_Drawing_BitmapDestroy(bitmap);
294f6603c60Sopenharmony_ci            }
295f6603c60Sopenharmony_ci        }
296f6603c60Sopenharmony_ci    }
297f6603c60Sopenharmony_ci}
298f6603c60Sopenharmony_ci
299f6603c60Sopenharmony_ci/*
300f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0205
301f6603c60Sopenharmony_ci * @tc.name: testBitmapCreateFromPixelsBoundary
302f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapCreateFromPixelsBoundary.
303f6603c60Sopenharmony_ci * @tc.size  : SmallTest
304f6603c60Sopenharmony_ci * @tc.type  : Function
305f6603c60Sopenharmony_ci * @tc.level : Level 3
306f6603c60Sopenharmony_ci */
307f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapCreateFromPixelsBoundary, TestSize.Level0) {
308f6603c60Sopenharmony_ci    // 1. Construct OH_Drawing_Image_Info by iterating through OH_Drawing_ColorFormat and OH_Drawing_AlphaFormat
309f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
310f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
311f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
312f6603c60Sopenharmony_ci    };
313f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
314f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
315f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
316f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
317f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
318f6603c60Sopenharmony_ci    };
319f6603c60Sopenharmony_ci    for (OH_Drawing_ColorFormat format : formats) {
320f6603c60Sopenharmony_ci        for (OH_Drawing_AlphaFormat alphaFormat : alphaFormats) {
321f6603c60Sopenharmony_ci            // 4K screen resolutionp
322f6603c60Sopenharmony_ci            int width = 4096;
323f6603c60Sopenharmony_ci            int height = 2160;
324f6603c60Sopenharmony_ci            int rowBytes = width * 4;
325f6603c60Sopenharmony_ci            OH_Drawing_Bitmap *bitmap1 = OH_Drawing_BitmapCreate();
326f6603c60Sopenharmony_ci            EXPECT_NE(bitmap1, nullptr);
327f6603c60Sopenharmony_ci            OH_Drawing_BitmapFormat cFormat{format, alphaFormat};
328f6603c60Sopenharmony_ci            OH_Drawing_BitmapBuild(bitmap1, width, height, &cFormat);
329f6603c60Sopenharmony_ci            void *pixels = OH_Drawing_BitmapGetPixels(bitmap1);
330f6603c60Sopenharmony_ci            if (pixels != nullptr) {
331f6603c60Sopenharmony_ci                OH_Drawing_Image_Info imageInfo;
332f6603c60Sopenharmony_ci                OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
333f6603c60Sopenharmony_ci                // 2. OH_Drawing_BitmapCreateFromPixels
334f6603c60Sopenharmony_ci                // Initialize the Bitmap with matching image information and call OH_Drawing_BitmapGet related
335f6603c60Sopenharmony_ci                // interfaces Verify that the parameters match the initialization parameters
336f6603c60Sopenharmony_ci                uint32_t height_ = OH_Drawing_BitmapGetHeight(bitmap);
337f6603c60Sopenharmony_ci                uint32_t width_ = OH_Drawing_BitmapGetWidth(bitmap);
338f6603c60Sopenharmony_ci                OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(bitmap);
339f6603c60Sopenharmony_ci                OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
340f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
341f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
342f6603c60Sopenharmony_ci                EXPECT_TRUE(colorFormat_ == format || colorFormat_ == 0);
343f6603c60Sopenharmony_ci                EXPECT_TRUE(alphaFormat_ == alphaFormat || alphaFormat_ == 0);
344f6603c60Sopenharmony_ci                // 3. OH_Drawing_BitmapCreateFromPixels
345f6603c60Sopenharmony_ci                // Initialize the Bitmap with rowBytes larger than the image, call OH_Drawing_BitmapGet related
346f6603c60Sopenharmony_ci                // interfaces (OH_Drawing_BitmapGetHeight, OH_Drawing_BitmapGetWidth), Verify that the parameters match
347f6603c60Sopenharmony_ci                // the initialization parameters
348f6603c60Sopenharmony_ci                int rowBytes2 = width * 4 + 1;
349f6603c60Sopenharmony_ci                bitmap = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes2);
350f6603c60Sopenharmony_ci                height_ = OH_Drawing_BitmapGetHeight(bitmap);
351f6603c60Sopenharmony_ci                width_ = OH_Drawing_BitmapGetWidth(bitmap);
352f6603c60Sopenharmony_ci                EXPECT_TRUE(height_ == height || height_ == 0);
353f6603c60Sopenharmony_ci                EXPECT_TRUE(width_ == width || width_ == 0);
354f6603c60Sopenharmony_ci                // 4. Free memory
355f6603c60Sopenharmony_ci                OH_Drawing_BitmapDestroy(bitmap);
356f6603c60Sopenharmony_ci            }
357f6603c60Sopenharmony_ci        }
358f6603c60Sopenharmony_ci    }
359f6603c60Sopenharmony_ci}
360f6603c60Sopenharmony_ci
361f6603c60Sopenharmony_ci/*
362f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0300
363f6603c60Sopenharmony_ci * @tc.name: testBitmapBuildNormal
364f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapBuildNormal.
365f6603c60Sopenharmony_ci * @tc.size  : SmallTest
366f6603c60Sopenharmony_ci * @tc.type  : Function
367f6603c60Sopenharmony_ci * @tc.level : Level 0
368f6603c60Sopenharmony_ci */
369f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapBuildNormal, TestSize.Level0) {
370f6603c60Sopenharmony_ci    const unsigned int width = 500;
371f6603c60Sopenharmony_ci    const unsigned int height = 500;
372f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
373f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
374f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
375f6603c60Sopenharmony_ci    };
376f6603c60Sopenharmony_ci
377f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
378f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
379f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
380f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
381f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
382f6603c60Sopenharmony_ci    };
383f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_;
384f6603c60Sopenharmony_ci
385f6603c60Sopenharmony_ci    // step 1
386f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
387f6603c60Sopenharmony_ci
388f6603c60Sopenharmony_ci    // step 2
389f6603c60Sopenharmony_ci    for (int i = 1; i < 4; i++) {
390f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat bitmapFormat = {formats[3], alphaFormats[i]};
391f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
392f6603c60Sopenharmony_ci        if (bitmap == nullptr) {
393f6603c60Sopenharmony_ci            alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
394f6603c60Sopenharmony_ci            EXPECT_EQ(alphaFormat_, alphaFormats[0]);
395f6603c60Sopenharmony_ci        } else {
396f6603c60Sopenharmony_ci            alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
397f6603c60Sopenharmony_ci            EXPECT_EQ(alphaFormat_, alphaFormats[i]);
398f6603c60Sopenharmony_ci        }
399f6603c60Sopenharmony_ci    }
400f6603c60Sopenharmony_ci
401f6603c60Sopenharmony_ci    // step 3
402f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
403f6603c60Sopenharmony_ci}
404f6603c60Sopenharmony_ci
405f6603c60Sopenharmony_ci/*
406f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0301
407f6603c60Sopenharmony_ci * @tc.name: testBitmapBuildNull
408f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapBuildNull.
409f6603c60Sopenharmony_ci * @tc.size  : SmallTest
410f6603c60Sopenharmony_ci * @tc.type  : Function
411f6603c60Sopenharmony_ci * @tc.level : Level 3
412f6603c60Sopenharmony_ci */
413f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapBuildNull, TestSize.Level3) {
414f6603c60Sopenharmony_ci    const unsigned int width = 500;
415f6603c60Sopenharmony_ci    const unsigned int height = 500;
416f6603c60Sopenharmony_ci
417f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
418f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
419f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
420f6603c60Sopenharmony_ci    };
421f6603c60Sopenharmony_ci
422f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
423f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
424f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
425f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
426f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
427f6603c60Sopenharmony_ci    };
428f6603c60Sopenharmony_ci
429f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
430f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat bitmapFormat = {formats[3], alphaFormats[0]};
431f6603c60Sopenharmony_ci
432f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, 0, height, &bitmapFormat);
433f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, 0, &bitmapFormat);
434f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, nullptr);
435f6603c60Sopenharmony_ci
436f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
437f6603c60Sopenharmony_ci}
438f6603c60Sopenharmony_ci
439f6603c60Sopenharmony_ci/*
440f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0302
441f6603c60Sopenharmony_ci * @tc.name: testBitmapBuildMultipleCalls
442f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapBuildMultipleCalls.
443f6603c60Sopenharmony_ci * @tc.size  : SmallTest
444f6603c60Sopenharmony_ci * @tc.type  : Function
445f6603c60Sopenharmony_ci * @tc.level : Level 3
446f6603c60Sopenharmony_ci */
447f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapBuildMultipleCalls, TestSize.Level3) {
448f6603c60Sopenharmony_ci    const unsigned int width = 500;
449f6603c60Sopenharmony_ci    const unsigned int height = 500;
450f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
451f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
452f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
453f6603c60Sopenharmony_ci    };
454f6603c60Sopenharmony_ci
455f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
456f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
457f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
458f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
459f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
460f6603c60Sopenharmony_ci    };
461f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_;
462f6603c60Sopenharmony_ci
463f6603c60Sopenharmony_ci    // step 1
464f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
465f6603c60Sopenharmony_ci
466f6603c60Sopenharmony_ci    // step 2
467f6603c60Sopenharmony_ci    for (int i = 1; i < 4; i++) {
468f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat bitmapFormat = {formats[3], alphaFormats[i]};
469f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
470f6603c60Sopenharmony_ci        if (bitmap == nullptr) {
471f6603c60Sopenharmony_ci            alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
472f6603c60Sopenharmony_ci            EXPECT_EQ(alphaFormat_, alphaFormats[0]);
473f6603c60Sopenharmony_ci        }
474f6603c60Sopenharmony_ci        alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
475f6603c60Sopenharmony_ci        EXPECT_EQ(alphaFormat_, alphaFormats[i]);
476f6603c60Sopenharmony_ci    }
477f6603c60Sopenharmony_ci
478f6603c60Sopenharmony_ci    // step 3
479f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
480f6603c60Sopenharmony_ci
481f6603c60Sopenharmony_ci    // step 4
482f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
483f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap2 = OH_Drawing_BitmapCreate();
484f6603c60Sopenharmony_ci    EXPECT_NE(bitmap2, nullptr);
485f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
486f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap2, width, height, &cFormat);
487f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(bitmap2);
488f6603c60Sopenharmony_ci    EXPECT_NE(pixels, nullptr);
489f6603c60Sopenharmony_ci    uint32_t rowBytes = width * height * 4;
490f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap3 = OH_Drawing_BitmapCreateFromPixels(&imageInfo, pixels, rowBytes);
491f6603c60Sopenharmony_ci
492f6603c60Sopenharmony_ci    // step 5
493f6603c60Sopenharmony_ci    for (int i = 1; i < 4; i++) {
494f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat bitmapFormat = {formats[3], alphaFormats[i]};
495f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap3, width, height, &bitmapFormat);
496f6603c60Sopenharmony_ci        alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap3);
497f6603c60Sopenharmony_ci        EXPECT_EQ(alphaFormat_, alphaFormats[i]);
498f6603c60Sopenharmony_ci    }
499f6603c60Sopenharmony_ci}
500f6603c60Sopenharmony_ci
501f6603c60Sopenharmony_ci/*
502f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0303
503f6603c60Sopenharmony_ci * @tc.name: testBitmapBuildBoundary
504f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapBuildBoundary.
505f6603c60Sopenharmony_ci * @tc.size  : SmallTest
506f6603c60Sopenharmony_ci * @tc.type  : Function
507f6603c60Sopenharmony_ci * @tc.level : Level 0
508f6603c60Sopenharmony_ci */
509f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapBuildBoundary, TestSize.Level0) {
510f6603c60Sopenharmony_ci    // 4K screen resolutionp
511f6603c60Sopenharmony_ci    const unsigned int width = 4096;
512f6603c60Sopenharmony_ci    const unsigned int height = 2160;
513f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat formats[] = {
514f6603c60Sopenharmony_ci        COLOR_FORMAT_UNKNOWN,   COLOR_FORMAT_ALPHA_8,   COLOR_FORMAT_RGB_565,
515f6603c60Sopenharmony_ci        COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888,
516f6603c60Sopenharmony_ci    };
517f6603c60Sopenharmony_ci
518f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormats[] = {
519f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNKNOWN,
520f6603c60Sopenharmony_ci        ALPHA_FORMAT_OPAQUE,
521f6603c60Sopenharmony_ci        ALPHA_FORMAT_PREMUL,
522f6603c60Sopenharmony_ci        ALPHA_FORMAT_UNPREMUL,
523f6603c60Sopenharmony_ci    };
524f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_;
525f6603c60Sopenharmony_ci
526f6603c60Sopenharmony_ci    // step 1
527f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
528f6603c60Sopenharmony_ci
529f6603c60Sopenharmony_ci    // step 2
530f6603c60Sopenharmony_ci    for (int i = 1; i < 4; i++) {
531f6603c60Sopenharmony_ci        OH_Drawing_BitmapFormat bitmapFormat = {formats[3], alphaFormats[i]};
532f6603c60Sopenharmony_ci        OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
533f6603c60Sopenharmony_ci        if (bitmap == nullptr) {
534f6603c60Sopenharmony_ci            alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
535f6603c60Sopenharmony_ci            EXPECT_EQ(alphaFormat_, alphaFormats[0]);
536f6603c60Sopenharmony_ci        } else {
537f6603c60Sopenharmony_ci            alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(bitmap);
538f6603c60Sopenharmony_ci            EXPECT_EQ(alphaFormat_, alphaFormats[i]);
539f6603c60Sopenharmony_ci        }
540f6603c60Sopenharmony_ci    }
541f6603c60Sopenharmony_ci
542f6603c60Sopenharmony_ci    // step 3
543f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
544f6603c60Sopenharmony_ci}
545f6603c60Sopenharmony_ci
546f6603c60Sopenharmony_ci/*
547f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0400
548f6603c60Sopenharmony_ci * @tc.name: testBitmapGetXXNormal
549f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapGetXXNormal.
550f6603c60Sopenharmony_ci * @tc.size  : SmallTest
551f6603c60Sopenharmony_ci * @tc.type  : Function
552f6603c60Sopenharmony_ci * @tc.level : Level 0
553f6603c60Sopenharmony_ci */
554f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapGetXXNormal, TestSize.Level0) {
555f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *cBitmap = OH_Drawing_BitmapCreate();
556f6603c60Sopenharmony_ci    EXPECT_NE(cBitmap, nullptr);
557f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
558f6603c60Sopenharmony_ci    uint32_t width = 100;
559f6603c60Sopenharmony_ci    uint32_t height = 100;
560f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
561f6603c60Sopenharmony_ci
562f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo1{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
563f6603c60Sopenharmony_ci    void *pixels1 = new uint32_t[width * height];
564f6603c60Sopenharmony_ci
565f6603c60Sopenharmony_ci    // step 1
566f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(cBitmap, &imageInfo1, pixels1, width * 4, 0, 0);
567f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
568f6603c60Sopenharmony_ci
569f6603c60Sopenharmony_ci    // step 2
570f6603c60Sopenharmony_ci    uint32_t w = OH_Drawing_BitmapGetWidth(cBitmap);
571f6603c60Sopenharmony_ci    EXPECT_EQ(w, 100);
572f6603c60Sopenharmony_ci
573f6603c60Sopenharmony_ci    // step 3
574f6603c60Sopenharmony_ci    uint32_t h = OH_Drawing_BitmapGetHeight(cBitmap);
575f6603c60Sopenharmony_ci    EXPECT_EQ(h, 100);
576f6603c60Sopenharmony_ci
577f6603c60Sopenharmony_ci    // step 5
578f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(cBitmap);
579f6603c60Sopenharmony_ci    EXPECT_EQ(colorFormat_, COLOR_FORMAT_RGBA_8888);
580f6603c60Sopenharmony_ci
581f6603c60Sopenharmony_ci    // step 5
582f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(cBitmap);
583f6603c60Sopenharmony_ci    EXPECT_EQ(alphaFormat_, ALPHA_FORMAT_OPAQUE);
584f6603c60Sopenharmony_ci
585f6603c60Sopenharmony_ci    // step 6
586f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(cBitmap);
587f6603c60Sopenharmony_ci    EXPECT_NE(pixels, nullptr);
588f6603c60Sopenharmony_ci
589f6603c60Sopenharmony_ci    // step 7
590f6603c60Sopenharmony_ci    OH_Drawing_Image_Info *imageInfo = new OH_Drawing_Image_Info();
591f6603c60Sopenharmony_ci    OH_Drawing_BitmapGetImageInfo(cBitmap, imageInfo);
592f6603c60Sopenharmony_ci    EXPECT_EQ(width, imageInfo->width);
593f6603c60Sopenharmony_ci    EXPECT_EQ(height, imageInfo->height);
594f6603c60Sopenharmony_ci
595f6603c60Sopenharmony_ci    // step 8
596f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(cBitmap);
597f6603c60Sopenharmony_ci}
598f6603c60Sopenharmony_ci
599f6603c60Sopenharmony_ci/*
600f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0401
601f6603c60Sopenharmony_ci * @tc.name: testBitmapGetXXNull
602f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapGetXXNull.
603f6603c60Sopenharmony_ci * @tc.size  : SmallTest
604f6603c60Sopenharmony_ci * @tc.type  : Function
605f6603c60Sopenharmony_ci * @tc.level : Level 3
606f6603c60Sopenharmony_ci */
607f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapGetXXNull, TestSize.Level3) {
608f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *cBitmap = OH_Drawing_BitmapCreate();
609f6603c60Sopenharmony_ci    EXPECT_NE(cBitmap, nullptr);
610f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
611f6603c60Sopenharmony_ci    uint32_t width = 100;
612f6603c60Sopenharmony_ci    uint32_t height = 100;
613f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
614f6603c60Sopenharmony_ci
615f6603c60Sopenharmony_ci    // step 1
616f6603c60Sopenharmony_ci    uint32_t w = OH_Drawing_BitmapGetWidth(nullptr);
617f6603c60Sopenharmony_ci    EXPECT_EQ(w, 0);
618f6603c60Sopenharmony_ci
619f6603c60Sopenharmony_ci    // step 2
620f6603c60Sopenharmony_ci    uint32_t h = OH_Drawing_BitmapGetHeight(nullptr);
621f6603c60Sopenharmony_ci    EXPECT_EQ(h, 0);
622f6603c60Sopenharmony_ci
623f6603c60Sopenharmony_ci    // step 3
624f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(nullptr);
625f6603c60Sopenharmony_ci    EXPECT_EQ(colorFormat_, 0);
626f6603c60Sopenharmony_ci
627f6603c60Sopenharmony_ci    // step 4
628f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(nullptr);
629f6603c60Sopenharmony_ci    EXPECT_EQ(alphaFormat_, 0);
630f6603c60Sopenharmony_ci
631f6603c60Sopenharmony_ci    // step 5
632f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(nullptr);
633f6603c60Sopenharmony_ci    EXPECT_EQ(pixels, nullptr);
634f6603c60Sopenharmony_ci
635f6603c60Sopenharmony_ci    // step 6
636f6603c60Sopenharmony_ci    OH_Drawing_Image_Info *imageInfo = new OH_Drawing_Image_Info();
637f6603c60Sopenharmony_ci    OH_Drawing_BitmapGetImageInfo(nullptr, imageInfo);
638f6603c60Sopenharmony_ci
639f6603c60Sopenharmony_ci    OH_Drawing_BitmapGetImageInfo(cBitmap, nullptr);
640f6603c60Sopenharmony_ci
641f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(cBitmap);
642f6603c60Sopenharmony_ci}
643f6603c60Sopenharmony_ci
644f6603c60Sopenharmony_ci/*
645f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0402
646f6603c60Sopenharmony_ci * @tc.name: testBitmapGetXXInputDestroyed
647f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapGetXXInputDestroyed.
648f6603c60Sopenharmony_ci * @tc.size  : SmallTest
649f6603c60Sopenharmony_ci * @tc.type  : Function
650f6603c60Sopenharmony_ci * @tc.level : Level 3
651f6603c60Sopenharmony_ci */
652f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapGetXXInputDestroyed, TestSize.Level3) {
653f6603c60Sopenharmony_ci    // Deprecated
654f6603c60Sopenharmony_ci}
655f6603c60Sopenharmony_ci
656f6603c60Sopenharmony_ci/*
657f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0403
658f6603c60Sopenharmony_ci * @tc.name: testBitmapGetXXBoundary
659f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapGetXXBoundary.
660f6603c60Sopenharmony_ci * @tc.size  : SmallTest
661f6603c60Sopenharmony_ci * @tc.type  : Function
662f6603c60Sopenharmony_ci * @tc.level : Level 0
663f6603c60Sopenharmony_ci */
664f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapGetXXBoundary, TestSize.Level0) {
665f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *cBitmap = OH_Drawing_BitmapCreate();
666f6603c60Sopenharmony_ci    EXPECT_NE(cBitmap, nullptr);
667f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
668f6603c60Sopenharmony_ci    uint32_t width = 4096;
669f6603c60Sopenharmony_ci    uint32_t height = 2160;
670f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
671f6603c60Sopenharmony_ci
672f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo1{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
673f6603c60Sopenharmony_ci    void *pixels1 = new uint32_t[width * height];
674f6603c60Sopenharmony_ci
675f6603c60Sopenharmony_ci    // step 1
676f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(cBitmap, &imageInfo1, pixels1, width * 4, 0, 0);
677f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
678f6603c60Sopenharmony_ci
679f6603c60Sopenharmony_ci    // step 2
680f6603c60Sopenharmony_ci    uint32_t w = OH_Drawing_BitmapGetWidth(cBitmap);
681f6603c60Sopenharmony_ci    EXPECT_EQ(w, width);
682f6603c60Sopenharmony_ci
683f6603c60Sopenharmony_ci    // step 3
684f6603c60Sopenharmony_ci    uint32_t h = OH_Drawing_BitmapGetHeight(cBitmap);
685f6603c60Sopenharmony_ci    EXPECT_EQ(h, height);
686f6603c60Sopenharmony_ci
687f6603c60Sopenharmony_ci    // step 5
688f6603c60Sopenharmony_ci    OH_Drawing_ColorFormat colorFormat_ = OH_Drawing_BitmapGetColorFormat(cBitmap);
689f6603c60Sopenharmony_ci    EXPECT_EQ(colorFormat_, COLOR_FORMAT_RGBA_8888);
690f6603c60Sopenharmony_ci
691f6603c60Sopenharmony_ci    // step 5
692f6603c60Sopenharmony_ci    OH_Drawing_AlphaFormat alphaFormat_ = OH_Drawing_BitmapGetAlphaFormat(cBitmap);
693f6603c60Sopenharmony_ci    EXPECT_EQ(alphaFormat_, ALPHA_FORMAT_OPAQUE);
694f6603c60Sopenharmony_ci
695f6603c60Sopenharmony_ci    // step 6
696f6603c60Sopenharmony_ci    void *pixels = OH_Drawing_BitmapGetPixels(cBitmap);
697f6603c60Sopenharmony_ci    EXPECT_NE(pixels, nullptr);
698f6603c60Sopenharmony_ci
699f6603c60Sopenharmony_ci    // step 7
700f6603c60Sopenharmony_ci    OH_Drawing_Image_Info *imageInfo = new OH_Drawing_Image_Info();
701f6603c60Sopenharmony_ci    OH_Drawing_BitmapGetImageInfo(cBitmap, imageInfo);
702f6603c60Sopenharmony_ci    EXPECT_EQ(width, imageInfo->width);
703f6603c60Sopenharmony_ci    EXPECT_EQ(height, imageInfo->height);
704f6603c60Sopenharmony_ci
705f6603c60Sopenharmony_ci    // step 8
706f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(cBitmap);
707f6603c60Sopenharmony_ci}
708f6603c60Sopenharmony_ci
709f6603c60Sopenharmony_ci/*
710f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0500
711f6603c60Sopenharmony_ci * @tc.name: testBitmapReadPixelsNormal
712f6603c60Sopenharmony_ci * @tc.desc: test for OH_Drawing_BitmapBuild.
713f6603c60Sopenharmony_ci * @tc.size  : SmallTest
714f6603c60Sopenharmony_ci * @tc.type  : Function
715f6603c60Sopenharmony_ci * @tc.level : Level 0
716f6603c60Sopenharmony_ci */
717f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapReadPixelsNormal, TestSize.Level0) {
718f6603c60Sopenharmony_ci    const unsigned int width = 500;
719f6603c60Sopenharmony_ci    const unsigned int height = 500;
720f6603c60Sopenharmony_ci
721f6603c60Sopenharmony_ci    // step 1
722f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
723f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat bitmapFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
724f6603c60Sopenharmony_ci
725f6603c60Sopenharmony_ci    // step 2
726f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
727f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
728f6603c60Sopenharmony_ci    void *pixels = new uint32_t[width * height];
729f6603c60Sopenharmony_ci
730f6603c60Sopenharmony_ci    // step 3
731f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, width * 4, 0, 0);
732f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
733f6603c60Sopenharmony_ci
734f6603c60Sopenharmony_ci    // step 4
735f6603c60Sopenharmony_ci    // don't know how to test
736f6603c60Sopenharmony_ci
737f6603c60Sopenharmony_ci    // step 5
738f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
739f6603c60Sopenharmony_ci}
740f6603c60Sopenharmony_ci
741f6603c60Sopenharmony_ci/*
742f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0501
743f6603c60Sopenharmony_ci * @tc.name: testBitmapReadPixelsNull
744f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapReadPixelsNull.
745f6603c60Sopenharmony_ci * @tc.size  : SmallTest
746f6603c60Sopenharmony_ci * @tc.type  : Function
747f6603c60Sopenharmony_ci * @tc.level : Level 3
748f6603c60Sopenharmony_ci */
749f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapReadPixelsNull, TestSize.Level3) {
750f6603c60Sopenharmony_ci    const unsigned int width = 500;
751f6603c60Sopenharmony_ci    const unsigned int height = 500;
752f6603c60Sopenharmony_ci
753f6603c60Sopenharmony_ci    // step 1
754f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
755f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat bitmapFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
756f6603c60Sopenharmony_ci
757f6603c60Sopenharmony_ci    // step 2
758f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
759f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
760f6603c60Sopenharmony_ci    void *pixels = new uint32_t[width * height];
761f6603c60Sopenharmony_ci
762f6603c60Sopenharmony_ci    // step 3
763f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(nullptr, &imageInfo, pixels, width * 4, 0, 0);
764f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
765f6603c60Sopenharmony_ci
766f6603c60Sopenharmony_ci    // step 4
767f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, nullptr, pixels, width * 4, 0, 0);
768f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
769f6603c60Sopenharmony_ci
770f6603c60Sopenharmony_ci    // step 5
771f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, nullptr, width * 4, 0, 0);
772f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
773f6603c60Sopenharmony_ci
774f6603c60Sopenharmony_ci    // step 6
775f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, 0, 0, 0);
776f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
777f6603c60Sopenharmony_ci
778f6603c60Sopenharmony_ci    // step 7
779f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, width * 4, 0, 1);
780f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
781f6603c60Sopenharmony_ci
782f6603c60Sopenharmony_ci    // step 8
783f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, width * 4, 1, 0);
784f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
785f6603c60Sopenharmony_ci
786f6603c60Sopenharmony_ci    // step 9
787f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
788f6603c60Sopenharmony_ci}
789f6603c60Sopenharmony_ci
790f6603c60Sopenharmony_ci/*
791f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0502
792f6603c60Sopenharmony_ci * @tc.name: testBitmapReadPixelsInputDestroyed
793f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapReadPixelsInputDestroyed.
794f6603c60Sopenharmony_ci * @tc.size  : SmallTest
795f6603c60Sopenharmony_ci * @tc.type  : Function
796f6603c60Sopenharmony_ci * @tc.level : Level 3
797f6603c60Sopenharmony_ci */
798f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapReadPixelsInputDestroyed, TestSize.Level3) {
799f6603c60Sopenharmony_ci    // Deprecated
800f6603c60Sopenharmony_ci}
801f6603c60Sopenharmony_ci
802f6603c60Sopenharmony_ci/*
803f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0503
804f6603c60Sopenharmony_ci * @tc.name: testBitmapReadPixelsMismatch
805f6603c60Sopenharmony_ci * @tc.desc: test for testBitmapReadPixelsMismatch.
806f6603c60Sopenharmony_ci * @tc.size  : SmallTest
807f6603c60Sopenharmony_ci * @tc.type  : Function
808f6603c60Sopenharmony_ci * @tc.level : Level 3
809f6603c60Sopenharmony_ci */
810f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapReadPixelsMismatch, TestSize.Level3) {
811f6603c60Sopenharmony_ci    // step 1
812f6603c60Sopenharmony_ci    const unsigned int width = 500;
813f6603c60Sopenharmony_ci    const unsigned int height = 500;
814f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
815f6603c60Sopenharmony_ci
816f6603c60Sopenharmony_ci    // step 2
817f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat bitmapFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
818f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
819f6603c60Sopenharmony_ci
820f6603c60Sopenharmony_ci    // step 3
821f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{1, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
822f6603c60Sopenharmony_ci    void *pixels = new uint32_t[width * height];
823f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, width * 4, 0, 0);
824f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
825f6603c60Sopenharmony_ci
826f6603c60Sopenharmony_ci    // step 4
827f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo2{width, 1, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
828f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo2, pixels, width * 4, 0, 0);
829f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
830f6603c60Sopenharmony_ci
831f6603c60Sopenharmony_ci    // step 5
832f6603c60Sopenharmony_ci    // OH_Drawing_BitmapReadPixels OH_Drawing_Image_Info color type mismatch
833f6603c60Sopenharmony_ci    // compile error, skip case
834f6603c60Sopenharmony_ci
835f6603c60Sopenharmony_ci    // step 6
836f6603c60Sopenharmony_ci    // OH_Drawing_BitmapReadPixels OH_Drawing_Image_Info alpha type mismatch
837f6603c60Sopenharmony_ci    // compile error, skip case
838f6603c60Sopenharmony_ci
839f6603c60Sopenharmony_ci    // step 7
840f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo4{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
841f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo4, pixels, width * 3, 0, 0);
842f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
843f6603c60Sopenharmony_ci
844f6603c60Sopenharmony_ci    // step 8
845f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo5{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
846f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo5, pixels, width * 4, 1000, 0);
847f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
848f6603c60Sopenharmony_ci
849f6603c60Sopenharmony_ci    // step 9
850f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo6{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
851f6603c60Sopenharmony_ci    res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo6, pixels, width * 4, 0, 1000);
852f6603c60Sopenharmony_ci    EXPECT_EQ(res, false);
853f6603c60Sopenharmony_ci}
854f6603c60Sopenharmony_ci
855f6603c60Sopenharmony_ci/*
856f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BITMAP_0504
857f6603c60Sopenharmony_ci * @tc.name: testBitmapReadPixelsBoundary
858f6603c60Sopenharmony_ci * @tc.desc: test for OH_Drawing_BitmapBuild.
859f6603c60Sopenharmony_ci * @tc.size  : SmallTest
860f6603c60Sopenharmony_ci * @tc.type  : Function
861f6603c60Sopenharmony_ci * @tc.level : Level 0
862f6603c60Sopenharmony_ci */
863f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBitmapTest, testBitmapReadPixelsBoundary, TestSize.Level0) {
864f6603c60Sopenharmony_ci    const unsigned int width = 4096;
865f6603c60Sopenharmony_ci    const unsigned int height = 2160;
866f6603c60Sopenharmony_ci
867f6603c60Sopenharmony_ci    // step 1
868f6603c60Sopenharmony_ci    OH_Drawing_Bitmap *bitmap = OH_Drawing_BitmapCreate();
869f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat bitmapFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
870f6603c60Sopenharmony_ci
871f6603c60Sopenharmony_ci    // step 2
872f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &bitmapFormat);
873f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo{width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_UNPREMUL};
874f6603c60Sopenharmony_ci    void *pixels = new uint32_t[width * height];
875f6603c60Sopenharmony_ci
876f6603c60Sopenharmony_ci    // step 3
877f6603c60Sopenharmony_ci    bool res = OH_Drawing_BitmapReadPixels(bitmap, &imageInfo, pixels, width * 4, 0, 0);
878f6603c60Sopenharmony_ci    EXPECT_EQ(res, true);
879f6603c60Sopenharmony_ci
880f6603c60Sopenharmony_ci    // step 4
881f6603c60Sopenharmony_ci    // don't know how to test
882f6603c60Sopenharmony_ci
883f6603c60Sopenharmony_ci    // step 5
884f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
885f6603c60Sopenharmony_ci}
886f6603c60Sopenharmony_ci
887f6603c60Sopenharmony_ci} // namespace Drawing
888f6603c60Sopenharmony_ci} // namespace Rosen
889f6603c60Sopenharmony_ci} // namespace OHOS