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 "DrawingNativeMatrixCommon.h"
17f6603c60Sopenharmony_ci#include "drawing_error_code.h"
18f6603c60Sopenharmony_ci#include "drawing_matrix.h"
19f6603c60Sopenharmony_ci#include "drawing_rect.h"
20f6603c60Sopenharmony_ci#include "utils/scalar.h"
21f6603c60Sopenharmony_ci#include "gtest/gtest.h"
22f6603c60Sopenharmony_ci#include <iostream>
23f6603c60Sopenharmony_ci#include <random>
24f6603c60Sopenharmony_ci
25f6603c60Sopenharmony_ciusing namespace testing;
26f6603c60Sopenharmony_ciusing namespace testing::ext;
27f6603c60Sopenharmony_ci
28f6603c60Sopenharmony_cinamespace OHOS {
29f6603c60Sopenharmony_cinamespace Rosen {
30f6603c60Sopenharmony_cinamespace Drawing {
31f6603c60Sopenharmony_ci
32f6603c60Sopenharmony_ci/*
33f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0100
34f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateDestroyNormal
35f6603c60Sopenharmony_ci * @tc.desc: Test for creating and destroying a matrix with normal parameters.
36f6603c60Sopenharmony_ci * @tc.size  : SmallTest
37f6603c60Sopenharmony_ci * @tc.type  : Function
38f6603c60Sopenharmony_ci * @tc.level : Level 0
39f6603c60Sopenharmony_ci */
40f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateDestroyNormal, TestSize.Level0) {
41f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
42f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
43f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
44f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixDestroy
45f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
46f6603c60Sopenharmony_ci}
47f6603c60Sopenharmony_ci
48f6603c60Sopenharmony_ci/*
49f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0101
50f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateDestroyNULL
51f6603c60Sopenharmony_ci * @tc.desc: Test for creating and destroying a matrix with NULL parameters.
52f6603c60Sopenharmony_ci * @tc.size  : SmallTest
53f6603c60Sopenharmony_ci * @tc.type  : Function
54f6603c60Sopenharmony_ci * @tc.level : Level 3
55f6603c60Sopenharmony_ci */
56f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateDestroyNULL, TestSize.Level3) {
57f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixDestroy with nullptr parameter
58f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(nullptr);
59f6603c60Sopenharmony_ci}
60f6603c60Sopenharmony_ci
61f6603c60Sopenharmony_ci/*
62f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0102
63f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateDestroyMultipleCalls
64f6603c60Sopenharmony_ci * @tc.desc: Test for multiple calls of creating and destroying a matrix.
65f6603c60Sopenharmony_ci * @tc.size  : SmallTest
66f6603c60Sopenharmony_ci * @tc.type  : Function
67f6603c60Sopenharmony_ci * @tc.level : Level 3
68f6603c60Sopenharmony_ci */
69f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateDestroyMultipleCalls, TestSize.Level3) {
70f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_MatrixCreate 10 times
71f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrices[10];
72f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
73f6603c60Sopenharmony_ci        matrices[i] = OH_Drawing_MatrixCreate();
74f6603c60Sopenharmony_ci        EXPECT_NE(matrices[i], nullptr);
75f6603c60Sopenharmony_ci    }
76f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixDestroy 10 times
77f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
78f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrices[i]);
79f6603c60Sopenharmony_ci    }
80f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_MatrixCreate and OH_Drawing_MatrixDestroy alternately 10 times
81f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
82f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
83f6603c60Sopenharmony_ci        EXPECT_NE(matrix, nullptr);
84f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
85f6603c60Sopenharmony_ci    }
86f6603c60Sopenharmony_ci}
87f6603c60Sopenharmony_ci
88f6603c60Sopenharmony_ci/*
89f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0200
90f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateRotationNormal
91f6603c60Sopenharmony_ci * @tc.desc: Test for creating a rotation matrix with normal parameters.
92f6603c60Sopenharmony_ci * @tc.size  : SmallTest
93f6603c60Sopenharmony_ci * @tc.type  : Function
94f6603c60Sopenharmony_ci * @tc.level : Level 0
95f6603c60Sopenharmony_ci */
96f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateRotationNormal, TestSize.Level0) {
97f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateRotation, rotate angles deg traverse 0 degrees, 180 degrees, 360 degrees, -90 degrees,
98f6603c60Sopenharmony_ci    // -180 degrees, -360 degrees, 45.5 degrees, x\y cover decimals and integers
99f6603c60Sopenharmony_ci    float degs[] = {0, 180, 360, -90, -180, -360, 45.5};
100f6603c60Sopenharmony_ci    float x[] = {0, 10, 10.0f, 20, 20.0f, 30, 30.0f};
101f6603c60Sopenharmony_ci    float y[] = {0, 10, 10.0f, 20, 20.0f, 30, 30.0f};
102f6603c60Sopenharmony_ci    for (int i = 0; i < 7; i++) {
103f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateRotation(degs[i], x[i], y[i]);
104f6603c60Sopenharmony_ci        EXPECT_NE(matrix, nullptr);
105f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
106f6603c60Sopenharmony_ci    }
107f6603c60Sopenharmony_ci}
108f6603c60Sopenharmony_ci
109f6603c60Sopenharmony_ci/*
110f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0201
111f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateRotationNull
112f6603c60Sopenharmony_ci * @tc.desc: Test for creating a rotation matrix with NULL parameters.
113f6603c60Sopenharmony_ci * @tc.size  : SmallTest
114f6603c60Sopenharmony_ci * @tc.type  : Function
115f6603c60Sopenharmony_ci * @tc.level : Level 3
116f6603c60Sopenharmony_ci */
117f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateRotationNull, TestSize.Level3) {
118f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateRotation with the first parameter as null
119f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateRotation(0, 10.0f, 10.0f);
120f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateRotation with the second parameter as null
121f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateRotation(180, 0, 10.0f);
122f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateRotation with the third parameter as null
123f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateRotation(360, 10.0f, 0);
124f6603c60Sopenharmony_ci    // 4. Free memory
125f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
126f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
127f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
128f6603c60Sopenharmony_ci}
129f6603c60Sopenharmony_ci
130f6603c60Sopenharmony_ci/*
131f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0202
132f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateRotationAbnormal
133f6603c60Sopenharmony_ci * @tc.desc: Test for creating a rotation matrix with abnormal parameters.
134f6603c60Sopenharmony_ci * @tc.size  : SmallTest
135f6603c60Sopenharmony_ci * @tc.type  : Function
136f6603c60Sopenharmony_ci * @tc.level : Level 3
137f6603c60Sopenharmony_ci */
138f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateRotationAbnormal, TestSize.Level3) {
139f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateRotation with an input angle greater than 360 degrees
140f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateRotation(361, 10.0f, 10.0f);
141f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateRotation with a negative value for the x parameter
142f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateRotation(180, -10.0f, 10.0f);
143f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateRotation with a negative value for the y parameter
144f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateRotation(180, 10.0f, -10.0f);
145f6603c60Sopenharmony_ci    // 4. Free memory
146f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
147f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
148f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
149f6603c60Sopenharmony_ci}
150f6603c60Sopenharmony_ci
151f6603c60Sopenharmony_ci/*
152f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0203
153f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateRotationMaximum
154f6603c60Sopenharmony_ci * @tc.desc: Test for creating a rotation matrix with maximum values.
155f6603c60Sopenharmony_ci * @tc.size  : SmallTest
156f6603c60Sopenharmony_ci * @tc.type  : Function
157f6603c60Sopenharmony_ci * @tc.level : Level 3
158f6603c60Sopenharmony_ci */
159f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateRotationMaximum, TestSize.Level3) {
160f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateRotation with the maximum value of the rotation angle parameter deg
161f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateRotation(FLT_MAX, 10.0f, 10.0f);
162f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateRotation with the maximum value of the x parameter
163f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateRotation(180, FLT_MAX, 10.0f);
164f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateRotation with the maximum value of the y parameter
165f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateRotation(180, 10.0f, FLT_MAX);
166f6603c60Sopenharmony_ci    // 4. Free memory
167f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
168f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
169f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
170f6603c60Sopenharmony_ci}
171f6603c60Sopenharmony_ci
172f6603c60Sopenharmony_ci/*
173f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0205
174f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateRotationMultipleCalls
175f6603c60Sopenharmony_ci * @tc.desc: Test for multiple calls of creating a rotation matrix.
176f6603c60Sopenharmony_ci * @tc.size  : SmallTest
177f6603c60Sopenharmony_ci * @tc.type  : Function
178f6603c60Sopenharmony_ci * @tc.level : Level 3
179f6603c60Sopenharmony_ci */
180f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateRotationMultipleCalls, TestSize.Level3) {
181f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_MatrixCreateRotation 10 times, each time with different rotation angles and coordinate points
182f6603c60Sopenharmony_ci    std::random_device rd;
183f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
184f6603c60Sopenharmony_ci    std::uniform_int_distribution<int> deg_dist(-360, 360);
185f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> x_dist(0.0f, 100.0f);
186f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> y_dist(0.0f, 100.0f);
187f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
188f6603c60Sopenharmony_ci        float deg = deg_dist(gen);
189f6603c60Sopenharmony_ci        float x = x_dist(gen);
190f6603c60Sopenharmony_ci        float y = y_dist(gen);
191f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateRotation(deg, x, y);
192f6603c60Sopenharmony_ci        EXPECT_NE(matrix, nullptr);
193f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
194f6603c60Sopenharmony_ci    }
195f6603c60Sopenharmony_ci}
196f6603c60Sopenharmony_ci
197f6603c60Sopenharmony_ci/*
198f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0300
199f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateTranslationNormal
200f6603c60Sopenharmony_ci * @tc.desc: Test for creating a translation matrix with normal parameters.
201f6603c60Sopenharmony_ci * @tc.size  : SmallTest
202f6603c60Sopenharmony_ci * @tc.type  : Function
203f6603c60Sopenharmony_ci * @tc.level : Level 0
204f6603c60Sopenharmony_ci */
205f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateTranslationNormal, TestSize.Level0) {
206f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateTranslation, passing in a decimal number
207f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(10.0f, 10.0f);
208f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateTranslation, passing in an integer
209f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(20, 20);
210f6603c60Sopenharmony_ci    // 3. Free memory
211f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
212f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
213f6603c60Sopenharmony_ci}
214f6603c60Sopenharmony_ci
215f6603c60Sopenharmony_ci/*
216f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0301
217f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateTranslationNull
218f6603c60Sopenharmony_ci * @tc.desc: Test for creating a translation matrix with NULL parameters.
219f6603c60Sopenharmony_ci * @tc.size  : SmallTest
220f6603c60Sopenharmony_ci * @tc.type  : Function
221f6603c60Sopenharmony_ci * @tc.level : Level 3
222f6603c60Sopenharmony_ci */
223f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateTranslationNull, TestSize.Level3) {
224f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateTranslation with the first parameter as null
225f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(0, 10.0f);
226f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateTranslation with the second parameter as null
227f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(10.0f, 0);
228f6603c60Sopenharmony_ci    // 3. Free memory
229f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
230f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
231f6603c60Sopenharmony_ci}
232f6603c60Sopenharmony_ci
233f6603c60Sopenharmony_ci/*
234f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0302
235f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateTranslationAbnormal
236f6603c60Sopenharmony_ci * @tc.desc: Test for creating a translation matrix with abnormal parameters.
237f6603c60Sopenharmony_ci * @tc.size  : SmallTest
238f6603c60Sopenharmony_ci * @tc.type  : Function
239f6603c60Sopenharmony_ci * @tc.level : Level 3
240f6603c60Sopenharmony_ci */
241f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateTranslationAbnormal, TestSize.Level3) {
242f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateTranslation with the first parameter as a negative number
243f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(-10.0f, 10.0f);
244f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateTranslation with the second parameter as a negative number
245f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(10.0f, -10.0f);
246f6603c60Sopenharmony_ci    // 3. Free memory
247f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
248f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
249f6603c60Sopenharmony_ci}
250f6603c60Sopenharmony_ci
251f6603c60Sopenharmony_ci/*
252f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0303
253f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateTranslationMaximum
254f6603c60Sopenharmony_ci * @tc.desc: Test for creating a translation matrix with maximum values.
255f6603c60Sopenharmony_ci * @tc.size  : SmallTest
256f6603c60Sopenharmony_ci * @tc.type  : Function
257f6603c60Sopenharmony_ci * @tc.level : Level 3
258f6603c60Sopenharmony_ci */
259f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateTranslationMaximum, TestSize.Level3) {
260f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateTranslation with the first parameter as the maximum value
261f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(FLT_MAX, 10.0f);
262f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateTranslation with the second parameter as the maximum value
263f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateTranslation(10.0f, FLT_MAX);
264f6603c60Sopenharmony_ci    // 3. Free memory
265f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
266f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
267f6603c60Sopenharmony_ci}
268f6603c60Sopenharmony_ci
269f6603c60Sopenharmony_ci/*
270f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0304
271f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateTranslationMultipleCalls
272f6603c60Sopenharmony_ci * @tc.desc: Test for multiple calls of creating a translation matrix.
273f6603c60Sopenharmony_ci * @tc.size  : SmallTest
274f6603c60Sopenharmony_ci * @tc.type  : Function
275f6603c60Sopenharmony_ci * @tc.level : Level 3
276f6603c60Sopenharmony_ci */
277f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateTranslationMultipleCalls, TestSize.Level3) {
278f6603c60Sopenharmony_ci    std::random_device rd;
279f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
280f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
281f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_MatrixCreateTranslation 10 times, each time with different random values for dx and dy
282f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
283f6603c60Sopenharmony_ci        float dx = dis(gen);
284f6603c60Sopenharmony_ci        float dy = dis(gen);
285f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateTranslation(dx, dy);
286f6603c60Sopenharmony_ci        EXPECT_NE(matrix, nullptr);
287f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
288f6603c60Sopenharmony_ci    }
289f6603c60Sopenharmony_ci}
290f6603c60Sopenharmony_ci
291f6603c60Sopenharmony_ci/*
292f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0400
293f6603c60Sopenharmony_ci * @tc.name: testMatrixMatrixSetGetMatrixNormal
294f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting matrix values with normal parameters.
295f6603c60Sopenharmony_ci * @tc.size  : SmallTest
296f6603c60Sopenharmony_ci * @tc.type  : Function
297f6603c60Sopenharmony_ci * @tc.level : Level 0
298f6603c60Sopenharmony_ci */
299f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixMatrixSetGetMatrixNormal, TestSize.Level0) {
300f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
301f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
302f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
303f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixSetMatrix with integer parameters, calling OH_Drawing_MatrixGetAll and
304f6603c60Sopenharmony_ci    // OH_Drawing_MatrixGetValue interfaces
305f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
306f6603c60Sopenharmony_ci    float value[9];
307f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code = OH_Drawing_MatrixGetAll(matrix, value);
308f6603c60Sopenharmony_ci    EXPECT_EQ(code, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
309f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(matrix, 0);
310f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 0), 1);
311f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixSetMatrix with floating-point parameters, calling OH_Drawing_MatrixGetAll and
312f6603c60Sopenharmony_ci    // OH_Drawing_MatrixGetValue interfaces
313f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1.1, 0, 0, 0, -1.1, 0, 0, 0, 1.1);
314f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code2 = OH_Drawing_MatrixGetAll(matrix, value);
315f6603c60Sopenharmony_ci    EXPECT_EQ(code2, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
316f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(matrix, 1);
317f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 1), 0);
318f6603c60Sopenharmony_ci    // 4. Free memory
319f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
320f6603c60Sopenharmony_ci}
321f6603c60Sopenharmony_ci
322f6603c60Sopenharmony_ci/*
323f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0401
324f6603c60Sopenharmony_ci * @tc.name: testMatrixMatrixSetGetMatrixNull
325f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting matrix values with NULL parameters.
326f6603c60Sopenharmony_ci * @tc.size  : SmallTest
327f6603c60Sopenharmony_ci * @tc.type  : Function
328f6603c60Sopenharmony_ci * @tc.level : Level 3
329f6603c60Sopenharmony_ci */
330f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixMatrixSetGetMatrixNull, TestSize.Level3) {
331f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
332f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
333f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
334f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixSetMatrix with the first parameter as null, check the error code with OH_Drawing_ErrorCodeGet
335f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(nullptr, 1, 0, 0, 0, -1, 0, 0, 0, 1);
336f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
337f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixSetMatrix with the second to tenth parameters as null
338f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 0, 1, 1, 1, 1, 1, 1, 1, 1);
339f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 1, 1, 1, 1, 1, 1, 1);
340f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 0, 1, 1, 1, 1, 1, 1);
341f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 0, 1, 1, 1, 1, 1);
342f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 0, 1, 1, 1, 1);
343f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 0, 1, 1, 1);
344f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 0, 1, 1);
345f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, 0, 1);
346f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, 1, 0);
347f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixGetAll with the first parameter as null, check the error code with OH_Drawing_ErrorCodeGet
348f6603c60Sopenharmony_ci    float value[9];
349f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code = OH_Drawing_MatrixGetAll(nullptr, value);
350f6603c60Sopenharmony_ci    EXPECT_EQ(code, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
351f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixGetAll with the second parameter as an empty array, check the error code with
352f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet
353f6603c60Sopenharmony_ci    float value2[0];
354f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code2 = OH_Drawing_MatrixGetAll(matrix, value2);
355f6603c60Sopenharmony_ci    EXPECT_EQ(code2, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
356f6603c60Sopenharmony_ci    // 6. OH_Drawing_MatrixGetAll with the second parameter as null, check the error code with OH_Drawing_ErrorCodeGet
357f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code3 = OH_Drawing_MatrixGetAll(matrix, nullptr);
358f6603c60Sopenharmony_ci    EXPECT_EQ(code3, OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
359f6603c60Sopenharmony_ci    // 7. OH_Drawing_MatrixGetValue with the first parameter as null, check the error code with OH_Drawing_ErrorCodeGet
360f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(nullptr, 0);
361f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
362f6603c60Sopenharmony_ci    // 8. OH_Drawing_MatrixGetValue with the second parameter as null
363f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(matrix, 0);
364f6603c60Sopenharmony_ci    // 9. Free memory
365f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
366f6603c60Sopenharmony_ci}
367f6603c60Sopenharmony_ci
368f6603c60Sopenharmony_ci/*
369f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0402
370f6603c60Sopenharmony_ci * @tc.name: testMatrixMatrixSetGetMatrixAbnormal
371f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting matrix values with abnormal parameters.
372f6603c60Sopenharmony_ci * @tc.size  : SmallTest
373f6603c60Sopenharmony_ci * @tc.type  : Function
374f6603c60Sopenharmony_ci * @tc.level : Level 3
375f6603c60Sopenharmony_ci */
376f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixMatrixSetGetMatrixAbnormal, TestSize.Level3) {
377f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
378f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
379f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixSetMatrix with the second to tenth parameters as negative numbers
380f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, -1, 1, 1, 1, 1, 1, 1, 1, 1);
381f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, -1, 1, 1, 1, 1, 1, 1, 1);
382f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, -1, 1, 1, 1, 1, 1, 1);
383f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, -1, 1, 1, 1, 1, 1);
384f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, -1, 1, 1, 1, 1);
385f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, -1, 1, 1, 1);
386f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, -1, 1, 1);
387f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, -1, 1);
388f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, 1, -1);
389f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixGetAll with an array 'value' of length less than 9
390f6603c60Sopenharmony_ci    float value2[9];
391f6603c60Sopenharmony_ci    OH_Drawing_ErrorCode code2 = OH_Drawing_MatrixGetAll(matrix, value2);
392f6603c60Sopenharmony_ci    EXPECT_EQ(code2, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
393f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixGetValue with the parameter 'index' as -1, check the error code with OH_Drawing_ErrorCodeGet
394f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(matrix, -1);
395f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
396f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixGetValue with the parameter 'index' as 9, check the error code with OH_Drawing_ErrorCodeGet
397f6603c60Sopenharmony_ci    OH_Drawing_MatrixGetValue(matrix, 9);
398f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
399f6603c60Sopenharmony_ci    // 6. Free memory
400f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
401f6603c60Sopenharmony_ci}
402f6603c60Sopenharmony_ci
403f6603c60Sopenharmony_ci/*
404f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0403
405f6603c60Sopenharmony_ci * @tc.name: testMatrixMatrixSetGetMatrixMaximum
406f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting matrix values with maximum values.
407f6603c60Sopenharmony_ci * @tc.size  : SmallTest
408f6603c60Sopenharmony_ci * @tc.type  : Function
409f6603c60Sopenharmony_ci * @tc.level : Level 3
410f6603c60Sopenharmony_ci */
411f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixMatrixSetGetMatrixMaximum, TestSize.Level3) {
412f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixSetMatrix with the second to tenth parameters as maximum values
413f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
414f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, FLT_MAX, 1, 1, 1, 1, 1, 1, 1, 1);
415f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, FLT_MAX, 1, 1, 1, 1, 1, 1, 1);
416f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, FLT_MAX, 1, 1, 1, 1, 1, 1);
417f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, FLT_MAX, 1, 1, 1, 1, 1);
418f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, FLT_MAX, 1, 1, 1, 1);
419f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, FLT_MAX, 1, 1, 1);
420f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, FLT_MAX, 1, 1);
421f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, FLT_MAX, 1);
422f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetMatrix(matrix, 1, 1, 1, 1, 1, 1, 1, 1, FLT_MAX);
423f6603c60Sopenharmony_ci    // 2. Free memory
424f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
425f6603c60Sopenharmony_ci}
426f6603c60Sopenharmony_ci
427f6603c60Sopenharmony_ci/*
428f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0404
429f6603c60Sopenharmony_ci * @tc.name: testMatrixMatrixSetGetMatrixMultipleCalls
430f6603c60Sopenharmony_ci * @tc.desc: Test for multiple calls of setting and getting matrix values.
431f6603c60Sopenharmony_ci * @tc.size  : SmallTest
432f6603c60Sopenharmony_ci * @tc.type  : Function
433f6603c60Sopenharmony_ci * @tc.level : Level 3
434f6603c60Sopenharmony_ci */
435f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixMatrixSetGetMatrixMultipleCalls, TestSize.Level3) {
436f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
437f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
438f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixSetMatrix with random parameters, calling the interface 10 times, corresponding to calling
439f6603c60Sopenharmony_ci    // OH_Drawing_MatrixGetAll and OH_Drawing_MatrixGetValue interfaces
440f6603c60Sopenharmony_ci    std::random_device rd;
441f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
442f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
443f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
444f6603c60Sopenharmony_ci        float value[9];
445f6603c60Sopenharmony_ci        float val0 = dis(gen);
446f6603c60Sopenharmony_ci        float val1 = dis(gen);
447f6603c60Sopenharmony_ci        float val2 = dis(gen);
448f6603c60Sopenharmony_ci        float val3 = dis(gen);
449f6603c60Sopenharmony_ci        float val4 = dis(gen);
450f6603c60Sopenharmony_ci        float val5 = dis(gen);
451f6603c60Sopenharmony_ci        float val6 = dis(gen);
452f6603c60Sopenharmony_ci        float val7 = dis(gen);
453f6603c60Sopenharmony_ci        float val8 = dis(gen);
454f6603c60Sopenharmony_ci        OH_Drawing_MatrixSetMatrix(matrix, val0, val1, val2, val3, val4, val5, val6, val7, val8);
455f6603c60Sopenharmony_ci        OH_Drawing_ErrorCode code = OH_Drawing_MatrixGetAll(matrix, value);
456f6603c60Sopenharmony_ci        EXPECT_EQ(code, OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
457f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 0), val0);
458f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 1), val1);
459f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 2), val2);
460f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 3), val3);
461f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 4), val4);
462f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 5), val5);
463f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 6), val6);
464f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 7), val7);
465f6603c60Sopenharmony_ci        EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix, 8), val8);
466f6603c60Sopenharmony_ci    }
467f6603c60Sopenharmony_ci    // 3. Free memory
468f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
469f6603c60Sopenharmony_ci}
470f6603c60Sopenharmony_ci
471f6603c60Sopenharmony_ci/*
472f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0500
473f6603c60Sopenharmony_ci * @tc.name: testMatrixTranslateNormal
474f6603c60Sopenharmony_ci * @tc.desc: Test for translating a matrix with normal parameters.
475f6603c60Sopenharmony_ci * @tc.size  : SmallTest
476f6603c60Sopenharmony_ci * @tc.type  : Function
477f6603c60Sopenharmony_ci * @tc.level : Level 0
478f6603c60Sopenharmony_ci */
479f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixTranslateNormal, TestSize.Level0) {
480f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
481f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
482f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
483f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixTranslate, passing in floating point numbers
484f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 10.0f, 10.0f);
485f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixTranslate, passing in integers
486f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 20, 20);
487f6603c60Sopenharmony_ci    // 4. Free memory
488f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
489f6603c60Sopenharmony_ci}
490f6603c60Sopenharmony_ci
491f6603c60Sopenharmony_ci/*
492f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0501
493f6603c60Sopenharmony_ci * @tc.name: testMatrixTranslateNull
494f6603c60Sopenharmony_ci * @tc.desc: Test for translating a matrix with NULL parameters.
495f6603c60Sopenharmony_ci * @tc.size  : SmallTest
496f6603c60Sopenharmony_ci * @tc.type  : Function
497f6603c60Sopenharmony_ci * @tc.level : Level 3
498f6603c60Sopenharmony_ci */
499f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixTranslateNull, TestSize.Level3) {
500f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
501f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
502f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
503f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixTranslate with the first parameter as null, check the error code with OH_Drawing_ErrorCodeGet
504f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(nullptr, 10.0f, 10.0f);
505f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
506f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixTranslate with the second parameter as null
507f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 0, 10.0f);
508f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixTranslate with the third parameter as null
509f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 10.0f, 0);
510f6603c60Sopenharmony_ci    // 5. Free memory
511f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
512f6603c60Sopenharmony_ci}
513f6603c60Sopenharmony_ci
514f6603c60Sopenharmony_ci/*
515f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0502
516f6603c60Sopenharmony_ci * @tc.name: testMatrixTranslateAbnormal
517f6603c60Sopenharmony_ci * @tc.desc: Test for translating a matrix with abnormal parameters.
518f6603c60Sopenharmony_ci * @tc.size  : SmallTest
519f6603c60Sopenharmony_ci * @tc.type  : Function
520f6603c60Sopenharmony_ci * @tc.level : Level 3
521f6603c60Sopenharmony_ci */
522f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixTranslateAbnormal, TestSize.Level3) {
523f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
524f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
525f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
526f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixTranslate with the second parameter as a negative number
527f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, -10.0f, 10.0f);
528f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixTranslate with the third parameter as a negative number
529f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 10.0f, -10.0f);
530f6603c60Sopenharmony_ci    // 4. Free memory
531f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
532f6603c60Sopenharmony_ci}
533f6603c60Sopenharmony_ci
534f6603c60Sopenharmony_ci/*
535f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0503
536f6603c60Sopenharmony_ci * @tc.name: testMatrixTranslateMaximum
537f6603c60Sopenharmony_ci * @tc.desc: Test for translating a matrix with maximum values.
538f6603c60Sopenharmony_ci * @tc.size  : SmallTest
539f6603c60Sopenharmony_ci * @tc.type  : Function
540f6603c60Sopenharmony_ci * @tc.level : Level 3
541f6603c60Sopenharmony_ci */
542f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixTranslateMaximum, TestSize.Level3) {
543f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
544f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
545f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
546f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixTranslate with the second parameter as the maximum value
547f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, FLT_MAX, 10.0f);
548f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixTranslate with the third parameter as the maximum value
549f6603c60Sopenharmony_ci    OH_Drawing_MatrixTranslate(matrix, 10.0f, FLT_MAX);
550f6603c60Sopenharmony_ci    // 4. Free memory
551f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
552f6603c60Sopenharmony_ci}
553f6603c60Sopenharmony_ci
554f6603c60Sopenharmony_ci/*
555f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0504
556f6603c60Sopenharmony_ci * @tc.name: testMatrixTranslateMultipleCalls
557f6603c60Sopenharmony_ci * @tc.desc: Test for multiple calls of translating a matrix.
558f6603c60Sopenharmony_ci * @tc.size  : SmallTest
559f6603c60Sopenharmony_ci * @tc.type  : Function
560f6603c60Sopenharmony_ci * @tc.level : Level 3
561f6603c60Sopenharmony_ci */
562f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixTranslateMultipleCalls, TestSize.Level3) {
563f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
564f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
565f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
566f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixTranslate, passing in random numbers for dx and dy
567f6603c60Sopenharmony_ci    std::random_device rd;
568f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
569f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
570f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
571f6603c60Sopenharmony_ci        float dx = dis(gen);
572f6603c60Sopenharmony_ci        float dy = dis(gen);
573f6603c60Sopenharmony_ci        OH_Drawing_MatrixTranslate(matrix, dx, dy);
574f6603c60Sopenharmony_ci    }
575f6603c60Sopenharmony_ci    // 3. Free memory
576f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
577f6603c60Sopenharmony_ci}
578f6603c60Sopenharmony_ci
579f6603c60Sopenharmony_ci/*
580f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0600
581f6603c60Sopenharmony_ci * @tc.name: testMatrixRotateNormal
582f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixRotateNormal.
583f6603c60Sopenharmony_ci * @tc.size  : SmallTest
584f6603c60Sopenharmony_ci * @tc.type  : Function
585f6603c60Sopenharmony_ci * @tc.level : Level 0
586f6603c60Sopenharmony_ci */
587f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixRotateNormal, TestSize.Level0) {
588f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
589f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
590f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
591f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixRotate, rotate angles include 0 degrees, 180 degrees, 360 degrees, -90 degrees, -180 degrees,
592f6603c60Sopenharmony_ci    // -360 degrees, and 45.5 degrees, px and py cover both decimals and integers
593f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 0, 0, 0);
594f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, 10, 10);
595f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 360, 10.0f, 10.0f);
596f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, -90, 20, 20);
597f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, -180, 20.0f, 20.0f);
598f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, -360, 30, 30);
599f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 45.5, 30.0f, 30.0f);
600f6603c60Sopenharmony_ci    // 3. Free memory
601f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
602f6603c60Sopenharmony_ci}
603f6603c60Sopenharmony_ci
604f6603c60Sopenharmony_ci/*
605f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0601
606f6603c60Sopenharmony_ci * @tc.name: testMatrixRotateNull
607f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixRotateNull.
608f6603c60Sopenharmony_ci * @tc.size  : SmallTest
609f6603c60Sopenharmony_ci * @tc.type  : Function
610f6603c60Sopenharmony_ci * @tc.level : Level 3
611f6603c60Sopenharmony_ci */
612f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixRotateNull, TestSize.Level3) {
613f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
614f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
615f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
616f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixRotate with the first parameter as null, check the error code with OH_Drawing_ErrorCodeGet
617f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(nullptr, 180, 10, 10);
618f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
619f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixRotate with the second parameter as null
620f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 0, 10, 10);
621f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixRotate with the third parameter as null
622f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, 0, 10);
623f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixRotate with the fourth parameter as null
624f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, 10, 0);
625f6603c60Sopenharmony_ci    // 6. Free memory
626f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
627f6603c60Sopenharmony_ci}
628f6603c60Sopenharmony_ci
629f6603c60Sopenharmony_ci/*
630f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0602
631f6603c60Sopenharmony_ci * @tc.name: testMatrixRotateAbnormal
632f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixRotateAbnormal.
633f6603c60Sopenharmony_ci * @tc.size  : SmallTest
634f6603c60Sopenharmony_ci * @tc.type  : Function
635f6603c60Sopenharmony_ci * @tc.level : Level 3
636f6603c60Sopenharmony_ci */
637f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixRotateAbnormal, TestSize.Level3) {
638f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
639f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
640f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixRotate with the third parameter as a negative number
641f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, -10, 10);
642f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixRotate with the fourth parameter as a negative number
643f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, 10, -10);
644f6603c60Sopenharmony_ci    // 4. Free memory
645f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
646f6603c60Sopenharmony_ci}
647f6603c60Sopenharmony_ci
648f6603c60Sopenharmony_ci/*
649f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0603
650f6603c60Sopenharmony_ci * @tc.name: testMatrixRotateMaximum
651f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixRotateMaximum.
652f6603c60Sopenharmony_ci * @tc.size  : SmallTest
653f6603c60Sopenharmony_ci * @tc.type  : Function
654f6603c60Sopenharmony_ci * @tc.level : Level 3
655f6603c60Sopenharmony_ci */
656f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixRotateMaximum, TestSize.Level3) {
657f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
658f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
659f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixRotate with the second parameter as the maximum value
660f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, FLT_MAX, 10.0f, 10.0f);
661f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixRotate with the third parameter as the maximum value
662f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, FLT_MAX, 10.0f);
663f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixRotate with the fourth parameter as the maximum value
664f6603c60Sopenharmony_ci    OH_Drawing_MatrixRotate(matrix, 180, 10.0f, FLT_MAX);
665f6603c60Sopenharmony_ci    // 5. Free memory
666f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
667f6603c60Sopenharmony_ci}
668f6603c60Sopenharmony_ci
669f6603c60Sopenharmony_ci/*
670f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0604
671f6603c60Sopenharmony_ci * @tc.name: testMatrixRotateMultipleCalls
672f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixRotateMultipleCalls.
673f6603c60Sopenharmony_ci * @tc.size  : SmallTest
674f6603c60Sopenharmony_ci * @tc.type  : Function
675f6603c60Sopenharmony_ci * @tc.level : Level 3
676f6603c60Sopenharmony_ci */
677f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixRotateMultipleCalls, TestSize.Level3) {
678f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
679f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
680f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixRotate, passing in random numbers for degree, px, and py
681f6603c60Sopenharmony_ci    std::random_device rd;
682f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
683f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
684f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
685f6603c60Sopenharmony_ci        float degree = dis(gen);
686f6603c60Sopenharmony_ci        float px = dis(gen);
687f6603c60Sopenharmony_ci        float py = dis(gen);
688f6603c60Sopenharmony_ci        OH_Drawing_MatrixRotate(matrix, degree, px, py);
689f6603c60Sopenharmony_ci    }
690f6603c60Sopenharmony_ci    // 3. Free memory
691f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
692f6603c60Sopenharmony_ci}
693f6603c60Sopenharmony_ci
694f6603c60Sopenharmony_ci/*
695f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0700
696f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateScaleNormal
697f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixCreateScaleNormal.
698f6603c60Sopenharmony_ci * @tc.size  : SmallTest
699f6603c60Sopenharmony_ci * @tc.type  : Function
700f6603c60Sopenharmony_ci * @tc.level : Level 0
701f6603c60Sopenharmony_ci */
702f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateScaleNormal, TestSize.Level0) {
703f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateScale, passing in decimals
704f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, 10.0f, 10.0f);
705f6603c60Sopenharmony_ci    EXPECT_NE(matrix, nullptr);
706f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateScale, passing in integers
707f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateScale(20, 20, 20, 20);
708f6603c60Sopenharmony_ci    EXPECT_NE(matrix2, nullptr);
709f6603c60Sopenharmony_ci    // 3. Free memory
710f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
711f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
712f6603c60Sopenharmony_ci}
713f6603c60Sopenharmony_ci
714f6603c60Sopenharmony_ci/*
715f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0701
716f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateScaleNull
717f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixCreateScaleNull.
718f6603c60Sopenharmony_ci * @tc.size  : SmallTest
719f6603c60Sopenharmony_ci * @tc.type  : Function
720f6603c60Sopenharmony_ci * @tc.level : Level 3
721f6603c60Sopenharmony_ci */
722f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateScaleNull, TestSize.Level3) {
723f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateScale with the first parameter as null
724f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(0, 10.0f, 10.0f, 10.0f);
725f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateScale with the second parameter as null
726f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateScale(10.0f, 0, 10.0f, 10.0f);
727f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateScale with the third parameter as null
728f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, 0, 10.0f);
729f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixCreateScale with the fourth parameter as null
730f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix4 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, 10.0f, 0);
731f6603c60Sopenharmony_ci    // 5. Free memory
732f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
733f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
734f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
735f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix4);
736f6603c60Sopenharmony_ci}
737f6603c60Sopenharmony_ci
738f6603c60Sopenharmony_ci/*
739f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0702
740f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateScaleAbnormal
741f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixCreateScaleAbnormal.
742f6603c60Sopenharmony_ci * @tc.size  : SmallTest
743f6603c60Sopenharmony_ci * @tc.type  : Function
744f6603c60Sopenharmony_ci * @tc.level : Level 3
745f6603c60Sopenharmony_ci */
746f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateScaleAbnormal, TestSize.Level3) {
747f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateScale with the first parameter as a negative number
748f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(-10.0f, 10.0f, 10.0f, 10.0f);
749f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateScale with the second parameter as a negative number
750f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateScale(10.0f, -10.0f, 10.0f, 10.0f);
751f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateScale with the third parameter as a negative number
752f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, -10.0f, 10.0f);
753f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixCreateScale with the fourth parameter as a negative number
754f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix4 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, 10.0f, -10.0f);
755f6603c60Sopenharmony_ci    // 5. Free memory
756f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
757f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
758f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
759f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix4);
760f6603c60Sopenharmony_ci}
761f6603c60Sopenharmony_ci
762f6603c60Sopenharmony_ci/*
763f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0703
764f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateScaleMaximum
765f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixCreateScaleMaximum.
766f6603c60Sopenharmony_ci * @tc.size  : SmallTest
767f6603c60Sopenharmony_ci * @tc.type  : Function
768f6603c60Sopenharmony_ci * @tc.level : Level 3
769f6603c60Sopenharmony_ci */
770f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateScaleMaximum, TestSize.Level3) {
771f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreateScale with the first parameter as the maximum value
772f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(FLT_MAX, 10.0f, 10.0f, 10.0f);
773f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixCreateScale with the second parameter as the maximum value
774f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreateScale(10.0f, FLT_MAX, 10.0f, 10.0f);
775f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixCreateScale with the third parameter as the maximum value
776f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, FLT_MAX, 10.0f);
777f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixCreateScale with the fourth parameter as the maximum value
778f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix4 = OH_Drawing_MatrixCreateScale(10.0f, 10.0f, 10.0f, FLT_MAX);
779f6603c60Sopenharmony_ci    // 5. Free memory
780f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
781f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix2);
782f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix3);
783f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix4);
784f6603c60Sopenharmony_ci}
785f6603c60Sopenharmony_ci
786f6603c60Sopenharmony_ci/*
787f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0704
788f6603c60Sopenharmony_ci * @tc.name: testMatrixCreateScaleMultipleCalls
789f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixCreateScaleMultipleCalls.
790f6603c60Sopenharmony_ci * @tc.size  : SmallTest
791f6603c60Sopenharmony_ci * @tc.type  : Function
792f6603c60Sopenharmony_ci * @tc.level : Level 3
793f6603c60Sopenharmony_ci */
794f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixCreateScaleMultipleCalls, TestSize.Level3) {
795f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_MatrixCreateScale 10 times with random numbers for sx, sy, px, and py, and ensure successful
796f6603c60Sopenharmony_ci    // execution
797f6603c60Sopenharmony_ci    std::random_device rd;
798f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
799f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
800f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
801f6603c60Sopenharmony_ci        float sx = dis(gen);
802f6603c60Sopenharmony_ci        float sy = dis(gen);
803f6603c60Sopenharmony_ci        float px = dis(gen);
804f6603c60Sopenharmony_ci        float py = dis(gen);
805f6603c60Sopenharmony_ci        OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreateScale(sx, sy, px, py);
806f6603c60Sopenharmony_ci        EXPECT_NE(matrix, nullptr);
807f6603c60Sopenharmony_ci        OH_Drawing_MatrixDestroy(matrix);
808f6603c60Sopenharmony_ci    }
809f6603c60Sopenharmony_ci}
810f6603c60Sopenharmony_ci
811f6603c60Sopenharmony_ci/*
812f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0800
813f6603c60Sopenharmony_ci * @tc.name: testMatrixScaleNormal
814f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixScaleNormal.
815f6603c60Sopenharmony_ci * @tc.size  : SmallTest
816f6603c60Sopenharmony_ci * @tc.type  : Function
817f6603c60Sopenharmony_ci * @tc.level : Level 0
818f6603c60Sopenharmony_ci */
819f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixScaleNormal, TestSize.Level0) {
820f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
821f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
822f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixScale, passing in decimals
823f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, 10.0f, 10.0f);
824f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixScale, passing in integers
825f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 20, 20, 20, 20);
826f6603c60Sopenharmony_ci    // 4. Free memory
827f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
828f6603c60Sopenharmony_ci}
829f6603c60Sopenharmony_ci
830f6603c60Sopenharmony_ci/*
831f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0801
832f6603c60Sopenharmony_ci * @tc.name: testMatrixScaleNull
833f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixScaleNull.
834f6603c60Sopenharmony_ci * @tc.size  : SmallTest
835f6603c60Sopenharmony_ci * @tc.type  : Function
836f6603c60Sopenharmony_ci * @tc.level : Level 3
837f6603c60Sopenharmony_ci */
838f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixScaleNull, TestSize.Level3) {
839f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
840f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
841f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixScale with the first parameter as null, check the error code using OH_Drawing_ErrorCodeGet
842f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(nullptr, 10.0f, 10.0f, 10.0f, 10.0f);
843f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
844f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixScale with the second parameter as null
845f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 0, 10.0f, 10.0f, 10.0f);
846f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixScale with the third parameter as null
847f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 0, 10.0f, 10.0f);
848f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixScale with the fourth parameter as null
849f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, 0, 10.0f);
850f6603c60Sopenharmony_ci    // 6. OH_Drawing_MatrixScale with the fifth parameter as null
851f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, 10.0f, 0);
852f6603c60Sopenharmony_ci    // 7. Free memory
853f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
854f6603c60Sopenharmony_ci}
855f6603c60Sopenharmony_ci
856f6603c60Sopenharmony_ci/*
857f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0802
858f6603c60Sopenharmony_ci * @tc.name: testMatrixScaleAbnormal
859f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixScaleAbnormal.
860f6603c60Sopenharmony_ci * @tc.size  : SmallTest
861f6603c60Sopenharmony_ci * @tc.type  : Function
862f6603c60Sopenharmony_ci * @tc.level : Level 3
863f6603c60Sopenharmony_ci */
864f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixScaleAbnormal, TestSize.Level3) {
865f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
866f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
867f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixScale with the second parameter as a negative number
868f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, -10.0f, 10.0f, 10.0f, 10.0f);
869f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixScale with the third parameter as a negative number
870f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, -10.0f, 10.0f, 10.0f);
871f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixScale with the fourth parameter as a negative number
872f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, -10.0f, 10.0f);
873f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixScale with the fifth parameter as a negative number
874f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, 10.0f, -10.0f);
875f6603c60Sopenharmony_ci    // 6. Free memory
876f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
877f6603c60Sopenharmony_ci}
878f6603c60Sopenharmony_ci
879f6603c60Sopenharmony_ci/*
880f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0803
881f6603c60Sopenharmony_ci * @tc.name: testMatrixScaleMaximum
882f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixScaleMaximum.
883f6603c60Sopenharmony_ci * @tc.size  : SmallTest
884f6603c60Sopenharmony_ci * @tc.type  : Function
885f6603c60Sopenharmony_ci * @tc.level : Level 3
886f6603c60Sopenharmony_ci */
887f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixScaleMaximum, TestSize.Level3) {
888f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
889f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
890f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixScale with the second parameter as the maximum value
891f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, FLT_MAX, 10.0f, 10.0f, 10.0f);
892f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixScale with the third parameter as the maximum value
893f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, FLT_MAX, 10.0f, 10.0f);
894f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixScale with the fourth parameter as the maximum value
895f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, FLT_MAX, 10.0f);
896f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixScale with the fifth parameter as the maximum value
897f6603c60Sopenharmony_ci    OH_Drawing_MatrixScale(matrix, 10.0f, 10.0f, 10.0f, FLT_MAX);
898f6603c60Sopenharmony_ci    // 6. Free memory
899f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
900f6603c60Sopenharmony_ci}
901f6603c60Sopenharmony_ci
902f6603c60Sopenharmony_ci/*
903f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0804
904f6603c60Sopenharmony_ci * @tc.name: testMatrixScaleMultipleCalls
905f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixScaleMultipleCalls.
906f6603c60Sopenharmony_ci * @tc.size  : SmallTest
907f6603c60Sopenharmony_ci * @tc.type  : Function
908f6603c60Sopenharmony_ci * @tc.level : Level 3
909f6603c60Sopenharmony_ci */
910f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixScaleMultipleCalls, TestSize.Level3) {
911f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
912f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
913f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixCreateScale 10 times with random numbers for sx, sy, px, and py
914f6603c60Sopenharmony_ci    std::random_device rd;
915f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
916f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
917f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
918f6603c60Sopenharmony_ci        float sx = dis(gen);
919f6603c60Sopenharmony_ci        float sy = dis(gen);
920f6603c60Sopenharmony_ci        float px = dis(gen);
921f6603c60Sopenharmony_ci        float py = dis(gen);
922f6603c60Sopenharmony_ci        OH_Drawing_MatrixScale(matrix, sx, sy, px, py);
923f6603c60Sopenharmony_ci    }
924f6603c60Sopenharmony_ci    // 3. Free memory
925f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
926f6603c60Sopenharmony_ci}
927f6603c60Sopenharmony_ci
928f6603c60Sopenharmony_ci/*
929f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0900
930f6603c60Sopenharmony_ci * @tc.name: testMatrixSetRectToRectNormal
931f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixSetRectToRectNormal.
932f6603c60Sopenharmony_ci * @tc.size  : SmallTest
933f6603c60Sopenharmony_ci * @tc.type  : Function
934f6603c60Sopenharmony_ci * @tc.level : Level 0
935f6603c60Sopenharmony_ci */
936f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixSetRectToRectNormal, TestSize.Level0) {
937f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
938f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
939f6603c60Sopenharmony_ci    // 2. Enumerate OH_Drawing_ScaleToFit values in OH_Drawing_MatrixSetRectToRect
940f6603c60Sopenharmony_ci    OH_Drawing_Rect *rectSrc = OH_Drawing_RectCreate(0, 0, 100, 100);
941f6603c60Sopenharmony_ci    OH_Drawing_Rect *rectDst = OH_Drawing_RectCreate(0, 0, 200, 200);
942f6603c60Sopenharmony_ci    OH_Drawing_ScaleToFit fitList[] = {
943f6603c60Sopenharmony_ci        SCALE_TO_FIT_FILL,
944f6603c60Sopenharmony_ci        SCALE_TO_FIT_START,
945f6603c60Sopenharmony_ci        SCALE_TO_FIT_CENTER,
946f6603c60Sopenharmony_ci        SCALE_TO_FIT_END,
947f6603c60Sopenharmony_ci    };
948f6603c60Sopenharmony_ci    for (OH_Drawing_ScaleToFit fit : fitList) {
949f6603c60Sopenharmony_ci        bool isSuccess = OH_Drawing_MatrixSetRectToRect(matrix, rectSrc, rectDst, fit);
950f6603c60Sopenharmony_ci        EXPECT_EQ(isSuccess, true);
951f6603c60Sopenharmony_ci    }
952f6603c60Sopenharmony_ci    // 3. Free memory
953f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
954f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rectSrc);
955f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rectDst);
956f6603c60Sopenharmony_ci}
957f6603c60Sopenharmony_ci
958f6603c60Sopenharmony_ci/*
959f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0901
960f6603c60Sopenharmony_ci * @tc.name: testMatrixSetRectToRectNull
961f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixSetRectToRectNull.
962f6603c60Sopenharmony_ci * @tc.size  : SmallTest
963f6603c60Sopenharmony_ci * @tc.type  : Function
964f6603c60Sopenharmony_ci * @tc.level : Level 3
965f6603c60Sopenharmony_ci */
966f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixSetRectToRectNull, TestSize.Level3) {
967f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
968f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
969f6603c60Sopenharmony_ci    OH_Drawing_Rect *rectSrc = OH_Drawing_RectCreate(0, 0, 0, 0);
970f6603c60Sopenharmony_ci    OH_Drawing_Rect *rectDst = OH_Drawing_RectCreate(0, 0, 0, 0);
971f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixSetRectToRect, the first parameter is null, check the error code using
972f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet
973f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetRectToRect(nullptr, rectSrc, rectDst, SCALE_TO_FIT_FILL);
974f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
975f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixSetRectToRect, the second parameter is null, check the error code using
976f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet
977f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetRectToRect(matrix, nullptr, rectDst, SCALE_TO_FIT_FILL);
978f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
979f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixSetRectToRect, the third parameter is null, check the error code using
980f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet
981f6603c60Sopenharmony_ci    OH_Drawing_MatrixSetRectToRect(matrix, rectSrc, nullptr, SCALE_TO_FIT_FILL);
982f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
983f6603c60Sopenharmony_ci    // 5. Free memory
984f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
985f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rectSrc);
986f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rectDst);
987f6603c60Sopenharmony_ci}
988f6603c60Sopenharmony_ci
989f6603c60Sopenharmony_ci/*
990f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_0902
991f6603c60Sopenharmony_ci * @tc.name: testMatrixSetRectToRectMultipleCalls
992f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixSetRectToRectMultipleCalls.
993f6603c60Sopenharmony_ci * @tc.size  : SmallTest
994f6603c60Sopenharmony_ci * @tc.type  : Function
995f6603c60Sopenharmony_ci * @tc.level : Level 3
996f6603c60Sopenharmony_ci */
997f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixSetRectToRectMultipleCalls, TestSize.Level3) {
998f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
999f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1000f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixSetRectToRect 10 times with random enum values and different rect sizes
1001f6603c60Sopenharmony_ci    std::random_device rd;
1002f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1003f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1004f6603c60Sopenharmony_ci    OH_Drawing_ScaleToFit fitList[] = {
1005f6603c60Sopenharmony_ci        SCALE_TO_FIT_FILL,
1006f6603c60Sopenharmony_ci        SCALE_TO_FIT_START,
1007f6603c60Sopenharmony_ci        SCALE_TO_FIT_CENTER,
1008f6603c60Sopenharmony_ci        SCALE_TO_FIT_END,
1009f6603c60Sopenharmony_ci    };
1010f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1011f6603c60Sopenharmony_ci        OH_Drawing_Rect *rectSrc = OH_Drawing_RectCreate(dis(gen), dis(gen), dis(gen) + 100, dis(gen) + 100);
1012f6603c60Sopenharmony_ci        OH_Drawing_Rect *rectDst = OH_Drawing_RectCreate(dis(gen), dis(gen), dis(gen) + 200, dis(gen) + 200);
1013f6603c60Sopenharmony_ci        OH_Drawing_ScaleToFit fit = fitList[i % 4];
1014f6603c60Sopenharmony_ci        bool isSuccess = OH_Drawing_MatrixSetRectToRect(matrix, rectSrc, rectDst, fit);
1015f6603c60Sopenharmony_ci        EXPECT_EQ(isSuccess, true);
1016f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rectSrc);
1017f6603c60Sopenharmony_ci        OH_Drawing_RectDestroy(rectDst);
1018f6603c60Sopenharmony_ci    }
1019f6603c60Sopenharmony_ci}
1020f6603c60Sopenharmony_ci
1021f6603c60Sopenharmony_ci/*
1022f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1000
1023f6603c60Sopenharmony_ci * @tc.name: testMatrixPreRotateNormal
1024f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreRotateNormal.
1025f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1026f6603c60Sopenharmony_ci * @tc.type  : Function
1027f6603c60Sopenharmony_ci * @tc.level : Level 0
1028f6603c60Sopenharmony_ci */
1029f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreRotateNormal, TestSize.Level0) {
1030f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1031f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1032f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreRotate, rotate angles include 0 degrees, 180 degrees, 360 degrees, -90 degrees, -180
1033f6603c60Sopenharmony_ci    // degrees, -360 degrees, and 45.5 degrees, px and py cover both decimals and integers
1034f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 0, 0, 0);
1035f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, 10, 10);
1036f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 360, 10.0f, 10.0f);
1037f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, -90, 20, 20);
1038f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, -180, 20.0f, 20.0f);
1039f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, -360, 30, 30);
1040f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 45.5, 30.0f, 30.0f);
1041f6603c60Sopenharmony_ci    // 3. Free memory
1042f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1043f6603c60Sopenharmony_ci}
1044f6603c60Sopenharmony_ci
1045f6603c60Sopenharmony_ci/*
1046f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1001
1047f6603c60Sopenharmony_ci * @tc.name: testMatrixPreRotateNull
1048f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreRotateNull.
1049f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1050f6603c60Sopenharmony_ci * @tc.type  : Function
1051f6603c60Sopenharmony_ci * @tc.level : Level 3
1052f6603c60Sopenharmony_ci */
1053f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreRotateNull, TestSize.Level3) {
1054f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1055f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1056f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreRotate with the first parameter as null, check the error code using
1057f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet, no crash, error code returns OH_DRAWING_ERROR_INVALID_PARAMETER
1058f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(nullptr, 180, 10, 10);
1059f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
1060f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreRotate with the second parameter as null
1061f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 0, 10, 10);
1062f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreRotate with the third parameter as null
1063f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, 0, 10);
1064f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPreRotate with the fourth parameter as null
1065f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, 10, 0);
1066f6603c60Sopenharmony_ci    // 6. Free memory
1067f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1068f6603c60Sopenharmony_ci}
1069f6603c60Sopenharmony_ci
1070f6603c60Sopenharmony_ci/*
1071f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1002
1072f6603c60Sopenharmony_ci * @tc.name: testMatrixPreRotateAbnormal
1073f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreRotateAbnormal.
1074f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1075f6603c60Sopenharmony_ci * @tc.type  : Function
1076f6603c60Sopenharmony_ci * @tc.level : Level 3
1077f6603c60Sopenharmony_ci */
1078f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreRotateAbnormal, TestSize.Level3) {
1079f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1080f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1081f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreRotate with a negative value for the third parameter
1082f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, -10, 10);
1083f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreRotate with a negative value for the fourth parameter
1084f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, 10, -10);
1085f6603c60Sopenharmony_ci    // 4. Free memory
1086f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1087f6603c60Sopenharmony_ci}
1088f6603c60Sopenharmony_ci
1089f6603c60Sopenharmony_ci/*
1090f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1003
1091f6603c60Sopenharmony_ci * @tc.name: testMatrixPreRotateMaximum
1092f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreRotateMaximum.
1093f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1094f6603c60Sopenharmony_ci * @tc.type  : Function
1095f6603c60Sopenharmony_ci * @tc.level : Level 3
1096f6603c60Sopenharmony_ci */
1097f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreRotateMaximum, TestSize.Level3) {
1098f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1099f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1100f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreRotate with the second parameter as the maximum value
1101f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, FLT_MAX, 10.0f, 10.0f);
1102f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreRotate with the third parameter as the maximum value
1103f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, FLT_MAX, 10.0f);
1104f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreRotate with the fourth parameter as the maximum value
1105f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreRotate(matrix, 180, 10.0f, FLT_MAX);
1106f6603c60Sopenharmony_ci    // 5. Free memory
1107f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1108f6603c60Sopenharmony_ci}
1109f6603c60Sopenharmony_ci
1110f6603c60Sopenharmony_ci/*
1111f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1004
1112f6603c60Sopenharmony_ci * @tc.name: testMatrixPreRotateMultipleCalls
1113f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreRotateMultipleCalls.
1114f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1115f6603c60Sopenharmony_ci * @tc.type  : Function
1116f6603c60Sopenharmony_ci * @tc.level : Level 3
1117f6603c60Sopenharmony_ci */
1118f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreRotateMultipleCalls, TestSize.Level3) {
1119f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1120f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1121f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreRotate, pass in random numbers for degree, px, and py
1122f6603c60Sopenharmony_ci    std::random_device rd;
1123f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1124f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1125f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1126f6603c60Sopenharmony_ci        float degree = dis(gen);
1127f6603c60Sopenharmony_ci        float px = dis(gen);
1128f6603c60Sopenharmony_ci        float py = dis(gen);
1129f6603c60Sopenharmony_ci        OH_Drawing_MatrixPreRotate(matrix, degree, px, py);
1130f6603c60Sopenharmony_ci    }
1131f6603c60Sopenharmony_ci    // 3. Free memory
1132f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1133f6603c60Sopenharmony_ci}
1134f6603c60Sopenharmony_ci
1135f6603c60Sopenharmony_ci/*
1136f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1100
1137f6603c60Sopenharmony_ci * @tc.name: testMatrixPreScaleNormal
1138f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreScaleNormal.
1139f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1140f6603c60Sopenharmony_ci * @tc.type  : Function
1141f6603c60Sopenharmony_ci * @tc.level : Level 0
1142f6603c60Sopenharmony_ci */
1143f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreScaleNormal, TestSize.Level0) {
1144f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1145f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1146f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreScale, pass in decimals
1147f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, 10.0f, 10.0f);
1148f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreScale, pass in integers
1149f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 20, 20, 20, 20);
1150f6603c60Sopenharmony_ci    // 4. Free memory
1151f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1152f6603c60Sopenharmony_ci}
1153f6603c60Sopenharmony_ci
1154f6603c60Sopenharmony_ci/*
1155f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1101
1156f6603c60Sopenharmony_ci * @tc.name: testMatrixPreScaleNull
1157f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreScaleNull.
1158f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1159f6603c60Sopenharmony_ci * @tc.type  : Function
1160f6603c60Sopenharmony_ci * @tc.level : Level 3
1161f6603c60Sopenharmony_ci */
1162f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreScaleNull, TestSize.Level3) {
1163f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1164f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1165f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreScale, the first parameter is null, check the error code using OH_Drawing_ErrorCodeGet, no
1166f6603c60Sopenharmony_ci    // crash, error code returns OH_DRAWING_ERROR_INVALID_PARAMETER
1167f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(nullptr, 10.0f, 10.0f, 10.0f, 10.0f);
1168f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
1169f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreScale, the second parameter is null
1170f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 0, 10.0f, 10.0f, 10.0f);
1171f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreScale, the third parameter is null
1172f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 0, 10.0f, 10.0f);
1173f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPreScale, the fourth parameter is null
1174f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, 0, 10.0f);
1175f6603c60Sopenharmony_ci    // 6. OH_Drawing_MatrixPreScale, the fifth parameter is null
1176f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, 10.0f, 0);
1177f6603c60Sopenharmony_ci    // 7. Free memory
1178f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1179f6603c60Sopenharmony_ci}
1180f6603c60Sopenharmony_ci
1181f6603c60Sopenharmony_ci/*
1182f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1102
1183f6603c60Sopenharmony_ci * @tc.name: testMatrixPreScaleAbnormal
1184f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreScaleAbnormal.
1185f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1186f6603c60Sopenharmony_ci * @tc.type  : Function
1187f6603c60Sopenharmony_ci * @tc.level : Level 3
1188f6603c60Sopenharmony_ci */
1189f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreScaleAbnormal, TestSize.Level3) {
1190f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1191f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1192f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreScale, the second parameter is negative
1193f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, -10.0f, 10.0f, 10.0f, 10.0f);
1194f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreScale, the third parameter is negative
1195f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, -10.0f, 10.0f, 10.0f);
1196f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreScale, the fourth parameter is negative
1197f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, -10.0f, 10.0f);
1198f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPreScale, the fifth parameter is negative
1199f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, 10.0f, -10.0f);
1200f6603c60Sopenharmony_ci    // 6. Free memory
1201f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1202f6603c60Sopenharmony_ci}
1203f6603c60Sopenharmony_ci
1204f6603c60Sopenharmony_ci/*
1205f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1103
1206f6603c60Sopenharmony_ci * @tc.name: testMatrixPreScaleMaximum
1207f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreScaleMaximum.
1208f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1209f6603c60Sopenharmony_ci * @tc.type  : Function
1210f6603c60Sopenharmony_ci * @tc.level : Level 3
1211f6603c60Sopenharmony_ci */
1212f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreScaleMaximum, TestSize.Level3) {
1213f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1214f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1215f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreScale with the second parameter as the maximum value
1216f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, FLT_MAX, 10.0f, 10.0f, 10.0f);
1217f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreScale with the third parameter as the maximum value
1218f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, FLT_MAX, 10.0f, 10.0f);
1219f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreScale with the fourth parameter as the maximum value
1220f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, FLT_MAX, 10.0f);
1221f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPreScale with the fifth parameter as the maximum value
1222f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreScale(matrix, 10.0f, 10.0f, 10.0f, FLT_MAX);
1223f6603c60Sopenharmony_ci    // 6. Free memory
1224f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1225f6603c60Sopenharmony_ci}
1226f6603c60Sopenharmony_ci
1227f6603c60Sopenharmony_ci/*
1228f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1104
1229f6603c60Sopenharmony_ci * @tc.name: testMatrixPreScaleMultipleCalls
1230f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreScaleMultipleCalls.
1231f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1232f6603c60Sopenharmony_ci * @tc.type  : Function
1233f6603c60Sopenharmony_ci * @tc.level : Level 3
1234f6603c60Sopenharmony_ci */
1235f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreScaleMultipleCalls, TestSize.Level3) {
1236f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1237f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1238f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixCreateScale 10 times, passing in random numbers for sx, sy, px, and py
1239f6603c60Sopenharmony_ci    std::random_device rd;
1240f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1241f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1242f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1243f6603c60Sopenharmony_ci        float sx = dis(gen);
1244f6603c60Sopenharmony_ci        float sy = dis(gen);
1245f6603c60Sopenharmony_ci        float px = dis(gen);
1246f6603c60Sopenharmony_ci        float py = dis(gen);
1247f6603c60Sopenharmony_ci        OH_Drawing_MatrixPreScale(matrix, sx, sy, px, py);
1248f6603c60Sopenharmony_ci    }
1249f6603c60Sopenharmony_ci    // 3. Free memory
1250f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1251f6603c60Sopenharmony_ci}
1252f6603c60Sopenharmony_ci
1253f6603c60Sopenharmony_ci/*
1254f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1200
1255f6603c60Sopenharmony_ci * @tc.name: testMatrixPreTranslateNormal
1256f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreTranslateNormal.
1257f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1258f6603c60Sopenharmony_ci * @tc.type  : Function
1259f6603c60Sopenharmony_ci * @tc.level : Level 0
1260f6603c60Sopenharmony_ci */
1261f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreTranslateNormal, TestSize.Level0) {
1262f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1263f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1264f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreTranslate, pass in decimals
1265f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 10.0f, 10.0f);
1266f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreTranslate, pass in integers
1267f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 20, 20);
1268f6603c60Sopenharmony_ci    // 4. Free memory
1269f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1270f6603c60Sopenharmony_ci}
1271f6603c60Sopenharmony_ci
1272f6603c60Sopenharmony_ci/*
1273f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1201
1274f6603c60Sopenharmony_ci * @tc.name: testMatrixPreTranslateNull
1275f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreTranslateNull.
1276f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1277f6603c60Sopenharmony_ci * @tc.type  : Function
1278f6603c60Sopenharmony_ci * @tc.level : Level 3
1279f6603c60Sopenharmony_ci */
1280f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreTranslateNull, TestSize.Level3) {
1281f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1282f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1283f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreTranslate, the first parameter is null, check the error code using OH_Drawing_ErrorCodeGet
1284f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(nullptr, 10.0f, 10.0f);
1285f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
1286f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreTranslate, the second parameter is null
1287f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 0, 10.0f);
1288f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPreTranslate, the third parameter is null
1289f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 10.0f, 0);
1290f6603c60Sopenharmony_ci    // 5. Free memory
1291f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1292f6603c60Sopenharmony_ci}
1293f6603c60Sopenharmony_ci
1294f6603c60Sopenharmony_ci/*
1295f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1202
1296f6603c60Sopenharmony_ci * @tc.name: testMatrixPreTranslateAbnormal
1297f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreTranslateAbnormal.
1298f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1299f6603c60Sopenharmony_ci * @tc.type  : Function
1300f6603c60Sopenharmony_ci * @tc.level : Level 3
1301f6603c60Sopenharmony_ci */
1302f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreTranslateAbnormal, TestSize.Level3) {
1303f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1304f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1305f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreTranslate, the second parameter is negative
1306f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, -10.0f, 10.0f);
1307f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreTranslate, the third parameter is negative
1308f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 10.0f, -10.0f);
1309f6603c60Sopenharmony_ci    // 4. Free memory
1310f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1311f6603c60Sopenharmony_ci}
1312f6603c60Sopenharmony_ci
1313f6603c60Sopenharmony_ci/*
1314f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1203
1315f6603c60Sopenharmony_ci * @tc.name: testMatrixPreTranslateMaximum
1316f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreTranslateMaximum.
1317f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1318f6603c60Sopenharmony_ci * @tc.type  : Function
1319f6603c60Sopenharmony_ci * @tc.level : Level 3
1320f6603c60Sopenharmony_ci */
1321f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreTranslateMaximum, TestSize.Level3) {
1322f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1323f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1324f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreTranslate with the second parameter as the maximum value
1325f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, FLT_MAX, 10.0f);
1326f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPreTranslate with the third parameter as the maximum value
1327f6603c60Sopenharmony_ci    OH_Drawing_MatrixPreTranslate(matrix, 10.0f, FLT_MAX);
1328f6603c60Sopenharmony_ci    // 4. Free memory
1329f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1330f6603c60Sopenharmony_ci}
1331f6603c60Sopenharmony_ci
1332f6603c60Sopenharmony_ci/*
1333f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1204
1334f6603c60Sopenharmony_ci * @tc.name: testMatrixPreTranslateMultipleCalls
1335f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPreTranslateMultipleCalls.
1336f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1337f6603c60Sopenharmony_ci * @tc.type  : Function
1338f6603c60Sopenharmony_ci * @tc.level : Level 3
1339f6603c60Sopenharmony_ci */
1340f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPreTranslateMultipleCalls, TestSize.Level3) {
1341f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1342f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1343f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPreTranslate, pass in random numbers for dx and dy
1344f6603c60Sopenharmony_ci    std::random_device rd;
1345f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1346f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1347f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1348f6603c60Sopenharmony_ci        float dx = dis(gen);
1349f6603c60Sopenharmony_ci        float dy = dis(gen);
1350f6603c60Sopenharmony_ci        OH_Drawing_MatrixPreTranslate(matrix, dx, dy);
1351f6603c60Sopenharmony_ci    }
1352f6603c60Sopenharmony_ci    // 3. Free memory
1353f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1354f6603c60Sopenharmony_ci}
1355f6603c60Sopenharmony_ci
1356f6603c60Sopenharmony_ci/*
1357f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1300
1358f6603c60Sopenharmony_ci * @tc.name: testMatrixPostRotateNormal
1359f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostRotateNormal.
1360f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1361f6603c60Sopenharmony_ci * @tc.type  : Function
1362f6603c60Sopenharmony_ci * @tc.level : Level 0
1363f6603c60Sopenharmony_ci */
1364f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostRotateNormal, TestSize.Level0) {
1365f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1366f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1367f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostRotate, rotate angles include 0 degrees, 180 degrees, 360 degrees, -90 degrees, -180
1368f6603c60Sopenharmony_ci    // degrees, -360 degrees, and 45.5 degrees, px and py cover decimals and integers
1369f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 0, 0, 0);
1370f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, 10, 10);
1371f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 360, 10.0f, 10.0f);
1372f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, -90, 20, 20);
1373f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, -180, 20.0f, 20.0f);
1374f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, -360, 30, 30);
1375f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 45.5, 30.0f, 30.0f);
1376f6603c60Sopenharmony_ci    // 3. Free memory
1377f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1378f6603c60Sopenharmony_ci}
1379f6603c60Sopenharmony_ci
1380f6603c60Sopenharmony_ci/*
1381f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1301
1382f6603c60Sopenharmony_ci * @tc.name: testMatrixPostRotateNull
1383f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostRotateNull.
1384f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1385f6603c60Sopenharmony_ci * @tc.type  : Function
1386f6603c60Sopenharmony_ci * @tc.level : Level 3
1387f6603c60Sopenharmony_ci */
1388f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostRotateNull, TestSize.Level3) {
1389f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1390f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1391f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostRotate with the first parameter as null, check the error code using
1392f6603c60Sopenharmony_ci    // OH_Drawing_ErrorCodeGet
1393f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(nullptr, 180, 10, 10);
1394f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
1395f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostRotate with the second parameter as null
1396f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 0, 10, 10);
1397f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPostRotate with the third parameter as null
1398f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, 0, 10);
1399f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPostRotate with the fourth parameter as null
1400f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, 10, 0);
1401f6603c60Sopenharmony_ci    // 6. Free memory
1402f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1403f6603c60Sopenharmony_ci}
1404f6603c60Sopenharmony_ci
1405f6603c60Sopenharmony_ci/*
1406f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1302
1407f6603c60Sopenharmony_ci * @tc.name: testMatrixPostRotateAbnormal
1408f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostRotateAbnormal.
1409f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1410f6603c60Sopenharmony_ci * @tc.type  : Function
1411f6603c60Sopenharmony_ci * @tc.level : Level 3
1412f6603c60Sopenharmony_ci */
1413f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostRotateAbnormal, TestSize.Level3) {
1414f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1415f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1416f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostRotate, the third parameter is negative
1417f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, -10, 10);
1418f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostRotate, the fourth parameter is negative
1419f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, 10, -10);
1420f6603c60Sopenharmony_ci    // 4. Free memory
1421f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1422f6603c60Sopenharmony_ci}
1423f6603c60Sopenharmony_ci
1424f6603c60Sopenharmony_ci/*
1425f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1303
1426f6603c60Sopenharmony_ci * @tc.name: testMatrixPostRotateMaximum
1427f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostRotateMaximum.
1428f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1429f6603c60Sopenharmony_ci * @tc.type  : Function
1430f6603c60Sopenharmony_ci * @tc.level : Level 3
1431f6603c60Sopenharmony_ci */
1432f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostRotateMaximum, TestSize.Level3) {
1433f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1434f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1435f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostRotate with the second parameter as the maximum value
1436f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, FLT_MAX, 10.0f, 10.0f);
1437f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostRotate with the third parameter as the maximum value
1438f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, FLT_MAX, 10.0f);
1439f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPostRotate with the fourth parameter as the maximum value
1440f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostRotate(matrix, 180, 10.0f, FLT_MAX);
1441f6603c60Sopenharmony_ci    // 5. Free memory
1442f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1443f6603c60Sopenharmony_ci}
1444f6603c60Sopenharmony_ci
1445f6603c60Sopenharmony_ci/*
1446f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1304
1447f6603c60Sopenharmony_ci * @tc.name: testMatrixPostRotateMultipleCalls
1448f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostRotateMultipleCalls.
1449f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1450f6603c60Sopenharmony_ci * @tc.type  : Function
1451f6603c60Sopenharmony_ci * @tc.level : Level 3
1452f6603c60Sopenharmony_ci */
1453f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostRotateMultipleCalls, TestSize.Level3) {
1454f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1455f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1456f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostRotate, pass in random numbers for degree, px, and py
1457f6603c60Sopenharmony_ci    std::random_device rd;
1458f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1459f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1460f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1461f6603c60Sopenharmony_ci        float degree = dis(gen);
1462f6603c60Sopenharmony_ci        float px = dis(gen);
1463f6603c60Sopenharmony_ci        float py = dis(gen);
1464f6603c60Sopenharmony_ci        OH_Drawing_MatrixPostRotate(matrix, degree, px, py);
1465f6603c60Sopenharmony_ci    }
1466f6603c60Sopenharmony_ci    // 3. Free memory
1467f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1468f6603c60Sopenharmony_ci}
1469f6603c60Sopenharmony_ci
1470f6603c60Sopenharmony_ci/*
1471f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1400
1472f6603c60Sopenharmony_ci * @tc.name: testMatrixPostScaleNormal
1473f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostScaleNormal.
1474f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1475f6603c60Sopenharmony_ci * @tc.type  : Function
1476f6603c60Sopenharmony_ci * @tc.level : Level 0
1477f6603c60Sopenharmony_ci */
1478f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostScaleNormal, TestSize.Level0) {
1479f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1480f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1481f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostScale, pass in decimals
1482f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, 10.0f, 10.0f);
1483f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostScale, pass in integers
1484f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 20, 20, 20, 20);
1485f6603c60Sopenharmony_ci    // 4. Free memory
1486f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1487f6603c60Sopenharmony_ci}
1488f6603c60Sopenharmony_ci
1489f6603c60Sopenharmony_ci/*
1490f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1401
1491f6603c60Sopenharmony_ci * @tc.name: testMatrixPostScaleNull
1492f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostScaleNull.
1493f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1494f6603c60Sopenharmony_ci * @tc.type  : Function
1495f6603c60Sopenharmony_ci * @tc.level : Level 3
1496f6603c60Sopenharmony_ci */
1497f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostScaleNull, TestSize.Level3) {
1498f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1499f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1500f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostScale, the first parameter is null, check the error code using OH_Drawing_ErrorCodeGet
1501f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(nullptr, 10.0f, 10.0f, 10.0f, 10.0f);
1502f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
1503f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostScale, the second parameter is null
1504f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 0, 10.0f, 10.0f, 10.0f);
1505f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPostScale, the third parameter is null
1506f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 0, 10.0f, 10.0f);
1507f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPostScale, the fourth parameter is null
1508f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, 0, 10.0f);
1509f6603c60Sopenharmony_ci    // 6. OH_Drawing_MatrixPostScale, the fifth parameter is null
1510f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, 10.0f, 0);
1511f6603c60Sopenharmony_ci    // 7. Free memory
1512f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1513f6603c60Sopenharmony_ci}
1514f6603c60Sopenharmony_ci
1515f6603c60Sopenharmony_ci/*
1516f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1402
1517f6603c60Sopenharmony_ci * @tc.name: testMatrixPostScaleAbnormal
1518f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostScaleAbnormal.
1519f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1520f6603c60Sopenharmony_ci * @tc.type  : Function
1521f6603c60Sopenharmony_ci * @tc.level : Level 3
1522f6603c60Sopenharmony_ci */
1523f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostScaleAbnormal, TestSize.Level3) {
1524f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1525f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1526f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostScale, the second parameter is negative
1527f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, -10.0f, 10.0f, 10.0f, 10.0f);
1528f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostScale, the third parameter is negative
1529f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, -10.0f, 10.0f, 10.0f);
1530f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPostScale, the fourth parameter is negative
1531f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, -10.0f, 10.0f);
1532f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPostScale, the fifth parameter is negative
1533f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, 10.0f, -10.0f);
1534f6603c60Sopenharmony_ci    // 6. Free memory
1535f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1536f6603c60Sopenharmony_ci}
1537f6603c60Sopenharmony_ci
1538f6603c60Sopenharmony_ci/*
1539f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1403
1540f6603c60Sopenharmony_ci * @tc.name: testMatrixPostScaleMaximum
1541f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostScaleMaximum.
1542f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1543f6603c60Sopenharmony_ci * @tc.type  : Function
1544f6603c60Sopenharmony_ci * @tc.level : Level 3
1545f6603c60Sopenharmony_ci */
1546f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostScaleMaximum, TestSize.Level3) {
1547f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1548f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1549f6603c60Sopenharmony_ci    // 2. OH_Drawing_MatrixPostScale, the second parameter is the maximum value
1550f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, FLT_MAX, 10.0f, 10.0f, 10.0f);
1551f6603c60Sopenharmony_ci    // 3. OH_Drawing_MatrixPostScale, the third parameter is the maximum value
1552f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, FLT_MAX, 10.0f, 10.0f);
1553f6603c60Sopenharmony_ci    // 4. OH_Drawing_MatrixPostScale, the fourth parameter is the maximum value
1554f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, FLT_MAX, 10.0f);
1555f6603c60Sopenharmony_ci    // 5. OH_Drawing_MatrixPostScale, the fifth parameter is the maximum value
1556f6603c60Sopenharmony_ci    OH_Drawing_MatrixPostScale(matrix, 10.0f, 10.0f, 10.0f, FLT_MAX);
1557f6603c60Sopenharmony_ci    // 6. Free memory
1558f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1559f6603c60Sopenharmony_ci}
1560f6603c60Sopenharmony_ci
1561f6603c60Sopenharmony_ci/*
1562f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1404
1563f6603c60Sopenharmony_ci * @tc.name: testMatrixPostScaleMultipleCalls
1564f6603c60Sopenharmony_ci * @tc.desc: test for testMatrixPostScaleMultipleCalls.
1565f6603c60Sopenharmony_ci * @tc.size  : SmallTest
1566f6603c60Sopenharmony_ci * @tc.type  : Function
1567f6603c60Sopenharmony_ci * @tc.level : Level 3
1568f6603c60Sopenharmony_ci */
1569f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeMatrixTest, testMatrixPostScaleMultipleCalls, TestSize.Level3) {
1570f6603c60Sopenharmony_ci    // 1. OH_Drawing_MatrixCreate
1571f6603c60Sopenharmony_ci    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
1572f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_MatrixCreateScale 10 times, passing in random numbers for sx, sy, px, and py
1573f6603c60Sopenharmony_ci    std::random_device rd;
1574f6603c60Sopenharmony_ci    std::mt19937 gen(rd());
1575f6603c60Sopenharmony_ci    std::uniform_real_distribution<float> dis(0.0, 100.0);
1576f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
1577f6603c60Sopenharmony_ci        float sx = dis(gen);
1578f6603c60Sopenharmony_ci        float sy = dis(gen);
1579f6603c60Sopenharmony_ci        float px = dis(gen);
1580f6603c60Sopenharmony_ci        float py = dis(gen);
1581f6603c60Sopenharmony_ci        OH_Drawing_MatrixPostScale(matrix, sx, sy, px, py);
1582f6603c60Sopenharmony_ci    }
1583f6603c60Sopenharmony_ci    // 3. Free memory
1584f6603c60Sopenharmony_ci    OH_Drawing_MatrixDestroy(matrix);
1585f6603c60Sopenharmony_ci}
1586f6603c60Sopenharmony_ci
1587f6603c60Sopenharmony_ci} // namespace Drawing
1588f6603c60Sopenharmony_ci} // namespace Rosen
1589f6603c60Sopenharmony_ci} // namespace OHOS