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