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