1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device 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, Hardware
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_path.h"
29f6603c60Sopenharmony_ci#include "drawing_pen.h"
30f6603c60Sopenharmony_ci#include "drawing_point.h"
31f6603c60Sopenharmony_ci#include "drawing_rect.h"
32f6603c60Sopenharmony_ci#include "drawing_region.h"
33f6603c60Sopenharmony_ci#include "drawing_round_rect.h"
34f6603c60Sopenharmony_ci#include "drawing_sampling_options.h"
35f6603c60Sopenharmony_ci#include "drawing_shader_effect.h"
36f6603c60Sopenharmony_ci#include "drawing_text_blob.h"
37f6603c60Sopenharmony_ci#include "drawing_typeface.h"
38f6603c60Sopenharmony_ci#include "drawing_memory_stream.h"
39f6603c60Sopenharmony_ci#include "effect/color_filter.h"
40f6603c60Sopenharmony_ci#include "effect/filter.h"
41f6603c60Sopenharmony_ci
42f6603c60Sopenharmony_ciusing namespace testing;
43f6603c60Sopenharmony_ciusing namespace testing::ext;
44f6603c60Sopenharmony_ci
45f6603c60Sopenharmony_cinamespace OHOS {
46f6603c60Sopenharmony_cinamespace Rosen {
47f6603c60Sopenharmony_cinamespace Drawing {
48f6603c60Sopenharmony_ciclass NativeDrawingCanvasLargeValueTest : public testing::Test {
49f6603c60Sopenharmony_cipublic:
50f6603c60Sopenharmony_ci    static void SetUpTestCase();
51f6603c60Sopenharmony_ci    static void TearDownTestCase();
52f6603c60Sopenharmony_ci    void SetUp() override;
53f6603c60Sopenharmony_ci    void TearDown() override;
54f6603c60Sopenharmony_ci    protected:
55f6603c60Sopenharmony_ci        OH_Drawing_Canvas *canvas_ = nullptr;
56f6603c60Sopenharmony_ci        OH_Drawing_Brush *brush_ = nullptr;
57f6603c60Sopenharmony_ci};
58f6603c60Sopenharmony_ci
59f6603c60Sopenharmony_civoid NativeDrawingCanvasLargeValueTest::SetUpTestCase() {}
60f6603c60Sopenharmony_civoid NativeDrawingCanvasLargeValueTest::TearDownTestCase() {}
61f6603c60Sopenharmony_civoid NativeDrawingCanvasLargeValueTest::SetUp()
62f6603c60Sopenharmony_ci{
63f6603c60Sopenharmony_ci    canvas_ = OH_Drawing_CanvasCreate();
64f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, canvas_);
65f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas_, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
66f6603c60Sopenharmony_ci    brush_ = OH_Drawing_BrushCreate();
67f6603c60Sopenharmony_ci    EXPECT_NE(brush_, nullptr);
68f6603c60Sopenharmony_ci    OH_Drawing_BrushSetColor(brush_, 0xffff0000);
69f6603c60Sopenharmony_ci    OH_Drawing_CanvasAttachBrush(canvas_, brush_);
70f6603c60Sopenharmony_ci}
71f6603c60Sopenharmony_ci
72f6603c60Sopenharmony_civoid NativeDrawingCanvasLargeValueTest::TearDown()
73f6603c60Sopenharmony_ci{
74f6603c60Sopenharmony_ci    if (canvas_ != nullptr) {
75f6603c60Sopenharmony_ci        OH_Drawing_CanvasDetachBrush(canvas_);
76f6603c60Sopenharmony_ci        OH_Drawing_BrushDestroy(brush_);
77f6603c60Sopenharmony_ci        brush_ = nullptr;
78f6603c60Sopenharmony_ci        OH_Drawing_CanvasDestroy(canvas_);
79f6603c60Sopenharmony_ci        canvas_ = nullptr;
80f6603c60Sopenharmony_ci    }
81f6603c60Sopenharmony_ci}
82f6603c60Sopenharmony_ci
83f6603c60Sopenharmony_ci/*
84f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_DrawPath005
85f6603c60Sopenharmony_ci * @tc.desc: test for OH_Drawing_CanvasDrawPath.
86f6603c60Sopenharmony_ci * @tc.size  : MediumTest
87f6603c60Sopenharmony_ci * @tc.type  : Function
88f6603c60Sopenharmony_ci * @tc.level : Level 1
89f6603c60Sopenharmony_ci */
90f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_DrawPath005, TestSize.Level1)
91f6603c60Sopenharmony_ci{
92f6603c60Sopenharmony_ci    OH_Drawing_Path* path = OH_Drawing_PathCreate();
93f6603c60Sopenharmony_ci    EXPECT_NE(path, nullptr);
94f6603c60Sopenharmony_ci    constexpr int height = 4096;
95f6603c60Sopenharmony_ci    constexpr int width = 2160;
96f6603c60Sopenharmony_ci    constexpr float arc = 18.0f;
97f6603c60Sopenharmony_ci    int len = height / 4;
98f6603c60Sopenharmony_ci    float aX = width / 2;
99f6603c60Sopenharmony_ci    float aY = height / 4;
100f6603c60Sopenharmony_ci    float dX = aX - len * std::sin(arc);
101f6603c60Sopenharmony_ci    float dY = aY + len * std::cos(arc);
102f6603c60Sopenharmony_ci    float cX = aX + len * std::sin(arc);
103f6603c60Sopenharmony_ci    float cY = dY;
104f6603c60Sopenharmony_ci    float bX = aX + (len / 2.0);
105f6603c60Sopenharmony_ci    float bY = aY + std::sqrt((cX - dX) * (cX - dX) + (len / 2.0) * (len / 2.0));
106f6603c60Sopenharmony_ci    float eX = aX - (len / 2.0);
107f6603c60Sopenharmony_ci    float eY = bY;
108f6603c60Sopenharmony_ci    OH_Drawing_PathMoveTo(path, aX, aY);
109f6603c60Sopenharmony_ci    OH_Drawing_PathLineTo(path, bX, bY);
110f6603c60Sopenharmony_ci    OH_Drawing_PathLineTo(path, cX, cY);
111f6603c60Sopenharmony_ci    OH_Drawing_PathLineTo(path, dX, dY);
112f6603c60Sopenharmony_ci    OH_Drawing_PathLineTo(path, eX, eY);
113f6603c60Sopenharmony_ci    OH_Drawing_PathClose(path);
114f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawPath(canvas_, path);
115f6603c60Sopenharmony_ci    OH_Drawing_PathDestroy(path);
116f6603c60Sopenharmony_ci}
117f6603c60Sopenharmony_ci
118f6603c60Sopenharmony_ci/*
119f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_DrawBitmap021
120f6603c60Sopenharmony_ci * @tc.desc: test for DrawBitmap
121f6603c60Sopenharmony_ci * @tc.size  : MediumTest
122f6603c60Sopenharmony_ci * @tc.type  : Function
123f6603c60Sopenharmony_ci * @tc.level : Level 1
124f6603c60Sopenharmony_ci */
125f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_DrawBitmap021, TestSize.Level1)
126f6603c60Sopenharmony_ci{
127f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
128f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
129f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
130f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
131f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
132f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas_, bitmap);
133f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmap(canvas_, bitmap, 0, 0);
134f6603c60Sopenharmony_ci    OH_Drawing_CanvasClear(canvas_, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
135f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
136f6603c60Sopenharmony_ci}
137f6603c60Sopenharmony_ci/*
138f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_DrawBitmapRect022
139f6603c60Sopenharmony_ci * @tc.desc: test for DrawBitmapRect
140f6603c60Sopenharmony_ci * @tc.size  : MediumTest
141f6603c60Sopenharmony_ci * @tc.type  : Function
142f6603c60Sopenharmony_ci * @tc.level : Level 1
143f6603c60Sopenharmony_ci */
144f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_DrawBitmapRect022, TestSize.Level1)
145f6603c60Sopenharmony_ci{
146f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
147f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
148f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
149f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
150f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
151f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
152f6603c60Sopenharmony_ci    OH_Drawing_Rect* src = OH_Drawing_RectCreate(0, 0, 200, 200);
153f6603c60Sopenharmony_ci    EXPECT_NE(src, nullptr);
154f6603c60Sopenharmony_ci    OH_Drawing_Rect* dst = OH_Drawing_RectCreate(0, 0, 200, 200);
155f6603c60Sopenharmony_ci    EXPECT_NE(dst, nullptr);
156f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions* options = OH_Drawing_SamplingOptionsCreate(
157f6603c60Sopenharmony_ci        OH_Drawing_FilterMode::FILTER_MODE_NEAREST, OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
158f6603c60Sopenharmony_ci    EXPECT_NE(options, nullptr);
159f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas_, bitmap, src, dst, options);
160f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas_, bitmap, src, dst, nullptr);
161f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas_, bitmap, src, nullptr, nullptr);
162f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas_, bitmap, nullptr, nullptr, nullptr);
163f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(canvas_, nullptr, nullptr, nullptr, nullptr);
164f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawBitmapRect(nullptr, nullptr, nullptr, nullptr, nullptr);
165f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
166f6603c60Sopenharmony_ci}
167f6603c60Sopenharmony_ci
168f6603c60Sopenharmony_ci/*
169f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_DrawImageRect025
170f6603c60Sopenharmony_ci * @tc.desc: test for DrawImageRect
171f6603c60Sopenharmony_ci * @tc.size  : MediumTest
172f6603c60Sopenharmony_ci * @tc.type  : Function
173f6603c60Sopenharmony_ci * @tc.level : Level 1
174f6603c60Sopenharmony_ci */
175f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_DrawImageRect025, TestSize.Level1)
176f6603c60Sopenharmony_ci{
177f6603c60Sopenharmony_ci    OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 200, 200);
178f6603c60Sopenharmony_ci    EXPECT_NE(rect, nullptr);
179f6603c60Sopenharmony_ci    OH_Drawing_Image* image = OH_Drawing_ImageCreate();
180f6603c60Sopenharmony_ci    EXPECT_NE(image, nullptr);
181f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
182f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
183f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
184f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
185f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
186f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
187f6603c60Sopenharmony_ci    OH_Drawing_ImageBuildFromBitmap(image, bitmap);
188f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions* options = OH_Drawing_SamplingOptionsCreate(
189f6603c60Sopenharmony_ci        OH_Drawing_FilterMode::FILTER_MODE_NEAREST, OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
190f6603c60Sopenharmony_ci    EXPECT_NE(options, nullptr);
191f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas_, image, rect, options);
192f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas_, image, rect, nullptr);
193f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas_, image, nullptr, nullptr);
194f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(canvas_, nullptr, nullptr, nullptr);
195f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRect(nullptr, nullptr, nullptr, nullptr);
196f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(canvas_, image, rect, rect, options, STRICT_SRC_RECT_CONSTRAINT);
197f6603c60Sopenharmony_ci    OH_Drawing_CanvasDrawImageRectWithSrc(nullptr, nullptr, nullptr, nullptr, nullptr, STRICT_SRC_RECT_CONSTRAINT);
198f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
199f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
200f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
201f6603c60Sopenharmony_ci}
202f6603c60Sopenharmony_ci
203f6603c60Sopenharmony_ci/*
204f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_ReadPixels027
205f6603c60Sopenharmony_ci * @tc.desc: test for ReadPixels
206f6603c60Sopenharmony_ci * @tc.size  : MediumTest
207f6603c60Sopenharmony_ci * @tc.type  : Function
208f6603c60Sopenharmony_ci * @tc.level : Level 1
209f6603c60Sopenharmony_ci */
210f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_ReadPixels027, TestSize.Level1)
211f6603c60Sopenharmony_ci{
212f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo;
213f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
214f6603c60Sopenharmony_ci    EXPECT_NE(bitmap, nullptr);
215f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
216f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
217f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
218f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
219f6603c60Sopenharmony_ci    void* pixels = OH_Drawing_BitmapGetPixels(bitmap);
220f6603c60Sopenharmony_ci    EXPECT_TRUE(!OH_Drawing_CanvasReadPixels(canvas_, &imageInfo, pixels, 0, 0, 0));
221f6603c60Sopenharmony_ci    EXPECT_TRUE(!OH_Drawing_CanvasReadPixels(canvas_, &imageInfo, nullptr, 0, 0, 0));
222f6603c60Sopenharmony_ci    EXPECT_TRUE(!OH_Drawing_CanvasReadPixels(canvas_, nullptr, nullptr, 0, 0, 0));
223f6603c60Sopenharmony_ci    EXPECT_TRUE(!OH_Drawing_CanvasReadPixels(nullptr, nullptr, nullptr, 0, 0, 0));
224f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
225f6603c60Sopenharmony_ci}
226f6603c60Sopenharmony_ci
227f6603c60Sopenharmony_ci/*
228f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_IsClipEmpty042
229f6603c60Sopenharmony_ci * @tc.desc: test for if clip is empty
230f6603c60Sopenharmony_ci * @tc.type: FUNC
231f6603c60Sopenharmony_ci * @tc.require: AR000GTO5R
232f6603c60Sopenharmony_ci */
233f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_IsClipEmpty042, TestSize.Level1)
234f6603c60Sopenharmony_ci{
235f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
236f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
237f6603c60Sopenharmony_ci    // 2160: bitmap's width, 2160: bitmap's height
238f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
239f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
240f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
241f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas_, bitmap);
242f6603c60Sopenharmony_ci
243f6603c60Sopenharmony_ci    // 150.0f: rect's left, 100.0f: rect's top, 500.0f: rect's right, 500.0f: rect's bottom
244f6603c60Sopenharmony_ci    OH_Drawing_Rect* rect = OH_Drawing_RectCreate(150.0f, 100.0f, 500.f, 500.f);
245f6603c60Sopenharmony_ci
246f6603c60Sopenharmony_ci    OH_Drawing_CanvasClipRect(canvas_, rect, OH_Drawing_CanvasClipOp::INTERSECT, false);
247f6603c60Sopenharmony_ci
248f6603c60Sopenharmony_ci    bool isClipEmpty = false;
249f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasIsClipEmpty(canvas_, &isClipEmpty), OH_DRAWING_SUCCESS);
250f6603c60Sopenharmony_ci    EXPECT_EQ(isClipEmpty, false);
251f6603c60Sopenharmony_ci
252f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
253f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
254f6603c60Sopenharmony_ci}
255f6603c60Sopenharmony_ci
256f6603c60Sopenharmony_ci/*
257f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_GetImageInfo043
258f6603c60Sopenharmony_ci * @tc.desc: test for Gets ImageInfo of Canvas.
259f6603c60Sopenharmony_ci * @tc.type: FUNC
260f6603c60Sopenharmony_ci * @tc.require: AR000GTO5R
261f6603c60Sopenharmony_ci */
262f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_GetImageInfo043, TestSize.Level1)
263f6603c60Sopenharmony_ci{
264f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
265f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
266f6603c60Sopenharmony_ci    // 2160: bitmap's width, 2160: bitmap's height
267f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160;
268f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096;
269f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
270f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas_, bitmap);
271f6603c60Sopenharmony_ci    OH_Drawing_Image_Info* imageInfo = new OH_Drawing_Image_Info();
272f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasGetImageInfo(canvas_, imageInfo), OH_DRAWING_SUCCESS);
273f6603c60Sopenharmony_ci    EXPECT_EQ(2160, imageInfo->width);
274f6603c60Sopenharmony_ci    EXPECT_EQ(4096, imageInfo->height);
275f6603c60Sopenharmony_ci    EXPECT_EQ(1, imageInfo->alphaType);
276f6603c60Sopenharmony_ci    EXPECT_EQ(4, imageInfo->colorType);
277f6603c60Sopenharmony_ci    delete imageInfo;
278f6603c60Sopenharmony_ci}
279f6603c60Sopenharmony_ci
280f6603c60Sopenharmony_ci
281f6603c60Sopenharmony_ci/*
282f6603c60Sopenharmony_ci * @tc.name: NativeDrawingCanvasLargeValueTest_ClipRegion044
283f6603c60Sopenharmony_ci * @tc.desc: test for Drawing Canvas Clip Region.
284f6603c60Sopenharmony_ci * @tc.type: FUNC
285f6603c60Sopenharmony_ci * @tc.require: AR000GTO5R
286f6603c60Sopenharmony_ci */
287f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingCanvasLargeValueTest, NativeDrawingCanvasLargeValueTest_ClipRegion044, TestSize.Level1)
288f6603c60Sopenharmony_ci{
289f6603c60Sopenharmony_ci    OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
290f6603c60Sopenharmony_ci    OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
291f6603c60Sopenharmony_ci    constexpr uint32_t width = 2160; // 2160: width of canvas
292f6603c60Sopenharmony_ci    constexpr uint32_t height = 4096; // 4096: height of canvas
293f6603c60Sopenharmony_ci    OH_Drawing_BitmapBuild(bitmap, width, height, &cFormat);
294f6603c60Sopenharmony_ci    OH_Drawing_CanvasBind(canvas_, bitmap);
295f6603c60Sopenharmony_ci
296f6603c60Sopenharmony_ci    OH_Drawing_Region *region = OH_Drawing_RegionCreate();
297f6603c60Sopenharmony_ci    // 0.0f: rect's left, 0.0f: rect's top, 4096.0f: rect's right, 2160.0f: rect's bottom
298f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0.0f, 0.0f, 2160.f, 4096.f);
299f6603c60Sopenharmony_ci    OH_Drawing_RegionSetRect(region, rect);
300f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasClipRegion(canvas_, region, OH_Drawing_CanvasClipOp::INTERSECT), OH_DRAWING_SUCCESS);
301f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_CanvasClipRegion(nullptr, region, OH_Drawing_CanvasClipOp::INTERSECT),
302f6603c60Sopenharmony_ci        OH_DRAWING_ERROR_INVALID_PARAMETER);
303f6603c60Sopenharmony_ci
304f6603c60Sopenharmony_ci    EXPECT_EQ(2160, OH_Drawing_CanvasGetWidth(canvas_));
305f6603c60Sopenharmony_ci    EXPECT_EQ(4096, OH_Drawing_CanvasGetHeight(canvas_));
306f6603c60Sopenharmony_ci
307f6603c60Sopenharmony_ci    OH_Drawing_RegionDestroy(region);
308f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
309f6603c60Sopenharmony_ci    OH_Drawing_BitmapDestroy(bitmap);
310f6603c60Sopenharmony_ci}
311f6603c60Sopenharmony_ci} // namespace Drawing
312f6603c60Sopenharmony_ci} // namespace Rosen
313f6603c60Sopenharmony_ci} // namespace OHOS