1f6603c60Sopenharmony_ci/* 2f6603c60Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License. 5f6603c60Sopenharmony_ci * You may obtain a copy of the License at 6f6603c60Sopenharmony_ci * 7f6603c60Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8f6603c60Sopenharmony_ci * 9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, Hardware 10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and 13f6603c60Sopenharmony_ci * limitations under the License. 14f6603c60Sopenharmony_ci */ 15f6603c60Sopenharmony_ci 16f6603c60Sopenharmony_ci#include "gtest/gtest.h" 17f6603c60Sopenharmony_ci 18f6603c60Sopenharmony_ci#include "drawing_error_code.h" 19f6603c60Sopenharmony_ci#include "drawing_matrix.h" 20f6603c60Sopenharmony_ci#include "drawing_rect.h" 21f6603c60Sopenharmony_ci#include "utils/scalar.h" 22f6603c60Sopenharmony_ci 23f6603c60Sopenharmony_ciusing namespace testing; 24f6603c60Sopenharmony_ciusing namespace testing::ext; 25f6603c60Sopenharmony_ci 26f6603c60Sopenharmony_cinamespace OHOS { 27f6603c60Sopenharmony_cinamespace Rosen { 28f6603c60Sopenharmony_cinamespace Drawing { 29f6603c60Sopenharmony_ciclass NativeDrawingMatrixTest : public testing::Test { 30f6603c60Sopenharmony_cipublic: 31f6603c60Sopenharmony_ci static void SetUpTestCase(); 32f6603c60Sopenharmony_ci static void TearDownTestCase(); 33f6603c60Sopenharmony_ci void SetUp() override; 34f6603c60Sopenharmony_ci void TearDown() override; 35f6603c60Sopenharmony_ci}; 36f6603c60Sopenharmony_ci 37f6603c60Sopenharmony_ciconstexpr uint32_t MAPPOINTS_SIZE = 5; 38f6603c60Sopenharmony_ciconstexpr uint32_t MAPPOINTS_COUNT = 2; 39f6603c60Sopenharmony_ci 40f6603c60Sopenharmony_civoid NativeDrawingMatrixTest::SetUpTestCase() {} 41f6603c60Sopenharmony_civoid NativeDrawingMatrixTest::TearDownTestCase() {} 42f6603c60Sopenharmony_civoid NativeDrawingMatrixTest::SetUp() {} 43f6603c60Sopenharmony_civoid NativeDrawingMatrixTest::TearDown() {} 44f6603c60Sopenharmony_ci 45f6603c60Sopenharmony_ci/* 46f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetMatrix001 47f6603c60Sopenharmony_ci * @tc.desc: test for SetMatrix. 48f6603c60Sopenharmony_ci * @tc.size : MediumTest 49f6603c60Sopenharmony_ci * @tc.type : Function 50f6603c60Sopenharmony_ci * @tc.level : Level 1 51f6603c60Sopenharmony_ci */ 52f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetMatrix001, TestSize.Level1) 53f6603c60Sopenharmony_ci{ 54f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 55f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 56f6603c60Sopenharmony_ci matrix, 57f6603c60Sopenharmony_ci 1, 0, 0, 58f6603c60Sopenharmony_ci 0, -1, 0, 59f6603c60Sopenharmony_ci 0, 0, 1); 60f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 61f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(nullptr); 62f6603c60Sopenharmony_ci} 63f6603c60Sopenharmony_ci 64f6603c60Sopenharmony_ci/* 65f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetRectToRect002 66f6603c60Sopenharmony_ci * @tc.desc: test for SetRectToRect. 67f6603c60Sopenharmony_ci * @tc.size : MediumTest 68f6603c60Sopenharmony_ci * @tc.type : Function 69f6603c60Sopenharmony_ci * @tc.level : Level 1 70f6603c60Sopenharmony_ci */ 71f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetRectToRect002, TestSize.Level1) 72f6603c60Sopenharmony_ci{ 73f6603c60Sopenharmony_ci OH_Drawing_Rect *rectSrcOne = OH_Drawing_RectCreate(0, 0, 0, 0); 74f6603c60Sopenharmony_ci OH_Drawing_Rect *rectDstOne = OH_Drawing_RectCreate(0, 0, 0, 0); 75f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrixOne = OH_Drawing_MatrixCreate(); 76f6603c60Sopenharmony_ci bool isSuccess = OH_Drawing_MatrixSetRectToRect(matrixOne, 77f6603c60Sopenharmony_ci rectSrcOne, rectDstOne, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 78f6603c60Sopenharmony_ci EXPECT_EQ(isSuccess, false); 79f6603c60Sopenharmony_ci isSuccess = OH_Drawing_MatrixSetRectToRect(nullptr, 80f6603c60Sopenharmony_ci rectSrcOne, rectDstOne, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 81f6603c60Sopenharmony_ci EXPECT_EQ(isSuccess, false); 82f6603c60Sopenharmony_ci isSuccess = OH_Drawing_MatrixSetRectToRect(matrixOne, 83f6603c60Sopenharmony_ci nullptr, rectDstOne, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 84f6603c60Sopenharmony_ci EXPECT_EQ(isSuccess, false); 85f6603c60Sopenharmony_ci isSuccess = OH_Drawing_MatrixSetRectToRect(matrixOne, 86f6603c60Sopenharmony_ci rectSrcOne, nullptr, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 87f6603c60Sopenharmony_ci EXPECT_EQ(isSuccess, false); 88f6603c60Sopenharmony_ci isSuccess = OH_Drawing_MatrixSetRectToRect(nullptr, nullptr, nullptr, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 89f6603c60Sopenharmony_ci EXPECT_EQ(isSuccess, false); 90f6603c60Sopenharmony_ci 91f6603c60Sopenharmony_ci OH_Drawing_Rect *rectSrcTwo = OH_Drawing_RectCreate(1, 2, 3, 4); 92f6603c60Sopenharmony_ci OH_Drawing_Rect *rectDstTwo = OH_Drawing_RectCreate(5, 6, 8, 9); 93f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrixTwo = OH_Drawing_MatrixCreate(); 94f6603c60Sopenharmony_ci bool isSuccessTwo = OH_Drawing_MatrixSetRectToRect(matrixTwo, 95f6603c60Sopenharmony_ci rectSrcTwo, rectDstTwo, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 96f6603c60Sopenharmony_ci EXPECT_EQ(isSuccessTwo, true); 97f6603c60Sopenharmony_ci float value; 98f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 0); 99f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1.5f)); 100f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 1); 101f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0.0f)); 102f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 2); 103f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 3.5f)); 104f6603c60Sopenharmony_ci 105f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 3); 106f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0.0f)); 107f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 4); 108f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1.5f)); 109f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 5); 110f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 3.0f)); 111f6603c60Sopenharmony_ci 112f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 6); 113f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0.0f)); 114f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 7); 115f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0.0f)); 116f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixTwo, 8); 117f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1.0f)); 118f6603c60Sopenharmony_ci 119f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixOne); 120f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixTwo); 121f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectSrcOne); 122f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectDstOne); 123f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectSrcTwo); 124f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectDstTwo); 125f6603c60Sopenharmony_ci} 126f6603c60Sopenharmony_ci 127f6603c60Sopenharmony_ci/* 128f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Reset003 129f6603c60Sopenharmony_ci * @tc.desc: test for Reset. 130f6603c60Sopenharmony_ci * @tc.size : MediumTest 131f6603c60Sopenharmony_ci * @tc.type : Function 132f6603c60Sopenharmony_ci * @tc.level : Level 1 133f6603c60Sopenharmony_ci */ 134f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Reset003, TestSize.Level1) 135f6603c60Sopenharmony_ci{ 136f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 137f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 0, 0, 0, 1, 2, 0, 0, 1); 138f6603c60Sopenharmony_ci OH_Drawing_MatrixReset(matrix); 139f6603c60Sopenharmony_ci bool isIdentity = OH_Drawing_MatrixIsIdentity(matrix); 140f6603c60Sopenharmony_ci EXPECT_EQ(isIdentity, true); 141f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 142f6603c60Sopenharmony_ci} 143f6603c60Sopenharmony_ci 144f6603c60Sopenharmony_ci/* 145f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_CreateRotation004 146f6603c60Sopenharmony_ci * @tc.desc: test for CreateRotation. 147f6603c60Sopenharmony_ci * @tc.size : MediumTest 148f6603c60Sopenharmony_ci * @tc.type : Function 149f6603c60Sopenharmony_ci * @tc.level : Level 1 150f6603c60Sopenharmony_ci */ 151f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_CreateRotation004, TestSize.Level1) 152f6603c60Sopenharmony_ci{ 153f6603c60Sopenharmony_ci // rotate deg: 180 pivot, point (1, 1) 154f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateRotation(180, 1, 1); 155f6603c60Sopenharmony_ci float value; 156f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 157f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -1)); 158f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 159f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 160f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 161f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 2)); 162f6603c60Sopenharmony_ci 163f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 164f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 165f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 166f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -1)); 167f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 168f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 2)); 169f6603c60Sopenharmony_ci 170f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 171f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 172f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 173f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 174f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 175f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 176f6603c60Sopenharmony_ci 177f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 178f6603c60Sopenharmony_ci} 179f6603c60Sopenharmony_ci 180f6603c60Sopenharmony_ci/* 181f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_CreateScale005 182f6603c60Sopenharmony_ci * @tc.desc: test for CreateScale. 183f6603c60Sopenharmony_ci * @tc.size : MediumTest 184f6603c60Sopenharmony_ci * @tc.type : Function 185f6603c60Sopenharmony_ci * @tc.level : Level 1 186f6603c60Sopenharmony_ci */ 187f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_CreateScale005, TestSize.Level1) 188f6603c60Sopenharmony_ci{ 189f6603c60Sopenharmony_ci /* The first 10 is horizontal scale factor. 190f6603c60Sopenharmony_ci The second 10 is vertical scale factor. 191f6603c60Sopenharmony_ci The third 10 is pivot on x-axis. 192f6603c60Sopenharmony_ci The fourth 10 is the pivot on y-axis. 193f6603c60Sopenharmony_ci */ 194f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateScale(10, 10, 10, 10); 195f6603c60Sopenharmony_ci float value; 196f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 197f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 198f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 199f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 200f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 201f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -90)); 202f6603c60Sopenharmony_ci 203f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 204f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 205f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 206f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 207f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 208f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -90)); 209f6603c60Sopenharmony_ci 210f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 211f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 212f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 213f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 214f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 215f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 216f6603c60Sopenharmony_ci 217f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 218f6603c60Sopenharmony_ci} 219f6603c60Sopenharmony_ci 220f6603c60Sopenharmony_ci/* 221f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_CreateTranslation006 222f6603c60Sopenharmony_ci * @tc.desc: test for CreateTranslation. 223f6603c60Sopenharmony_ci * @tc.size : MediumTest 224f6603c60Sopenharmony_ci * @tc.type : Function 225f6603c60Sopenharmony_ci * @tc.level : Level 1 226f6603c60Sopenharmony_ci */ 227f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_CreateTranslation006, TestSize.Level1) 228f6603c60Sopenharmony_ci{ 229f6603c60Sopenharmony_ci // translate x= 100, y = 200 230f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(100, 200); 231f6603c60Sopenharmony_ci float value; 232f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 233f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 234f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 235f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 236f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 237f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 100)); 238f6603c60Sopenharmony_ci 239f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 240f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 241f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 242f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 243f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 244f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 200)); 245f6603c60Sopenharmony_ci 246f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 247f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 248f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 249f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 250f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 251f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 252f6603c60Sopenharmony_ci 253f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 254f6603c60Sopenharmony_ci} 255f6603c60Sopenharmony_ci 256f6603c60Sopenharmony_ci/* 257f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Concat007 258f6603c60Sopenharmony_ci * @tc.desc: test for Concat. 259f6603c60Sopenharmony_ci * @tc.size : MediumTest 260f6603c60Sopenharmony_ci * @tc.type : Function 261f6603c60Sopenharmony_ci * @tc.level : Level 1 262f6603c60Sopenharmony_ci */ 263f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Concat007, TestSize.Level1) 264f6603c60Sopenharmony_ci{ 265f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixA = OH_Drawing_MatrixCreate(); 266f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixB = OH_Drawing_MatrixCreate(); 267f6603c60Sopenharmony_ci bool ret; 268f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(nullptr, matrixB); 269f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 270f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrixA, nullptr); 271f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 272f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrixA, matrixB); 273f6603c60Sopenharmony_ci EXPECT_TRUE(ret); 274f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 275f6603c60Sopenharmony_ci matrixA, 276f6603c60Sopenharmony_ci 1, 0, 0, 277f6603c60Sopenharmony_ci 0, -1, 0, 278f6603c60Sopenharmony_ci 0, 0, 1); 279f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 280f6603c60Sopenharmony_ci matrixB, 281f6603c60Sopenharmony_ci 1, 0, 100, 282f6603c60Sopenharmony_ci 0, -1, 200, 283f6603c60Sopenharmony_ci 0, 0, 1); 284f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrixA, matrixB); 285f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 286f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 287f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(nullptr, matrixA, matrixB); 288f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(matrix, nullptr, matrixB); 289f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(matrix, matrixA, nullptr); 290f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(matrix, matrixA, matrixB); 291f6603c60Sopenharmony_ci float value; 292f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 293f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 294f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 295f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 296f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 297f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 100)); 298f6603c60Sopenharmony_ci 299f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 300f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 301f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 302f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 303f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 304f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -200)); 305f6603c60Sopenharmony_ci 306f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 307f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 308f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 309f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 310f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 311f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 312f6603c60Sopenharmony_ci 313f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 314f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixA); 315f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixB); 316f6603c60Sopenharmony_ci} 317f6603c60Sopenharmony_ci 318f6603c60Sopenharmony_ci/* 319f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Rotate008 320f6603c60Sopenharmony_ci * @tc.desc: test for Rotate. 321f6603c60Sopenharmony_ci * @tc.size : MediumTest 322f6603c60Sopenharmony_ci * @tc.type : Function 323f6603c60Sopenharmony_ci * @tc.level : Level 1 324f6603c60Sopenharmony_ci */ 325f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Rotate008, TestSize.Level1) 326f6603c60Sopenharmony_ci{ 327f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 328f6603c60Sopenharmony_ci OH_Drawing_MatrixRotate(nullptr, 180, 1, 1); 329f6603c60Sopenharmony_ci OH_Drawing_MatrixRotate(matrix, 180, 1, 1); 330f6603c60Sopenharmony_ci float value; 331f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 332f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -1)); 333f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 334f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 335f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 336f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 2)); 337f6603c60Sopenharmony_ci 338f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 339f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 340f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 341f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -1)); 342f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 343f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 2)); 344f6603c60Sopenharmony_ci 345f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 346f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 347f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 348f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 349f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 350f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 351f6603c60Sopenharmony_ci 352f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(nullptr, 8); 353f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 354f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, -1); 355f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 356f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 9); 357f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 358f6603c60Sopenharmony_ci 359f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 360f6603c60Sopenharmony_ci} 361f6603c60Sopenharmony_ci 362f6603c60Sopenharmony_ci/* 363f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PreRotate009 364f6603c60Sopenharmony_ci * @tc.desc: test for PreRotate. 365f6603c60Sopenharmony_ci * @tc.size : MediumTest 366f6603c60Sopenharmony_ci * @tc.type : Function 367f6603c60Sopenharmony_ci * @tc.level : Level 1 368f6603c60Sopenharmony_ci */ 369f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PreRotate009, TestSize.Level1) 370f6603c60Sopenharmony_ci{ 371f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 372f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 0, 0, 0, 1, 2, 0, 0, 1); 373f6603c60Sopenharmony_ci OH_Drawing_MatrixPreRotate(matrix, 5, 10, 20); 374f6603c60Sopenharmony_ci OH_Drawing_MatrixPreRotate(nullptr, 5, 10, 20); 375f6603c60Sopenharmony_ci 376f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9); 377f6603c60Sopenharmony_ci OH_Drawing_MatrixPreRotate(matrix, 90, 1, 0); 378f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 379f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, 2, -1, 2, 5, -4, 5, 8, -7, 8); 380f6603c60Sopenharmony_ci bool ret = false; 381f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 382f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 383f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 384f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 385f6603c60Sopenharmony_ci} 386f6603c60Sopenharmony_ci 387f6603c60Sopenharmony_ci/* 388f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PostRotate010 389f6603c60Sopenharmony_ci * @tc.desc: test for PostRotate. 390f6603c60Sopenharmony_ci * @tc.size : MediumTest 391f6603c60Sopenharmony_ci * @tc.type : Function 392f6603c60Sopenharmony_ci * @tc.level : Level 1 393f6603c60Sopenharmony_ci */ 394f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PostRotate010, TestSize.Level1) 395f6603c60Sopenharmony_ci{ 396f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 397f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 0, 0, 0, 1, 2, 0, 0, 1); 398f6603c60Sopenharmony_ci OH_Drawing_MatrixPostRotate(matrix, 5, 10, 20); 399f6603c60Sopenharmony_ci OH_Drawing_MatrixPostRotate(nullptr, 5, 10, 20); 400f6603c60Sopenharmony_ci 401f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 4, 5, 6, 7, 8, 9); 402f6603c60Sopenharmony_ci OH_Drawing_MatrixPostRotate(matrix, 90, 1, 0); 403f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 404f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, 3, 3, 3, -6, -6, -6, 7, 8, 9); 405f6603c60Sopenharmony_ci bool ret = false; 406f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 407f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 408f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 409f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 410f6603c60Sopenharmony_ci} 411f6603c60Sopenharmony_ci 412f6603c60Sopenharmony_ci/* 413f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Scale011 414f6603c60Sopenharmony_ci * @tc.desc: test for Scale. 415f6603c60Sopenharmony_ci * @tc.size : MediumTest 416f6603c60Sopenharmony_ci * @tc.type : Function 417f6603c60Sopenharmony_ci * @tc.level : Level 1 418f6603c60Sopenharmony_ci */ 419f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Scale011, TestSize.Level1) 420f6603c60Sopenharmony_ci{ 421f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 422f6603c60Sopenharmony_ci 423f6603c60Sopenharmony_ci OH_Drawing_MatrixScale(nullptr, 10, 10, 10, 10); 424f6603c60Sopenharmony_ci OH_Drawing_MatrixScale(matrix, 10, 10, 10, 10); 425f6603c60Sopenharmony_ci float value; 426f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 427f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 428f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 429f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 430f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 431f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -90)); 432f6603c60Sopenharmony_ci 433f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 434f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 435f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 436f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 437f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 438f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -90)); 439f6603c60Sopenharmony_ci 440f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 441f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 442f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 443f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 444f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 445f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 446f6603c60Sopenharmony_ci 447f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 448f6603c60Sopenharmony_ci} 449f6603c60Sopenharmony_ci 450f6603c60Sopenharmony_ci/* 451f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PreScale012 452f6603c60Sopenharmony_ci * @tc.desc: test for PreScale. 453f6603c60Sopenharmony_ci * @tc.size : MediumTest 454f6603c60Sopenharmony_ci * @tc.type : Function 455f6603c60Sopenharmony_ci * @tc.level : Level 1 456f6603c60Sopenharmony_ci */ 457f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PreScale012, TestSize.Level1) 458f6603c60Sopenharmony_ci{ 459f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 460f6603c60Sopenharmony_ci OH_Drawing_MatrixPreScale(nullptr, 10, 10, 10, 10); 461f6603c60Sopenharmony_ci OH_Drawing_MatrixPreScale(matrix, 10, 10, 10, 10); 462f6603c60Sopenharmony_ci float value; 463f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 464f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 465f6603c60Sopenharmony_ci 466f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1); 467f6603c60Sopenharmony_ci OH_Drawing_MatrixPreScale(matrix, 4, 6, 5, 7); 468f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 469f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, 8, 6, -62, 4, 12, -83, 12, 6, -79); 470f6603c60Sopenharmony_ci bool ret = false; 471f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 472f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 473f6603c60Sopenharmony_ci 474f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 475f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 476f6603c60Sopenharmony_ci} 477f6603c60Sopenharmony_ci 478f6603c60Sopenharmony_ci/* 479f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PostScale013 480f6603c60Sopenharmony_ci * @tc.desc: test for PostScale. 481f6603c60Sopenharmony_ci * @tc.size : MediumTest 482f6603c60Sopenharmony_ci * @tc.type : Function 483f6603c60Sopenharmony_ci * @tc.level : Level 1 484f6603c60Sopenharmony_ci */ 485f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PostScale013, TestSize.Level1) 486f6603c60Sopenharmony_ci{ 487f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 488f6603c60Sopenharmony_ci OH_Drawing_MatrixPostScale(nullptr, 10, 10, 10, 10); 489f6603c60Sopenharmony_ci OH_Drawing_MatrixPostScale(matrix, 10, 10, 10, 10); 490f6603c60Sopenharmony_ci float value; 491f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 492f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 10)); 493f6603c60Sopenharmony_ci 494f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1); 495f6603c60Sopenharmony_ci OH_Drawing_MatrixPostScale(matrix, 4, 6, 5, 7); 496f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 497f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, -37, -11, -3, -99, -23, -23, 3, 1, 1); 498f6603c60Sopenharmony_ci bool ret = false; 499f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 500f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 501f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 502f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 503f6603c60Sopenharmony_ci} 504f6603c60Sopenharmony_ci 505f6603c60Sopenharmony_ci/* 506f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Translate014 507f6603c60Sopenharmony_ci * @tc.desc: test for Translate. 508f6603c60Sopenharmony_ci * @tc.size : MediumTest 509f6603c60Sopenharmony_ci * @tc.type : Function 510f6603c60Sopenharmony_ci * @tc.level : Level 1 511f6603c60Sopenharmony_ci */ 512f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Translate014, TestSize.Level1) 513f6603c60Sopenharmony_ci{ 514f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 515f6603c60Sopenharmony_ci bool ret; 516f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsIdentity(matrix); 517f6603c60Sopenharmony_ci EXPECT_TRUE(ret); 518f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsIdentity(nullptr); 519f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 520f6603c60Sopenharmony_ci 521f6603c60Sopenharmony_ci OH_Drawing_MatrixTranslate(nullptr, 100, 200); 522f6603c60Sopenharmony_ci OH_Drawing_MatrixTranslate(matrix, 100, 200); 523f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsIdentity(matrix); 524f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 525f6603c60Sopenharmony_ci float value; 526f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 527f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 528f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 1); 529f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 530f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 2); 531f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 100)); 532f6603c60Sopenharmony_ci 533f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 3); 534f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 535f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 4); 536f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 537f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 5); 538f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 200)); 539f6603c60Sopenharmony_ci 540f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 6); 541f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 542f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 7); 543f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 544f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 8); 545f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 546f6603c60Sopenharmony_ci 547f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 548f6603c60Sopenharmony_ci} 549f6603c60Sopenharmony_ci 550f6603c60Sopenharmony_ci/* 551f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PreTranslate015 552f6603c60Sopenharmony_ci * @tc.desc: test for PreTranslate. 553f6603c60Sopenharmony_ci * @tc.size : MediumTest 554f6603c60Sopenharmony_ci * @tc.type : Function 555f6603c60Sopenharmony_ci * @tc.level : Level 1 556f6603c60Sopenharmony_ci */ 557f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PreTranslate015, TestSize.Level1) 558f6603c60Sopenharmony_ci{ 559f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 560f6603c60Sopenharmony_ci OH_Drawing_MatrixPreTranslate(nullptr, 10, 10); 561f6603c60Sopenharmony_ci OH_Drawing_MatrixPreTranslate(matrix, 10, 10); 562f6603c60Sopenharmony_ci float value; 563f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 564f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 565f6603c60Sopenharmony_ci 566f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1); 567f6603c60Sopenharmony_ci OH_Drawing_MatrixPreTranslate(matrix, 2, 4); 568f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 569f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, 2, 1, 11, 1, 2, 12, 3, 1, 11); 570f6603c60Sopenharmony_ci bool ret = false; 571f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 572f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 573f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 574f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 575f6603c60Sopenharmony_ci} 576f6603c60Sopenharmony_ci 577f6603c60Sopenharmony_ci/* 578f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_PostTranslate016 579f6603c60Sopenharmony_ci * @tc.desc: test for PostTranslate. 580f6603c60Sopenharmony_ci * @tc.size : MediumTest 581f6603c60Sopenharmony_ci * @tc.type : Function 582f6603c60Sopenharmony_ci * @tc.level : Level 1 583f6603c60Sopenharmony_ci */ 584f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_PostTranslate016, TestSize.Level1) 585f6603c60Sopenharmony_ci{ 586f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 587f6603c60Sopenharmony_ci OH_Drawing_MatrixPostTranslate(nullptr, 10, 10); 588f6603c60Sopenharmony_ci OH_Drawing_MatrixPostTranslate(matrix, 10, 10); 589f6603c60Sopenharmony_ci float value; 590f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrix, 0); 591f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 592f6603c60Sopenharmony_ci 593f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 2, 1, 3, 1, 2, 2, 3, 1, 1); 594f6603c60Sopenharmony_ci OH_Drawing_MatrixPostTranslate(matrix, 2, 4); 595f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate(); 596f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix2, 8, 3, 5, 13, 6, 6, 3, 1, 1); 597f6603c60Sopenharmony_ci bool ret = false; 598f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixIsEqual(matrix, matrix2); 599f6603c60Sopenharmony_ci EXPECT_EQ(ret, true); 600f6603c60Sopenharmony_ci 601f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 602f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix2); 603f6603c60Sopenharmony_ci} 604f6603c60Sopenharmony_ci 605f6603c60Sopenharmony_ci/* 606f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_Invert017 607f6603c60Sopenharmony_ci * @tc.desc: test for Invert. 608f6603c60Sopenharmony_ci * @tc.size : MediumTest 609f6603c60Sopenharmony_ci * @tc.type : Function 610f6603c60Sopenharmony_ci * @tc.level : Level 1 611f6603c60Sopenharmony_ci */ 612f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_Invert017, TestSize.Level1) 613f6603c60Sopenharmony_ci{ 614f6603c60Sopenharmony_ci bool ret; 615f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixInvert(nullptr, nullptr); 616f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 617f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixA = OH_Drawing_MatrixCreate(); 618f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixB = OH_Drawing_MatrixCreate(); 619f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixInvert(nullptr, matrixB); 620f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 621f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixInvert(matrixA, nullptr); 622f6603c60Sopenharmony_ci EXPECT_TRUE(!ret); 623f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixInvert(matrixA, matrixB); 624f6603c60Sopenharmony_ci EXPECT_TRUE(ret); 625f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 626f6603c60Sopenharmony_ci matrixA, 627f6603c60Sopenharmony_ci 1, 0, 0, 628f6603c60Sopenharmony_ci 0, -0.5, 0, 629f6603c60Sopenharmony_ci 0, 0, 1); 630f6603c60Sopenharmony_ci ret = OH_Drawing_MatrixInvert(matrixA, matrixB); 631f6603c60Sopenharmony_ci EXPECT_TRUE(ret); 632f6603c60Sopenharmony_ci 633f6603c60Sopenharmony_ci float value; 634f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 0); 635f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 636f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 1); 637f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 638f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 2); 639f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 640f6603c60Sopenharmony_ci 641f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 3); 642f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 643f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 4); 644f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, -2)); 645f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 5); 646f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 647f6603c60Sopenharmony_ci 648f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 6); 649f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 650f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 7); 651f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 0)); 652f6603c60Sopenharmony_ci value = OH_Drawing_MatrixGetValue(matrixB, 8); 653f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(value, 1)); 654f6603c60Sopenharmony_ci 655f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixA); 656f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixB); 657f6603c60Sopenharmony_ci} 658f6603c60Sopenharmony_ci 659f6603c60Sopenharmony_ci/* 660f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetPolyToPoly018 661f6603c60Sopenharmony_ci * @tc.desc: test for set poly to poly of Matrix. 662f6603c60Sopenharmony_ci * @tc.size : MediumTest 663f6603c60Sopenharmony_ci * @tc.type : Function 664f6603c60Sopenharmony_ci * @tc.level : Level 1 665f6603c60Sopenharmony_ci */ 666f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetPolyToPoly018, TestSize.Level1) 667f6603c60Sopenharmony_ci{ 668f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 669f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 670f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 671f6603c60Sopenharmony_ci matrix, 672f6603c60Sopenharmony_ci 1, 0, 0, 673f6603c60Sopenharmony_ci 0, -1, 0, 674f6603c60Sopenharmony_ci 0, 0, 1); 675f6603c60Sopenharmony_ci OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}}; 676f6603c60Sopenharmony_ci OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}}; 677f6603c60Sopenharmony_ci EXPECT_TRUE(OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 0)); 678f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 679f6603c60Sopenharmony_ci} 680f6603c60Sopenharmony_ci 681f6603c60Sopenharmony_ci/* 682f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetPolyToPoly019 683f6603c60Sopenharmony_ci * @tc.desc: test for set poly to poly of Matrix. 684f6603c60Sopenharmony_ci * @tc.size : MediumTest 685f6603c60Sopenharmony_ci * @tc.type : Function 686f6603c60Sopenharmony_ci * @tc.level : Level 1 687f6603c60Sopenharmony_ci */ 688f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetPolyToPoly019, TestSize.Level1) 689f6603c60Sopenharmony_ci{ 690f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 691f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 692f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 693f6603c60Sopenharmony_ci matrix, 694f6603c60Sopenharmony_ci 1, 0, 0, 695f6603c60Sopenharmony_ci 0, -1, 0, 696f6603c60Sopenharmony_ci 0, 0, 1); 697f6603c60Sopenharmony_ci OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}}; 698f6603c60Sopenharmony_ci OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}}; 699f6603c60Sopenharmony_ci EXPECT_TRUE(OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 1)); 700f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 701f6603c60Sopenharmony_ci} 702f6603c60Sopenharmony_ci 703f6603c60Sopenharmony_ci/* 704f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetPolyToPoly020 705f6603c60Sopenharmony_ci * @tc.desc: test for set poly to poly of Matrix. 706f6603c60Sopenharmony_ci * @tc.size : MediumTest 707f6603c60Sopenharmony_ci * @tc.type : Function 708f6603c60Sopenharmony_ci * @tc.level : Level 1 709f6603c60Sopenharmony_ci */ 710f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetPolyToPoly020, TestSize.Level1) 711f6603c60Sopenharmony_ci{ 712f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 713f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 714f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 715f6603c60Sopenharmony_ci matrix, 716f6603c60Sopenharmony_ci 1, 0, 0, 717f6603c60Sopenharmony_ci 0, -1, 0, 718f6603c60Sopenharmony_ci 0, 0, 1); 719f6603c60Sopenharmony_ci OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}}; 720f6603c60Sopenharmony_ci OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}}; 721f6603c60Sopenharmony_ci EXPECT_TRUE(OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 4)); 722f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 723f6603c60Sopenharmony_ci} 724f6603c60Sopenharmony_ci 725f6603c60Sopenharmony_ci/* 726f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetPolyToPoly021 727f6603c60Sopenharmony_ci * @tc.desc: test for set poly to poly of Matrix. 728f6603c60Sopenharmony_ci * @tc.size : MediumTest 729f6603c60Sopenharmony_ci * @tc.type : Function 730f6603c60Sopenharmony_ci * @tc.level : Level 1 731f6603c60Sopenharmony_ci */ 732f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetPolyToPoly021, TestSize.Level1) 733f6603c60Sopenharmony_ci{ 734f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 735f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 736f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix( 737f6603c60Sopenharmony_ci matrix, 738f6603c60Sopenharmony_ci 1, 0, 0, 739f6603c60Sopenharmony_ci 0, -1, 0, 740f6603c60Sopenharmony_ci 0, 0, 1); 741f6603c60Sopenharmony_ci OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}}; 742f6603c60Sopenharmony_ci OH_Drawing_Point2D dst[] = {{0, 0}, {100, 30}, {100, 70}, {0, 100}, {0, 100}}; 743f6603c60Sopenharmony_ci EXPECT_FALSE(OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, 5)); 744f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 745f6603c60Sopenharmony_ci} 746f6603c60Sopenharmony_ci 747f6603c60Sopenharmony_ci/** 748f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_GetAll022 749f6603c60Sopenharmony_ci * @tc.desc: test for Copies nine scalar values contained by Matrix into buffer. 750f6603c60Sopenharmony_ci * @tc.type: FUNC 751f6603c60Sopenharmony_ci * @tc.require: AR20240104201189 752f6603c60Sopenharmony_ci */ 753f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_GetAll022, TestSize.Level1) 754f6603c60Sopenharmony_ci{ 755f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 756f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 757f6603c60Sopenharmony_ci float buffer[9]; 758f6603c60Sopenharmony_ci float emptyBuffer[9] = {1, 2, 3, 3, 2, 1, 4, 5, 6}; 759f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 2, 3, 3, 2, 1, 4, 5, 6); 760f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_MatrixGetAll(matrix, buffer), OH_DRAWING_SUCCESS); 761f6603c60Sopenharmony_ci for (int i = 0; i < 9; ++i) { 762f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(buffer[i], emptyBuffer[i])); 763f6603c60Sopenharmony_ci } 764f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 765f6603c60Sopenharmony_ci} 766f6603c60Sopenharmony_ci 767f6603c60Sopenharmony_ci/* 768f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_IsEqualAndConcat023 769f6603c60Sopenharmony_ci * @tc.desc: test for IsEqual and Concat. 770f6603c60Sopenharmony_ci * @tc.type: FUNC 771f6603c60Sopenharmony_ci * @tc.require: SR000S9F0C 772f6603c60Sopenharmony_ci */ 773f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_IsEqualAndConcat023, TestSize.Level1) 774f6603c60Sopenharmony_ci{ 775f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixA = OH_Drawing_MatrixCreate(); 776f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrixB = OH_Drawing_MatrixCreate(); 777f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 778f6603c60Sopenharmony_ci OH_Drawing_MatrixIsEqual(nullptr, matrixB); 779f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 780f6603c60Sopenharmony_ci OH_Drawing_MatrixIsEqual(matrixA, nullptr); 781f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 782f6603c60Sopenharmony_ci 783f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(nullptr, matrixA, matrixB); 784f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 785f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(matrix, nullptr, matrixB); 786f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 787f6603c60Sopenharmony_ci OH_Drawing_MatrixConcat(matrix, matrixA, nullptr); 788f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 789f6603c60Sopenharmony_ci 790f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 791f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixA); 792f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixB); 793f6603c60Sopenharmony_ci} 794f6603c60Sopenharmony_ci 795f6603c60Sopenharmony_ci/* 796f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_SetRectToRect024 797f6603c60Sopenharmony_ci * @tc.desc: test for SetRectToRect. 798f6603c60Sopenharmony_ci * @tc.type: FUNC 799f6603c60Sopenharmony_ci * @tc.require: SR000S9F0C 800f6603c60Sopenharmony_ci */ 801f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_SetRectToRect024, TestSize.Level1) 802f6603c60Sopenharmony_ci{ 803f6603c60Sopenharmony_ci OH_Drawing_Rect *rectSrcOne = OH_Drawing_RectCreate(0, 0, 0, 0); 804f6603c60Sopenharmony_ci OH_Drawing_Rect *rectDstOne = OH_Drawing_RectCreate(0, 0, 0, 0); 805f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrixOne = OH_Drawing_MatrixCreate(); 806f6603c60Sopenharmony_ci OH_Drawing_MatrixSetRectToRect(nullptr, rectSrcOne, rectDstOne, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 807f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 808f6603c60Sopenharmony_ci OH_Drawing_MatrixSetRectToRect(matrixOne, nullptr, rectDstOne, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 809f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 810f6603c60Sopenharmony_ci OH_Drawing_MatrixSetRectToRect(matrixOne, rectSrcOne, nullptr, OH_Drawing_ScaleToFit::SCALE_TO_FIT_FILL); 811f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 812f6603c60Sopenharmony_ci 813f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrixOne); 814f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectSrcOne); 815f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rectDstOne); 816f6603c60Sopenharmony_ci} 817f6603c60Sopenharmony_ci 818f6603c60Sopenharmony_ci/** 819f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_MapPoints025 820f6603c60Sopenharmony_ci * @tc.desc: test for maps the src point array to the dst point array by matrix transformation. 821f6603c60Sopenharmony_ci * @tc.type: FUNC 822f6603c60Sopenharmony_ci * @tc.require: AR20240104201189 823f6603c60Sopenharmony_ci */ 824f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_MapPoints025, TestSize.Level1) 825f6603c60Sopenharmony_ci{ 826f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 827f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 828f6603c60Sopenharmony_ci OH_Drawing_Point2D src[] = {{0, 0}, {100, 0}, {100, 100}, {0, 100}, {0, 100}}; 829f6603c60Sopenharmony_ci OH_Drawing_Point2D dst[MAPPOINTS_SIZE]; 830f6603c60Sopenharmony_ci 831f6603c60Sopenharmony_ci OH_Drawing_MatrixMapPoints(nullptr, src, dst, MAPPOINTS_COUNT); 832f6603c60Sopenharmony_ci OH_Drawing_MatrixTranslate(matrix, 100, 200); 833f6603c60Sopenharmony_ci OH_Drawing_MatrixMapPoints(matrix, src, dst, MAPPOINTS_COUNT); 834f6603c60Sopenharmony_ci 835f6603c60Sopenharmony_ci EXPECT_EQ(dst[0].x, 100); 836f6603c60Sopenharmony_ci EXPECT_EQ(dst[0].y, 200); 837f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 838f6603c60Sopenharmony_ci} 839f6603c60Sopenharmony_ci 840f6603c60Sopenharmony_ci/** 841f6603c60Sopenharmony_ci * @tc.name: NativeDrawingMatrixTest_MapRect026 842f6603c60Sopenharmony_ci * @tc.desc: test for sets dst to bounds of src corners mapped by matrix transformation. 843f6603c60Sopenharmony_ci * @tc.type: FUNC 844f6603c60Sopenharmony_ci * @tc.require: AR20240104201189 845f6603c60Sopenharmony_ci */ 846f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingMatrixTest, NativeDrawingMatrixTest_MapRect026, TestSize.Level1) 847f6603c60Sopenharmony_ci{ 848f6603c60Sopenharmony_ci OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate(); 849f6603c60Sopenharmony_ci ASSERT_TRUE(matrix != nullptr); 850f6603c60Sopenharmony_ci OH_Drawing_Rect* src = OH_Drawing_RectCreate(0, 100, 200, 200); 851f6603c60Sopenharmony_ci OH_Drawing_Rect* dst = OH_Drawing_RectCreate(0, 0, 0, 0); 852f6603c60Sopenharmony_ci 853f6603c60Sopenharmony_ci EXPECT_FALSE(OH_Drawing_MatrixMapRect(nullptr, src, dst)); 854f6603c60Sopenharmony_ci OH_Drawing_MatrixTranslate(matrix, 100, 200); 855f6603c60Sopenharmony_ci EXPECT_TRUE(OH_Drawing_MatrixMapRect(matrix, src, dst)); 856f6603c60Sopenharmony_ci 857f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(OH_Drawing_RectGetHeight(dst), 100.f)); 858f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(OH_Drawing_RectGetLeft(dst), 100.f)); 859f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(src); 860f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(dst); 861f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 862f6603c60Sopenharmony_ci} 863f6603c60Sopenharmony_ci} // namespace Drawing 864f6603c60Sopenharmony_ci} // namespace Rosen 865f6603c60Sopenharmony_ci} // namespace OHOS 866