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