1f6603c60Sopenharmony_ci/* 2f6603c60Sopenharmony_ci * Copyright (c) 2022-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 <cstdio> 17f6603c60Sopenharmony_ci#include "gtest/gtest.h" 18f6603c60Sopenharmony_ci 19f6603c60Sopenharmony_ci#include "drawing_path.h" 20f6603c60Sopenharmony_ci#include "drawing_matrix.h" 21f6603c60Sopenharmony_ci#include "drawing_rect.h" 22f6603c60Sopenharmony_ci#include "drawing_round_rect.h" 23f6603c60Sopenharmony_ci#include "draw/path.h" 24f6603c60Sopenharmony_ci#include "utils/scalar.h" 25f6603c60Sopenharmony_ci 26f6603c60Sopenharmony_ciusing namespace testing; 27f6603c60Sopenharmony_ciusing namespace testing::ext; 28f6603c60Sopenharmony_ci 29f6603c60Sopenharmony_cinamespace OHOS { 30f6603c60Sopenharmony_cinamespace Rosen { 31f6603c60Sopenharmony_cinamespace Drawing { 32f6603c60Sopenharmony_ciclass NativeDrawingPathLargeValueTest : public testing::Test { 33f6603c60Sopenharmony_cipublic: 34f6603c60Sopenharmony_ci static void SetUpTestCase(); 35f6603c60Sopenharmony_ci static void TearDownTestCase(); 36f6603c60Sopenharmony_ci void SetUp() override; 37f6603c60Sopenharmony_ci void TearDown() override; 38f6603c60Sopenharmony_ci}; 39f6603c60Sopenharmony_ci 40f6603c60Sopenharmony_civoid NativeDrawingPathLargeValueTest::SetUpTestCase() {} 41f6603c60Sopenharmony_civoid NativeDrawingPathLargeValueTest::TearDownTestCase() {} 42f6603c60Sopenharmony_civoid NativeDrawingPathLargeValueTest::SetUp() {} 43f6603c60Sopenharmony_civoid NativeDrawingPathLargeValueTest::TearDown() {} 44f6603c60Sopenharmony_ci 45f6603c60Sopenharmony_ci/* 46f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathCreate001 47f6603c60Sopenharmony_ci * @tc.desc: test for create drawing_path. 48f6603c60Sopenharmony_ci * @tc.size : MediumTest 49f6603c60Sopenharmony_ci * @tc.type : Function 50f6603c60Sopenharmony_ci * @tc.level : Level 1 51f6603c60Sopenharmony_ci */ 52f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathCreate001, TestSize.Level1) 53f6603c60Sopenharmony_ci{ 54f6603c60Sopenharmony_ci OH_Drawing_Path* path = OH_Drawing_PathCreate(); 55f6603c60Sopenharmony_ci EXPECT_EQ(path == nullptr, false); 56f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 57f6603c60Sopenharmony_ci} 58f6603c60Sopenharmony_ci 59f6603c60Sopenharmony_ci/* 60f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathMoveTo002 61f6603c60Sopenharmony_ci * @tc.desc: test for PathMoveTo func. 62f6603c60Sopenharmony_ci * @tc.size : MediumTest 63f6603c60Sopenharmony_ci * @tc.type : Function 64f6603c60Sopenharmony_ci * @tc.level : Level 1 65f6603c60Sopenharmony_ci */ 66f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathMoveTo002, TestSize.Level1) 67f6603c60Sopenharmony_ci{ 68f6603c60Sopenharmony_ci OH_Drawing_Path* path1 = OH_Drawing_PathCreate(); 69f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path1, 2160, 4096); 70f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path1, -1, 20.6f); 71f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path1); 72f6603c60Sopenharmony_ci} 73f6603c60Sopenharmony_ci 74f6603c60Sopenharmony_ci/* 75f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathLineTo003 76f6603c60Sopenharmony_ci * @tc.desc: test for PathLineTo func. 77f6603c60Sopenharmony_ci * @tc.size : MediumTest 78f6603c60Sopenharmony_ci * @tc.type : Function 79f6603c60Sopenharmony_ci * @tc.level : Level 1 80f6603c60Sopenharmony_ci */ 81f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathLineTo003, TestSize.Level1) 82f6603c60Sopenharmony_ci{ 83f6603c60Sopenharmony_ci OH_Drawing_Path* path2 = OH_Drawing_PathCreate(); 84f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path2, 2160, 4096); 85f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path2, -50, 10.2f); 86f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path2); 87f6603c60Sopenharmony_ci} 88f6603c60Sopenharmony_ci 89f6603c60Sopenharmony_ci/* 90f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathReset004 91f6603c60Sopenharmony_ci * @tc.desc: test for PathReset func. 92f6603c60Sopenharmony_ci * @tc.size : MediumTest 93f6603c60Sopenharmony_ci * @tc.type : Function 94f6603c60Sopenharmony_ci * @tc.level : Level 1 95f6603c60Sopenharmony_ci */ 96f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathReset004, TestSize.Level1) 97f6603c60Sopenharmony_ci{ 98f6603c60Sopenharmony_ci OH_Drawing_Path* path3 = OH_Drawing_PathCreate(); 99f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path3, 2160, 4096); 100f6603c60Sopenharmony_ci OH_Drawing_PathReset(path3); 101f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path3); 102f6603c60Sopenharmony_ci} 103f6603c60Sopenharmony_ci 104f6603c60Sopenharmony_ci/* 105f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathArcTo005 106f6603c60Sopenharmony_ci * @tc.desc: test for PathArcTo func. 107f6603c60Sopenharmony_ci * @tc.size : MediumTest 108f6603c60Sopenharmony_ci * @tc.type : Function 109f6603c60Sopenharmony_ci * @tc.level : Level 1 110f6603c60Sopenharmony_ci */ 111f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathArcTo005, TestSize.Level1) 112f6603c60Sopenharmony_ci{ 113f6603c60Sopenharmony_ci OH_Drawing_Path* path4 = OH_Drawing_PathCreate(); 114f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path4, 10, 10, 2160, 4096, 0, 90); 115f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path4, -10, 10, 10, -10, 0, 90); 116f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path4); 117f6603c60Sopenharmony_ci} 118f6603c60Sopenharmony_ci 119f6603c60Sopenharmony_ci/* 120f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathQuadTo006 121f6603c60Sopenharmony_ci * @tc.desc: test for PathQuadTo func. 122f6603c60Sopenharmony_ci * @tc.size : MediumTest 123f6603c60Sopenharmony_ci * @tc.type : Function 124f6603c60Sopenharmony_ci * @tc.level : Level 1 125f6603c60Sopenharmony_ci */ 126f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathQuadTo006, TestSize.Level1) 127f6603c60Sopenharmony_ci{ 128f6603c60Sopenharmony_ci OH_Drawing_Path* path5 = OH_Drawing_PathCreate(); 129f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path5, 0, 0, 2160, 4096); 130f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path5, -20.5f, -20.5f, 30, 0); 131f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path5); 132f6603c60Sopenharmony_ci} 133f6603c60Sopenharmony_ci 134f6603c60Sopenharmony_ci/* 135f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathCubicTo007 136f6603c60Sopenharmony_ci * @tc.desc: test for PathCubicTo func. 137f6603c60Sopenharmony_ci * @tc.size : MediumTest 138f6603c60Sopenharmony_ci * @tc.type : Function 139f6603c60Sopenharmony_ci * @tc.level : Level 1 140f6603c60Sopenharmony_ci */ 141f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathCubicTo007, TestSize.Level1) 142f6603c60Sopenharmony_ci{ 143f6603c60Sopenharmony_ci OH_Drawing_Path* path6 = OH_Drawing_PathCreate(); 144f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path6, 30, 40, 60, 0, 2160, 4096); 145f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path6, -30, 40, 60, -30.6f, 50, -20); 146f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path6); 147f6603c60Sopenharmony_ci} 148f6603c60Sopenharmony_ci 149f6603c60Sopenharmony_ci/* 150f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathClose008 151f6603c60Sopenharmony_ci * @tc.desc: test for PathClose func. 152f6603c60Sopenharmony_ci * @tc.size : MediumTest 153f6603c60Sopenharmony_ci * @tc.type : Function 154f6603c60Sopenharmony_ci * @tc.level : Level 1 155f6603c60Sopenharmony_ci */ 156f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathClose008, TestSize.Level1) 157f6603c60Sopenharmony_ci{ 158f6603c60Sopenharmony_ci OH_Drawing_Path* path7 = OH_Drawing_PathCreate(); 159f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path7, 2160, 4096); 160f6603c60Sopenharmony_ci OH_Drawing_PathClose(path7); 161f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path7); 162f6603c60Sopenharmony_ci} 163f6603c60Sopenharmony_ci 164f6603c60Sopenharmony_ci/* 165f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathCopy009 166f6603c60Sopenharmony_ci * @tc.desc: test for PathCopy func. 167f6603c60Sopenharmony_ci * @tc.size : MediumTest 168f6603c60Sopenharmony_ci * @tc.type : Function 169f6603c60Sopenharmony_ci * @tc.level : Level 1 170f6603c60Sopenharmony_ci */ 171f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathCopy009, TestSize.Level1) 172f6603c60Sopenharmony_ci{ 173f6603c60Sopenharmony_ci OH_Drawing_Path* path7 = OH_Drawing_PathCreate(); 174f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path7, 2160, 4096); 175f6603c60Sopenharmony_ci OH_Drawing_PathClose(path7); 176f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_PathCopy(nullptr), nullptr); 177f6603c60Sopenharmony_ci OH_Drawing_Path* pathCopy = OH_Drawing_PathCopy(path7); 178f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetWidth(), 2160.0)); 179f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(pathCopy)->GetBounds().GetHeight(), 4096.0)); 180f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path7); 181f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(pathCopy); 182f6603c60Sopenharmony_ci} 183f6603c60Sopenharmony_ci 184f6603c60Sopenharmony_ci/* 185f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathAddRect010 186f6603c60Sopenharmony_ci * @tc.desc: test for PathAddRect func. 187f6603c60Sopenharmony_ci * @tc.size : MediumTest 188f6603c60Sopenharmony_ci * @tc.type : Function 189f6603c60Sopenharmony_ci * @tc.level : Level 1 190f6603c60Sopenharmony_ci */ 191f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathAddRect010, TestSize.Level1) 192f6603c60Sopenharmony_ci{ 193f6603c60Sopenharmony_ci OH_Drawing_Path* path = OH_Drawing_PathCreate(); 194f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(nullptr, 50, 50, 2160, 4096, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 195f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 50, 50, 2160, 4096, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 196f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 2110.0)); 197f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 4046.0)); 198f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 199f6603c60Sopenharmony_ci} 200f6603c60Sopenharmony_ci 201f6603c60Sopenharmony_ci/* 202f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPathLargeValueTest_pathAddRoundRect011 203f6603c60Sopenharmony_ci * @tc.desc: test for PathAddRoundRect func. 204f6603c60Sopenharmony_ci * @tc.size : MediumTest 205f6603c60Sopenharmony_ci * @tc.type : Function 206f6603c60Sopenharmony_ci * @tc.level : Level 1 207f6603c60Sopenharmony_ci */ 208f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPathLargeValueTest, NativeDrawingPathLargeValueTest_pathAddRoundRect011, TestSize.Level1) 209f6603c60Sopenharmony_ci{ 210f6603c60Sopenharmony_ci OH_Drawing_Path* path = OH_Drawing_PathCreate(); 211f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(nullptr, 50, 50, 2160, 4096, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 212f6603c60Sopenharmony_ci OH_Drawing_Rect* rect = OH_Drawing_RectCreate(50, 50, 2160, 4096); 213f6603c60Sopenharmony_ci OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20); 214f6603c60Sopenharmony_ci OH_Drawing_PathAddRoundRect(path, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 215f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetWidth(), 2110.0)); 216f6603c60Sopenharmony_ci EXPECT_TRUE(IsScalarAlmostEqual(reinterpret_cast<Path*>(path)->GetBounds().GetHeight(), 4046.0)); 217f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 218f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 219f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 220f6603c60Sopenharmony_ci} 221f6603c60Sopenharmony_ci} // namespace Drawing 222f6603c60Sopenharmony_ci} // namespace Rosen 223f6603c60Sopenharmony_ci} // namespace OHOS