1f6603c60Sopenharmony_ci/* 2f6603c60Sopenharmony_ci * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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, software 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 "DrawingNativePathCommon.h" 17f6603c60Sopenharmony_ci#include "drawing_color.h" 18f6603c60Sopenharmony_ci#include "drawing_color_filter.h" 19f6603c60Sopenharmony_ci#include "drawing_filter.h" 20f6603c60Sopenharmony_ci#include "drawing_image.h" 21f6603c60Sopenharmony_ci#include "drawing_matrix.h" 22f6603c60Sopenharmony_ci#include "drawing_path.h" 23f6603c60Sopenharmony_ci#include "drawing_path_effect.h" 24f6603c60Sopenharmony_ci#include "drawing_pen.h" 25f6603c60Sopenharmony_ci#include "drawing_point.h" 26f6603c60Sopenharmony_ci#include "drawing_rect.h" 27f6603c60Sopenharmony_ci#include "drawing_region.h" 28f6603c60Sopenharmony_ci#include "drawing_round_rect.h" 29f6603c60Sopenharmony_ci#include "utils/scalar.h" 30f6603c60Sopenharmony_ci#include "gtest/gtest.h" 31f6603c60Sopenharmony_ci 32f6603c60Sopenharmony_ciusing namespace testing; 33f6603c60Sopenharmony_ciusing namespace testing::ext; 34f6603c60Sopenharmony_ci 35f6603c60Sopenharmony_cinamespace OHOS { 36f6603c60Sopenharmony_cinamespace Rosen { 37f6603c60Sopenharmony_cinamespace Drawing { 38f6603c60Sopenharmony_ci 39f6603c60Sopenharmony_ci/* 40f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1900 41f6603c60Sopenharmony_ci * @tc.name: testPathAddArcNormal 42f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with normal parameters. 43f6603c60Sopenharmony_ci * @tc.size : SmallTest 44f6603c60Sopenharmony_ci * @tc.type : Function 45f6603c60Sopenharmony_ci * @tc.level : Level 0 46f6603c60Sopenharmony_ci */ 47f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddArcNormal, TestSize.Level0) { 48f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 49f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 50f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 51f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 52f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 53f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 54f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 55f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 56f6603c60Sopenharmony_ci // 5. Add an arc to the path using OH_Drawing_PathAddArc, which serves as the starting point of the new contour. 57f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 0.0, 0.0); 58f6603c60Sopenharmony_ci // 6. Free the memory. 59f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 60f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 61f6603c60Sopenharmony_ci} 62f6603c60Sopenharmony_ci 63f6603c60Sopenharmony_ci/* 64f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1901 65f6603c60Sopenharmony_ci * @tc.name: testPathAddArcNull 66f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with NULL or invalid parameters. 67f6603c60Sopenharmony_ci * @tc.size : SmallTest 68f6603c60Sopenharmony_ci * @tc.type : Function 69f6603c60Sopenharmony_ci * @tc.level : Level 3 70f6603c60Sopenharmony_ci */ 71f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddArcNull, TestSize.Level3) { 72f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 73f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 74f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 75f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 76f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddArc with a nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 77f6603c60Sopenharmony_ci // error code. 78f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(nullptr, rect, 0.0, 0.0); 79f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 80f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddArc with a nullptr as the second parameter, expecting 81f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 82f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, nullptr, 0.0, 0.0); 83f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 84f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddArc with 0.0 as the third parameter, expecting failure without crash. 85f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 0.0, 0.0); 86f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddArc with 0.0 as the fourth parameter, expecting failure without crash. 87f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 0.0, 0.0); 88f6603c60Sopenharmony_ci // 7. Free the memory. 89f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 90f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 91f6603c60Sopenharmony_ci} 92f6603c60Sopenharmony_ci 93f6603c60Sopenharmony_ci/* 94f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1902 95f6603c60Sopenharmony_ci * @tc.name: testPathAddArcAbnormal 96f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with abnormal data types as parameters. 97f6603c60Sopenharmony_ci * @tc.size : SmallTest 98f6603c60Sopenharmony_ci * @tc.type : Function 99f6603c60Sopenharmony_ci * @tc.level : Level 3 100f6603c60Sopenharmony_ci */ 101f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddArcAbnormal, TestSize.Level3) { 102f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 103f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 104f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 105f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 106f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 107f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 108f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 109f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 110f6603c60Sopenharmony_ci // 5. Add an arc to the path using OH_Drawing_PathAddArc, passing an integer or character type as the third 111f6603c60Sopenharmony_ci // parameter. 112f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 30, 30.0f); 113f6603c60Sopenharmony_ci // 6. Add an arc to the path using OH_Drawing_PathAddArc, passing an integer or character type as the fourth 114f6603c60Sopenharmony_ci // parameter. 115f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 30.0f, 30); 116f6603c60Sopenharmony_ci // 7. Free the memory. 117f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 118f6603c60Sopenharmony_ci} 119f6603c60Sopenharmony_ci 120f6603c60Sopenharmony_ci/* 121f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1903 122f6603c60Sopenharmony_ci * @tc.name: testPathAddArcMaximal 123f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with maximal values as parameters. 124f6603c60Sopenharmony_ci * @tc.size : SmallTest 125f6603c60Sopenharmony_ci * @tc.type : Function 126f6603c60Sopenharmony_ci * @tc.level : Level 3 127f6603c60Sopenharmony_ci */ 128f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddArcMaximal, TestSize.Level3) { 129f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 130f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 131f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 132f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 133f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 134f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 135f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 136f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 137f6603c60Sopenharmony_ci // 5. Add an arc to the path using OH_Drawing_PathAddArc, passing FLT_MAX + 1 as the third parameter, which will 138f6603c60Sopenharmony_ci // fail without crashing. 139f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, FLT_MAX + 1, 0.0); 140f6603c60Sopenharmony_ci // 6. Add an arc to the path using OH_Drawing_PathAddArc, passing FLT_MAX + 1 as the fourth parameter, which will 141f6603c60Sopenharmony_ci // fail without crashing. 142f6603c60Sopenharmony_ci OH_Drawing_PathAddArc(path, rect, 0.0, FLT_MAX + 1); 143f6603c60Sopenharmony_ci // 7. Free the memory. 144f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 145f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 146f6603c60Sopenharmony_ci} 147f6603c60Sopenharmony_ci 148f6603c60Sopenharmony_ci/* 149f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2000 150f6603c60Sopenharmony_ci * @tc.name: testPathAddPathNormal 151f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with normal parameters. 152f6603c60Sopenharmony_ci * @tc.size : SmallTest 153f6603c60Sopenharmony_ci * @tc.type : Function 154f6603c60Sopenharmony_ci * @tc.level : Level 0 155f6603c60Sopenharmony_ci */ 156f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathNormal, TestSize.Level0) { 157f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 158f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 159f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 160f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 161f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 162f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 163f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 164f6603c60Sopenharmony_ci // path src). 165f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 166f6603c60Sopenharmony_ci // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPath. 167f6603c60Sopenharmony_ci OH_Drawing_PathAddPath(path, src, nullptr); 168f6603c60Sopenharmony_ci // 6. Free the memory. 169f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 170f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 171f6603c60Sopenharmony_ci} 172f6603c60Sopenharmony_ci 173f6603c60Sopenharmony_ci/* 174f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2001 175f6603c60Sopenharmony_ci * @tc.name: testPathAddPathNull 176f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with NULL or invalid parameters. 177f6603c60Sopenharmony_ci * @tc.size : SmallTest 178f6603c60Sopenharmony_ci * @tc.type : Function 179f6603c60Sopenharmony_ci * @tc.level : Level 3 180f6603c60Sopenharmony_ci */ 181f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathNull, TestSize.Level3) { 182f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 183f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 184f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 185f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 186f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddPath with a nullptr as the first parameter, expecting 187f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 188f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 189f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 190f6603c60Sopenharmony_ci OH_Drawing_PathAddPath(nullptr, src, matrix); 191f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 192f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddPath with a nullptr as the second parameter, expecting 193f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 194f6603c60Sopenharmony_ci OH_Drawing_PathAddPath(path, nullptr, matrix); 195f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 196f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddPath with a nullptr as the third parameter, expecting failure without crash. 197f6603c60Sopenharmony_ci OH_Drawing_PathAddPath(path, src, nullptr); 198f6603c60Sopenharmony_ci // 6. Free the memory. 199f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 200f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 201f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 202f6603c60Sopenharmony_ci} 203f6603c60Sopenharmony_ci 204f6603c60Sopenharmony_ci/* 205f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2100 206f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithMatrixAndModeNormal 207f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with matrix and mode transformations using normal parameters. 208f6603c60Sopenharmony_ci * @tc.size : SmallTest 209f6603c60Sopenharmony_ci * @tc.type : Function 210f6603c60Sopenharmony_ci * @tc.level : Level 0 211f6603c60Sopenharmony_ci */ 212f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithMatrixAndModeNormal, TestSize.Level0) { 213f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 214f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 215f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 216f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 217f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 218f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 219f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 220f6603c60Sopenharmony_ci // path src). 221f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 222f6603c60Sopenharmony_ci // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPathWithMatrixAndMode. The fourth 223f6603c60Sopenharmony_ci // parameter enumerates calling this interface. 224f6603c60Sopenharmony_ci OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND}; 225f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 226f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 227f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 228f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMatrixAndMode(path, src, matrix, modes[i]); 229f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 230f6603c60Sopenharmony_ci } 231f6603c60Sopenharmony_ci // 6. Free the memory. 232f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 233f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 234f6603c60Sopenharmony_ci} 235f6603c60Sopenharmony_ci 236f6603c60Sopenharmony_ci/* 237f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2101 238f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithMatrixAndModeNull 239f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with matrix and mode transformations using NULL or invalid 240f6603c60Sopenharmony_ci * parameters. 241f6603c60Sopenharmony_ci * @tc.size : SmallTest 242f6603c60Sopenharmony_ci * @tc.type : Function 243f6603c60Sopenharmony_ci * @tc.level : Level 3 244f6603c60Sopenharmony_ci */ 245f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithMatrixAndModeNull, TestSize.Level3) { 246f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 247f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 248f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 249f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 250f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the first parameter, expecting 251f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 252f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 253f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 5, 4, 0, 0, -1, 0, 0, 0, 1); 254f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMatrixAndMode(nullptr, src, matrix, PATH_ADD_MODE_APPEND); 255f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 256f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the second parameter, expecting 257f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 258f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMatrixAndMode(path, nullptr, matrix, PATH_ADD_MODE_APPEND); 259f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 260f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddPathWithMatrixAndMode with a nullptr as the third parameter, expecting failure without 261f6603c60Sopenharmony_ci // crash. 262f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMatrixAndMode(path, src, nullptr, PATH_ADD_MODE_APPEND); 263f6603c60Sopenharmony_ci // 6. Free the memory. 264f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 265f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 266f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 267f6603c60Sopenharmony_ci} 268f6603c60Sopenharmony_ci 269f6603c60Sopenharmony_ci/* 270f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2200 271f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithModeNormal 272f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with mode transformations using normal parameters. 273f6603c60Sopenharmony_ci * @tc.size : SmallTest 274f6603c60Sopenharmony_ci * @tc.type : Function 275f6603c60Sopenharmony_ci * @tc.level : Level 0 276f6603c60Sopenharmony_ci */ 277f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithModeNormal, TestSize.Level0) { 278f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 279f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 280f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 281f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 282f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 283f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 284f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 285f6603c60Sopenharmony_ci // path src). 286f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 287f6603c60Sopenharmony_ci // 5. Add the source path to the current path using OH_Drawing_PathAddPathWithMode. The third parameter enumerates 288f6603c60Sopenharmony_ci // calling this interface. 289f6603c60Sopenharmony_ci OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND}; 290f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 291f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMode(path, src, modes[i]); 292f6603c60Sopenharmony_ci } 293f6603c60Sopenharmony_ci // 6. Free the memory. 294f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 295f6603c60Sopenharmony_ci} 296f6603c60Sopenharmony_ci 297f6603c60Sopenharmony_ci/* 298f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2201 299f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithModeNull 300f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with mode transformations using NULL or invalid parameters. 301f6603c60Sopenharmony_ci * @tc.size : SmallTest 302f6603c60Sopenharmony_ci * @tc.type : Function 303f6603c60Sopenharmony_ci * @tc.level : Level 3 304f6603c60Sopenharmony_ci */ 305f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithModeNull, TestSize.Level3) { 306f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 307f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 308f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 309f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 310f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddPathWithMode with a nullptr as the first parameter, expecting 311f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 312f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMode(nullptr, src, PATH_ADD_MODE_APPEND); 313f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 314f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddPathWithMode with a nullptr as the second parameter, expecting 315f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 316f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithMode(path, nullptr, PATH_ADD_MODE_APPEND); 317f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 318f6603c60Sopenharmony_ci // 5. Free the memory. 319f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 320f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 321f6603c60Sopenharmony_ci} 322f6603c60Sopenharmony_ci 323f6603c60Sopenharmony_ci/* 324f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2300 325f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithOffsetAndModeNormal 326f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with offset and mode transformations using normal parameters. 327f6603c60Sopenharmony_ci * @tc.size : SmallTest 328f6603c60Sopenharmony_ci * @tc.type : Function 329f6603c60Sopenharmony_ci * @tc.level : Level 0 330f6603c60Sopenharmony_ci */ 331f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithOffsetAndModeNormal, TestSize.Level0) { 332f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 333f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 334f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 335f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 336f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 337f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 338f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 339f6603c60Sopenharmony_ci // path src). 340f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 341f6603c60Sopenharmony_ci // 5. Add the transformed source path to the current path using OH_Drawing_PathAddPathWithOffsetAndMode. The fifth 342f6603c60Sopenharmony_ci // parameter enumerates calling this interface. 343f6603c60Sopenharmony_ci OH_Drawing_PathAddMode modes[] = {PATH_ADD_MODE_APPEND, PATH_ADD_MODE_EXTEND}; 344f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 345f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0, 10.0, modes[i]); 346f6603c60Sopenharmony_ci } 347f6603c60Sopenharmony_ci // 6. Free the memory. 348f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 349f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 350f6603c60Sopenharmony_ci} 351f6603c60Sopenharmony_ci 352f6603c60Sopenharmony_ci/* 353f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2301 354f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithOffsetAndModeNull 355f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with offset and mode transformations using NULL or invalid 356f6603c60Sopenharmony_ci * parameters. 357f6603c60Sopenharmony_ci * @tc.size : SmallTest 358f6603c60Sopenharmony_ci * @tc.type : Function 359f6603c60Sopenharmony_ci * @tc.level : Level 3 360f6603c60Sopenharmony_ci */ 361f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithOffsetAndModeNull, TestSize.Level3) { 362f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 363f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 364f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 365f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 366f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddPathWithOffsetAndMode with a nullptr as the first parameter, expecting 367f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 368f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(nullptr, src, 10.0, 10.0, PATH_ADD_MODE_APPEND); 369f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 370f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddPathWithOffsetAndMode with a nullptr as the second parameter, expecting 371f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 372f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, nullptr, 10.0, 10.0, PATH_ADD_MODE_APPEND); 373f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 374f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with 0.00 as the third parameter, expecting failure without 375f6603c60Sopenharmony_ci // crash. 376f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 0.0, 10.0, PATH_ADD_MODE_APPEND); 377f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with 0.00 as the fourth parameter, expecting failure without 378f6603c60Sopenharmony_ci // crash. 379f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0, 0.0, PATH_ADD_MODE_APPEND); 380f6603c60Sopenharmony_ci // 7. Free the memory. 381f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 382f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 383f6603c60Sopenharmony_ci} 384f6603c60Sopenharmony_ci 385f6603c60Sopenharmony_ci/* 386f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2302 387f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithOffsetAndModeAbnormal 388f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with offset and mode transformations using abnormal parameters. 389f6603c60Sopenharmony_ci * @tc.size : SmallTest 390f6603c60Sopenharmony_ci * @tc.type : Function 391f6603c60Sopenharmony_ci * @tc.level : Level 3 392f6603c60Sopenharmony_ci */ 393f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithOffsetAndModeAbnormal, TestSize.Level3) { 394f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 395f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 396f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 397f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 398f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 399f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 400f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 401f6603c60Sopenharmony_ci // path src). 402f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 403f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with an integer as the third parameter, expecting successful 404f6603c60Sopenharmony_ci // call. 405f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10, 10.0f, PATH_ADD_MODE_APPEND); 406f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with an integer as the fourth parameter, expecting successful 407f6603c60Sopenharmony_ci // call. 408f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0f, 10, PATH_ADD_MODE_APPEND); 409f6603c60Sopenharmony_ci // 7. Free the memory. 410f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 411f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 412f6603c60Sopenharmony_ci} 413f6603c60Sopenharmony_ci 414f6603c60Sopenharmony_ci/* 415f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2303 416f6603c60Sopenharmony_ci * @tc.name: testPathAddPathWithOffsetAndModeMaximal 417f6603c60Sopenharmony_ci * @tc.desc: Test for adding a path to another path with offset and mode transformations using maximal values. 418f6603c60Sopenharmony_ci * @tc.size : SmallTest 419f6603c60Sopenharmony_ci * @tc.type : Function 420f6603c60Sopenharmony_ci * @tc.level : Level 3 421f6603c60Sopenharmony_ci */ 422f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPathWithOffsetAndModeMaximal, TestSize.Level3) { 423f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 424f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 425f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 426f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 427f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 428f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 429f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo (create the source 430f6603c60Sopenharmony_ci // path src). 431f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 432f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddPathWithOffsetAndMode with the third parameter as FLT_MAX + 1, without crashing. 433f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, FLT_MAX + 1, 10.0f, PATH_ADD_MODE_APPEND); 434f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddPathWithOffsetAndMode with the fourth parameter as FLT_MAX + 1, without crashing. 435f6603c60Sopenharmony_ci OH_Drawing_PathAddPathWithOffsetAndMode(path, src, 10.0f, FLT_MAX + 1, PATH_ADD_MODE_APPEND); 436f6603c60Sopenharmony_ci // 7. Free the memory. 437f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 438f6603c60Sopenharmony_ci} 439f6603c60Sopenharmony_ci 440f6603c60Sopenharmony_ci/* 441f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2400 442f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalNormal 443f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path using normal parameters. 444f6603c60Sopenharmony_ci * @tc.size : SmallTest 445f6603c60Sopenharmony_ci * @tc.type : Function 446f6603c60Sopenharmony_ci * @tc.level : Level 0 447f6603c60Sopenharmony_ci */ 448f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalNormal, TestSize.Level0) { 449f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 450f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 451f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 452f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 453f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 454f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 455f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 456f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 457f6603c60Sopenharmony_ci // 5. Add an oval to the path with the specified direction using OH_Drawing_PathAddOval. The third parameter 458f6603c60Sopenharmony_ci // enumerates calling this interface. 459f6603c60Sopenharmony_ci OH_Drawing_PathDirection directions[] = {PATH_DIRECTION_CW, PATH_DIRECTION_CCW}; 460f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 461f6603c60Sopenharmony_ci OH_Drawing_PathAddOval(path, rect, directions[i]); 462f6603c60Sopenharmony_ci } 463f6603c60Sopenharmony_ci // 6. Free the memory. 464f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 465f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 466f6603c60Sopenharmony_ci} 467f6603c60Sopenharmony_ci 468f6603c60Sopenharmony_ci/* 469f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2401 470f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalNull 471f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path using NULL or invalid parameters. 472f6603c60Sopenharmony_ci * @tc.size : SmallTest 473f6603c60Sopenharmony_ci * @tc.type : Function 474f6603c60Sopenharmony_ci * @tc.level : Level 3 475f6603c60Sopenharmony_ci */ 476f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalNull, TestSize.Level3) { 477f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 478f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 479f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 480f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 481f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddOval with a nullptr as the first parameter, expecting 482f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 483f6603c60Sopenharmony_ci OH_Drawing_PathAddOval(nullptr, rect, PATH_DIRECTION_CW); 484f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 485f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddOval with a nullptr as the second parameter, expecting 486f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 487f6603c60Sopenharmony_ci OH_Drawing_PathAddOval(path, nullptr, PATH_DIRECTION_CW); 488f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 489f6603c60Sopenharmony_ci // 5. Free the memory. 490f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 491f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 492f6603c60Sopenharmony_ci} 493f6603c60Sopenharmony_ci 494f6603c60Sopenharmony_ci/* 495f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2500 496f6603c60Sopenharmony_ci * @tc.name: testPathAddPolygonNormal 497f6603c60Sopenharmony_ci * @tc.desc: Test for adding a polygon to a path with the fourth parameter set to true. 498f6603c60Sopenharmony_ci * @tc.size : SmallTest 499f6603c60Sopenharmony_ci * @tc.type : Function 500f6603c60Sopenharmony_ci * @tc.level : Level 0 501f6603c60Sopenharmony_ci */ 502f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPolygonNormal, TestSize.Level0) { 503f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 504f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 505f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 506f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 507f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 508f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 509f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 510f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 511f6603c60Sopenharmony_ci // 5. Add a polygon to the path. Set the fourth parameter to true. 512f6603c60Sopenharmony_ci OH_Drawing_Point2D point1 = {0, 0}; 513f6603c60Sopenharmony_ci OH_Drawing_Point2D point2 = {100, 0}; 514f6603c60Sopenharmony_ci OH_Drawing_Point2D point3 = {100, 100}; 515f6603c60Sopenharmony_ci OH_Drawing_Point2D point4 = {0, 100}; 516f6603c60Sopenharmony_ci OH_Drawing_Point2D points[4] = {point1, point2, point3, point4}; 517f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4, true); 518f6603c60Sopenharmony_ci // 6. Free the memory. 519f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 520f6603c60Sopenharmony_ci} 521f6603c60Sopenharmony_ci 522f6603c60Sopenharmony_ci/* 523f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2501 524f6603c60Sopenharmony_ci * @tc.name: testPathAddPolygonNormal2 525f6603c60Sopenharmony_ci * @tc.desc: Test for adding a polygon to a path with the fourth parameter set to false. 526f6603c60Sopenharmony_ci * @tc.size : SmallTest 527f6603c60Sopenharmony_ci * @tc.type : Function 528f6603c60Sopenharmony_ci * @tc.level : Level 0 529f6603c60Sopenharmony_ci */ 530f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPolygonNormal2, TestSize.Level0) { 531f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 532f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 533f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 534f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 535f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 536f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 537f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 538f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 539f6603c60Sopenharmony_ci // 5. Add a polygon to the path. Set the fourth parameter to false. 540f6603c60Sopenharmony_ci OH_Drawing_Point2D point1 = {0, 0}; 541f6603c60Sopenharmony_ci OH_Drawing_Point2D point2 = {100, 0}; 542f6603c60Sopenharmony_ci OH_Drawing_Point2D point3 = {100, 100}; 543f6603c60Sopenharmony_ci OH_Drawing_Point2D point4 = {0, 100}; 544f6603c60Sopenharmony_ci OH_Drawing_Point2D points[4] = {point1, point2, point3, point4}; 545f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4, false); 546f6603c60Sopenharmony_ci // 6. Free the memory. 547f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 548f6603c60Sopenharmony_ci} 549f6603c60Sopenharmony_ci 550f6603c60Sopenharmony_ci/* 551f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2502 552f6603c60Sopenharmony_ci * @tc.name: testPathAddPolygonNull 553f6603c60Sopenharmony_ci * @tc.desc: Test for adding a polygon to a path using NULL or invalid parameters. 554f6603c60Sopenharmony_ci * @tc.size : SmallTest 555f6603c60Sopenharmony_ci * @tc.type : Function 556f6603c60Sopenharmony_ci * @tc.level : Level 3 557f6603c60Sopenharmony_ci */ 558f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPolygonNull, TestSize.Level3) { 559f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 560f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 561f6603c60Sopenharmony_ci OH_Drawing_Point2D point1 = {0, 0}; 562f6603c60Sopenharmony_ci OH_Drawing_Point2D point2 = {100, 0}; 563f6603c60Sopenharmony_ci OH_Drawing_Point2D point3 = {100, 100}; 564f6603c60Sopenharmony_ci OH_Drawing_Point2D point4 = {0, 100}; 565f6603c60Sopenharmony_ci OH_Drawing_Point2D points[4] = {point1, point2, point3, point4}; 566f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathAddPolygon with a nullptr as the first parameter, expecting 567f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 568f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(nullptr, points, 4, true); 569f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 570f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddPolygon with a nullptr as the second parameter, expecting 571f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 572f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, nullptr, 4, true); 573f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 574f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddPolygon with the third parameter as 0, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 575f6603c60Sopenharmony_ci // error code. 576f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 0, true); 577f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 578f6603c60Sopenharmony_ci // 5. Free the memory. 579f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 580f6603c60Sopenharmony_ci} 581f6603c60Sopenharmony_ci 582f6603c60Sopenharmony_ci/* 583f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2503 584f6603c60Sopenharmony_ci * @tc.name: testPathAddPolygonAbnormal 585f6603c60Sopenharmony_ci * @tc.desc: Test for adding a polygon to a path using abnormal parameters. 586f6603c60Sopenharmony_ci * @tc.size : SmallTest 587f6603c60Sopenharmony_ci * @tc.type : Function 588f6603c60Sopenharmony_ci * @tc.level : Level 3 589f6603c60Sopenharmony_ci */ 590f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPolygonAbnormal, TestSize.Level3) { 591f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 592f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 593f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 594f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 595f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 596f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 597f6603c60Sopenharmony_ci // 4. Add a polygon to the path with the second parameter's x-coordinate as an integer or character type, which will 598f6603c60Sopenharmony_ci // succeed. 599f6603c60Sopenharmony_ci OH_Drawing_Point2D point1 = {0, 0}; 600f6603c60Sopenharmony_ci OH_Drawing_Point2D point2 = {100, 0}; 601f6603c60Sopenharmony_ci OH_Drawing_Point2D point3 = {100, 100}; 602f6603c60Sopenharmony_ci OH_Drawing_Point2D point4 = {0, 100}; 603f6603c60Sopenharmony_ci OH_Drawing_Point2D points[4] = {point1, point2, point3, point4}; 604f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4, true); 605f6603c60Sopenharmony_ci // 5. Add a polygon to the path with the second parameter's y-coordinate as an integer or character type, which will 606f6603c60Sopenharmony_ci // succeed. 607f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4, true); 608f6603c60Sopenharmony_ci // 6. Add a polygon to the path with the third parameter as a float or character type, which will succeed. 609f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4.0f, true); 610f6603c60Sopenharmony_ci // 7. Free the memory. 611f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 612f6603c60Sopenharmony_ci} 613f6603c60Sopenharmony_ci 614f6603c60Sopenharmony_ci/* 615f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2504 616f6603c60Sopenharmony_ci * @tc.name: testPathAddPolygonMaximal 617f6603c60Sopenharmony_ci * @tc.desc: Test for adding a polygon to a path using maximal values. 618f6603c60Sopenharmony_ci * @tc.size : SmallTest 619f6603c60Sopenharmony_ci * @tc.type : Function 620f6603c60Sopenharmony_ci * @tc.level : Level 3 621f6603c60Sopenharmony_ci */ 622f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddPolygonMaximal, TestSize.Level3) { 623f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 624f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 625f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 626f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 627f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 628f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 629f6603c60Sopenharmony_ci // 4. Add a polygon to the path with the second parameter's x-coordinate set to FLT_MAX + 1, no crash occurs. 630f6603c60Sopenharmony_ci OH_Drawing_Point2D point1 = {FLT_MAX + 1, 0}; 631f6603c60Sopenharmony_ci OH_Drawing_Point2D point2 = {FLT_MAX + 1, 0}; 632f6603c60Sopenharmony_ci OH_Drawing_Point2D point3 = {FLT_MAX + 1, 100}; 633f6603c60Sopenharmony_ci OH_Drawing_Point2D point4 = {FLT_MAX + 1, 100}; 634f6603c60Sopenharmony_ci OH_Drawing_Point2D points[4] = {point1, point2, point3, point4}; 635f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points, 4, true); 636f6603c60Sopenharmony_ci // 5. Add a polygon to the path with the second parameter's y-coordinate set to FLT_MAX + 1, no crash occurs. 637f6603c60Sopenharmony_ci OH_Drawing_Point2D point5 = {0, FLT_MAX + 1}; 638f6603c60Sopenharmony_ci OH_Drawing_Point2D point6 = {100, FLT_MAX + 1}; 639f6603c60Sopenharmony_ci OH_Drawing_Point2D point7 = {100, FLT_MAX + 1}; 640f6603c60Sopenharmony_ci OH_Drawing_Point2D point8 = {0, FLT_MAX + 1}; 641f6603c60Sopenharmony_ci OH_Drawing_Point2D points2[4] = {point5, point6, point7, point8}; 642f6603c60Sopenharmony_ci OH_Drawing_PathAddPolygon(path, points2, 4, true); 643f6603c60Sopenharmony_ci // 6. Free the memory. 644f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 645f6603c60Sopenharmony_ci} 646f6603c60Sopenharmony_ci 647f6603c60Sopenharmony_ci/* 648f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2600 649f6603c60Sopenharmony_ci * @tc.name: testPathAddCircleNormal 650f6603c60Sopenharmony_ci * @tc.desc: Test for adding a circle to a path using normal parameters. 651f6603c60Sopenharmony_ci * @tc.size : SmallTest 652f6603c60Sopenharmony_ci * @tc.type : Function 653f6603c60Sopenharmony_ci * @tc.level : Level 0 654f6603c60Sopenharmony_ci */ 655f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddCircleNormal, TestSize.Level0) { 656f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 657f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 658f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 659f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 660f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 661f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 662f6603c60Sopenharmony_ci // 4. Add a circle to the path with the specified direction. 663f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 664f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 665f6603c60Sopenharmony_ci // 5. Free the memory. 666f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 667f6603c60Sopenharmony_ci} 668f6603c60Sopenharmony_ci 669f6603c60Sopenharmony_ci/* 670f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2601 671f6603c60Sopenharmony_ci * @tc.name: testPathAddCircleNull 672f6603c60Sopenharmony_ci * @tc.desc: Test for adding a circle to a path using NULL or invalid parameters. 673f6603c60Sopenharmony_ci * @tc.size : SmallTest 674f6603c60Sopenharmony_ci * @tc.type : Function 675f6603c60Sopenharmony_ci * @tc.level : Level 3 676f6603c60Sopenharmony_ci */ 677f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddCircleNull, TestSize.Level3) { 678f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 679f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 680f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathAddCircle with a nullptr as the first parameter, expecting 681f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 682f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(nullptr, 50, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 683f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 684f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddCircle with the second parameter as 0.00, which will fail without crashing. 685f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 0.00, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 686f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddCircle with the third parameter as 0.00, which will fail without crashing. 687f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 0.00, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 688f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddCircle with the fourth parameter less than or equal to 0.00, expecting 689f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE error code. 690f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 50, 0.00, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 691f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); 692f6603c60Sopenharmony_ci // 6. Free the memory. 693f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 694f6603c60Sopenharmony_ci} 695f6603c60Sopenharmony_ci 696f6603c60Sopenharmony_ci/* 697f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2602 698f6603c60Sopenharmony_ci * @tc.name: testPathAddCircleAbnormal 699f6603c60Sopenharmony_ci * @tc.desc: Test for adding a circle to a path using abnormal parameters. 700f6603c60Sopenharmony_ci * @tc.size : SmallTest 701f6603c60Sopenharmony_ci * @tc.type : Function 702f6603c60Sopenharmony_ci * @tc.level : Level 3 703f6603c60Sopenharmony_ci */ 704f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddCircleAbnormal, TestSize.Level3) { 705f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 706f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 707f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 708f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 709f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 710f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 711f6603c60Sopenharmony_ci // 4. Add a circle to the path with the second parameter as an integer, which will succeed. 712f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 50.0f, 10.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 713f6603c60Sopenharmony_ci // 5. Add a circle to the path with the third parameter as an integer, which will succeed. 714f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50.0f, 50, 10.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 715f6603c60Sopenharmony_ci // 6. Add a circle to the path with the fourth parameter as an integer, which will succeed. 716f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50.0f, 50.0f, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 717f6603c60Sopenharmony_ci // 7. Free the memory. 718f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 719f6603c60Sopenharmony_ci} 720f6603c60Sopenharmony_ci 721f6603c60Sopenharmony_ci/* 722f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2603 723f6603c60Sopenharmony_ci * @tc.name: testPathAddCircleMaximal 724f6603c60Sopenharmony_ci * @tc.desc: Test for adding a circle to a path using maximal values. 725f6603c60Sopenharmony_ci * @tc.size : SmallTest 726f6603c60Sopenharmony_ci * @tc.type : Function 727f6603c60Sopenharmony_ci * @tc.level : Level 3 728f6603c60Sopenharmony_ci */ 729f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddCircleMaximal, TestSize.Level3) { 730f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 731f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 732f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 733f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 734f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 735f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 736f6603c60Sopenharmony_ci // 4. Add a circle to the path with the second parameter set to FLT_MAX + 1, no crash occurs. 737f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, FLT_MAX + 1, 50, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 738f6603c60Sopenharmony_ci // 5. Add a circle to the path with the third parameter set to FLT_MAX + 1, no crash occurs. 739f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, FLT_MAX + 1, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 740f6603c60Sopenharmony_ci // 6. Add a circle to the path with the fourth parameter set to FLT_MAX + 1, no crash occurs. 741f6603c60Sopenharmony_ci OH_Drawing_PathAddCircle(path, 50, 50, FLT_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CCW); 742f6603c60Sopenharmony_ci // 7. Free the memory. 743f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 744f6603c60Sopenharmony_ci} 745f6603c60Sopenharmony_ci 746f6603c60Sopenharmony_ci/* 747f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2700 748f6603c60Sopenharmony_ci * @tc.name: testPathBuildFromSvgStringNormal 749f6603c60Sopenharmony_ci * @tc.desc: Test for building a path from an SVG string using normal parameters. 750f6603c60Sopenharmony_ci * @tc.size : SmallTest 751f6603c60Sopenharmony_ci * @tc.type : Function 752f6603c60Sopenharmony_ci * @tc.level : Level 0 753f6603c60Sopenharmony_ci */ 754f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathBuildFromSvgStringNormal, TestSize.Level0) { 755f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 756f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 757f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 758f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 759f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 760f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 761f6603c60Sopenharmony_ci // 4. Parse the path represented by the SVG string using OH_Drawing_PathBuildFromSvgString. 762f6603c60Sopenharmony_ci const char *svgString = "M 0 0 L 100 100"; 763f6603c60Sopenharmony_ci OH_Drawing_PathBuildFromSvgString(path, svgString); 764f6603c60Sopenharmony_ci // 5. Free the memory. 765f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 766f6603c60Sopenharmony_ci} 767f6603c60Sopenharmony_ci 768f6603c60Sopenharmony_ci/* 769f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2701 770f6603c60Sopenharmony_ci * @tc.name: testPathBuildFromSvgStringNull 771f6603c60Sopenharmony_ci * @tc.desc: Test for building a path from an SVG string using NULL or invalid parameters. 772f6603c60Sopenharmony_ci * @tc.size : SmallTest 773f6603c60Sopenharmony_ci * @tc.type : Function 774f6603c60Sopenharmony_ci * @tc.level : Level 3 775f6603c60Sopenharmony_ci */ 776f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathBuildFromSvgStringNull, TestSize.Level3) { 777f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 778f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 779f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathBuildFromSvgString with a nullptr as the first parameter, expecting 780f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 781f6603c60Sopenharmony_ci OH_Drawing_PathBuildFromSvgString(nullptr, "M 0 0 L 100 100"); 782f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 783f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathBuildFromSvgString with a nullptr as the second parameter, expecting 784f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 785f6603c60Sopenharmony_ci OH_Drawing_PathBuildFromSvgString(path, nullptr); 786f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 787f6603c60Sopenharmony_ci // 4. Free the memory. 788f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 789f6603c60Sopenharmony_ci} 790f6603c60Sopenharmony_ci 791f6603c60Sopenharmony_ci/* 792f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2800 793f6603c60Sopenharmony_ci * @tc.name: testPathContainsNormal 794f6603c60Sopenharmony_ci * @tc.desc: Test for checking if a path contains a specified point using normal parameters. 795f6603c60Sopenharmony_ci * @tc.size : SmallTest 796f6603c60Sopenharmony_ci * @tc.type : Function 797f6603c60Sopenharmony_ci * @tc.level : Level 0 798f6603c60Sopenharmony_ci */ 799f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathContainsNormal, TestSize.Level0) { 800f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 801f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 802f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 803f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 804f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 805f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 806f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 807f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 808f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 809f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 0); 810f6603c60Sopenharmony_ci // 6. Close the path using OH_Drawing_PathClose. 811f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 812f6603c60Sopenharmony_ci // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains. 813f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_PathContains(path, 50, 50), true); 814f6603c60Sopenharmony_ci // 8. Free the memory. 815f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 816f6603c60Sopenharmony_ci} 817f6603c60Sopenharmony_ci 818f6603c60Sopenharmony_ci/* 819f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2801 820f6603c60Sopenharmony_ci * @tc.name: testPathContainsNull 821f6603c60Sopenharmony_ci * @tc.desc: Test for checking if a path contains a specified point using NULL or invalid parameters. 822f6603c60Sopenharmony_ci * @tc.size : SmallTest 823f6603c60Sopenharmony_ci * @tc.type : Function 824f6603c60Sopenharmony_ci * @tc.level : Level 3 825f6603c60Sopenharmony_ci */ 826f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathContainsNull, TestSize.Level3) { 827f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 828f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 829f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathContains with a nullptr as the first parameter, expecting 830f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 831f6603c60Sopenharmony_ci OH_Drawing_PathContains(nullptr, 50, 50); 832f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathContains with the second parameter as 0.00, the call fails without crashing. 833f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, 0.0, 50); 834f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathContains with the third parameter as 0.00, the call fails without crashing. 835f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, 50, 0.0); 836f6603c60Sopenharmony_ci // 5. Free the memory. 837f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 838f6603c60Sopenharmony_ci} 839f6603c60Sopenharmony_ci 840f6603c60Sopenharmony_ci/* 841f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2802 842f6603c60Sopenharmony_ci * @tc.name: testPathContainsAbnormal 843f6603c60Sopenharmony_ci * @tc.desc: Test for checking if a path contains a specified point using abnormal parameters. 844f6603c60Sopenharmony_ci * @tc.size : SmallTest 845f6603c60Sopenharmony_ci * @tc.type : Function 846f6603c60Sopenharmony_ci * @tc.level : Level 3 847f6603c60Sopenharmony_ci */ 848f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathContainsAbnormal, TestSize.Level3) { 849f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 850f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 851f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 852f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 853f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 854f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 855f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 856f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 857f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 858f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 0); 859f6603c60Sopenharmony_ci // 6. Close the path using OH_Drawing_PathClose. 860f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 861f6603c60Sopenharmony_ci // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains. 862f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, 50, 50.0f); 863f6603c60Sopenharmony_ci // 8. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains. 864f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, 50.0f, 50); 865f6603c60Sopenharmony_ci // 9. Free the memory. 866f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 867f6603c60Sopenharmony_ci} 868f6603c60Sopenharmony_ci 869f6603c60Sopenharmony_ci/* 870f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2803 871f6603c60Sopenharmony_ci * @tc.name: testPathContainsMaximal 872f6603c60Sopenharmony_ci * @tc.desc: Test for checking if a path contains a specified point using maximal values. 873f6603c60Sopenharmony_ci * @tc.size : SmallTest 874f6603c60Sopenharmony_ci * @tc.type : Function 875f6603c60Sopenharmony_ci * @tc.level : Level 3 876f6603c60Sopenharmony_ci */ 877f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathContainsMaximal, TestSize.Level3) { 878f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 879f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 880f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 881f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 882f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 883f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 884f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 885f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 886f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 887f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 100); 888f6603c60Sopenharmony_ci // 6. Close the path using OH_Drawing_PathClose. 889f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 890f6603c60Sopenharmony_ci // 7. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains with the second 891f6603c60Sopenharmony_ci // parameter as FLT_MAX + 1. 892f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, FLT_MAX + 1, 50); 893f6603c60Sopenharmony_ci // 8. Check if the specified coordinates are contained in the path using OH_Drawing_PathContains with the third 894f6603c60Sopenharmony_ci // parameter as FLT_MAX + 1. 895f6603c60Sopenharmony_ci OH_Drawing_PathContains(path, 50, FLT_MAX + 1); 896f6603c60Sopenharmony_ci // 9. Free the memory. 897f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 898f6603c60Sopenharmony_ci} 899f6603c60Sopenharmony_ci 900f6603c60Sopenharmony_ci/* 901f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2900 902f6603c60Sopenharmony_ci * @tc.name: testPathTransformNormal 903f6603c60Sopenharmony_ci * @tc.desc: Test for transforming a path using normal parameters. 904f6603c60Sopenharmony_ci * @tc.size : SmallTest 905f6603c60Sopenharmony_ci * @tc.type : Function 906f6603c60Sopenharmony_ci * @tc.level : Level 0 907f6603c60Sopenharmony_ci */ 908f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathTransformNormal, TestSize.Level0) { 909f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 910f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 911f6603c60Sopenharmony_ci // 2. Create a matrix object using OH_Drawing_MatrixCreate. 912f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 913f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1); 914f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 915f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 916f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 917f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 918f6603c60Sopenharmony_ci // 5. Transform the path using OH_Drawing_PathTransform. 919f6603c60Sopenharmony_ci OH_Drawing_PathTransform(path, matrix); 920f6603c60Sopenharmony_ci // 6. Free the memory. 921f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 922f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 923f6603c60Sopenharmony_ci} 924f6603c60Sopenharmony_ci 925f6603c60Sopenharmony_ci/* 926f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_2901 927f6603c60Sopenharmony_ci * @tc.name: testPathTransformNull 928f6603c60Sopenharmony_ci * @tc.desc: Test for transforming a path using NULL or invalid parameters. 929f6603c60Sopenharmony_ci * @tc.size : SmallTest 930f6603c60Sopenharmony_ci * @tc.type : Function 931f6603c60Sopenharmony_ci * @tc.level : Level 3 932f6603c60Sopenharmony_ci */ 933f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathTransformNull, TestSize.Level3) { 934f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 935f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 936f6603c60Sopenharmony_ci // 2. Create a matrix object using OH_Drawing_MatrixCreate. 937f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 938f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1); 939f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathTransform with a nullptr as the first parameter, expecting 940f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 941f6603c60Sopenharmony_ci OH_Drawing_PathTransform(nullptr, matrix); 942f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 943f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathTransform with a nullptr as the second parameter, expecting 944f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 945f6603c60Sopenharmony_ci OH_Drawing_PathTransform(path, nullptr); 946f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 947f6603c60Sopenharmony_ci // 5. Free the memory. 948f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 949f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 950f6603c60Sopenharmony_ci} 951f6603c60Sopenharmony_ci 952f6603c60Sopenharmony_ci/* 953f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3000 954f6603c60Sopenharmony_ci * @tc.name: testPathTransformWithPerspectiveClipNormal 955f6603c60Sopenharmony_ci * @tc.desc: Test for transforming a path with perspective clip using normal parameters. 956f6603c60Sopenharmony_ci * @tc.size : SmallTest 957f6603c60Sopenharmony_ci * @tc.type : Function 958f6603c60Sopenharmony_ci * @tc.level : Level 0 959f6603c60Sopenharmony_ci */ 960f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathTransformWithPerspectiveClipNormal, TestSize.Level0) { 961f6603c60Sopenharmony_ci // 1. Create a path object src using OH_Drawing_PathCreate. 962f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 963f6603c60Sopenharmony_ci // 2. Create a matrix object using OH_Drawing_MatrixCreate. 964f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 965f6603c60Sopenharmony_ci OH_Drawing_MatrixSetMatrix(matrix, 1, 0, 0, 0, -1, 0, 0, 0, 1); 966f6603c60Sopenharmony_ci // 3. Create a path object dst using OH_Drawing_PathCreate. 967f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 968f6603c60Sopenharmony_ci // 4. Set the starting point of the path using OH_Drawing_PathMoveTo. 969f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 970f6603c60Sopenharmony_ci // 5. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 971f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 972f6603c60Sopenharmony_ci // 6. Transform the path using OH_Drawing_PathTransformWithPerspectiveClip, with the fourth parameter set to true. 973f6603c60Sopenharmony_ci OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, dst, true); 974f6603c60Sopenharmony_ci // 7. Free the memory. 975f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 976f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 977f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 978f6603c60Sopenharmony_ci} 979f6603c60Sopenharmony_ci 980f6603c60Sopenharmony_ci/* 981f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3001 982f6603c60Sopenharmony_ci * @tc.name: testPathTransformWithPerspectiveClipNormal2 983f6603c60Sopenharmony_ci * @tc.desc: Test for transforming a path with perspective clip using normal parameters with false perspective clip. 984f6603c60Sopenharmony_ci * @tc.size : SmallTest 985f6603c60Sopenharmony_ci * @tc.type : Function 986f6603c60Sopenharmony_ci * @tc.level : Level 0 987f6603c60Sopenharmony_ci */ 988f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathTransformWithPerspectiveClipNormal2, TestSize.Level0) { 989f6603c60Sopenharmony_ci // 1. Create a path object src using OH_Drawing_PathCreate. 990f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 991f6603c60Sopenharmony_ci // 2. Create a matrix object using OH_Drawing_MatrixCreate. 992f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 993f6603c60Sopenharmony_ci // 3. Create a path object dst using OH_Drawing_PathCreate. 994f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 995f6603c60Sopenharmony_ci // 4. Set the starting point of the path using OH_Drawing_PathMoveTo. 996f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(src, 0, 0); 997f6603c60Sopenharmony_ci // 5. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 998f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(src, 100, 100); 999f6603c60Sopenharmony_ci // 6. Transform the path using OH_Drawing_PathTransformWithPerspectiveClip, with the fourth parameter set to false. 1000f6603c60Sopenharmony_ci OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, dst, false); 1001f6603c60Sopenharmony_ci // 7. Free the memory. 1002f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 1003f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 1004f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 1005f6603c60Sopenharmony_ci} 1006f6603c60Sopenharmony_ci 1007f6603c60Sopenharmony_ci/* 1008f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3002 1009f6603c60Sopenharmony_ci * @tc.name: testPathTransformWithPerspectiveClipNull 1010f6603c60Sopenharmony_ci * @tc.desc: Test for transforming a path with perspective clip using NULL or invalid parameters. 1011f6603c60Sopenharmony_ci * @tc.size : SmallTest 1012f6603c60Sopenharmony_ci * @tc.type : Function 1013f6603c60Sopenharmony_ci * @tc.level : Level 3 1014f6603c60Sopenharmony_ci */ 1015f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathTransformWithPerspectiveClipNull, TestSize.Level3) { 1016f6603c60Sopenharmony_ci // 1. Create a path object src using OH_Drawing_PathCreate. 1017f6603c60Sopenharmony_ci OH_Drawing_Path *src = OH_Drawing_PathCreate(); 1018f6603c60Sopenharmony_ci // 2. Create a matrix object using OH_Drawing_MatrixCreate. 1019f6603c60Sopenharmony_ci OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); 1020f6603c60Sopenharmony_ci // 3. Create a path object dst using OH_Drawing_PathCreate. 1021f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 1022f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the first parameter, expecting 1023f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1024f6603c60Sopenharmony_ci OH_Drawing_PathTransformWithPerspectiveClip(nullptr, matrix, dst, true); 1025f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1026f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the second parameter, expecting 1027f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1028f6603c60Sopenharmony_ci OH_Drawing_PathTransformWithPerspectiveClip(src, nullptr, dst, true); 1029f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1030f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathTransformWithPerspectiveClip with a nullptr as the third parameter, no crash. 1031f6603c60Sopenharmony_ci OH_Drawing_PathTransformWithPerspectiveClip(src, matrix, nullptr, true); 1032f6603c60Sopenharmony_ci // 7. Free the memory. 1033f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(src); 1034f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 1035f6603c60Sopenharmony_ci OH_Drawing_MatrixDestroy(matrix); 1036f6603c60Sopenharmony_ci} 1037f6603c60Sopenharmony_ci 1038f6603c60Sopenharmony_ci/* 1039f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3100 1040f6603c60Sopenharmony_ci * @tc.name: testPathSetFillTypeNormal 1041f6603c60Sopenharmony_ci * @tc.desc: Test for setting fill type of a path using normal parameters. 1042f6603c60Sopenharmony_ci * @tc.size : SmallTest 1043f6603c60Sopenharmony_ci * @tc.type : Function 1044f6603c60Sopenharmony_ci * @tc.level : Level 0 1045f6603c60Sopenharmony_ci */ 1046f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathSetFillTypeNormal, TestSize.Level0) { 1047f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1048f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1049f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1050f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1051f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1052f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1053f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 1054f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 1055f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 1056f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 0); 1057f6603c60Sopenharmony_ci // 6. Close the path using OH_Drawing_PathClose. 1058f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 1059f6603c60Sopenharmony_ci // 7. Set the fill type of the path using OH_Drawing_PathSetFillType, with the second parameter iterating through 1060f6603c60Sopenharmony_ci // the enumeration. 1061f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING); 1062f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD); 1063f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_WINDING); 1064f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, OH_Drawing_PathFillType::PATH_FILL_TYPE_INVERSE_EVEN_ODD); 1065f6603c60Sopenharmony_ci // 8. Free the memory. 1066f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1067f6603c60Sopenharmony_ci} 1068f6603c60Sopenharmony_ci 1069f6603c60Sopenharmony_ci/* 1070f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3101 1071f6603c60Sopenharmony_ci * @tc.name: testPathSetFillTypeNull 1072f6603c60Sopenharmony_ci * @tc.desc: Test for setting fill type of a path using NULL or invalid parameters. 1073f6603c60Sopenharmony_ci * @tc.size : SmallTest 1074f6603c60Sopenharmony_ci * @tc.type : Function 1075f6603c60Sopenharmony_ci * @tc.level : Level 3 1076f6603c60Sopenharmony_ci */ 1077f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathSetFillTypeNull, TestSize.Level3) { 1078f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1079f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1080f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathSetFillType with a nullptr as the first parameter, expecting 1081f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1082f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(nullptr, OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING); 1083f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1084f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathSetFillType with a value that is not within the enumeration range as the second parameter, 1085f6603c60Sopenharmony_ci // expecting OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE error code. 1086f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(-1)); 1087f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE); 1088f6603c60Sopenharmony_ci // 4. Free the memory. 1089f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1090f6603c60Sopenharmony_ci} 1091f6603c60Sopenharmony_ci 1092f6603c60Sopenharmony_ci/* 1093f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3102 1094f6603c60Sopenharmony_ci * @tc.name: testPathSetFillTypeMultipleCalls 1095f6603c60Sopenharmony_ci * @tc.desc: Test for setting fill type of a path with multiple calls. 1096f6603c60Sopenharmony_ci * @tc.size : SmallTest 1097f6603c60Sopenharmony_ci * @tc.type : Function 1098f6603c60Sopenharmony_ci * @tc.level : Level 3 1099f6603c60Sopenharmony_ci */ 1100f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathSetFillTypeMultipleCalls, TestSize.Level3) { 1101f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1102f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1103f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1104f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1105f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1106f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1107f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 1108f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 1109f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 1110f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 0); 1111f6603c60Sopenharmony_ci // 6. Close the path using OH_Drawing_PathClose. 1112f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 1113f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathSetFillType in a loop 10 times, iterating through the enumeration to set different fill 1114f6603c60Sopenharmony_ci // rules for the path. 1115f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 1116f6603c60Sopenharmony_ci OH_Drawing_PathSetFillType(path, static_cast<OH_Drawing_PathFillType>(i)); 1117f6603c60Sopenharmony_ci } 1118f6603c60Sopenharmony_ci // 8. Free the memory. 1119f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1120f6603c60Sopenharmony_ci} 1121f6603c60Sopenharmony_ci 1122f6603c60Sopenharmony_ci/* 1123f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3200 1124f6603c60Sopenharmony_ci * @tc.name: testPathGetLengthNormal 1125f6603c60Sopenharmony_ci * @tc.desc: Test for getting the length of a path using normal parameters with detailed length. 1126f6603c60Sopenharmony_ci * @tc.size : SmallTest 1127f6603c60Sopenharmony_ci * @tc.type : Function 1128f6603c60Sopenharmony_ci * @tc.level : Level 0 1129f6603c60Sopenharmony_ci */ 1130f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathGetLengthNormal, TestSize.Level0) { 1131f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1132f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1133f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1134f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1135f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1136f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1137f6603c60Sopenharmony_ci // 4. Get the length of the current path by calling OH_Drawing_PathGetLength, with the second parameter set to true. 1138f6603c60Sopenharmony_ci float length = OH_Drawing_PathGetLength(path, true); 1139f6603c60Sopenharmony_ci EXPECT_NE(length, 0.0f); 1140f6603c60Sopenharmony_ci // 5. Free the memory. 1141f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1142f6603c60Sopenharmony_ci} 1143f6603c60Sopenharmony_ci 1144f6603c60Sopenharmony_ci/* 1145f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3201 1146f6603c60Sopenharmony_ci * @tc.name: testPathGetLengthNormal2 1147f6603c60Sopenharmony_ci * @tc.desc: Test for getting the length of a path using normal parameters without detailed length. 1148f6603c60Sopenharmony_ci * @tc.size : SmallTest 1149f6603c60Sopenharmony_ci * @tc.type : Function 1150f6603c60Sopenharmony_ci * @tc.level : Level 0 1151f6603c60Sopenharmony_ci */ 1152f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathGetLengthNormal2, TestSize.Level0) { 1153f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1154f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1155f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1156f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1157f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1158f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1159f6603c60Sopenharmony_ci // 4. Get the length of the current path by calling OH_Drawing_PathGetLength, with the second parameter set to 1160f6603c60Sopenharmony_ci // false. 1161f6603c60Sopenharmony_ci float length = OH_Drawing_PathGetLength(path, false); 1162f6603c60Sopenharmony_ci EXPECT_NE(length, 0.0f); 1163f6603c60Sopenharmony_ci // 5. Free the memory. 1164f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1165f6603c60Sopenharmony_ci} 1166f6603c60Sopenharmony_ci 1167f6603c60Sopenharmony_ci/* 1168f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3202 1169f6603c60Sopenharmony_ci * @tc.name: testPathGetLengthNull 1170f6603c60Sopenharmony_ci * @tc.desc: Test for getting the length of a path using NULL or invalid parameters. 1171f6603c60Sopenharmony_ci * @tc.size : SmallTest 1172f6603c60Sopenharmony_ci * @tc.type : Function 1173f6603c60Sopenharmony_ci * @tc.level : Level 3 1174f6603c60Sopenharmony_ci */ 1175f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathGetLengthNull, TestSize.Level3) { 1176f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1177f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1178f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathGetLength with a nullptr as the first parameter, expecting 1179f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1180f6603c60Sopenharmony_ci OH_Drawing_PathGetLength(nullptr, true); 1181f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1182f6603c60Sopenharmony_ci // 3. Free the memory. 1183f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1184f6603c60Sopenharmony_ci} 1185f6603c60Sopenharmony_ci 1186f6603c60Sopenharmony_ci/* 1187f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3300 1188f6603c60Sopenharmony_ci * @tc.name: testPathGetBoundsNormal 1189f6603c60Sopenharmony_ci * @tc.desc: Test for getting the bounds of a path using normal parameters. 1190f6603c60Sopenharmony_ci * @tc.size : SmallTest 1191f6603c60Sopenharmony_ci * @tc.type : Function 1192f6603c60Sopenharmony_ci * @tc.level : Level 0 1193f6603c60Sopenharmony_ci */ 1194f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathGetBoundsNormal, TestSize.Level0) { 1195f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1196f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1197f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 1198f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 1199f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 1200f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1201f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1202f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1203f6603c60Sopenharmony_ci // 5. Get the minimum bounding box that contains the path by calling OH_Drawing_PathGetBounds. 1204f6603c60Sopenharmony_ci OH_Drawing_PathGetBounds(path, rect); 1205f6603c60Sopenharmony_ci // 6. Free the memory. 1206f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1207f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1208f6603c60Sopenharmony_ci} 1209f6603c60Sopenharmony_ci 1210f6603c60Sopenharmony_ci/* 1211f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3301 1212f6603c60Sopenharmony_ci * @tc.name: testPathGetBoundsNull 1213f6603c60Sopenharmony_ci * @tc.desc: Test for getting the bounds of a path using NULL or invalid parameters. 1214f6603c60Sopenharmony_ci * @tc.size : SmallTest 1215f6603c60Sopenharmony_ci * @tc.type : Function 1216f6603c60Sopenharmony_ci * @tc.level : Level 3 1217f6603c60Sopenharmony_ci */ 1218f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathGetBoundsNull, TestSize.Level3) { 1219f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1220f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1221f6603c60Sopenharmony_ci // 2. Create a rectangle object using OH_Drawing_RectCreate. 1222f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 1223f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathGetBounds with a nullptr as the first parameter, expecting 1224f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1225f6603c60Sopenharmony_ci OH_Drawing_PathGetBounds(nullptr, rect); 1226f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1227f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathGetBounds with a nullptr as the second parameter, expecting 1228f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER error code. 1229f6603c60Sopenharmony_ci OH_Drawing_PathGetBounds(path, nullptr); 1230f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1231f6603c60Sopenharmony_ci // 5. Free the memory. 1232f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1233f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1234f6603c60Sopenharmony_ci} 1235f6603c60Sopenharmony_ci 1236f6603c60Sopenharmony_ci/* 1237f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3400 1238f6603c60Sopenharmony_ci * @tc.name: testPathCloseNormal 1239f6603c60Sopenharmony_ci * @tc.desc: test for testPathCloseNormal. 1240f6603c60Sopenharmony_ci * @tc.size : SmallTest 1241f6603c60Sopenharmony_ci * @tc.type : Function 1242f6603c60Sopenharmony_ci * @tc.level : Level 0 1243f6603c60Sopenharmony_ci */ 1244f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCloseNormal, TestSize.Level0) { 1245f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1246f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1247f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1248f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1249f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1250f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1251f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point using OH_Drawing_PathLineTo. 1252f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 1253f6603c60Sopenharmony_ci // 5. Close the path by adding a line segment from the last point of the path to the starting point. 1254f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 1255f6603c60Sopenharmony_ci // 6. Free the memory. 1256f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1257f6603c60Sopenharmony_ci} 1258f6603c60Sopenharmony_ci 1259f6603c60Sopenharmony_ci/* 1260f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3401 1261f6603c60Sopenharmony_ci * @tc.name: testPathCloseNull 1262f6603c60Sopenharmony_ci * @tc.desc: Test for closing a path using NULL or invalid parameters. 1263f6603c60Sopenharmony_ci * @tc.size : SmallTest 1264f6603c60Sopenharmony_ci * @tc.type : Function 1265f6603c60Sopenharmony_ci * @tc.level : Level 3 1266f6603c60Sopenharmony_ci */ 1267f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCloseNull, TestSize.Level3) { 1268f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1269f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1270f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathClose with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error 1271f6603c60Sopenharmony_ci // code. 1272f6603c60Sopenharmony_ci OH_Drawing_PathClose(nullptr); 1273f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1274f6603c60Sopenharmony_ci // 3. Free the memory. 1275f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1276f6603c60Sopenharmony_ci} 1277f6603c60Sopenharmony_ci 1278f6603c60Sopenharmony_ci/* 1279f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3500 1280f6603c60Sopenharmony_ci * @tc.name: testPathOffsetNormal 1281f6603c60Sopenharmony_ci * @tc.desc: Test for offsetting a path using normal parameters. 1282f6603c60Sopenharmony_ci * @tc.size : SmallTest 1283f6603c60Sopenharmony_ci * @tc.type : Function 1284f6603c60Sopenharmony_ci * @tc.level : Level 0 1285f6603c60Sopenharmony_ci */ 1286f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathOffsetNormal, TestSize.Level0) { 1287f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1288f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1289f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 1290f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 1291f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 1292f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1293f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1294f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1295f6603c60Sopenharmony_ci // 5. Offset all points in the path by a certain distance along the x and y axes, and store the result in the 1296f6603c60Sopenharmony_ci // destination path object using OH_Drawing_PathOffset. 1297f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 10, 10); 1298f6603c60Sopenharmony_ci // 6. Free the memory. 1299f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1300f6603c60Sopenharmony_ci} 1301f6603c60Sopenharmony_ci 1302f6603c60Sopenharmony_ci/* 1303f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3501 1304f6603c60Sopenharmony_ci * @tc.name: testPathOffsetNull 1305f6603c60Sopenharmony_ci * @tc.desc: Test for offsetting a path using NULL or invalid parameters. 1306f6603c60Sopenharmony_ci * @tc.size : SmallTest 1307f6603c60Sopenharmony_ci * @tc.type : Function 1308f6603c60Sopenharmony_ci * @tc.level : Level 3 1309f6603c60Sopenharmony_ci */ 1310f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathOffsetNull, TestSize.Level3) { 1311f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1312f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1313f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 1314f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 1315f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathOffset with a nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1316f6603c60Sopenharmony_ci // error code. 1317f6603c60Sopenharmony_ci OH_Drawing_PathOffset(nullptr, dst, 10, 10); 1318f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1319f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathOffset with a nullptr as the second parameter, expecting failure without crashing. 1320f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, nullptr, 10, 10); 1321f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathOffset with 0.00 as the third parameter, expecting failure without crashing. 1322f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 0.00, 10); 1323f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathOffset with 0.00 as the fourth parameter, expecting failure without crashing. 1324f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 10, 0.00); 1325f6603c60Sopenharmony_ci // 7. Free the memory. 1326f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1327f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 1328f6603c60Sopenharmony_ci} 1329f6603c60Sopenharmony_ci 1330f6603c60Sopenharmony_ci/* 1331f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3502 1332f6603c60Sopenharmony_ci * @tc.name: testPathOffsetAbnormal 1333f6603c60Sopenharmony_ci * @tc.desc: Test for offsetting a path with abnormal parameters (non-float values). 1334f6603c60Sopenharmony_ci * @tc.size : SmallTest 1335f6603c60Sopenharmony_ci * @tc.type : Function 1336f6603c60Sopenharmony_ci * @tc.level : Level 3 1337f6603c60Sopenharmony_ci */ 1338f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathOffsetAbnormal, TestSize.Level3) { 1339f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1340f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1341f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 1342f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 1343f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 1344f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1345f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1346f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1347f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathOffset with an integer as the third parameter. 1348f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 10, 10.0f); 1349f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathOffset with an integer as the fourth parameter. 1350f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 10.0f, 10); 1351f6603c60Sopenharmony_ci // 7. Free the memory. 1352f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1353f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 1354f6603c60Sopenharmony_ci} 1355f6603c60Sopenharmony_ci 1356f6603c60Sopenharmony_ci/* 1357f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3503 1358f6603c60Sopenharmony_ci * @tc.name: testPathOffsetMaximal 1359f6603c60Sopenharmony_ci * @tc.desc: Test for offsetting a path with maximal values. 1360f6603c60Sopenharmony_ci * @tc.size : SmallTest 1361f6603c60Sopenharmony_ci * @tc.type : Function 1362f6603c60Sopenharmony_ci * @tc.level : Level 3 1363f6603c60Sopenharmony_ci */ 1364f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathOffsetMaximal, TestSize.Level3) { 1365f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1366f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1367f6603c60Sopenharmony_ci // 2. Create a path object using OH_Drawing_PathCreate. 1368f6603c60Sopenharmony_ci OH_Drawing_Path *dst = OH_Drawing_PathCreate(); 1369f6603c60Sopenharmony_ci // 3. Set the starting point of the path using OH_Drawing_PathMoveTo. 1370f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1371f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1372f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1373f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathOffset with the third parameter set to the maximum value FLT_MAX + 1. 1374f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, FLT_MAX + 1, 10.0f); 1375f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathOffset with the fourth parameter set to the maximum value FLT_MAX + 1. 1376f6603c60Sopenharmony_ci OH_Drawing_PathOffset(path, dst, 10.0f, FLT_MAX + 1); 1377f6603c60Sopenharmony_ci // 7. Free the memory. 1378f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1379f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(dst); 1380f6603c60Sopenharmony_ci} 1381f6603c60Sopenharmony_ci 1382f6603c60Sopenharmony_ci/* 1383f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3600 1384f6603c60Sopenharmony_ci * @tc.name: testPathResetNormal 1385f6603c60Sopenharmony_ci * @tc.desc: Test for resetting a path using normal parameters. 1386f6603c60Sopenharmony_ci * @tc.size : SmallTest 1387f6603c60Sopenharmony_ci * @tc.type : Function 1388f6603c60Sopenharmony_ci * @tc.level : Level 0 1389f6603c60Sopenharmony_ci */ 1390f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathResetNormal, TestSize.Level0) { 1391f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1392f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1393f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1394f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1395f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1396f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1397f6603c60Sopenharmony_ci // 4. Reset the custom path data using OH_Drawing_PathReset. 1398f6603c60Sopenharmony_ci OH_Drawing_PathReset(path); 1399f6603c60Sopenharmony_ci // 5. Free the memory. 1400f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1401f6603c60Sopenharmony_ci} 1402f6603c60Sopenharmony_ci 1403f6603c60Sopenharmony_ci/* 1404f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3601 1405f6603c60Sopenharmony_ci * @tc.name: testPathResetNull 1406f6603c60Sopenharmony_ci * @tc.desc: Test for resetting a path using NULL or invalid parameters. 1407f6603c60Sopenharmony_ci * @tc.size : SmallTest 1408f6603c60Sopenharmony_ci * @tc.type : Function 1409f6603c60Sopenharmony_ci * @tc.level : Level 3 1410f6603c60Sopenharmony_ci */ 1411f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathResetNull, TestSize.Level3) { 1412f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1413f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1414f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathReset with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error 1415f6603c60Sopenharmony_ci // code. 1416f6603c60Sopenharmony_ci OH_Drawing_PathReset(nullptr); 1417f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1418f6603c60Sopenharmony_ci // 3. Free the memory. 1419f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1420f6603c60Sopenharmony_ci} 1421f6603c60Sopenharmony_ci 1422f6603c60Sopenharmony_ci/* 1423f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_3602 1424f6603c60Sopenharmony_ci * @tc.name: testPathResetMultipleCalls 1425f6603c60Sopenharmony_ci * @tc.desc: Test for resetting a path with multiple calls. 1426f6603c60Sopenharmony_ci * @tc.size : SmallTest 1427f6603c60Sopenharmony_ci * @tc.type : Function 1428f6603c60Sopenharmony_ci * @tc.level : Level 3 1429f6603c60Sopenharmony_ci */ 1430f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathResetMultipleCalls, TestSize.Level3) { 1431f6603c60Sopenharmony_ci // 1. Create a path object using OH_Drawing_PathCreate. 1432f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1433f6603c60Sopenharmony_ci // 2. Set the starting point of the path using OH_Drawing_PathMoveTo. 1434f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1435f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point using OH_Drawing_PathLineTo. 1436f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1437f6603c60Sopenharmony_ci // 4. Reset the custom path data using OH_Drawing_PathReset. 1438f6603c60Sopenharmony_ci OH_Drawing_PathReset(path); 1439f6603c60Sopenharmony_ci // 5. Loop through steps 2 to 4 for 10 times to verify success. 1440f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 1441f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1442f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1443f6603c60Sopenharmony_ci OH_Drawing_PathReset(path); 1444f6603c60Sopenharmony_ci } 1445f6603c60Sopenharmony_ci // 6. Free the memory. 1446f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1447f6603c60Sopenharmony_ci} 1448f6603c60Sopenharmony_ci 1449f6603c60Sopenharmony_ci} // namespace Drawing 1450f6603c60Sopenharmony_ci} // namespace Rosen 1451f6603c60Sopenharmony_ci} // namespace OHOS