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 "EGL/egl.h"
17f6603c60Sopenharmony_ci#include "EGL/eglext.h"
18f6603c60Sopenharmony_ci#include "drawing_bitmap.h"
19f6603c60Sopenharmony_ci#include "drawing_error_code.h"
20f6603c60Sopenharmony_ci#include "drawing_gpu_context.h"
21f6603c60Sopenharmony_ci#include "drawing_surface.h"
22f6603c60Sopenharmony_ci#include "gtest/gtest.h"
23f6603c60Sopenharmony_ci
24f6603c60Sopenharmony_ciusing namespace testing;
25f6603c60Sopenharmony_ciusing namespace testing::ext;
26f6603c60Sopenharmony_ci
27f6603c60Sopenharmony_cinamespace OHOS {
28f6603c60Sopenharmony_cinamespace Rosen {
29f6603c60Sopenharmony_cinamespace Drawing {
30f6603c60Sopenharmony_ciclass DrawingNativeSurFaceTest : public testing::Test {
31f6603c60Sopenharmony_ci  public:
32f6603c60Sopenharmony_ci    static void SetUpTestCase();
33f6603c60Sopenharmony_ci    static void TearDownTestCase();
34f6603c60Sopenharmony_ci    void SetUp() override;
35f6603c60Sopenharmony_ci    void TearDown() override;
36f6603c60Sopenharmony_ci
37f6603c60Sopenharmony_ci  protected:
38f6603c60Sopenharmony_ci    EGLDisplay eglDisplay_ = EGL_NO_DISPLAY;
39f6603c60Sopenharmony_ci    EGLConfig eglConfig_ = EGL_NO_CONFIG_KHR;
40f6603c60Sopenharmony_ci    EGLContext eglContext_ = EGL_NO_CONTEXT;
41f6603c60Sopenharmony_ci    EGLSurface eglSurface_ = EGL_NO_SURFACE;
42f6603c60Sopenharmony_ci    OH_Drawing_GpuContext *gpuContext_ = nullptr;
43f6603c60Sopenharmony_ci    OH_Drawing_Surface *surface_ = nullptr;
44f6603c60Sopenharmony_ci    OH_Drawing_Canvas *canvas_ = nullptr;
45f6603c60Sopenharmony_ci};
46f6603c60Sopenharmony_ci
47f6603c60Sopenharmony_civoid DrawingNativeSurFaceTest::SetUpTestCase() {}
48f6603c60Sopenharmony_civoid DrawingNativeSurFaceTest::TearDownTestCase() {}
49f6603c60Sopenharmony_civoid DrawingNativeSurFaceTest::SetUp()
50f6603c60Sopenharmony_ci{
51f6603c60Sopenharmony_ci    eglDisplay_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
52f6603c60Sopenharmony_ci    EXPECT_NE(eglDisplay_, EGL_NO_DISPLAY);
53f6603c60Sopenharmony_ci
54f6603c60Sopenharmony_ci    EGLint eglMajVers;
55f6603c60Sopenharmony_ci    EGLint eglMinVers;
56f6603c60Sopenharmony_ci    EGLBoolean ret = eglInitialize(eglDisplay_, &eglMajVers, &eglMinVers);
57f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
58f6603c60Sopenharmony_ci
59f6603c60Sopenharmony_ci    EGLint count;
60f6603c60Sopenharmony_ci    EGLint configAttribs[] = {
61f6603c60Sopenharmony_ci        EGL_SURFACE_TYPE,
62f6603c60Sopenharmony_ci        EGL_WINDOW_BIT,
63f6603c60Sopenharmony_ci        EGL_RED_SIZE,
64f6603c60Sopenharmony_ci        8,
65f6603c60Sopenharmony_ci        EGL_GREEN_SIZE,
66f6603c60Sopenharmony_ci        8,
67f6603c60Sopenharmony_ci        EGL_BLUE_SIZE,
68f6603c60Sopenharmony_ci        8,
69f6603c60Sopenharmony_ci        EGL_ALPHA_SIZE,
70f6603c60Sopenharmony_ci        8,
71f6603c60Sopenharmony_ci        EGL_RENDERABLE_TYPE,
72f6603c60Sopenharmony_ci        EGL_OPENGL_ES3_BIT,
73f6603c60Sopenharmony_ci        EGL_NONE,
74f6603c60Sopenharmony_ci    };
75f6603c60Sopenharmony_ci    ret = eglChooseConfig(eglDisplay_, configAttribs, &eglConfig_, 1, &count);
76f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
77f6603c60Sopenharmony_ci    EXPECT_GE(count, 1);
78f6603c60Sopenharmony_ci
79f6603c60Sopenharmony_ci    const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
80f6603c60Sopenharmony_ci    eglContext_ = eglCreateContext(eglDisplay_, eglConfig_, EGL_NO_CONTEXT, contextAttribs);
81f6603c60Sopenharmony_ci    EXPECT_NE(eglContext_, EGL_NO_CONTEXT);
82f6603c60Sopenharmony_ci
83f6603c60Sopenharmony_ci    EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
84f6603c60Sopenharmony_ci    eglSurface_ = eglCreatePbufferSurface(eglDisplay_, eglConfig_, attribs);
85f6603c60Sopenharmony_ci    EXPECT_NE(eglSurface_, EGL_NO_SURFACE);
86f6603c60Sopenharmony_ci
87f6603c60Sopenharmony_ci    ret = eglMakeCurrent(eglDisplay_, eglSurface_, eglSurface_, eglContext_);
88f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
89f6603c60Sopenharmony_ci}
90f6603c60Sopenharmony_ci
91f6603c60Sopenharmony_civoid DrawingNativeSurFaceTest::TearDown()
92f6603c60Sopenharmony_ci{
93f6603c60Sopenharmony_ci    EGLBoolean ret = eglDestroySurface(eglDisplay_, eglSurface_);
94f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
95f6603c60Sopenharmony_ci
96f6603c60Sopenharmony_ci    ret = eglDestroyContext(eglDisplay_, eglContext_);
97f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
98f6603c60Sopenharmony_ci
99f6603c60Sopenharmony_ci    ret = eglTerminate(eglDisplay_);
100f6603c60Sopenharmony_ci    EXPECT_EQ(ret, EGL_TRUE);
101f6603c60Sopenharmony_ci
102f6603c60Sopenharmony_ci    eglSurface_ = EGL_NO_SURFACE;
103f6603c60Sopenharmony_ci    eglContext_ = EGL_NO_CONTEXT;
104f6603c60Sopenharmony_ci    eglDisplay_ = EGL_NO_DISPLAY;
105f6603c60Sopenharmony_ci}
106f6603c60Sopenharmony_ci
107f6603c60Sopenharmony_ci/*
108f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0100
109f6603c60Sopenharmony_ci * @tc.name: testSurfaceCreateFromGpuContextNormal
110f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceCreateFromGpuContextNormal.
111f6603c60Sopenharmony_ci * @tc.size  : SmallTest
112f6603c60Sopenharmony_ci * @tc.type  : Function
113f6603c60Sopenharmony_ci * @tc.level : Level 0
114f6603c60Sopenharmony_ci */
115f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceCreateFromGpuContextNormal, TestSize.Level0) {
116f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
117f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
118f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
119f6603c60Sopenharmony_ci    const int32_t width = 500;
120f6603c60Sopenharmony_ci    const int32_t height = 500;
121f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
122f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
123f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
124f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
125f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, false, imageInfo);
126f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
127f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
128f6603c60Sopenharmony_ci}
129f6603c60Sopenharmony_ci
130f6603c60Sopenharmony_ci/*
131f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0101
132f6603c60Sopenharmony_ci * @tc.name: testSurfaceCreateFromGpuContextNull
133f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceCreateFromGpuContextNull.
134f6603c60Sopenharmony_ci * @tc.size  : SmallTest
135f6603c60Sopenharmony_ci * @tc.type  : Function
136f6603c60Sopenharmony_ci * @tc.level : Level 3
137f6603c60Sopenharmony_ci */
138f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceCreateFromGpuContextNull, TestSize.Level3) {
139f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
140f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
141f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
142f6603c60Sopenharmony_ci    const int32_t width = 500;
143f6603c60Sopenharmony_ci    const int32_t height = 500;
144f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
145f6603c60Sopenharmony_ci    // OH_Drawing_GpuContext is NULL, check error code using OH_Drawing_ErrorCodeGet
146f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(nullptr, true, imageInfo);
147f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
148f6603c60Sopenharmony_ci    // Exceptional parameter passing for OH_Drawing_Image_Info
149f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo2 = {0, 0, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
150f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, false, imageInfo2);
151f6603c60Sopenharmony_ci    EXPECT_EQ(surface_, nullptr);
152f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
153f6603c60Sopenharmony_ci}
154f6603c60Sopenharmony_ci
155f6603c60Sopenharmony_ci/*
156f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0102
157f6603c60Sopenharmony_ci * @tc.name: testSurfaceCreateFromGpuContextBoundary
158f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceCreateFromGpuContextBoundary.
159f6603c60Sopenharmony_ci * @tc.size  : SmallTest
160f6603c60Sopenharmony_ci * @tc.type  : Function
161f6603c60Sopenharmony_ci * @tc.level : Level 0
162f6603c60Sopenharmony_ci */
163f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceCreateFromGpuContextBoundary, TestSize.Level0) {
164f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
165f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
166f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
167f6603c60Sopenharmony_ci    const int32_t width = 4096;
168f6603c60Sopenharmony_ci    const int32_t height = 2160;
169f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
170f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
171f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
172f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
173f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, false, imageInfo);
174f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
175f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
176f6603c60Sopenharmony_ci}
177f6603c60Sopenharmony_ci
178f6603c60Sopenharmony_ci/*
179f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0200
180f6603c60Sopenharmony_ci * @tc.name: testSurfaceDestroyNormal
181f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceDestroyNormal.
182f6603c60Sopenharmony_ci * @tc.size  : SmallTest
183f6603c60Sopenharmony_ci * @tc.type  : Function
184f6603c60Sopenharmony_ci * @tc.level : Level 0
185f6603c60Sopenharmony_ci */
186f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceDestroyNormal, TestSize.Level0) {
187f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
188f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
189f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
190f6603c60Sopenharmony_ci    const int32_t width = 500;
191f6603c60Sopenharmony_ci    const int32_t height = 500;
192f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
193f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
194f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
195f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
196f6603c60Sopenharmony_ci}
197f6603c60Sopenharmony_ci
198f6603c60Sopenharmony_ci/*
199f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0201
200f6603c60Sopenharmony_ci * @tc.name: testSurfaceDestroyNull
201f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceDestroyNull.
202f6603c60Sopenharmony_ci * @tc.size  : SmallTest
203f6603c60Sopenharmony_ci * @tc.type  : Function
204f6603c60Sopenharmony_ci * @tc.level : Level 3
205f6603c60Sopenharmony_ci */
206f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceDestroyNull, TestSize.Level3) {
207f6603c60Sopenharmony_ci    // free
208f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(nullptr);
209f6603c60Sopenharmony_ci}
210f6603c60Sopenharmony_ci
211f6603c60Sopenharmony_ci/*
212f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0300
213f6603c60Sopenharmony_ci * @tc.name: testSurfaceGetCanvasNormal
214f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceGetCanvasNormal.
215f6603c60Sopenharmony_ci * @tc.size  : SmallTest
216f6603c60Sopenharmony_ci * @tc.type  : Function
217f6603c60Sopenharmony_ci * @tc.level : Level 0
218f6603c60Sopenharmony_ci */
219f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceGetCanvasNormal, TestSize.Level0) {
220f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
221f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
222f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
223f6603c60Sopenharmony_ci    // 1. OH_Drawing_SurfaceCreateFromGpuContext
224f6603c60Sopenharmony_ci    const int32_t width = 500;
225f6603c60Sopenharmony_ci    const int32_t height = 500;
226f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
227f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
228f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
229f6603c60Sopenharmony_ci    // 2. OH_Drawing_SurfaceGetCanvas, get the canvas object from the surface object, a pointer to the surface object,
230f6603c60Sopenharmony_ci    // and call the drawing interface
231f6603c60Sopenharmony_ci    canvas_ = OH_Drawing_SurfaceGetCanvas(surface_);
232f6603c60Sopenharmony_ci    EXPECT_NE(canvas_, nullptr);
233f6603c60Sopenharmony_ci    // 3. Free memory
234f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
235f6603c60Sopenharmony_ci}
236f6603c60Sopenharmony_ci
237f6603c60Sopenharmony_ci/*
238f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0301
239f6603c60Sopenharmony_ci * @tc.name: testSurfaceGetCanvasNull
240f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceGetCanvasNull.
241f6603c60Sopenharmony_ci * @tc.size  : SmallTest
242f6603c60Sopenharmony_ci * @tc.type  : Function
243f6603c60Sopenharmony_ci * @tc.level : Level 3
244f6603c60Sopenharmony_ci */
245f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceGetCanvasNull, TestSize.Level3) {
246f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
247f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
248f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
249f6603c60Sopenharmony_ci    // 1. OH_Drawing_SurfaceCreateFromGpuContext
250f6603c60Sopenharmony_ci    const int32_t width = 500;
251f6603c60Sopenharmony_ci    const int32_t height = 500;
252f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
253f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
254f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
255f6603c60Sopenharmony_ci    // 2. OH_Drawing_SurfaceGetCanvas with null parameter, check error code using OH_Drawing_ErrorCodeGet
256f6603c60Sopenharmony_ci    canvas_ = OH_Drawing_SurfaceGetCanvas(nullptr);
257f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
258f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
259f6603c60Sopenharmony_ci}
260f6603c60Sopenharmony_ci
261f6603c60Sopenharmony_ci/*
262f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SURFACE_0302
263f6603c60Sopenharmony_ci * @tc.name: testSurfaceGetCanvasBoundary
264f6603c60Sopenharmony_ci * @tc.desc: test for testSurfaceGetCanvasBoundary.
265f6603c60Sopenharmony_ci * @tc.size  : SmallTest
266f6603c60Sopenharmony_ci * @tc.type  : Function
267f6603c60Sopenharmony_ci * @tc.level : Level 0
268f6603c60Sopenharmony_ci */
269f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeSurFaceTest, testSurfaceGetCanvasBoundary, TestSize.Level0) {
270f6603c60Sopenharmony_ci    OH_Drawing_GpuContextOptions options{true};
271f6603c60Sopenharmony_ci    gpuContext_ = OH_Drawing_GpuContextCreateFromGL(options);
272f6603c60Sopenharmony_ci    EXPECT_NE(gpuContext_, nullptr);
273f6603c60Sopenharmony_ci    // 1. OH_Drawing_SurfaceCreateFromGpuContext
274f6603c60Sopenharmony_ci    const int32_t width = 4096;
275f6603c60Sopenharmony_ci    const int32_t height = 2160;
276f6603c60Sopenharmony_ci    OH_Drawing_Image_Info imageInfo = {width, height, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
277f6603c60Sopenharmony_ci    surface_ = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext_, true, imageInfo);
278f6603c60Sopenharmony_ci    EXPECT_NE(surface_, nullptr);
279f6603c60Sopenharmony_ci    // 2. OH_Drawing_SurfaceGetCanvas, get the canvas object from the surface object, a pointer to the surface object,
280f6603c60Sopenharmony_ci    // and call the drawing interface
281f6603c60Sopenharmony_ci    canvas_ = OH_Drawing_SurfaceGetCanvas(surface_);
282f6603c60Sopenharmony_ci    EXPECT_NE(canvas_, nullptr);
283f6603c60Sopenharmony_ci    // 3. Free memory
284f6603c60Sopenharmony_ci    OH_Drawing_SurfaceDestroy(surface_);
285f6603c60Sopenharmony_ci}
286f6603c60Sopenharmony_ci} // namespace Drawing
287f6603c60Sopenharmony_ci} // namespace Rosen
288f6603c60Sopenharmony_ci} // namespace OHOS