• 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 DrawingNativeMatrixPart2Test : public testing::Test {
31     protected:
32     // 在每个测试用例执行前调用
SetUp()33     void SetUp() override
34     {
35         // 设置代码
36         std::cout << "DrawingNativeMatrixPart2Test Setup code called before each test case." << std::endl;
37         OH_Drawing_ErrorCodeReset();
38         std::cout << "DrawingNativeMatrixPart2Test errorCodeReset before each test case." << std::endl;
39     }
TearDown()40     void TearDown() override
41     {
42         std::cout << "DrawingNativeMatrixPart2Test Setup code called after each test case." << std::endl;
43         OH_Drawing_ErrorCodeReset();
44         std::cout << "DrawingNativeMatrixPart2Test errorCodeReset after each test case." << std::endl;
45     }
46 };
47 
48 /*
49  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1500
50  * @tc.name: testMatrixPostTranslateNormal
51  * @tc.desc: test for testMatrixPostTranslateNormal.
52  * @tc.size  : SmallTest
53  * @tc.type  : Function
54  * @tc.level : Level 0
55  */
56 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixPostTranslateNormal, Function | SmallTest | Level0) {
57     // 1. OH_Drawing_MatrixCreate
58     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
59     EXPECT_NE(matrix, nullptr);
60     // 2. OH_Drawing_MatrixPostTranslate, passing decimal numbers
61     OH_Drawing_MatrixPostTranslate(matrix, 1.5, 2.5);
62     // add assert
63     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
64     // 3. OH_Drawing_MatrixPostTranslate, passing integers
65     OH_Drawing_MatrixPostTranslate(matrix, 3, 4);
66     // add assert
67     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
68     // 4. Free memory
69     OH_Drawing_MatrixDestroy(matrix);
70 }
71 
72 /*
73  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1501
74  * @tc.name: testMatrixPostTranslateNull
75  * @tc.desc: test for testMatrixPostTranslateNull.
76  * @tc.size  : SmallTest
77  * @tc.type  : Function
78  * @tc.level : Level 3
79  */
80 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixPostTranslateNull, Function | SmallTest | Level3) {
81     // 1. OH_Drawing_MatrixCreate
82     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
83     EXPECT_NE(matrix, nullptr);
84     // 2. OH_Drawing_MatrixPostTranslate, passing nullptr as the first parameter, check the error code with
85     // OH_Drawing_ErrorCodeGet, no crash, error code returns OH_DRAWING_ERROR_INVALID_PARAMETER
86     OH_Drawing_MatrixPostTranslate(nullptr, 1.5, 2.5);
87     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
88     // 3. OH_Drawing_MatrixPostTranslate, passing 0 as the second parameter
89     OH_Drawing_MatrixPostTranslate(matrix, 0, 2.5);
90     // 4. OH_Drawing_MatrixPostTranslate, passing 0 as the third parameter
91     OH_Drawing_MatrixPostTranslate(matrix, 1.5, 0);
92     // 5. Free memory
93     OH_Drawing_MatrixDestroy(matrix);
94 }
95 
96 /*
97  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1502
98  * @tc.name: testMatrixPostTranslateAbnormal
99  * @tc.desc: test for testMatrixPostTranslateAbnormal.
100  * @tc.size  : SmallTest
101  * @tc.type  : Function
102  * @tc.level : Level 3
103  */
104 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixPostTranslateAbnormal, Function | SmallTest | Level3) {
105     // 1. OH_Drawing_MatrixCreate
106     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
107     EXPECT_NE(matrix, nullptr);
108     // 2. OH_Drawing_MatrixPostTranslate with a negative value as the second parameter
109     OH_Drawing_MatrixPostTranslate(matrix, -1.5, 2.5);
110     // 3. OH_Drawing_MatrixPostTranslate with a negative value as the third parameter
111     OH_Drawing_MatrixPostTranslate(matrix, 1.5, -2.5);
112     // 4. Free memory
113     OH_Drawing_MatrixDestroy(matrix);
114 }
115 
116 /*
117  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1503
118  * @tc.name: testMatrixPostTranslateMaximum
119  * @tc.desc: test for testMatrixPostTranslateMaximum.
120  * @tc.size  : SmallTest
121  * @tc.type  : Function
122  * @tc.level : Level 3
123  */
124 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixPostTranslateMaximum, Function | SmallTest | Level3) {
125     // 1. OH_Drawing_MatrixCreate
126     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
127     EXPECT_NE(matrix, nullptr);
128     // 2. OH_Drawing_MatrixPostTranslate with the second parameter as the maximum value
129     OH_Drawing_MatrixPostTranslate(matrix, FLT_MAX, 2.5);
130     // 3. OH_Drawing_MatrixPostTranslate with the third parameter as the maximum value
131     OH_Drawing_MatrixPostTranslate(matrix, 1.5, FLT_MAX);
132     // 4. Free memory
133     OH_Drawing_MatrixDestroy(matrix);
134 }
135 
136 /*
137  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1504
138  * @tc.name: testMatrixPostTranslateMultipleCalls
139  * @tc.desc: test for testMatrixPostTranslateMultipleCalls.
140  * @tc.size  : SmallTest
141  * @tc.type  : Function
142  * @tc.level : Level 3
143  */
144 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixPostTranslateMultipleCalls, Function | SmallTest | Level3) {
145     // 1. OH_Drawing_MatrixCreate
146     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
147     EXPECT_NE(matrix, nullptr);
148     // 2. Call OH_Drawing_MatrixPostTranslate 10 times, with dx and dy as random numbers
149     std::random_device rd;
150     std::mt19937 gen(rd());
151     std::uniform_real_distribution<float> dis(-100, 100);
152     for (int i = 0; i < 10; i++) {
153         OH_Drawing_MatrixPostTranslate(matrix, dis(gen), dis(gen));
154     }
155     // 3. Free memory
156     OH_Drawing_MatrixDestroy(matrix);
157 }
158 
159 /*
160  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1600
161  * @tc.name: testMatrixResetNormal
162  * @tc.desc: test for testMatrixResetNormal.
163  * @tc.size  : SmallTest
164  * @tc.type  : Function
165  * @tc.level : Level 0
166  */
167 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixResetNormal, Function | SmallTest | Level0) {
168     // 1. OH_Drawing_MatrixCreate
169     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
170     // add assert
171     EXPECT_NE(matrix, nullptr);
172     // 2. OH_Drawing_MatrixReset with the identity matrix
173     OH_Drawing_MatrixReset(matrix);
174     // add assert
175     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
176     // 3. OH_Drawing_MatrixReset with a non-identity matrix
177     OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1);
178     OH_Drawing_MatrixReset(matrix);
179     // add assert
180     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
181     // 4. Free memory
182     OH_Drawing_MatrixDestroy(matrix);
183 }
184 
185 /*
186  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1601
187  * @tc.name: testMatrixResetNull
188  * @tc.desc: test for testMatrixResetNull.
189  * @tc.size  : SmallTest
190  * @tc.type  : Function
191  * @tc.level : Level 3
192  */
193 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixResetNull, Function | SmallTest | Level3) {
194     // 1. OH_Drawing_MatrixReset with nullptr as the parameter, check the error code with OH_Drawing_ErrorCodeGet, no
195     // crash, error code returns OH_DRAWING_ERROR_INVALID_PARAMETER
196     OH_Drawing_MatrixReset(nullptr);
197     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
198 }
199 
200 /*
201  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1602
202  * @tc.name: testMatrixResetMultipleCalls
203  * @tc.desc: test for testMatrixResetMultipleCalls.
204  * @tc.size  : SmallTest
205  * @tc.type  : Function
206  * @tc.level : Level 3
207  */
208 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixResetMultipleCalls, Function | SmallTest | Level3) {
209     // 1. OH_Drawing_MatrixCreate
210     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
211     // add assert
212     EXPECT_NE(matrix, nullptr);
213     // 2. Call OH_Drawing_MatrixSetMatrix 10 times
214     for (int i = 0; i < 10; i++) {
215         OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1);
216     }
217     // 3. Call OH_Drawing_MatrixReset 10 times
218     for (int i = 0; i < 10; i++) {
219         OH_Drawing_MatrixReset(matrix);
220     }
221     // 4. Call OH_Drawing_MatrixSetMatrix and OH_Drawing_MatrixReset alternately 10 times
222     for (int i = 0; i < 10; i++) {
223         OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1);
224         OH_Drawing_MatrixReset(matrix);
225     }
226     // 5. Free memory
227     OH_Drawing_MatrixDestroy(matrix);
228 }
229 
230 /*
231  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1700
232  * @tc.name: testMatrixConcatNormal
233  * @tc.desc: test for testMatrixConcatNormal.
234  * @tc.size  : SmallTest
235  * @tc.type  : Function
236  * @tc.level : Level 0
237  */
238 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixConcatNormal, Function | SmallTest | Level0) {
239     // Define matrices a and b
240     OH_Drawing_Matrix *a = OH_Drawing_MatrixCreate();
241     // add assert
242     EXPECT_NE(a, nullptr);
243     OH_Drawing_MatrixSetMatrix(a, 1, 0, 0, 0, -1, 0, 0, 0, 1);
244     OH_Drawing_Matrix *b = OH_Drawing_MatrixCreate();
245     // add assert
246     EXPECT_NE(b, nullptr);
247     OH_Drawing_MatrixSetMatrix(b, 1, 0, 0, 0, 1, 0, 0, 0, 1);
248     OH_Drawing_Matrix *c = OH_Drawing_MatrixCreate();
249     // add assert
250     EXPECT_NE(c, nullptr);
251     // 1. Call OH_Drawing_MatrixConcat with matrices a and b of different sizes,
252     // and use OH_Drawing_MatrixGetAll to get the result of matrix a multiplied by matrix b
253     OH_Drawing_MatrixConcat(c, b, a);
254     // add assert
255     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
256     float values[9];
257     OH_Drawing_MatrixGetAll(c, values);
258     EXPECT_EQ(values[0], 1);
259     // 2. Free memory
260     OH_Drawing_MatrixDestroy(a);
261     OH_Drawing_MatrixDestroy(b);
262     OH_Drawing_MatrixDestroy(c);
263 }
264 
265 /*
266  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1701
267  * @tc.name: testMatrixConcatNull
268  * @tc.desc: test for testMatrixConcatNull.
269  * @tc.size  : SmallTest
270  * @tc.type  : Function
271  * @tc.level : Level 3
272  */
273 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixConcatNull, Function | SmallTest | Level3) {
274     // 1. OH_Drawing_MatrixCreate
275     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
276     // add assert
277     EXPECT_NE(matrix, nullptr);
278     // 2. OH_Drawing_MatrixConcat, passing nullptr as the first parameter, check the error code with
279     // OH_Drawing_ErrorCodeGet
280     OH_Drawing_MatrixConcat(nullptr, matrix, matrix);
281     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
282     OH_Drawing_ErrorCodeReset();
283     // 3. OH_Drawing_MatrixConcat, passing nullptr as the second parameter, check the error code with
284     // OH_Drawing_ErrorCodeGet
285     OH_Drawing_MatrixConcat(matrix, nullptr, matrix);
286     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
287     OH_Drawing_ErrorCodeReset();
288     // 4. OH_Drawing_MatrixConcat, passing nullptr as the third parameter, check the error code with
289     // OH_Drawing_ErrorCodeGet
290     OH_Drawing_MatrixConcat(matrix, matrix, nullptr);
291     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
292     // 5. Free memory
293     OH_Drawing_MatrixDestroy(matrix);
294 }
295 
296 /*
297  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1702
298  * @tc.name: testMatrixConcatMultipleCalls
299  * @tc.desc: test for testMatrixConcatMultipleCalls.
300  * @tc.size  : SmallTest
301  * @tc.type  : Function
302  * @tc.level : Level 3
303  */
304 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixConcatMultipleCalls, Function | SmallTest | Level3) {
305     // 1. Call OH_Drawing_MatrixConcat 10 times with matrices a and b of different sizes,
306     // and use OH_Drawing_MatrixGetAll to get the result of matrix a multiplied by matrix b
307     OH_Drawing_Matrix *a = OH_Drawing_MatrixCreate();
308     // add assert
309     EXPECT_NE(a, nullptr);
310     OH_Drawing_MatrixSetMatrix(a, 1, 0, 0, 0, -1, 0, 0, 0, 1);
311     OH_Drawing_Matrix *b = OH_Drawing_MatrixCreate();
312     // add assert
313     EXPECT_NE(b, nullptr);
314     OH_Drawing_MatrixSetMatrix(b, 1, 0, 0, 0, 1, 0, 0, 0, 1);
315     OH_Drawing_Matrix *c = OH_Drawing_MatrixCreate();
316     // add assert
317     EXPECT_NE(c, nullptr);
318     for (int i = 0; i < 10; i++) {
319         OH_Drawing_MatrixConcat(c, b, a);
320         float values[9];
321         OH_Drawing_MatrixGetAll(c, values);
322         EXPECT_EQ(values[0], 1);
323         EXPECT_EQ(values[1], 0);
324         EXPECT_EQ(values[2], 0);
325         EXPECT_EQ(values[3], 0);
326         EXPECT_EQ(values[4], -1);
327         EXPECT_EQ(values[5], 0);
328         EXPECT_EQ(values[6], 0);
329         EXPECT_EQ(values[7], 0);
330         EXPECT_EQ(values[8], 1);
331     }
332     // 2. Free memory
333     OH_Drawing_MatrixDestroy(a);
334     OH_Drawing_MatrixDestroy(b);
335     OH_Drawing_MatrixDestroy(c);
336 }
337 
338 /*
339  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1800
340  * @tc.name: testMatrixInvertNormal
341  * @tc.desc: test for testMatrixInvertNormal.
342  * @tc.size  : SmallTest
343  * @tc.type  : Function
344  * @tc.level : Level 0
345  */
346 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixInvertNormal, Function | SmallTest | Level0) {
347     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
348     // add assert
349     EXPECT_NE(matrix, nullptr);
350     OH_Drawing_Matrix *inverse = OH_Drawing_MatrixCreate();
351     // add assert
352     EXPECT_NE(inverse, nullptr);
353     OH_Drawing_MatrixInvert(matrix, inverse);
354     // add assert
355     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
356     OH_Drawing_MatrixInvert(inverse, matrix);
357     // add assert
358     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
359     OH_Drawing_MatrixDestroy(matrix);
360     OH_Drawing_MatrixDestroy(inverse);
361 }
362 
363 /*
364  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1801
365  * @tc.name: testMatrixInvertNull
366  * @tc.desc: test for testMatrixInvertNull.
367  * @tc.size  : SmallTest
368  * @tc.type  : Function
369  * @tc.level : Level 3
370  */
371 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixInvertNull, Function | SmallTest | Level3) {
372     // 1. OH_Drawing_MatrixCreate
373     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
374     // add assert
375     EXPECT_NE(matrix, nullptr);
376     // 2. OH_Drawing_MatrixInvert with the first parameter as nullptr, check the error code with OH_Drawing_ErrorCodeGet
377     OH_Drawing_MatrixInvert(nullptr, matrix);
378     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
379     OH_Drawing_ErrorCodeReset();
380     // 3. OH_Drawing_MatrixInvert with the second parameter as nullptr, check the error code with
381     // OH_Drawing_ErrorCodeGet
382     OH_Drawing_MatrixInvert(matrix, nullptr);
383     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
384     // 4. Free memory
385     OH_Drawing_MatrixDestroy(matrix);
386 }
387 
388 /*
389  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1802
390  * @tc.name: testMatrixInvertMultipleCalls
391  * @tc.desc: test for testMatrixInvertMultipleCalls.
392  * @tc.size  : SmallTest
393  * @tc.type  : Function
394  * @tc.level : Level 3
395  */
396 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixInvertMultipleCalls, Function | SmallTest | Level3) {
397     // 1. Call OH_Drawing_MatrixInvert 10 times with matrices of different sizes
398     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
399     // add assert
400     EXPECT_NE(matrix, nullptr);
401     OH_Drawing_Matrix *inverse = OH_Drawing_MatrixCreate();
402     // add assert
403     EXPECT_NE(inverse, nullptr);
404     OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
405     for (int i = 0; i < 10; i++) {
406         OH_Drawing_MatrixInvert(matrix, inverse);
407         OH_Drawing_MatrixInvert(inverse, matrix);
408         float values[9];
409         OH_Drawing_MatrixGetAll(matrix, values);
410         EXPECT_EQ(values[0], 1);
411         EXPECT_EQ(values[1], 0);
412         EXPECT_EQ(values[2], 0);
413         EXPECT_EQ(values[3], 0);
414         EXPECT_EQ(values[4], -1);
415         EXPECT_EQ(values[5], 0);
416         EXPECT_EQ(values[6], 0);
417         EXPECT_EQ(values[7], 0);
418         EXPECT_EQ(values[8], 1);
419     }
420     // 2. Free memory
421     OH_Drawing_MatrixDestroy(matrix);
422     OH_Drawing_MatrixDestroy(inverse);
423 }
424 
425 /*
426  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1900
427  * @tc.name: testMatrixSetPolyToPolyNormal
428  * @tc.desc: test for testMatrixSetPolyToPolyNormal.
429  * @tc.size  : SmallTest
430  * @tc.type  : Function
431  * @tc.level : Level 0
432  */
433 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixSetPolyToPolyNormal, Function | SmallTest | Level0) {
434     // 1. OH_Drawing_MatrixCreate
435     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
436     EXPECT_NE(matrix, nullptr);
437     // 2. OH_Drawing_MatrixSetPolyToPoly
438     OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1);
439     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
440     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
441     OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 1);
442     // add assert
443     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
444     // 3. OH_Drawing_MatrixSetPolyToPoly, iterate count from 0 to 4, keeping the length of the array consistent with
445     // count
446     std::random_device rd;
447     std::mt19937 gen(rd());
448     std::uniform_real_distribution<float> dis(0, 100);
449     for (int i = 0; i < 5; i++) {
450         OH_Drawing_ErrorCodeReset();
451         OH_Drawing_Point2D src[i];
452         OH_Drawing_Point2D dst[i];
453         for (int j = 0; j < i; j++) {
454             // Generate random numbers
455             src[j] = {dis(gen), dis(gen)};
456             dst[j] = {dis(gen), dis(gen)};
457         }
458         OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, i);
459         // add assert
460         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
461     }
462     // 4. Free memory
463     OH_Drawing_MatrixDestroy(matrix);
464 }
465 
466 /*
467  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1901
468  * @tc.name: testMatrixSetPolyToPolyNull
469  * @tc.desc: test for testMatrixSetPolyToPolyNull.
470  * @tc.size  : SmallTest
471  * @tc.type  : Function
472  * @tc.level : Level 3
473  */
474 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixSetPolyToPolyNull, Function | SmallTest | Level3) {
475     // 1. OH_Drawing_MatrixCreate
476     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
477     // add assert
478     EXPECT_NE(matrix, nullptr);
479     // 2. OH_Drawing_MatrixSetPolyToPoly, the first parameter is nullptr, check the error code with
480     // OH_Drawing_ErrorCodeGet
481     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
482     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
483     OH_Drawing_MatrixSetPolyToPoly(nullptr, src, dst, 5);
484     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
485     // 3. OH_Drawing_MatrixSetPolyToPoly, the second parameter is nullptr, check the error code with
486     // OH_Drawing_ErrorCodeGet
487     OH_Drawing_MatrixSetPolyToPoly(matrix, nullptr, dst, 5);
488     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
489     // 4. OH_Drawing_MatrixSetPolyToPoly, the third parameter is nullptr, check the error code with
490     // OH_Drawing_ErrorCodeGet
491     OH_Drawing_MatrixSetPolyToPoly(matrix, src, nullptr, 5);
492     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
493     // 5. Free memory
494     OH_Drawing_MatrixDestroy(matrix);
495 }
496 
497 /*
498  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1902
499  * @tc.name: testMatrixSetPolyToPolyAbnormal
500  * @tc.desc: test for testMatrixSetPolyToPolyAbnormal.
501  * @tc.size  : SmallTest
502  * @tc.type  : Function
503  * @tc.level : Level 3
504  */
505 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixSetPolyToPolyAbnormal, Function | SmallTest | Level3) {
506     // 1. OH_Drawing_MatrixCreate
507     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
508     // add assert
509     EXPECT_NE(matrix, nullptr);
510     // 2. OH_Drawing_MatrixSetPolyToPoly, pass -1 as count, check the error code with OH_Drawing_ErrorCodeGet
511     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}};
512     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}};
513     OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, -1);
514     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
515     // 3. OH_Drawing_MatrixSetPolyToPoly, pass 5 as count, check the error code with OH_Drawing_ErrorCodeGet
516     OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 5);
517     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE);
518     // 4. Free memory
519     OH_Drawing_MatrixDestroy(matrix);
520 }
521 
522 /*
523  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_1904
524  * @tc.name: testMatrixSetPolyToPolyMultipleCalls
525  * @tc.desc: test for testMatrixSetPolyToPolyMultipleCalls.
526  * @tc.size  : SmallTest
527  * @tc.type  : Function
528  * @tc.level : Level 3
529  */
530 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixSetPolyToPolyMultipleCalls, Function | SmallTest | Level3) {
531     // 1. OH_Drawing_MatrixCreate
532     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
533     // add assert
534     EXPECT_NE(matrix, nullptr);
535     // 2. Call OH_Drawing_MatrixSetPolyToPoly 10 times
536     std::random_device rd;
537     std::mt19937 gen(rd());
538     std::uniform_real_distribution<float> dis(0, 100);
539     for (int i = 0; i < 10; i++) {
540         OH_Drawing_Point2D src[2] = {{dis(gen), dis(gen)}, {dis(gen), dis(gen)}};
541         OH_Drawing_Point2D dst[2] = {{dis(gen), dis(gen)}, {dis(gen), dis(gen)}};
542         OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 2);
543     }
544     // 3. Free memory
545     OH_Drawing_MatrixDestroy(matrix);
546 }
547 
548 /*
549  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2000
550  * @tc.name: testMatrixMapPointsNormal
551  * @tc.desc: test for testMatrixMapPointsNormal.
552  * @tc.size  : SmallTest
553  * @tc.type  : Function
554  * @tc.level : Level 0
555  */
556 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapPointsNormal, Function | SmallTest | Level0) {
557     // 1. OH_Drawing_MatrixCreate
558     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
559     // add assert
560     EXPECT_NE(matrix, nullptr);
561     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
562     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
563     // 2. OH_Drawing_MatrixMapPoints, pass the float value 1.52 as count
564     double value = 1.52;
565     uint32_t count = static_cast<uint32_t>(value);
566     OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, count);
567     // 3. OH_Drawing_MatrixMapPoints, pass integer 5 as count
568     OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 5);
569     // 4. Free memory
570     OH_Drawing_MatrixDestroy(matrix);
571 }
572 
573 /*
574  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2001
575  * @tc.name: testMatrixMapPointsNull
576  * @tc.desc: test for testMatrixMapPointsNull.
577  * @tc.size  : SmallTest
578  * @tc.type  : Function
579  * @tc.level : Level 3
580  */
581 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapPointsNull, Function | SmallTest | Level3) {
582     // 1. OH_Drawing_MatrixCreate
583     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
584     // add assert
585     EXPECT_NE(matrix, nullptr);
586     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
587     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
588     // 2. OH_Drawing_MatrixMapPoints, the first parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
589     OH_Drawing_MatrixMapPoints(nullptr, src, dst, 5);
590     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
591     OH_Drawing_ErrorCodeReset();
592     // 3. OH_Drawing_MatrixMapPoints, the second parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
593     OH_Drawing_MatrixMapPoints(matrix, nullptr, dst, 5);
594     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
595     OH_Drawing_ErrorCodeReset();
596     // 4. OH_Drawing_MatrixMapPoints, the third parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
597     OH_Drawing_MatrixMapPoints(matrix, src, nullptr, 5);
598     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
599     OH_Drawing_ErrorCodeReset();
600     // 5. OH_Drawing_MatrixMapPoints, the fourth parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
601     OH_Drawing_MatrixMapPoints(matrix, src, dst, 0);
602     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
603     // 6. Free memory
604     OH_Drawing_MatrixDestroy(matrix);
605 }
606 
607 /*
608  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2002
609  * @tc.name: testMatrixMapPointsAbnormal
610  * @tc.desc: test for testMatrixMapPointsAbnormal.
611  * @tc.size  : SmallTest
612  * @tc.type  : Function
613  * @tc.level : Level 3
614  */
615 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapPointsAbnormal, Function | SmallTest | Level3) {
616     // 1. OH_Drawing_MatrixCreate
617     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
618     // add assert
619     EXPECT_NE(matrix, nullptr);
620     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
621     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
622     // 2. OH_Drawing_MatrixMapPoints, pass -1 as count, check the error code with OH_Drawing_ErrorCodeGet
623     OH_Drawing_MatrixMapPoints(matrix, src, dst, -1);
624     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
625     // 3. Free memory
626     OH_Drawing_MatrixDestroy(matrix);
627 }
628 
629 /*
630  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2003
631  * @tc.name: testMatrixMapPointsMultipleCalls
632  * @tc.desc: test for testMatrixMapPointsMultipleCalls.
633  * @tc.size  : SmallTest
634  * @tc.type  : Function
635  * @tc.level : Level 3
636  */
637 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapPointsMultipleCalls, Function | SmallTest | Level3) {
638     // 1. OH_Drawing_MatrixCreate
639     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
640     // add assert
641     EXPECT_NE(matrix, nullptr);
642     OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}};
643     OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}};
644     // 2. Call OH_Drawing_MatrixMapPoints 10 times
645     for (int i = 0; i < 10; i++) {
646         OH_Drawing_ErrorCodeReset();
647         OH_Drawing_MatrixMapPoints(matrix, src, dst, 5);
648         // add assert
649         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
650     }
651     // 3. Free memory
652     OH_Drawing_MatrixDestroy(matrix);
653 }
654 
655 /*
656  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2100
657  * @tc.name: testMatrixMapRectNormal
658  * @tc.desc: test for testMatrixMapRectNormal.
659  * @tc.size  : SmallTest
660  * @tc.type  : Function
661  * @tc.level : Level 0
662  */
663 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapRectNormal, Function | SmallTest | Level0) {
664     // 1. OH_Drawing_MatrixCreate
665     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
666     // add assert
667     EXPECT_NE(matrix, nullptr);
668     // 2. OH_Drawing_MatrixMapRect, src and dst are the same
669     OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
670     // add assert
671     EXPECT_NE(src, nullptr);
672     OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
673     // add assert
674     EXPECT_NE(dst, nullptr);
675     OH_Drawing_MatrixMapRect(matrix, src, dst);
676     // add assert
677     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
678     // 3. OH_Drawing_MatrixMapRect, src and dst are different
679     OH_Drawing_Rect *src2 = OH_Drawing_RectCreate(0, 0, 100, 100);
680     // add assert
681     EXPECT_NE(src2, nullptr);
682     OH_Drawing_Rect *dst2 = OH_Drawing_RectCreate(0, 0, 200, 200);
683     // add assert
684     EXPECT_NE(dst2, nullptr);
685     OH_Drawing_MatrixMapRect(matrix, src2, dst2);
686     // add assert
687     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
688     // 4. Free memory
689     OH_Drawing_MatrixDestroy(matrix);
690     OH_Drawing_RectDestroy(src);
691     OH_Drawing_RectDestroy(dst);
692     OH_Drawing_RectDestroy(src2);
693     OH_Drawing_RectDestroy(dst2);
694 }
695 
696 /*
697  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2101
698  * @tc.name: testMatrixMapRectNull
699  * @tc.desc: test for testMatrixMapRectNull.
700  * @tc.size  : SmallTest
701  * @tc.type  : Function
702  * @tc.level : Level 3
703  */
704 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapRectNull, Function | SmallTest | Level3) {
705     // 1. OH_Drawing_MatrixCreate
706     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
707     // add assert
708     EXPECT_NE(matrix, nullptr);
709     // 2. OH_Drawing_MatrixMapRect, the first parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
710     OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 100, 100);
711     // add assert
712     EXPECT_NE(src, nullptr);
713     OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 100, 100);
714     // add assert
715     EXPECT_NE(dst, nullptr);
716     OH_Drawing_MatrixMapRect(nullptr, src, dst);
717     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
718     OH_Drawing_ErrorCodeReset();
719     // 3. OH_Drawing_MatrixMapRect, the second parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
720     OH_Drawing_MatrixMapRect(matrix, nullptr, dst);
721     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
722     OH_Drawing_ErrorCodeReset();
723     // 4. OH_Drawing_MatrixMapRect, the third parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
724     OH_Drawing_MatrixMapRect(matrix, src, nullptr);
725     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
726     // 5. Free memory
727     OH_Drawing_MatrixDestroy(matrix);
728     OH_Drawing_RectDestroy(src);
729     OH_Drawing_RectDestroy(dst);
730 }
731 
732 /*
733  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2103
734  * @tc.name: testMatrixMapRectMultipleCalls
735  * @tc.desc: test for testMatrixMapRectMultipleCalls.
736  * @tc.size  : SmallTest
737  * @tc.type  : Function
738  * @tc.level : Level 3
739  */
740 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixMapRectMultipleCalls, Function | SmallTest | Level3) {
741     // 1. OH_Drawing_MatrixCreate
742     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
743     // add assert
744     EXPECT_NE(matrix, nullptr);
745     // 2. Call OH_Drawing_MatrixMapRect 10 times with different src and dst
746     std::random_device rd;
747     std::mt19937 gen(rd());
748     std::uniform_real_distribution<float> dis(100, 200);
749     for (int i = 0; i < 10; i++) {
750         OH_Drawing_ErrorCodeReset();
751         OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, dis(gen), dis(gen));
752         // add assert
753         EXPECT_NE(src, nullptr);
754         OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, dis(gen), dis(gen));
755         // add assert
756         EXPECT_NE(dst, nullptr);
757         OH_Drawing_MatrixMapRect(matrix, src, dst);
758         // add assert
759         EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
760         OH_Drawing_RectDestroy(src);
761         OH_Drawing_RectDestroy(dst);
762     }
763     // 3. Free memory
764     OH_Drawing_MatrixDestroy(matrix);
765 }
766 
767 /*
768  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2200
769  * @tc.name: testMatrixIsEqualNormal
770  * @tc.desc: test for testMatrixIsEqualNormal.
771  * @tc.size  : SmallTest
772  * @tc.type  : Function
773  * @tc.level : Level 0
774  */
775 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsEqualNormal, Function | SmallTest | Level0) {
776     // 1. OH_Drawing_MatrixIsEqual with the same matrix
777     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
778     // add assert
779     EXPECT_NE(matrix, nullptr);
780     OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
781     OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate();
782     // add assert
783     EXPECT_NE(matrix2, nullptr);
784     OH_Drawing_MatrixSetMatrix(matrix2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
785     bool ret = OH_Drawing_MatrixIsEqual(matrix, matrix2);
786     // add assert
787     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
788     EXPECT_EQ(ret, true);
789     // 2. OH_Drawing_MatrixIsEqual with different matrices
790     OH_Drawing_Matrix *matrix3 = OH_Drawing_MatrixCreate();
791     // add assert
792     EXPECT_NE(matrix3, nullptr);
793     OH_Drawing_MatrixSetMatrix(matrix3, 2, 2, 3, 4, 5, 6, 7, 8, 9);
794     ret = OH_Drawing_MatrixIsEqual(matrix, matrix3);
795     // add assert
796     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
797     EXPECT_EQ(ret, false);
798     // 3. Free memory
799     OH_Drawing_MatrixDestroy(matrix);
800     OH_Drawing_MatrixDestroy(matrix2);
801     OH_Drawing_MatrixDestroy(matrix3);
802 }
803 
804 /*
805  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2201
806  * @tc.name: testMatrixIsEqualNull
807  * @tc.desc: test for testMatrixIsEqualNull.
808  * @tc.size  : SmallTest
809  * @tc.type  : Function
810  * @tc.level : Level 3
811  */
812 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsEqualNull, Function | SmallTest | Level3) {
813     // 1. OH_Drawing_MatrixCreate
814     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
815     // add assert
816     EXPECT_NE(matrix, nullptr);
817     OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
818     // 2. OH_Drawing_MatrixIsEqual, the first parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
819     OH_Drawing_MatrixIsEqual(nullptr, matrix);
820     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
821     OH_Drawing_ErrorCodeReset();
822     // 3. OH_Drawing_MatrixIsEqual, the second parameter is nullptr, check the error code with OH_Drawing_ErrorCodeGet
823     OH_Drawing_MatrixIsEqual(matrix, nullptr);
824     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
825     // 4. Free memory
826     OH_Drawing_MatrixDestroy(matrix);
827 }
828 
829 /*
830  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2202
831  * @tc.name: testMatrixIsEqualMultipleCalls
832  * @tc.desc: test for testMatrixIsEqualMultipleCalls.
833  * @tc.size  : SmallTest
834  * @tc.type  : Function
835  * @tc.level : Level 3
836  */
837 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsEqualMultipleCalls, Function | SmallTest | Level3) {
838     // 1. OH_Drawing_MatrixCreate
839     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
840     // add assert
841     EXPECT_NE(matrix, nullptr);
842     OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate();
843     // add assert
844     EXPECT_NE(matrix2, nullptr);
845     // 2. Call OH_Drawing_MatrixIsEqual 10 times with alternating different or same matrices
846     for (int i = 0; i < 10; i++) {
847         if (i % 2 == 0) {
848             OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
849             OH_Drawing_MatrixSetMatrix(matrix2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
850             bool ret = OH_Drawing_MatrixIsEqual(matrix, matrix2);
851             EXPECT_EQ(ret, true);
852         } else {
853             OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
854             OH_Drawing_MatrixSetMatrix(matrix2, 2, 2, 3, 4, 5, 6, 7, 8, 9);
855             bool ret = OH_Drawing_MatrixIsEqual(matrix, matrix2);
856             EXPECT_EQ(ret, false);
857         }
858     }
859     // 3. Free memory
860     OH_Drawing_MatrixDestroy(matrix);
861     OH_Drawing_MatrixDestroy(matrix2);
862 }
863 
864 /*
865  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2300
866  * @tc.name: testMatrixIsIdentityNormal
867  * @tc.desc: test for testMatrixIsIdentityNormal.
868  * @tc.size  : SmallTest
869  * @tc.type  : Function
870  * @tc.level : Level 0
871  */
872 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsIdentityNormal, Function | SmallTest | Level0) {
873     // 1. OH_Drawing_MatrixIsIdentity with an identity matrix
874     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
875     // add assert
876     EXPECT_NE(matrix, nullptr);
877     bool ret = OH_Drawing_MatrixIsIdentity(matrix);
878     // add assert
879     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
880     EXPECT_EQ(ret, true);
881     // 2. OH_Drawing_MatrixIsIdentity with a non-identity matrix
882     OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
883     ret = OH_Drawing_MatrixIsIdentity(matrix);
884     // add assert
885     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
886     EXPECT_EQ(ret, false);
887     // 3. Free memory
888     OH_Drawing_MatrixDestroy(matrix);
889 }
890 
891 /*
892  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2301
893  * @tc.name: testMatrixIsIdentityNull
894  * @tc.desc: test for testMatrixIsIdentityNull.
895  * @tc.size  : SmallTest
896  * @tc.type  : Function
897  * @tc.level : Level 3
898  */
899 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsIdentityNull, Function | SmallTest | Level3) {
900     // 1. OH_Drawing_MatrixCreate
901     OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
902     // add assert
903     EXPECT_NE(matrix, nullptr);
904     // 2. OH_Drawing_MatrixIsIdentity with nullptr as parameter, check the error code with OH_Drawing_ErrorCodeGet
905     OH_Drawing_MatrixIsIdentity(nullptr);
906     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
907     // 3. Free memory
908     OH_Drawing_MatrixDestroy(matrix);
909 }
910 
911 /*
912  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2302
913  * @tc.name: testMatrixIsIdentityMultipleCalls
914  * @tc.desc: test for testMatrixIsIdentityMultipleCalls.
915  * @tc.size  : SmallTest
916  * @tc.type  : Function
917  * @tc.level : Level 3
918  */
919 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixIsIdentityMultipleCalls, Function | SmallTest | Level3) {
920     // Call OH_Drawing_MatrixIsIdentity 10 times with alternating identity or non-identity matrices
921     for (int i = 0; i < 10; i++) {
922         if (i % 2 == 0) {
923             OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
924             // add assert
925             EXPECT_NE(matrix, nullptr);
926             bool ret = OH_Drawing_MatrixIsIdentity(matrix);
927             EXPECT_EQ(ret, true);
928             OH_Drawing_MatrixDestroy(matrix);
929         } else {
930             OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
931             // add assert
932             EXPECT_NE(matrix, nullptr);
933             OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9);
934             bool ret = OH_Drawing_MatrixIsIdentity(matrix);
935             EXPECT_EQ(ret, false);
936             OH_Drawing_MatrixDestroy(matrix);
937         }
938     }
939 }
940 
941 /*
942  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2400
943  * @tc.name: testMatrixCopyNormal
944  * @tc.desc: test for testMatrixCopyNormal.
945  * @tc.size  : SmallTest
946  * @tc.type  : Function
947  * @tc.level : Level 0
948  */
949 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixCopyNormal, Function | SmallTest | Level0) {
950     // 1. Create a matrix object using OH_Drawing_MatrixCreate.
951     OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreate();
952     EXPECT_NE(matrix1, nullptr);
953     // 2. The function OH_Drawing_MatrixSetMatrix creates a identity matrix.
954     OH_Drawing_MatrixSetMatrix(matrix1, 1, 0, 0, 0, 1, 0, 0, 0, 1);
955     // 3. Using the function OH_Drawing_MatrixCopy copy another matrix.
956     OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCopy(matrix1);
957     EXPECT_NE(matrix2, nullptr);
958     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 0), 1);
959     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 1), 0);
960     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 2), 0);
961     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 3), 0);
962     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 4), 1);
963     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 5), 0);
964     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 6), 0);
965     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 7), 0);
966     EXPECT_EQ(OH_Drawing_MatrixGetValue(matrix2, 8), 1);
967     // 4. Free memory
968     OH_Drawing_MatrixDestroy(matrix1);
969     OH_Drawing_MatrixDestroy(matrix2);
970 }
971 
972 /*
973  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2401
974  * @tc.name: testMatrixCopyNull
975  * @tc.desc: test for testMatrixCopyNull.
976  * @tc.size  : SmallTest
977  * @tc.type  : Function
978  * @tc.level : Level 3
979  */
980 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixCopyNull, Function | SmallTest | Level3) {
981     // 1. Create a matrix object using OH_Drawing_MatrixCreate.
982     OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreate();
983     EXPECT_NE(matrix1, nullptr);
984     // 2. The function OH_Drawing_MatrixSetMatrix creates a identity matrix.
985     OH_Drawing_MatrixSetMatrix(matrix1, 1, 0, 0, 0, 1, 0, 0, 0, 1);
986     // 3. The function OH_Drawing_MatrixCopy passes to nullptr.
987     OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCopy(nullptr);
988     EXPECT_EQ(matrix2, nullptr);
989     // 4. Free memory
990     OH_Drawing_MatrixDestroy(matrix1);
991     OH_Drawing_MatrixDestroy(matrix2);
992 }
993 
994 
995 /*
996  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_MATRIX_2402
997  * @tc.name: testMatrixCopyMultipleCalls
998  * @tc.desc: test for testMatrixCopyMultipleCalls.
999  * @tc.size  : SmallTest
1000  * @tc.type  : Function
1001  * @tc.level : Level 3
1002  */
1003 HWTEST_F(DrawingNativeMatrixPart2Test, testMatrixCopyMultipleCalls, Function | SmallTest | Level3) {
1004     // 1. Create a matrix object using OH_Drawing_MatrixCreate.
1005     OH_Drawing_Matrix *matrix1 = OH_Drawing_MatrixCreate();
1006     EXPECT_NE(matrix1, nullptr);
1007     // 2. The function OH_Drawing_MatrixSetMatrix creates a identity matrix.
1008     OH_Drawing_MatrixSetMatrix(matrix1, 1, 0, 0, 0, 1, 0, 0, 0, 1);
1009     // 3. Using the function OH_Drawing_MatrixCopy copy another matrix.
1010     OH_Drawing_Matrix *matrix2 = OH_Drawing_MatrixCreate();
1011     // 4. The function OH_Drawing_MatrixCopy is called 10 times.
1012     for (int i = 0; i < 10; i++) {
1013         OH_Drawing_MatrixCopy(matrix1);
1014         EXPECT_NE(matrix2, nullptr);
1015     }
1016     // 5. Free memory
1017     OH_Drawing_MatrixDestroy(matrix1);
1018     OH_Drawing_MatrixDestroy(matrix2);
1019 }
1020 } // namespace Drawing
1021 } // namespace Rosen
1022 } // namespace OHOS