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_color.h"
19f6603c60Sopenharmony_ci#include "drawing_error_code.h"
20f6603c60Sopenharmony_ci#include "drawing_filter.h"
21f6603c60Sopenharmony_ci#include "drawing_image.h"
22f6603c60Sopenharmony_ci#include "drawing_mask_filter.h"
23f6603c60Sopenharmony_ci#include "drawing_matrix.h"
24f6603c60Sopenharmony_ci#include "drawing_point.h"
25f6603c60Sopenharmony_ci#include "drawing_rect.h"
26f6603c60Sopenharmony_ci#include "drawing_round_rect.h"
27f6603c60Sopenharmony_ci#include "drawing_sampling_options.h"
28f6603c60Sopenharmony_ci#include "drawing_shader_effect.h"
29f6603c60Sopenharmony_ci
30f6603c60Sopenharmony_ciusing namespace testing;
31f6603c60Sopenharmony_ciusing namespace testing::ext;
32f6603c60Sopenharmony_ci
33f6603c60Sopenharmony_cinamespace OHOS {
34f6603c60Sopenharmony_cinamespace Rosen {
35f6603c60Sopenharmony_cinamespace Drawing {
36f6603c60Sopenharmony_ciclass DrawingNativeShaderEffectTest : public testing::Test {};
37f6603c60Sopenharmony_ci
38f6603c60Sopenharmony_ci/*
39f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0100
40f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateColorShaderNormal
41f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateColorShaderNormal.
42f6603c60Sopenharmony_ci * @tc.size  : SmallTest
43f6603c60Sopenharmony_ci * @tc.type  : Function
44f6603c60Sopenharmony_ci * @tc.level : Level 0
45f6603c60Sopenharmony_ci */
46f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateColorShaderNormal, TestSize.Level0) {
47f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateColorShader
48f6603c60Sopenharmony_ci    uint32_t color = 0xFFFF0000;
49f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *colorShaderEffect = OH_Drawing_ShaderEffectCreateColorShader(color);
50f6603c60Sopenharmony_ci    // 2. Free memory
51f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(colorShaderEffect);
52f6603c60Sopenharmony_ci}
53f6603c60Sopenharmony_ci
54f6603c60Sopenharmony_ci/*
55f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0101
56f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateColorShaderNull
57f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateColorShaderNull.
58f6603c60Sopenharmony_ci * @tc.size  : SmallTest
59f6603c60Sopenharmony_ci * @tc.type  : Function
60f6603c60Sopenharmony_ci * @tc.level : Level 3
61f6603c60Sopenharmony_ci */
62f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateColorShaderNull, TestSize.Level3) {
63f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateColorShader with empty parameter
64f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *colorShaderEffect = OH_Drawing_ShaderEffectCreateColorShader(0);
65f6603c60Sopenharmony_ci    // 2. Free memory
66f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(colorShaderEffect);
67f6603c60Sopenharmony_ci}
68f6603c60Sopenharmony_ci
69f6603c60Sopenharmony_ci/*
70f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0102
71f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateColorShaderAbnormal
72f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateColorShaderAbnormal.
73f6603c60Sopenharmony_ci * @tc.size  : SmallTest
74f6603c60Sopenharmony_ci * @tc.type  : Function
75f6603c60Sopenharmony_ci * @tc.level : Level 3
76f6603c60Sopenharmony_ci */
77f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateColorShaderAbnormal, TestSize.Level3) {
78f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateColorShader with a negative parameter
79f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *colorShaderEffect = OH_Drawing_ShaderEffectCreateColorShader(-0xFFFF0000);
80f6603c60Sopenharmony_ci    // 2. Free memory
81f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(colorShaderEffect);
82f6603c60Sopenharmony_ci}
83f6603c60Sopenharmony_ci
84f6603c60Sopenharmony_ci/*
85f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0103
86f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateColorShaderMaximum
87f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateColorShaderMaximum.
88f6603c60Sopenharmony_ci * @tc.size  : SmallTest
89f6603c60Sopenharmony_ci * @tc.type  : Function
90f6603c60Sopenharmony_ci * @tc.level : Level 3
91f6603c60Sopenharmony_ci */
92f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateColorShaderMaximum, TestSize.Level3) {
93f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateColorShader with maximum value as parameter
94f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *colorShaderEffect = OH_Drawing_ShaderEffectCreateColorShader(UINT32_MAX);
95f6603c60Sopenharmony_ci    // 2. Free memory
96f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(colorShaderEffect);
97f6603c60Sopenharmony_ci}
98f6603c60Sopenharmony_ci
99f6603c60Sopenharmony_ci/*
100f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0104
101f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateColorShaderMultipleCalls
102f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateColorShaderMultipleCalls.
103f6603c60Sopenharmony_ci * @tc.size  : SmallTest
104f6603c60Sopenharmony_ci * @tc.type  : Function
105f6603c60Sopenharmony_ci * @tc.level : Level 3
106f6603c60Sopenharmony_ci */
107f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateColorShaderMultipleCalls, TestSize.Level3) {
108f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateColorShader 10 times with different colors
109f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
110f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *colorShaderEffect = OH_Drawing_ShaderEffectCreateColorShader(0xFF000000 + i);
111f6603c60Sopenharmony_ci        // 2. Free memory
112f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(colorShaderEffect);
113f6603c60Sopenharmony_ci    }
114f6603c60Sopenharmony_ci}
115f6603c60Sopenharmony_ci
116f6603c60Sopenharmony_ci/*
117f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0200
118f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradientWithLocalMatrixNormal
119f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradientWithLocalMatrixNormal.
120f6603c60Sopenharmony_ci * @tc.size  : SmallTest
121f6603c60Sopenharmony_ci * @tc.type  : Function
122f6603c60Sopenharmony_ci * @tc.level : Level 0
123f6603c60Sopenharmony_ci */
124f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradientWithLocalMatrixNormal, TestSize.Level0) {
125f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {0, 0};
126f6603c60Sopenharmony_ci    OH_Drawing_Point2D end = {100.f, 0};
127f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
128f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
129f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
130f6603c60Sopenharmony_ci        CLAMP,
131f6603c60Sopenharmony_ci        REPEAT,
132f6603c60Sopenharmony_ci        MIRROR,
133f6603c60Sopenharmony_ci        DECAL,
134f6603c60Sopenharmony_ci    };
135f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
136f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values for OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix, and test
137f6603c60Sopenharmony_ci    // with both identity and non-identity matrix
138f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
139f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *linearGradientEffect =
140f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, mode, matrix);
141f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
142f6603c60Sopenharmony_ci    }
143f6603c60Sopenharmony_ci
144f6603c60Sopenharmony_ci    // 2. Test OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix with pos set to NULL
145f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(
146f6603c60Sopenharmony_ci        &start, &end, colors, nullptr, 3, OH_Drawing_TileMode::CLAMP, matrix);
147f6603c60Sopenharmony_ci    // 3. Test OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix with matrix set to NULL
148f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 = OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(
149f6603c60Sopenharmony_ci        &start, &end, colors, pos, 3, OH_Drawing_TileMode::CLAMP, nullptr);
150f6603c60Sopenharmony_ci
151f6603c60Sopenharmony_ci    // 4. Free memory
152f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
153f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
154f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
155f6603c60Sopenharmony_ci}
156f6603c60Sopenharmony_ci
157f6603c60Sopenharmony_ci/*
158f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0201
159f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradientWithLocalMatrixNull
160f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradientWithLocalMatrixNull.
161f6603c60Sopenharmony_ci * @tc.size  : SmallTest
162f6603c60Sopenharmony_ci * @tc.type  : Function
163f6603c60Sopenharmony_ci * @tc.level : Level 3
164f6603c60Sopenharmony_ci */
165f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradientWithLocalMatrixNull, TestSize.Level3) {
166f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {0, 0};
167f6603c60Sopenharmony_ci    OH_Drawing_Point2D end = {100.f, 0};
168f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
169f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
170f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
171f6603c60Sopenharmony_ci        CLAMP,
172f6603c60Sopenharmony_ci        REPEAT,
173f6603c60Sopenharmony_ci        MIRROR,
174f6603c60Sopenharmony_ci        DECAL,
175f6603c60Sopenharmony_ci    };
176f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
177f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix with the first parameter set to nullptr, check the
178f6603c60Sopenharmony_ci    // error code using OH_Drawing_ErrorCodeGet
179f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect1 =
180f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(nullptr, &end, colors, pos, 3, modes[0], matrix);
181f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
182f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix with the second parameter set to nullptr, check the
183f6603c60Sopenharmony_ci    // error code using OH_Drawing_ErrorCodeGet
184f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 =
185f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, nullptr, colors, pos, 3, modes[0], matrix);
186f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
187f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix with the third parameter set to nullptr, check the
188f6603c60Sopenharmony_ci    // error code using OH_Drawing_ErrorCodeGet
189f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 =
190f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, nullptr, pos, 3, modes[0], matrix);
191f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
192f6603c60Sopenharmony_ci    // 4. Free memory
193f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
194f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect1);
195f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
196f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
197f6603c60Sopenharmony_ci}
198f6603c60Sopenharmony_ci
199f6603c60Sopenharmony_ci/*
200f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0202
201f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradientWithLocalMatrixAbnormal
202f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradientWithLocalMatrixAbnormal.
203f6603c60Sopenharmony_ci * @tc.size  : SmallTest
204f6603c60Sopenharmony_ci * @tc.type  : Function
205f6603c60Sopenharmony_ci * @tc.level : Level 3
206f6603c60Sopenharmony_ci */
207f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradientWithLocalMatrixAbnormal, TestSize.Level3) {
208f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {0, 0};
209f6603c60Sopenharmony_ci    OH_Drawing_Point2D end = {100.f, 0};
210f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
211f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
212f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
213f6603c60Sopenharmony_ci        CLAMP,
214f6603c60Sopenharmony_ci        REPEAT,
215f6603c60Sopenharmony_ci        MIRROR,
216f6603c60Sopenharmony_ci        DECAL,
217f6603c60Sopenharmony_ci    };
218f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
219f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with negative values for startPt
220f6603c60Sopenharmony_ci    start = {-1, -1};
221f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
222f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
223f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with negative values for endPt
224f6603c60Sopenharmony_ci    start = {0, 0};
225f6603c60Sopenharmony_ci    end = {-1, -1};
226f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 =
227f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
228f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with negative values for colors
229f6603c60Sopenharmony_ci    colors[0] = -0xFF00FFFF;
230f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect3 =
231f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
232f6603c60Sopenharmony_ci    // 4. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with negative values for pos
233f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
234f6603c60Sopenharmony_ci    pos[0] = -0.1f;
235f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect4 =
236f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
237f6603c60Sopenharmony_ci    // 5. Free memory
238f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
239f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
240f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
241f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect3);
242f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect4);
243f6603c60Sopenharmony_ci}
244f6603c60Sopenharmony_ci
245f6603c60Sopenharmony_ci/*
246f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0203
247f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradientWithLocalMatrixMaximum
248f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradientWithLocalMatrixMaximum.
249f6603c60Sopenharmony_ci * @tc.size  : SmallTest
250f6603c60Sopenharmony_ci * @tc.type  : Function
251f6603c60Sopenharmony_ci * @tc.level : Level 3
252f6603c60Sopenharmony_ci */
253f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradientWithLocalMatrixMaximum, TestSize.Level3) {
254f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {0, 0};
255f6603c60Sopenharmony_ci    OH_Drawing_Point2D end = {100.f, 0};
256f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
257f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
258f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
259f6603c60Sopenharmony_ci        CLAMP,
260f6603c60Sopenharmony_ci        REPEAT,
261f6603c60Sopenharmony_ci        MIRROR,
262f6603c60Sopenharmony_ci        DECAL,
263f6603c60Sopenharmony_ci    };
264f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
265f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with startPt set to maximum value
266f6603c60Sopenharmony_ci    start = {FLT_MAX, FLT_MAX};
267f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
268f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
269f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with endPt set to maximum value
270f6603c60Sopenharmony_ci    start = {0, 0};
271f6603c60Sopenharmony_ci    end = {FLT_MAX, FLT_MAX};
272f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 =
273f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
274f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with colors set to maximum value
275f6603c60Sopenharmony_ci    colors[0] = UINT32_MAX;
276f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect3 =
277f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
278f6603c60Sopenharmony_ci    // 4. OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix interface with pos set to maximum value
279f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
280f6603c60Sopenharmony_ci    pos[0] = FLT_MAX;
281f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect4 =
282f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, modes[0], matrix);
283f6603c60Sopenharmony_ci    // 5. Free memory
284f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
285f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
286f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
287f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect3);
288f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect4);
289f6603c60Sopenharmony_ci}
290f6603c60Sopenharmony_ci
291f6603c60Sopenharmony_ci/*
292f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0204
293f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradientWithLocalMatrixMultipleCalls
294f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradientWithLocalMatrixMultipleCalls.
295f6603c60Sopenharmony_ci * @tc.size  : SmallTest
296f6603c60Sopenharmony_ci * @tc.type  : Function
297f6603c60Sopenharmony_ci * @tc.level : Level 3
298f6603c60Sopenharmony_ci */
299f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradientWithLocalMatrixMultipleCalls,
300f6603c60Sopenharmony_ci         TestSize.Level3) {
301f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {0, 0};
302f6603c60Sopenharmony_ci    OH_Drawing_Point2D end = {100.f, 0};
303f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
304f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
305f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
306f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix 10 times
307f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
308f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *linearGradientEffect =
309f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateLinearGradientWithLocalMatrix(&start, &end, colors, pos, 3, CLAMP, matrix);
310f6603c60Sopenharmony_ci        // 2. Free memory
311f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
312f6603c60Sopenharmony_ci    }
313f6603c60Sopenharmony_ci}
314f6603c60Sopenharmony_ci
315f6603c60Sopenharmony_ci/*
316f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0300
317f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradienNormal
318f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradienNormal.
319f6603c60Sopenharmony_ci * @tc.size  : SmallTest
320f6603c60Sopenharmony_ci * @tc.type  : Function
321f6603c60Sopenharmony_ci * @tc.level : Level 0
322f6603c60Sopenharmony_ci */
323f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradienNormal, TestSize.Level0) {
324f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values in OH_Drawing_ShaderEffectCreateLinearGradient
325f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(0, 0);
326f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(100.f, 0);
327f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
328f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
329f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
330f6603c60Sopenharmony_ci        CLAMP,
331f6603c60Sopenharmony_ci        REPEAT,
332f6603c60Sopenharmony_ci        MIRROR,
333f6603c60Sopenharmony_ci        DECAL,
334f6603c60Sopenharmony_ci    };
335f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
336f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *linearGradientEffect =
337f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, mode);
338f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
339f6603c60Sopenharmony_ci    }
340f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradient interface with pos set to NULL
341f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
342f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, nullptr, 3, CLAMP);
343f6603c60Sopenharmony_ci    // 3. Free memory
344f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt);
345f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt);
346f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
347f6603c60Sopenharmony_ci}
348f6603c60Sopenharmony_ci
349f6603c60Sopenharmony_ci/*
350f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0301
351f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradienNull
352f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradienNull.
353f6603c60Sopenharmony_ci * @tc.size  : SmallTest
354f6603c60Sopenharmony_ci * @tc.type  : Function
355f6603c60Sopenharmony_ci * @tc.level : Level 3
356f6603c60Sopenharmony_ci */
357f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradienNull, TestSize.Level3) {
358f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(0, 0);
359f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(100.f, 0);
360f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
361f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
362f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateLinearGradient with the first parameter set to nullptr, check the error code
363f6603c60Sopenharmony_ci    // using OH_Drawing_ErrorCodeGet
364f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
365f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(nullptr, endPt, colors, pos, 3, CLAMP);
366f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
367f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradient with the second parameter set to nullptr, check the error code
368f6603c60Sopenharmony_ci    // using OH_Drawing_ErrorCodeGet
369f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 =
370f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, nullptr, colors, pos, 3, CLAMP);
371f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
372f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateLinearGradient with the third parameter set to nullptr, check the error code
373f6603c60Sopenharmony_ci    // using OH_Drawing_ErrorCodeGet
374f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect3 =
375f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, nullptr, pos, 3, CLAMP);
376f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
377f6603c60Sopenharmony_ci    // 4. Free memory
378f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt);
379f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt);
380f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
381f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
382f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect3);
383f6603c60Sopenharmony_ci}
384f6603c60Sopenharmony_ci
385f6603c60Sopenharmony_ci/*
386f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0302
387f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradienAbnormal
388f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradienAbnormal.
389f6603c60Sopenharmony_ci * @tc.size  : SmallTest
390f6603c60Sopenharmony_ci * @tc.type  : Function
391f6603c60Sopenharmony_ci * @tc.level : Level 3
392f6603c60Sopenharmony_ci */
393f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradienAbnormal, TestSize.Level3) {
394f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(0, 0);
395f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(100.f, 0);
396f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
397f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
398f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateLinearGradient interface with startPt set to negative values
399f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt2 = OH_Drawing_PointCreate(-1, -1);
400f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
401f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt2, endPt, colors, pos, 3, CLAMP);
402f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateLinearGradient interface with endPt set to negative values
403f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt2 = OH_Drawing_PointCreate(-1, -1);
404f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 =
405f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt2, colors, pos, 3, CLAMP);
406f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateLinearGradient interface with colors set to negative values
407f6603c60Sopenharmony_ci    colors[0] = -0xFF00FFFF;
408f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect3 =
409f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, CLAMP);
410f6603c60Sopenharmony_ci    // 4. OH_Drawing_ShaderEffectCreateLinearGradient interface with pos set to negative values
411f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
412f6603c60Sopenharmony_ci    pos[0] = -0.1f;
413f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect4 =
414f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, CLAMP);
415f6603c60Sopenharmony_ci    // 5. Free memory
416f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt);
417f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt);
418f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt2);
419f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt2);
420f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
421f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
422f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect3);
423f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect4);
424f6603c60Sopenharmony_ci}
425f6603c60Sopenharmony_ci
426f6603c60Sopenharmony_ci/*
427f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0303
428f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradienMaximum
429f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradienMaximum.
430f6603c60Sopenharmony_ci * @tc.size  : SmallTest
431f6603c60Sopenharmony_ci * @tc.type  : Function
432f6603c60Sopenharmony_ci * @tc.level : Level 3
433f6603c60Sopenharmony_ci */
434f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradienMaximum, TestSize.Level3) {
435f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(0, 0);
436f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(100.f, 0);
437f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
438f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
439f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateLinearGradient with startPt set to maximum values
440f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt2 = OH_Drawing_PointCreate(FLT_MAX, FLT_MAX);
441f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect =
442f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt2, endPt, colors, pos, 3, CLAMP);
443f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateLinearGradient with endPt set to maximum values
444f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt2 = OH_Drawing_PointCreate(FLT_MAX, FLT_MAX);
445f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect2 =
446f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt2, colors, pos, 3, CLAMP);
447f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateLinearGradient with colors set to maximum values
448f6603c60Sopenharmony_ci    colors[0] = UINT32_MAX;
449f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect3 =
450f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, CLAMP);
451f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateLinearGradient with pos set to maximum values
452f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
453f6603c60Sopenharmony_ci    pos[0] = FLT_MAX;
454f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *linearGradientEffect4 =
455f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, CLAMP);
456f6603c60Sopenharmony_ci    // 5. Free memory
457f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt);
458f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt);
459f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(startPt2);
460f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(endPt2);
461f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
462f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect2);
463f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect3);
464f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(linearGradientEffect4);
465f6603c60Sopenharmony_ci}
466f6603c60Sopenharmony_ci
467f6603c60Sopenharmony_ci/*
468f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0304
469f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateLinearGradienMultipleCalls
470f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateLinearGradienMultipleCalls.
471f6603c60Sopenharmony_ci * @tc.size  : SmallTest
472f6603c60Sopenharmony_ci * @tc.type  : Function
473f6603c60Sopenharmony_ci * @tc.level : Level 3
474f6603c60Sopenharmony_ci */
475f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateLinearGradienMultipleCalls, TestSize.Level3) {
476f6603c60Sopenharmony_ci    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(0, 0);
477f6603c60Sopenharmony_ci    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(100.f, 0);
478f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};
479f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
480f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateLinearGradient 10 times
481f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
482f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *linearGradientEffect =
483f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, colors, pos, 3, CLAMP);
484f6603c60Sopenharmony_ci        // 2. Free memory
485f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(linearGradientEffect);
486f6603c60Sopenharmony_ci    }
487f6603c60Sopenharmony_ci}
488f6603c60Sopenharmony_ci
489f6603c60Sopenharmony_ci/*
490f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0400
491f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientNormal
492f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientNormal.
493f6603c60Sopenharmony_ci * @tc.size  : SmallTest
494f6603c60Sopenharmony_ci * @tc.type  : Function
495f6603c60Sopenharmony_ci * @tc.level : Level 0
496f6603c60Sopenharmony_ci */
497f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientNormal, TestSize.Level0) {
498f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values in OH_Drawing_ShaderEffectCreateRadialGradient
499f6603c60Sopenharmony_ci    OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 100);
500f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
501f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
502f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
503f6603c60Sopenharmony_ci        CLAMP,
504f6603c60Sopenharmony_ci        REPEAT,
505f6603c60Sopenharmony_ci        MIRROR,
506f6603c60Sopenharmony_ci        DECAL,
507f6603c60Sopenharmony_ci    };
508f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
509f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, pos, 3, mode);
510f6603c60Sopenharmony_ci        EXPECT_NE(effect, nullptr);
511f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
512f6603c60Sopenharmony_ci    }
513f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateRadialGradient with pos set to nullptr
514f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect =
515f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, nullptr, 3, CLAMP);
516f6603c60Sopenharmony_ci    EXPECT_NE(effect, nullptr);
517f6603c60Sopenharmony_ci    // 3. Free memory
518f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point);
519f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
520f6603c60Sopenharmony_ci}
521f6603c60Sopenharmony_ci
522f6603c60Sopenharmony_ci/*
523f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0401
524f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientNull
525f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientNull.
526f6603c60Sopenharmony_ci * @tc.size  : SmallTest
527f6603c60Sopenharmony_ci * @tc.type  : Function
528f6603c60Sopenharmony_ci * @tc.level : Level 3
529f6603c60Sopenharmony_ci */
530f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientNull, TestSize.Level3) {
531f6603c60Sopenharmony_ci    OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 100);
532f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
533f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
534f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectCreateRadialGradient with the first parameter set to nullptr, check the error code
535f6603c60Sopenharmony_ci    // using OH_Drawing_ErrorCodeGet
536f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateRadialGradient(nullptr, 100, colors, pos, 3, CLAMP);
537f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
538f6603c60Sopenharmony_ci    // 2. OH_Drawing_ShaderEffectCreateRadialGradient with the second parameter set to nullptr
539f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, nullptr, pos, 3, CLAMP);
540f6603c60Sopenharmony_ci    EXPECT_EQ(effect2, nullptr);
541f6603c60Sopenharmony_ci    // 3. OH_Drawing_ShaderEffectCreateRadialGradient with the third parameter set to nullptr
542f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 =
543f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, nullptr, 3, CLAMP);
544f6603c60Sopenharmony_ci    EXPECT_NE(effect3, nullptr);
545f6603c60Sopenharmony_ci    // 4. Free memory
546f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point);
547f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
548f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
549f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
550f6603c60Sopenharmony_ci}
551f6603c60Sopenharmony_ci
552f6603c60Sopenharmony_ci/*
553f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0402
554f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientAbnormal
555f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientAbnormal.
556f6603c60Sopenharmony_ci * @tc.size  : SmallTest
557f6603c60Sopenharmony_ci * @tc.type  : Function
558f6603c60Sopenharmony_ci * @tc.level : Level 3
559f6603c60Sopenharmony_ci */
560f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientAbnormal, TestSize.Level3) {
561f6603c60Sopenharmony_ci    OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 100);
562f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
563f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
564f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradient with centerPt set to negative values
565f6603c60Sopenharmony_ci    OH_Drawing_Point *point2 = OH_Drawing_PointCreate(-100, -100);
566f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateRadialGradient(point2, 100, colors, pos, 3, CLAMP);
567f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradient with radius set to negative values
568f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateRadialGradient(point, -100, colors, pos, 3, CLAMP);
569f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradient with colors set to negative values
570f6603c60Sopenharmony_ci    colors[0] = -0xFFFF0000;
571f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, pos, 3, CLAMP);
572f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateRadialGradient with pos set to negative values
573f6603c60Sopenharmony_ci    colors[0] = 0xFFFF0000;
574f6603c60Sopenharmony_ci    pos[0] = -0.1f;
575f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, pos, 3, CLAMP);
576f6603c60Sopenharmony_ci    // 5. Free memory
577f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point);
578f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point2);
579f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
580f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
581f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
582f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
583f6603c60Sopenharmony_ci}
584f6603c60Sopenharmony_ci
585f6603c60Sopenharmony_ci/*
586f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0403
587f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientMaximum
588f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientMaximum.
589f6603c60Sopenharmony_ci * @tc.size  : SmallTest
590f6603c60Sopenharmony_ci * @tc.type  : Function
591f6603c60Sopenharmony_ci * @tc.level : Level 3
592f6603c60Sopenharmony_ci */
593f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientMaximum, TestSize.Level3) {
594f6603c60Sopenharmony_ci    OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 100);
595f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
596f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
597f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradient with centerPt set to maximum values
598f6603c60Sopenharmony_ci    OH_Drawing_Point *point2 = OH_Drawing_PointCreate(FLT_MAX, FLT_MAX);
599f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateRadialGradient(point2, 100, colors, pos, 3, CLAMP);
600f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradient with radius set to maximum values
601f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 =
602f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradient(point, FLT_MAX, colors, pos, 3, CLAMP);
603f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradient with colors set to maximum values
604f6603c60Sopenharmony_ci    uint32_t colors2[] = {UINT32_MAX, UINT32_MAX, UINT32_MAX};
605f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors2, pos, 3, CLAMP);
606f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateRadialGradient with pos set to maximum values
607f6603c60Sopenharmony_ci    float pos2[] = {FLT_MAX, FLT_MAX, FLT_MAX};
608f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 = OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, pos2, 3, CLAMP);
609f6603c60Sopenharmony_ci    // 5. Free memory
610f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point);
611f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(point2);
612f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
613f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
614f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
615f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
616f6603c60Sopenharmony_ci}
617f6603c60Sopenharmony_ci
618f6603c60Sopenharmony_ci/*
619f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0404
620f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientMultipleCalls
621f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientMultipleCalls.
622f6603c60Sopenharmony_ci * @tc.size  : SmallTest
623f6603c60Sopenharmony_ci * @tc.type  : Function
624f6603c60Sopenharmony_ci * @tc.level : Level 3
625f6603c60Sopenharmony_ci */
626f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientMultipleCalls, TestSize.Level3) {
627f6603c60Sopenharmony_ci    OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 100);
628f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
629f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
630f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradient 10 times
631f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
632f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect =
633f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateRadialGradient(point, 100, colors, pos, 3, CLAMP);
634f6603c60Sopenharmony_ci        // 2. Free memory
635f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
636f6603c60Sopenharmony_ci    }
637f6603c60Sopenharmony_ci}
638f6603c60Sopenharmony_ci
639f6603c60Sopenharmony_ci/*
640f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0500
641f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientWithLocalMatrixNormal
642f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientWithLocalMatrixNormal.
643f6603c60Sopenharmony_ci * @tc.size  : SmallTest
644f6603c60Sopenharmony_ci * @tc.type  : Function
645f6603c60Sopenharmony_ci * @tc.level : Level 0
646f6603c60Sopenharmony_ci */
647f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientWithLocalMatrixNormal, TestSize.Level0) {
648f6603c60Sopenharmony_ci    float pos[] = {0.0f, 0.5f, 1.0f};      // 0.5f: gradient color points, 1.0f: gradient color points
649f6603c60Sopenharmony_ci    float radius = 5.0;                    // 5.0f: gradient color radius
650f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {100.f, 0}; // 100.f: start point's x
651f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
652f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
653f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
654f6603c60Sopenharmony_ci        CLAMP,
655f6603c60Sopenharmony_ci        REPEAT,
656f6603c60Sopenharmony_ci        MIRROR,
657f6603c60Sopenharmony_ci        DECAL,
658f6603c60Sopenharmony_ci    };
659f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values in OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix, covering
660f6603c60Sopenharmony_ci    // both the identity matrix and non-identity matrices for matrix
661f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
662f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect =
663f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&start, radius, colors, pos, 3, mode, matrix);
664f6603c60Sopenharmony_ci        EXPECT_NE(effect, nullptr);
665f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
666f6603c60Sopenharmony_ci    }
667f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with pos set to nullptr
668f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(
669f6603c60Sopenharmony_ci        &start, radius, colors, nullptr, 3, OH_Drawing_TileMode::CLAMP, matrix);
670f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with matrix set to nullptr
671f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(
672f6603c60Sopenharmony_ci        &start, radius, colors, pos, 3, OH_Drawing_TileMode::CLAMP, nullptr);
673f6603c60Sopenharmony_ci    // 4. Free memory
674f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
675f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
676f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
677f6603c60Sopenharmony_ci}
678f6603c60Sopenharmony_ci
679f6603c60Sopenharmony_ci/*
680f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0501
681f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientWithLocalMatrixNull
682f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientWithLocalMatrixNull.
683f6603c60Sopenharmony_ci * @tc.size  : SmallTest
684f6603c60Sopenharmony_ci * @tc.type  : Function
685f6603c60Sopenharmony_ci * @tc.level : Level 3
686f6603c60Sopenharmony_ci */
687f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientWithLocalMatrixNull, TestSize.Level3) {
688f6603c60Sopenharmony_ci    float pos[] = {0.0f, 0.5f, 1.0f};      // 0.5f: gradient color points, 1.0f: gradient color points
689f6603c60Sopenharmony_ci    float radius = 5.0;                    // 5.0f: gradient color radius
690f6603c60Sopenharmony_ci    OH_Drawing_Point2D start = {100.f, 0}; // 100.f: start point's x
691f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
692f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
693f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with the first parameter set to nullptr and
694f6603c60Sopenharmony_ci    // check the error code using OH_Drawing_ErrorCodeGet
695f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect =
696f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(nullptr, radius, colors, pos, 3, CLAMP, matrix);
697f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
698f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with the second parameter set to nullptr
699f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 =
700f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&start, radius, nullptr, pos, 3, CLAMP, matrix);
701f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with the third parameter set to nullptr
702f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 =
703f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&start, radius, colors, nullptr, 3, CLAMP, matrix);
704f6603c60Sopenharmony_ci    // 4. Free memory
705f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
706f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
707f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
708f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
709f6603c60Sopenharmony_ci}
710f6603c60Sopenharmony_ci
711f6603c60Sopenharmony_ci/*
712f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0502
713f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientWithLocalMatrixAbnormal
714f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientWithLocalMatrixAbnormal.
715f6603c60Sopenharmony_ci * @tc.size  : SmallTest
716f6603c60Sopenharmony_ci * @tc.type  : Function
717f6603c60Sopenharmony_ci * @tc.level : Level 3
718f6603c60Sopenharmony_ci */
719f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientWithLocalMatrixAbnormal, TestSize.Level3) {
720f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with centerPt set to negative values
721f6603c60Sopenharmony_ci    OH_Drawing_Point2D centerPt = {-1, -1};
722f6603c60Sopenharmony_ci    float radius = 5.0;
723f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
724f6603c60Sopenharmony_ci    float pos[] = {0.0f, 0.5f, 1.0f};
725f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
726f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect =
727f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
728f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with radius set to negative values
729f6603c60Sopenharmony_ci    centerPt = {100, 0};
730f6603c60Sopenharmony_ci    radius = -5.0;
731f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 =
732f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
733f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with colors set to negative values
734f6603c60Sopenharmony_ci    colors[0] = -0xFFFF0000;
735f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 =
736f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
737f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with pos set to negative values
738f6603c60Sopenharmony_ci    colors[0] = 0xFFFF0000;
739f6603c60Sopenharmony_ci    pos[0] = -0.1f;
740f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 =
741f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
742f6603c60Sopenharmony_ci    // 5. Free memory
743f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
744f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
745f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
746f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
747f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
748f6603c60Sopenharmony_ci}
749f6603c60Sopenharmony_ci
750f6603c60Sopenharmony_ci/*
751f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0503
752f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientWithLocalMatrixMaximum
753f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientWithLocalMatrixMaximum.
754f6603c60Sopenharmony_ci * @tc.size  : SmallTest
755f6603c60Sopenharmony_ci * @tc.type  : Function
756f6603c60Sopenharmony_ci * @tc.level : Level 3
757f6603c60Sopenharmony_ci */
758f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientWithLocalMatrixMaximum, TestSize.Level3) {
759f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with centerPt set to a large number
760f6603c60Sopenharmony_ci    OH_Drawing_Point2D centerPt = {FLT_MAX, FLT_MAX};
761f6603c60Sopenharmony_ci    float radius = 5.0;
762f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
763f6603c60Sopenharmony_ci    float pos[] = {0.0f, 0.5f, 1.0f};
764f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
765f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect =
766f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
767f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with radius set to a large number
768f6603c60Sopenharmony_ci    centerPt = {100, 0};
769f6603c60Sopenharmony_ci    radius = FLT_MAX;
770f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 =
771f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
772f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with colors set to a large number
773f6603c60Sopenharmony_ci    colors[0] = UINT32_MAX;
774f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 =
775f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
776f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix with pos set to a large number
777f6603c60Sopenharmony_ci    colors[0] = 0xFFFF0000;
778f6603c60Sopenharmony_ci    pos[0] = FLT_MAX;
779f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 =
780f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(&centerPt, radius, colors, pos, 3, CLAMP, matrix);
781f6603c60Sopenharmony_ci    // 5. Free memory
782f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
783f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
784f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
785f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
786f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
787f6603c60Sopenharmony_ci}
788f6603c60Sopenharmony_ci
789f6603c60Sopenharmony_ci/*
790f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0504
791f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateRadialGradientWithLocalMatrixMultipleCalls
792f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateRadialGradientWithLocalMatrixMultipleCalls.
793f6603c60Sopenharmony_ci * @tc.size  : SmallTest
794f6603c60Sopenharmony_ci * @tc.type  : Function
795f6603c60Sopenharmony_ci * @tc.level : Level 3
796f6603c60Sopenharmony_ci */
797f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateRadialGradientWithLocalMatrixMultipleCalls,
798f6603c60Sopenharmony_ci         TestSize.Level3) {
799f6603c60Sopenharmony_ci    OH_Drawing_Point2D centerPt = {100, 100};
800f6603c60Sopenharmony_ci    float radius = 5.0;
801f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
802f6603c60Sopenharmony_ci    float pos[] = {0.0f, 0.5f, 1.0f};
803f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
804f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix 10 times
805f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
806f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix(
807f6603c60Sopenharmony_ci            &centerPt, radius, colors, pos, 3, CLAMP, matrix);
808f6603c60Sopenharmony_ci        // 2. Free memory
809f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
810f6603c60Sopenharmony_ci    }
811f6603c60Sopenharmony_ci}
812f6603c60Sopenharmony_ci
813f6603c60Sopenharmony_ci/*
814f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0600
815f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateSweepGradientNormal
816f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateSweepGradientNormal.
817f6603c60Sopenharmony_ci * @tc.size  : SmallTest
818f6603c60Sopenharmony_ci * @tc.type  : Function
819f6603c60Sopenharmony_ci * @tc.level : Level 0
820f6603c60Sopenharmony_ci */
821f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateSweepGradientNormal, TestSize.Level0) {
822f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values in OH_Drawing_ShaderEffectCreateSweepGradient
823f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(100, 100);
824f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
825f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
826f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
827f6603c60Sopenharmony_ci        CLAMP,
828f6603c60Sopenharmony_ci        REPEAT,
829f6603c60Sopenharmony_ci        MIRROR,
830f6603c60Sopenharmony_ci        DECAL,
831f6603c60Sopenharmony_ci    };
832f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
833f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, mode);
834f6603c60Sopenharmony_ci        EXPECT_NE(effect, nullptr);
835f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
836f6603c60Sopenharmony_ci    }
837f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateSweepGradient with pos set to nullptr
838f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, nullptr, 3, CLAMP);
839f6603c60Sopenharmony_ci    EXPECT_NE(effect, nullptr);
840f6603c60Sopenharmony_ci    // 3. Free memory
841f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt);
842f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
843f6603c60Sopenharmony_ci}
844f6603c60Sopenharmony_ci
845f6603c60Sopenharmony_ci/*
846f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0601
847f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateSweepGradientNull
848f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateSweepGradientNull.
849f6603c60Sopenharmony_ci * @tc.size  : SmallTest
850f6603c60Sopenharmony_ci * @tc.type  : Function
851f6603c60Sopenharmony_ci * @tc.level : Level 3
852f6603c60Sopenharmony_ci */
853f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateSweepGradientNull, TestSize.Level3) {
854f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(100, 100);
855f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
856f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
857f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateSweepGradient with the first parameter set to nullptr and check the error
858f6603c60Sopenharmony_ci    // code using OH_Drawing_ErrorCodeGet
859f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateSweepGradient(nullptr, colors, pos, 3, CLAMP);
860f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
861f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateSweepGradient with the second parameter set to nullptr and check the error
862f6603c60Sopenharmony_ci    // code using OH_Drawing_ErrorCodeGet
863f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, nullptr, pos, 3, CLAMP);
864f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
865f6603c60Sopenharmony_ci    // 3. Free memory
866f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt);
867f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
868f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
869f6603c60Sopenharmony_ci}
870f6603c60Sopenharmony_ci
871f6603c60Sopenharmony_ci/*
872f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0602
873f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateSweepGradientAbnormal
874f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateSweepGradientAbnormal.
875f6603c60Sopenharmony_ci * @tc.size  : SmallTest
876f6603c60Sopenharmony_ci * @tc.type  : Function
877f6603c60Sopenharmony_ci * @tc.level : Level 3
878f6603c60Sopenharmony_ci */
879f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateSweepGradientAbnormal, TestSize.Level3) {
880f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(100, 100);
881f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
882f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
883f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateSweepGradient with centerPt set to negative values
884f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt2 = OH_Drawing_PointCreate(-1, -1);
885f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect =
886f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt2, colors, pos, 3, CLAMP);
887f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateSweepGradient with colors set to negative values
888f6603c60Sopenharmony_ci    colors[0] = -0xFFFF0000;
889f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect2 =
890f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, CLAMP);
891f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateSweepGradient with pos set to negative values
892f6603c60Sopenharmony_ci    colors[0] = 0xFFFF0000;
893f6603c60Sopenharmony_ci    pos[0] = -0.1f;
894f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect3 =
895f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, CLAMP);
896f6603c60Sopenharmony_ci    // 4. Free memory
897f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt);
898f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt2);
899f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect);
900f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect2);
901f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect3);
902f6603c60Sopenharmony_ci}
903f6603c60Sopenharmony_ci
904f6603c60Sopenharmony_ci/*
905f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0603
906f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateSweepGradientMaximum
907f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateSweepGradientMaximum.
908f6603c60Sopenharmony_ci * @tc.size  : SmallTest
909f6603c60Sopenharmony_ci * @tc.type  : Function
910f6603c60Sopenharmony_ci * @tc.level : Level 3
911f6603c60Sopenharmony_ci */
912f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateSweepGradientMaximum, TestSize.Level3) {
913f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(100, 100);
914f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
915f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
916f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateSweepGradient with centerPt set to a large number
917f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt2 = OH_Drawing_PointCreate(FLT_MAX, FLT_MAX);
918f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect =
919f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt2, colors, pos, 3, CLAMP);
920f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateSweepGradient with colors set to a large number
921f6603c60Sopenharmony_ci    colors[0] = UINT32_MAX;
922f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect2 =
923f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, CLAMP);
924f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateSweepGradient with pos set to a large number
925f6603c60Sopenharmony_ci    colors[0] = 0xFFFF0000;
926f6603c60Sopenharmony_ci    pos[0] = FLT_MAX;
927f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *sweepGradientEffect3 =
928f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, CLAMP);
929f6603c60Sopenharmony_ci    // 4. Free memory
930f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt);
931f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt2);
932f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect);
933f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect2);
934f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(sweepGradientEffect3);
935f6603c60Sopenharmony_ci}
936f6603c60Sopenharmony_ci
937f6603c60Sopenharmony_ci/*
938f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0604
939f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateSweepGradientMultipleCalls
940f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateSweepGradientMultipleCalls.
941f6603c60Sopenharmony_ci * @tc.size  : SmallTest
942f6603c60Sopenharmony_ci * @tc.type  : Function
943f6603c60Sopenharmony_ci * @tc.level : Level 3
944f6603c60Sopenharmony_ci */
945f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateSweepGradientMultipleCalls, TestSize.Level3) {
946f6603c60Sopenharmony_ci    OH_Drawing_Point *centerPt = OH_Drawing_PointCreate(100, 100);
947f6603c60Sopenharmony_ci    uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
948f6603c60Sopenharmony_ci    float pos[] = {0, 0.5, 1.0};
949f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateSweepGradient 10 times
950f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
951f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *sweepGradientEffect =
952f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateSweepGradient(centerPt, colors, pos, 3, CLAMP);
953f6603c60Sopenharmony_ci        // 2. Free memory
954f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(sweepGradientEffect);
955f6603c60Sopenharmony_ci    }
956f6603c60Sopenharmony_ci}
957f6603c60Sopenharmony_ci
958f6603c60Sopenharmony_ci/*
959f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0700
960f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateImageShaderNormal
961f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateImageShaderNormal.
962f6603c60Sopenharmony_ci * @tc.size  : SmallTest
963f6603c60Sopenharmony_ci * @tc.type  : Function
964f6603c60Sopenharmony_ci * @tc.level : Level 0
965f6603c60Sopenharmony_ci */
966f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateImageShaderNormal, TestSize.Level0) {
967f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ImageCreate
968f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
969f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_SamplingOptionsCreate
970f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_LINEAR);
971f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateImageShader with different OH_Drawing_TileMode values for tileX and tileY
972f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
973f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
974f6603c60Sopenharmony_ci        CLAMP,
975f6603c60Sopenharmony_ci        REPEAT,
976f6603c60Sopenharmony_ci        MIRROR,
977f6603c60Sopenharmony_ci        DECAL,
978f6603c60Sopenharmony_ci    };
979f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode tileX : modes) {
980f6603c60Sopenharmony_ci        for (OH_Drawing_TileMode tileY : modes) {
981f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffect *effect =
982f6603c60Sopenharmony_ci                OH_Drawing_ShaderEffectCreateImageShader(image, tileX, tileY, options, matrix);
983f6603c60Sopenharmony_ci            EXPECT_NE(effect, nullptr);
984f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectDestroy(effect);
985f6603c60Sopenharmony_ci        }
986f6603c60Sopenharmony_ci    }
987f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateImageShader with null matrix
988f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateImageShader(image, CLAMP, CLAMP, options, nullptr);
989f6603c60Sopenharmony_ci    EXPECT_NE(effect, nullptr);
990f6603c60Sopenharmony_ci    // 5. Free memory
991f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
992f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
993f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
994f6603c60Sopenharmony_ci}
995f6603c60Sopenharmony_ci
996f6603c60Sopenharmony_ci/*
997f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0701
998f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateImageShaderNull
999f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateImageShaderNull.
1000f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1001f6603c60Sopenharmony_ci * @tc.type  : Function
1002f6603c60Sopenharmony_ci * @tc.level : Level 3
1003f6603c60Sopenharmony_ci */
1004f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateImageShaderNull, TestSize.Level3) {
1005f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateImageShader with the first parameter set to nullptr and check the error
1006f6603c60Sopenharmony_ci    // code using OH_Drawing_ErrorCodeGet
1007f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_LINEAR);
1008f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1009f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectCreateImageShader(nullptr, CLAMP, CLAMP, options, matrix);
1010f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1011f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateImageShader with the fourth parameter set to nullptr and check the error
1012f6603c60Sopenharmony_ci    // code using OH_Drawing_ErrorCodeGet
1013f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1014f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectCreateImageShader(image, CLAMP, CLAMP, nullptr, matrix);
1015f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1016f6603c60Sopenharmony_ci    // 3. Free memory
1017f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1018f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1019f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1020f6603c60Sopenharmony_ci}
1021f6603c60Sopenharmony_ci
1022f6603c60Sopenharmony_ci/*
1023f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0704
1024f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateImageShaderMultipleCalls
1025f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateImageShaderMultipleCalls.
1026f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1027f6603c60Sopenharmony_ci * @tc.type  : Function
1028f6603c60Sopenharmony_ci * @tc.level : Level 3
1029f6603c60Sopenharmony_ci */
1030f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateImageShaderMultipleCalls, TestSize.Level3) {
1031f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptions *options = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_LINEAR);
1032f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1033f6603c60Sopenharmony_ci    OH_Drawing_Image *image = OH_Drawing_ImageCreate();
1034f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateImageShader 10 times
1035f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1036f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect =
1037f6603c60Sopenharmony_ci            OH_Drawing_ShaderEffectCreateImageShader(image, CLAMP, CLAMP, options, matrix);
1038f6603c60Sopenharmony_ci        EXPECT_NE(effect, nullptr);
1039f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
1040f6603c60Sopenharmony_ci    }
1041f6603c60Sopenharmony_ci    // 2. Free memory
1042f6603c60Sopenharmony_ci    OH_Drawing_ImageDestroy(image);
1043f6603c60Sopenharmony_ci    OH_Drawing_SamplingOptionsDestroy(options);
1044f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1045f6603c60Sopenharmony_ci}
1046f6603c60Sopenharmony_ci
1047f6603c60Sopenharmony_ci/*
1048f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0800
1049f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateTwoPointConicalGradientNormal
1050f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateTwoPointConicalGradientNormal.
1051f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1052f6603c60Sopenharmony_ci * @tc.type  : Function
1053f6603c60Sopenharmony_ci * @tc.level : Level 0
1054f6603c60Sopenharmony_ci */
1055f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateTwoPointConicalGradientNormal, TestSize.Level0) {
1056f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1057f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1058f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1059f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1060f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1061f6603c60Sopenharmony_ci    OH_Drawing_TileMode modes[] = {
1062f6603c60Sopenharmony_ci        CLAMP,
1063f6603c60Sopenharmony_ci        REPEAT,
1064f6603c60Sopenharmony_ci        MIRROR,
1065f6603c60Sopenharmony_ci        DECAL,
1066f6603c60Sopenharmony_ci    };
1067f6603c60Sopenharmony_ci    // 1. Enumerate OH_Drawing_TileMode values for OH_Drawing_ShaderEffectCreateTwoPointConicalGradient, and cover both
1068f6603c60Sopenharmony_ci    // the identity matrix and non-identity matrix for the matrix parameter
1069f6603c60Sopenharmony_ci    for (OH_Drawing_TileMode mode : modes) {
1070f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1071f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect1 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1072f6603c60Sopenharmony_ci            &startPt, startRadius, &endPt, endRadius, colors, pos, 3, mode, matrix);
1073f6603c60Sopenharmony_ci        EXPECT_NE(effect1, nullptr);
1074f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect1);
1075f6603c60Sopenharmony_ci
1076f6603c60Sopenharmony_ci        OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 1, 0, 0, 0, 0, 0);
1077f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1078f6603c60Sopenharmony_ci            &startPt, startRadius, &endPt, endRadius, colors, pos, 3, mode, matrix);
1079f6603c60Sopenharmony_ci        EXPECT_NE(effect2, nullptr);
1080f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect2);
1081f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
1082f6603c60Sopenharmony_ci    }
1083f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with pos set to nullptr
1084f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1085f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1086f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, nullptr, 3, CLAMP, matrix);
1087f6603c60Sopenharmony_ci    EXPECT_NE(effect, nullptr);
1088f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with matrix set to nullptr
1089f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1090f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, nullptr);
1091f6603c60Sopenharmony_ci    EXPECT_NE(effect2, nullptr);
1092f6603c60Sopenharmony_ci    // 4. Free memory
1093f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1094f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
1095f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
1096f6603c60Sopenharmony_ci}
1097f6603c60Sopenharmony_ci
1098f6603c60Sopenharmony_ci/*
1099f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0801
1100f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateTwoPointConicalGradientNull
1101f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateTwoPointConicalGradientNull.
1102f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1103f6603c60Sopenharmony_ci * @tc.type  : Function
1104f6603c60Sopenharmony_ci * @tc.level : Level 3
1105f6603c60Sopenharmony_ci */
1106f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateTwoPointConicalGradientNull, TestSize.Level3) {
1107f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1108f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1109f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1110f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1111f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1112f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1113f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the first parameter set to nullptr and check
1114f6603c60Sopenharmony_ci    // the error code using OH_Drawing_ErrorCodeGet
1115f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1116f6603c60Sopenharmony_ci        nullptr, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1117f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1118f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the second parameter set to nullptr
1119f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1120f6603c60Sopenharmony_ci        &startPt, 0, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1121f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the third parameter set to nullptr and check
1122f6603c60Sopenharmony_ci    // the error code using OH_Drawing_ErrorCodeGet
1123f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1124f6603c60Sopenharmony_ci        &startPt, startRadius, nullptr, endRadius, colors, pos, 3, CLAMP, matrix);
1125f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1126f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the fourth parameter set to nullptr
1127f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1128f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, 0, colors, pos, 3, CLAMP, matrix);
1129f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the fifth parameter set to nullptr and check
1130f6603c60Sopenharmony_ci    // the error code using OH_Drawing_ErrorCodeGet
1131f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect5 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1132f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, nullptr, pos, 3, CLAMP, matrix);
1133f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
1134f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with the sixth parameter set to nullptr
1135f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect6 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1136f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, nullptr, 3, CLAMP, matrix);
1137f6603c60Sopenharmony_ci    // 7. Free memory
1138f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1139f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
1140f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
1141f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
1142f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
1143f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect5);
1144f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect6);
1145f6603c60Sopenharmony_ci}
1146f6603c60Sopenharmony_ci
1147f6603c60Sopenharmony_ci/*
1148f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0802
1149f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateTwoPointConicalGradientAbnormal
1150f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateTwoPointConicalGradientAbnormal.
1151f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1152f6603c60Sopenharmony_ci * @tc.type  : Function
1153f6603c60Sopenharmony_ci * @tc.level : Level 3
1154f6603c60Sopenharmony_ci */
1155f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateTwoPointConicalGradientAbnormal, TestSize.Level3) {
1156f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1157f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1158f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1159f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1160f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1161f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1162f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with startPt set to a negative value
1163f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt2 = {-1, -1};
1164f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1165f6603c60Sopenharmony_ci        &startPt2, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1166f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with startRadius set to a negative value
1167f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1168f6603c60Sopenharmony_ci        &startPt, -5.0f, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1169f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with endPt set to a negative value
1170f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt2 = {-1, -1};
1171f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1172f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt2, endRadius, colors, pos, 3, CLAMP, matrix);
1173f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with endRadius set to a negative value
1174f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1175f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, -10.0f, colors, pos, 3, CLAMP, matrix);
1176f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with colors set to a negative value
1177f6603c60Sopenharmony_ci    colors[0] = -0xFF00FFFF;
1178f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect5 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1179f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1180f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with pos set to a negative value
1181f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
1182f6603c60Sopenharmony_ci    pos[0] = -0.1f;
1183f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect6 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1184f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1185f6603c60Sopenharmony_ci    // 7. Free memory
1186f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1187f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
1188f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
1189f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
1190f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
1191f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect5);
1192f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect6);
1193f6603c60Sopenharmony_ci}
1194f6603c60Sopenharmony_ci
1195f6603c60Sopenharmony_ci/*
1196f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0803
1197f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateTwoPointConicalGradientMaximum
1198f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateTwoPointConicalGradientMaximum.
1199f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1200f6603c60Sopenharmony_ci * @tc.type  : Function
1201f6603c60Sopenharmony_ci * @tc.level : Level 3
1202f6603c60Sopenharmony_ci */
1203f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateTwoPointConicalGradientMaximum, TestSize.Level3) {
1204f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1205f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1206f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1207f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1208f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1209f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1210f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with startPt set to a maximum value
1211f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt2 = {FLT_MAX, FLT_MAX};
1212f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1213f6603c60Sopenharmony_ci        &startPt2, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1214f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with startRadius set to a maximum value
1215f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect2 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1216f6603c60Sopenharmony_ci        &startPt, FLT_MAX, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1217f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with endPt set to a maximum value
1218f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt2 = {FLT_MAX, FLT_MAX};
1219f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect3 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1220f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt2, endRadius, colors, pos, 3, CLAMP, matrix);
1221f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with endRadius set to a maximum value
1222f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect4 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1223f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, FLT_MAX, colors, pos, 3, CLAMP, matrix);
1224f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with colors set to a maximum value
1225f6603c60Sopenharmony_ci    colors[0] = UINT32_MAX;
1226f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect5 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1227f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1228f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient with pos set to a maximum value
1229f6603c60Sopenharmony_ci    colors[0] = 0xFF00FFFF;
1230f6603c60Sopenharmony_ci    pos[0] = FLT_MAX;
1231f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect6 = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1232f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1233f6603c60Sopenharmony_ci    // 7. Free memory
1234f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1235f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
1236f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect2);
1237f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect3);
1238f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect4);
1239f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect5);
1240f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect6);
1241f6603c60Sopenharmony_ci}
1242f6603c60Sopenharmony_ci
1243f6603c60Sopenharmony_ci/*
1244f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0804
1245f6603c60Sopenharmony_ci * @tc.name: testShaderEffectCreateTwoPointConicalGradientMultipleCalls
1246f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectCreateTwoPointConicalGradientMultipleCalls.
1247f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1248f6603c60Sopenharmony_ci * @tc.type  : Function
1249f6603c60Sopenharmony_ci * @tc.level : Level 3
1250f6603c60Sopenharmony_ci */
1251f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectCreateTwoPointConicalGradientMultipleCalls, TestSize.Level3) {
1252f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1253f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1254f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1255f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1256f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1257f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1258f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient 10 times
1259f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1260f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1261f6603c60Sopenharmony_ci            &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1262f6603c60Sopenharmony_ci        // 2. Free memory
1263f6603c60Sopenharmony_ci        OH_Drawing_ShaderEffectDestroy(effect);
1264f6603c60Sopenharmony_ci    }
1265f6603c60Sopenharmony_ci}
1266f6603c60Sopenharmony_ci
1267f6603c60Sopenharmony_ci/*
1268f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0900
1269f6603c60Sopenharmony_ci * @tc.name: testShaderEffectDestroyNormal
1270f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectDestroyNormal.
1271f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1272f6603c60Sopenharmony_ci * @tc.type  : Function
1273f6603c60Sopenharmony_ci * @tc.level : Level 0
1274f6603c60Sopenharmony_ci */
1275f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectDestroyNormal, TestSize.Level0) {
1276f6603c60Sopenharmony_ci    OH_Drawing_Point2D startPt = {0, 0};
1277f6603c60Sopenharmony_ci    OH_Drawing_Point2D endPt = {100.f, 0}; // 100.f: end point's x
1278f6603c60Sopenharmony_ci    uint32_t colors[3] = {0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00};
1279f6603c60Sopenharmony_ci    float pos[3] = {0.0f, 0.5f, 1.0f};           // 0.5f: gradient color points, 1.0f: gradient color points
1280f6603c60Sopenharmony_ci    float startRadius = 5.0f, endRadius = 10.0f; // 5.0f: gradient color radius, 10.0f: gradient color radius
1281f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1282f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_ShaderEffectCreateTwoPointConicalGradient
1283f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffect *effect = OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(
1284f6603c60Sopenharmony_ci        &startPt, startRadius, &endPt, endRadius, colors, pos, 3, CLAMP, matrix);
1285f6603c60Sopenharmony_ci    EXPECT_NE(effect, nullptr);
1286f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_ShaderEffectDestroy
1287f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(effect);
1288f6603c60Sopenharmony_ci}
1289f6603c60Sopenharmony_ci
1290f6603c60Sopenharmony_ci/*
1291f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_SHADOW_EFFECT_0901
1292f6603c60Sopenharmony_ci * @tc.name: testShaderEffectDestroyNull
1293f6603c60Sopenharmony_ci * @tc.desc: test for testShaderEffectDestroyNull.
1294f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1295f6603c60Sopenharmony_ci * @tc.type  : Function
1296f6603c60Sopenharmony_ci * @tc.level : Level 3
1297f6603c60Sopenharmony_ci */
1298f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeShaderEffectTest, testShaderEffectDestroyNull, TestSize.Level3) {
1299f6603c60Sopenharmony_ci    // 1. OH_Drawing_ShaderEffectDestroy parameter is null
1300f6603c60Sopenharmony_ci    OH_Drawing_ShaderEffectDestroy(nullptr);
1301f6603c60Sopenharmony_ci}
1302f6603c60Sopenharmony_ci
1303f6603c60Sopenharmony_ci} // namespace Drawing
1304f6603c60Sopenharmony_ci} // namespace Rosen
1305f6603c60Sopenharmony_ci} // namespace OHOS