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 * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0100 40f6603c60Sopenharmony_ci * @tc.name: testPathCreateNormal 41f6603c60Sopenharmony_ci * @tc.desc: Test for creating a path object with normal parameters. 42f6603c60Sopenharmony_ci * @tc.size : SmallTest 43f6603c60Sopenharmony_ci * @tc.type : Function 44f6603c60Sopenharmony_ci * @tc.level : Level 0 45f6603c60Sopenharmony_ci */ 46f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCreateNormal, TestSize.Level0) { 47f6603c60Sopenharmony_ci // 1. Call OH_Drawing_PathCreate to create a path object 48f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 49f6603c60Sopenharmony_ci EXPECT_NE(path, nullptr); 50f6603c60Sopenharmony_ci // 2. Free memory 51f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 52f6603c60Sopenharmony_ci} 53f6603c60Sopenharmony_ci 54f6603c60Sopenharmony_ci/* 55f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0200 56f6603c60Sopenharmony_ci * @tc.name: testPathCopyNormal 57f6603c60Sopenharmony_ci * @tc.desc: Test for copying a path with normal parameters and checking the copied path length. 58f6603c60Sopenharmony_ci * @tc.size : SmallTest 59f6603c60Sopenharmony_ci * @tc.type : Function 60f6603c60Sopenharmony_ci * @tc.level : Level 0 61f6603c60Sopenharmony_ci */ 62f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCopyNormal, TestSize.Level0) { 63f6603c60Sopenharmony_ci // 1. Create a path object 1 by calling OH_Drawing_PathCreate 64f6603c60Sopenharmony_ci OH_Drawing_Path *path1 = OH_Drawing_PathCreate(); 65f6603c60Sopenharmony_ci EXPECT_NE(path1, nullptr); 66f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 67f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path1, 0, 0); 68f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 69f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 100, 100); 70f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point to the path by calling 71f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 72f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 200, 200); 73f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point to the path by calling 74f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 75f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 300, 300); 76f6603c60Sopenharmony_ci // 6. Close the path by calling OH_Drawing_PathClose 77f6603c60Sopenharmony_ci OH_Drawing_PathClose(path1); 78f6603c60Sopenharmony_ci // 7. Copy path 1 to path 2 by calling OH_Drawing_PathCopy 79f6603c60Sopenharmony_ci OH_Drawing_Path *path2 = OH_Drawing_PathCopy(path1); 80f6603c60Sopenharmony_ci // 8. Get the length of path 2 by calling OH_Drawing_PathGetLength 81f6603c60Sopenharmony_ci bool isEqual = IsScalarAlmostEqual(OH_Drawing_PathGetLength(path1, false), OH_Drawing_PathGetLength(path2, false)); 82f6603c60Sopenharmony_ci EXPECT_TRUE(isEqual); 83f6603c60Sopenharmony_ci // 9. Free memory 84f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path1); 85f6603c60Sopenharmony_ci} 86f6603c60Sopenharmony_ci 87f6603c60Sopenharmony_ci/* 88f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0201 89f6603c60Sopenharmony_ci * @tc.name: testPathCopyNull 90f6603c60Sopenharmony_ci * @tc.desc: Test for copying a path with NULL parameters. 91f6603c60Sopenharmony_ci * @tc.size : SmallTest 92f6603c60Sopenharmony_ci * @tc.type : Function 93f6603c60Sopenharmony_ci * @tc.level : Level 3 94f6603c60Sopenharmony_ci */ 95f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCopyNull, TestSize.Level3) { 96f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 97f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 98f6603c60Sopenharmony_ci // 2. Copy a path with nullptr as the parameter 99f6603c60Sopenharmony_ci OH_Drawing_Path *path2 = OH_Drawing_PathCopy(nullptr); 100f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 101f6603c60Sopenharmony_ci // 3. Free memory 102f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 103f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path2); 104f6603c60Sopenharmony_ci} 105f6603c60Sopenharmony_ci 106f6603c60Sopenharmony_ci/* 107f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0202 108f6603c60Sopenharmony_ci * @tc.name: testPathCopyInputDestroyed 109f6603c60Sopenharmony_ci * @tc.desc: Test for copying a path and checking if the copied path is affected after the original path is destroyed. 110f6603c60Sopenharmony_ci * @tc.size : SmallTest 111f6603c60Sopenharmony_ci * @tc.type : Function 112f6603c60Sopenharmony_ci * @tc.level : Level 3 113f6603c60Sopenharmony_ci */ 114f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCopyInputDestroyed, TestSize.Level3) { 115f6603c60Sopenharmony_ci // 1. Create a path object 1 by calling OH_Drawing_PathCreate 116f6603c60Sopenharmony_ci OH_Drawing_Path *path1 = OH_Drawing_PathCreate(); 117f6603c60Sopenharmony_ci EXPECT_NE(path1, nullptr); 118f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 119f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path1, 0, 0); 120f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 121f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 100, 100); 122f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point to the path by calling 123f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 124f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 200, 200); 125f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point to the path by calling 126f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 127f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path1, 300, 300); 128f6603c60Sopenharmony_ci // 6. Close the path by calling OH_Drawing_PathClose 129f6603c60Sopenharmony_ci OH_Drawing_PathClose(path1); 130f6603c60Sopenharmony_ci // 7. Copy path 1 to path 2 by calling OH_Drawing_PathCopy 131f6603c60Sopenharmony_ci OH_Drawing_Path *path2 = OH_Drawing_PathCopy(path1); 132f6603c60Sopenharmony_ci // 8. Destroy path 1 by calling OH_Drawing_PathDestroy 133f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path1); 134f6603c60Sopenharmony_ci // 9. Get the length of path 2 by calling OH_Drawing_PathGetLength, if the return value is not 0, it means 135f6603c60Sopenharmony_ci // destroying path 1 does not affect path 2 136f6603c60Sopenharmony_ci EXPECT_NE(OH_Drawing_PathGetLength(path2, false), 0); 137f6603c60Sopenharmony_ci // 10. Free memory 138f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path2); 139f6603c60Sopenharmony_ci} 140f6603c60Sopenharmony_ci 141f6603c60Sopenharmony_ci/* 142f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0300 143f6603c60Sopenharmony_ci * @tc.name: testPathDestroyNormal 144f6603c60Sopenharmony_ci * @tc.desc: Test for creating and destroying a path object with normal parameters. 145f6603c60Sopenharmony_ci * @tc.size : SmallTest 146f6603c60Sopenharmony_ci * @tc.type : Function 147f6603c60Sopenharmony_ci * @tc.level : Level 0 148f6603c60Sopenharmony_ci */ 149f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathDestroyNormal, TestSize.Level0) { 150f6603c60Sopenharmony_ci // 1. Call OH_Drawing_PathCreate to create a path object 151f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 152f6603c60Sopenharmony_ci // 2. Free memory by calling OH_Drawing_PathDestroy 153f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 154f6603c60Sopenharmony_ci} 155f6603c60Sopenharmony_ci 156f6603c60Sopenharmony_ci/* 157f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0301 158f6603c60Sopenharmony_ci * @tc.name: testPathDestroyNull 159f6603c60Sopenharmony_ci * @tc.desc: Test for destroying a path object with NULL parameters. 160f6603c60Sopenharmony_ci * @tc.size : SmallTest 161f6603c60Sopenharmony_ci * @tc.type : Function 162f6603c60Sopenharmony_ci * @tc.level : Level 3 163f6603c60Sopenharmony_ci */ 164f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathDestroyNull, TestSize.Level3) { 165f6603c60Sopenharmony_ci // 1. Call OH_Drawing_PathCreate to create a path object 166f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 167f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathDestroy with nullptr as the parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER error 168f6603c60Sopenharmony_ci // code 169f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(nullptr); 170f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 171f6603c60Sopenharmony_ci // 3. Free memory 172f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 173f6603c60Sopenharmony_ci} 174f6603c60Sopenharmony_ci 175f6603c60Sopenharmony_ci/* 176f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0400 177f6603c60Sopenharmony_ci * @tc.name: testPathMoveToNormal 178f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path to a normal position with valid parameters. 179f6603c60Sopenharmony_ci * @tc.size : SmallTest 180f6603c60Sopenharmony_ci * @tc.type : Function 181f6603c60Sopenharmony_ci * @tc.level : Level 0 182f6603c60Sopenharmony_ci */ 183f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathMoveToNormal, TestSize.Level0) { 184f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 185f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 186f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 187f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 188f6603c60Sopenharmony_ci // 3. Free memory by calling OH_Drawing_PathDestroy 189f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 190f6603c60Sopenharmony_ci} 191f6603c60Sopenharmony_ci 192f6603c60Sopenharmony_ci/* 193f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0401 194f6603c60Sopenharmony_ci * @tc.name: testPathMoveToNull 195f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path with NULL or invalid parameters. 196f6603c60Sopenharmony_ci * @tc.size : SmallTest 197f6603c60Sopenharmony_ci * @tc.type : Function 198f6603c60Sopenharmony_ci * @tc.level : Level 3 199f6603c60Sopenharmony_ci */ 200f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathMoveToNull, TestSize.Level3) { 201f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 202f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 203f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathMoveTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 204f6603c60Sopenharmony_ci // error code 205f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(nullptr, 1, 1); 206f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 207f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathMoveTo with 0.00 as the second parameter 208f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0.00, 1); 209f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathMoveTo with 0.00 as the third parameter 210f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 1, 0.00); 211f6603c60Sopenharmony_ci // 5. Free memory 212f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 213f6603c60Sopenharmony_ci} 214f6603c60Sopenharmony_ci 215f6603c60Sopenharmony_ci/* 216f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0402 217f6603c60Sopenharmony_ci * @tc.name: testPathMoveToAbnormal 218f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path with abnormal data types as parameters. 219f6603c60Sopenharmony_ci * @tc.size : SmallTest 220f6603c60Sopenharmony_ci * @tc.type : Function 221f6603c60Sopenharmony_ci * @tc.level : Level 3 222f6603c60Sopenharmony_ci */ 223f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathMoveToAbnormal, TestSize.Level3) { 224f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 225f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 226f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo with an integer or character type as the 227f6603c60Sopenharmony_ci // second parameter 228f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 2, 1.0f); 229f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo with an integer or character type as the 230f6603c60Sopenharmony_ci // third parameter 231f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 1.0f, 2); 232f6603c60Sopenharmony_ci // 4. Free memory by calling OH_Drawing_PathDestroy 233f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 234f6603c60Sopenharmony_ci} 235f6603c60Sopenharmony_ci 236f6603c60Sopenharmony_ci/* 237f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0403 238f6603c60Sopenharmony_ci * @tc.name: testPathMoveToMaximal 239f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path with maximal values as parameters. 240f6603c60Sopenharmony_ci * @tc.size : SmallTest 241f6603c60Sopenharmony_ci * @tc.type : Function 242f6603c60Sopenharmony_ci * @tc.level : Level 3 243f6603c60Sopenharmony_ci */ 244f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathMoveToMaximal, TestSize.Level3) { 245f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 246f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 247f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo with the second parameter as the maximum 248f6603c60Sopenharmony_ci // value of FLT_MAX + 1, no crash 249f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, FLT_MAX + 1, 1.0); 250f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo with the third parameter as the maximum 251f6603c60Sopenharmony_ci // value of FLT_MAX + 1, no crash 252f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 1.0, FLT_MAX + 1); 253f6603c60Sopenharmony_ci // 4. Free memory 254f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 255f6603c60Sopenharmony_ci} 256f6603c60Sopenharmony_ci 257f6603c60Sopenharmony_ci/* 258f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0500 259f6603c60Sopenharmony_ci * @tc.name: testPathLineToNormal 260f6603c60Sopenharmony_ci * @tc.desc: Test for adding a line to a path with normal parameters. 261f6603c60Sopenharmony_ci * @tc.size : SmallTest 262f6603c60Sopenharmony_ci * @tc.type : Function 263f6603c60Sopenharmony_ci * @tc.level : Level 0 264f6603c60Sopenharmony_ci */ 265f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathLineToNormal, TestSize.Level0) { 266f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 267f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 268f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 269f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 270f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 271f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 272f6603c60Sopenharmony_ci // 4. Free memory by calling OH_Drawing_PathDestroy 273f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 274f6603c60Sopenharmony_ci} 275f6603c60Sopenharmony_ci 276f6603c60Sopenharmony_ci/* 277f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0501 278f6603c60Sopenharmony_ci * @tc.name: testPathLineToNull 279f6603c60Sopenharmony_ci * @tc.desc: Test for adding a line to a path with NULL or invalid parameters. 280f6603c60Sopenharmony_ci * @tc.size : SmallTest 281f6603c60Sopenharmony_ci * @tc.type : Function 282f6603c60Sopenharmony_ci * @tc.level : Level 3 283f6603c60Sopenharmony_ci */ 284f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathLineToNull, TestSize.Level3) { 285f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 286f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 287f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathLineTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 288f6603c60Sopenharmony_ci // error code 289f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(nullptr, 1, 1); 290f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 291f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathLineTo with 0.00 as the second parameter, no crash 292f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0.00, 1); 293f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathLineTo with 0.00 as the third parameter, no crash 294f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 1, 0.00); 295f6603c60Sopenharmony_ci // 5. Free memory 296f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 297f6603c60Sopenharmony_ci} 298f6603c60Sopenharmony_ci 299f6603c60Sopenharmony_ci/* 300f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0502 301f6603c60Sopenharmony_ci * @tc.name: testPathLineToAbnormal 302f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path with abnormal data types as parameters. 303f6603c60Sopenharmony_ci * @tc.size : SmallTest 304f6603c60Sopenharmony_ci * @tc.type : Function 305f6603c60Sopenharmony_ci * @tc.level : Level 3 306f6603c60Sopenharmony_ci */ 307f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathLineToAbnormal, TestSize.Level3) { 308f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 309f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 310f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 311f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 312f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 313f6603c60Sopenharmony_ci // with an integer or character type as the second parameter 314f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 2, 1.0f); 315f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 316f6603c60Sopenharmony_ci // with an integer or character type as the third parameter 317f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 1.0f, 2); 318f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 319f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 320f6603c60Sopenharmony_ci} 321f6603c60Sopenharmony_ci 322f6603c60Sopenharmony_ci/* 323f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0503 324f6603c60Sopenharmony_ci * @tc.name: testPathLineToMaximal 325f6603c60Sopenharmony_ci * @tc.desc: Test for moving a path with maximal values as parameters. 326f6603c60Sopenharmony_ci * @tc.size : SmallTest 327f6603c60Sopenharmony_ci * @tc.type : Function 328f6603c60Sopenharmony_ci * @tc.level : Level 3 329f6603c60Sopenharmony_ci */ 330f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathLineToMaximal, TestSize.Level3) { 331f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 332f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 333f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 334f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 335f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 336f6603c60Sopenharmony_ci // with the second parameter as the maximum value of FLT_MAX + 1, no crash 337f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, FLT_MAX + 1, 1.0); 338f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 339f6603c60Sopenharmony_ci // with the third parameter as the maximum value of FLT_MAX + 1, no crash 340f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 1.0, FLT_MAX + 1); 341f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 342f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 343f6603c60Sopenharmony_ci} 344f6603c60Sopenharmony_ci 345f6603c60Sopenharmony_ci/* 346f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0600 347f6603c60Sopenharmony_ci * @tc.name: testPathArcToNormal 348f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with normal parameters. 349f6603c60Sopenharmony_ci * @tc.size : SmallTest 350f6603c60Sopenharmony_ci * @tc.type : Function 351f6603c60Sopenharmony_ci * @tc.level : Level 0 352f6603c60Sopenharmony_ci */ 353f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathArcToNormal, TestSize.Level0) { 354f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 355f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 356f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 357f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 358f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 359f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 360f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point to the path by calling 361f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 362f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 200, 200); 363f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point to the path by calling 364f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 365f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 300, 300); 366f6603c60Sopenharmony_ci // 6. Close the path by calling OH_Drawing_PathClose 367f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 368f6603c60Sopenharmony_ci // 7. Add an arc to the path by calling OH_Drawing_PathArcTo 369f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, 90); 370f6603c60Sopenharmony_ci // 8. Free memory by calling OH_Drawing_PathDestroy 371f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 372f6603c60Sopenharmony_ci} 373f6603c60Sopenharmony_ci 374f6603c60Sopenharmony_ci/* 375f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0601 376f6603c60Sopenharmony_ci * @tc.name: testPathArcToNull 377f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with NULL or invalid parameters. 378f6603c60Sopenharmony_ci * @tc.size : SmallTest 379f6603c60Sopenharmony_ci * @tc.type : Function 380f6603c60Sopenharmony_ci * @tc.level : Level 3 381f6603c60Sopenharmony_ci */ 382f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathArcToNull, TestSize.Level3) { 383f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 384f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 385f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathArcTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 386f6603c60Sopenharmony_ci // error code 387f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(nullptr, 10, 10, 20, 0, 0, 90); 388f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 389f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathArcTo with 0.00 as the second parameter, no crash 390f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 0.00, 10, 20, 0, 0, 90); 391f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathArcTo with 0.00 as the third parameter, no crash 392f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 0.00, 20, 0, 0, 90); 393f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathArcTo with 0.00 as the fourth parameter, no crash 394f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 0.00, 0, 0, 90); 395f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathArcTo with 0.00 as the fifth parameter, no crash 396f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0.00, 0, 90); 397f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathArcTo with 0.00 as the sixth parameter, no crash 398f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0.00, 90); 399f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathArcTo with 0.00 as the seventh parameter, no crash 400f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, 0.00); 401f6603c60Sopenharmony_ci // 9. Free memory 402f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 403f6603c60Sopenharmony_ci} 404f6603c60Sopenharmony_ci 405f6603c60Sopenharmony_ci/* 406f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0602 407f6603c60Sopenharmony_ci * @tc.name: testPathArcToAbnormal 408f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with abnormal data types as parameters. 409f6603c60Sopenharmony_ci * @tc.size : SmallTest 410f6603c60Sopenharmony_ci * @tc.type : Function 411f6603c60Sopenharmony_ci * @tc.level : Level 3 412f6603c60Sopenharmony_ci */ 413f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathArcToAbnormal, TestSize.Level3) { 414f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 415f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 416f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 417f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 418f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 419f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 420f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point to the path by calling 421f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 422f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 200, 200); 423f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point to the path by calling 424f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 425f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 300, 300); 426f6603c60Sopenharmony_ci // 6. Close the path by calling OH_Drawing_PathClose 427f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 428f6603c60Sopenharmony_ci // 7. Add an arc to the path by calling OH_Drawing_PathArcTo with integer parameters 429f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 20, 20, 90); 430f6603c60Sopenharmony_ci // 8. Free memory by calling OH_Drawing_PathDestroy 431f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 432f6603c60Sopenharmony_ci} 433f6603c60Sopenharmony_ci 434f6603c60Sopenharmony_ci/* 435f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0603 436f6603c60Sopenharmony_ci * @tc.name: testPathArcToMaximal 437f6603c60Sopenharmony_ci * @tc.desc: Test for adding an arc to a path with maximal values as parameters. 438f6603c60Sopenharmony_ci * @tc.size : SmallTest 439f6603c60Sopenharmony_ci * @tc.type : Function 440f6603c60Sopenharmony_ci * @tc.level : Level 3 441f6603c60Sopenharmony_ci */ 442f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathArcToMaximal, TestSize.Level3) { 443f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 444f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 445f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 446f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 447f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point to the target point to the path by calling OH_Drawing_PathLineTo 448f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 449f6603c60Sopenharmony_ci // 4. Add a line segment from the last point of the path to the target point to the path by calling 450f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 451f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 200, 200); 452f6603c60Sopenharmony_ci // 5. Add a line segment from the last point of the path to the target point to the path by calling 453f6603c60Sopenharmony_ci // OH_Drawing_PathLineTo 454f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 300, 300); 455f6603c60Sopenharmony_ci // 6. Close the path by calling OH_Drawing_PathClose 456f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 457f6603c60Sopenharmony_ci // 7. Add an arc to the path by calling OH_Drawing_PathArcTo with the second parameter as the maximum value of 458f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 459f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, FLT_MAX + 1, 10, 20, 0, 0, 90); 460f6603c60Sopenharmony_ci // 8. Add an arc to the path by calling OH_Drawing_PathArcTo with the third parameter as the maximum value of 461f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 462f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, FLT_MAX + 1, 20, 0, 0, 90); 463f6603c60Sopenharmony_ci // 9. Add an arc to the path by calling OH_Drawing_PathArcTo with the fourth parameter as the maximum value of 464f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 465f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, FLT_MAX + 1, 0, 0, 90); 466f6603c60Sopenharmony_ci // 10. Add an arc to the path by calling OH_Drawing_PathArcTo with the fifth parameter as the maximum value of 467f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 468f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, FLT_MAX + 1, 0, 90); 469f6603c60Sopenharmony_ci // 11. Add an arc to the path by calling OH_Drawing_PathArcTo with the sixth parameter as the maximum value of 470f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 471f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0, FLT_MAX + 1, 90); 472f6603c60Sopenharmony_ci // 12. Add an arc to the path by calling OH_Drawing_PathArcTo with the seventh parameter as the maximum value of 473f6603c60Sopenharmony_ci // FLT_MAX + 1, no crash 474f6603c60Sopenharmony_ci OH_Drawing_PathArcTo(path, 10, 10, 20, 0, 0, FLT_MAX + 1); 475f6603c60Sopenharmony_ci // 13. Free memory 476f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 477f6603c60Sopenharmony_ci} 478f6603c60Sopenharmony_ci 479f6603c60Sopenharmony_ci/* 480f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0700 481f6603c60Sopenharmony_ci * @tc.name: testPathQuadToNormal 482f6603c60Sopenharmony_ci * @tc.desc: Test for adding a quadratic Bezier curve to a path with normal parameters. 483f6603c60Sopenharmony_ci * @tc.size : SmallTest 484f6603c60Sopenharmony_ci * @tc.type : Function 485f6603c60Sopenharmony_ci * @tc.level : Level 0 486f6603c60Sopenharmony_ci */ 487f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathQuadToNormal, TestSize.Level0) { 488f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 489f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 490f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 491f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 492f6603c60Sopenharmony_ci // 3. Add a quadratic Bezier curve from the last point of the path to the target point by calling 493f6603c60Sopenharmony_ci // OH_Drawing_PathQuadTo 494f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100, 200, 200); 495f6603c60Sopenharmony_ci // 4. Free memory by calling OH_Drawing_PathDestroy 496f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 497f6603c60Sopenharmony_ci} 498f6603c60Sopenharmony_ci 499f6603c60Sopenharmony_ci/* 500f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0701 501f6603c60Sopenharmony_ci * @tc.name: testPathQuadToNull 502f6603c60Sopenharmony_ci * @tc.desc: Test for adding a quadratic Bezier curve to a path with NULL or invalid parameters. 503f6603c60Sopenharmony_ci * @tc.size : SmallTest 504f6603c60Sopenharmony_ci * @tc.type : Function 505f6603c60Sopenharmony_ci * @tc.level : Level 3 506f6603c60Sopenharmony_ci */ 507f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathQuadToNull, TestSize.Level3) { 508f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 509f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 510f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathQuadTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 511f6603c60Sopenharmony_ci // error code 512f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(nullptr, 100, 100, 200, 200); 513f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 514f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathQuadTo with 0.00 as the second parameter, no crash 515f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 0.00, 100, 200, 200); 516f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathQuadTo with 0.00 as the third parameter, no crash 517f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 0.00, 200, 200); 518f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathQuadTo with 0.00 as the fourth parameter, no crash 519f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100, 0.00, 200); 520f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathQuadTo with 0.00 as the fifth parameter, no crash 521f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100, 200, 0.00); 522f6603c60Sopenharmony_ci // 7. Free memory 523f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 524f6603c60Sopenharmony_ci} 525f6603c60Sopenharmony_ci 526f6603c60Sopenharmony_ci/* 527f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0702 528f6603c60Sopenharmony_ci * @tc.name: testPathQuadToAbnormal 529f6603c60Sopenharmony_ci * @tc.desc: Test for adding a quadratic Bezier curve to a path with abnormal data types as parameters. 530f6603c60Sopenharmony_ci * @tc.size : SmallTest 531f6603c60Sopenharmony_ci * @tc.type : Function 532f6603c60Sopenharmony_ci * @tc.level : Level 3 533f6603c60Sopenharmony_ci */ 534f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathQuadToAbnormal, TestSize.Level3) { 535f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 536f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 537f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 538f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 539f6603c60Sopenharmony_ci // 3. Add a quadratic Bezier curve to the path with the second parameter as an integer 540f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100.0f, 200.0f, 200.0f); 541f6603c60Sopenharmony_ci // 4. Add a quadratic Bezier curve to the path with the third parameter as an integer 542f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100.0f, 100, 200.0f, 200.0f); 543f6603c60Sopenharmony_ci // 5. Add a quadratic Bezier curve to the path with the fourth parameter as an integer 544f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100.0f, 100.0f, 200, 200.0f); 545f6603c60Sopenharmony_ci // 6. Add a quadratic Bezier curve to the path with the fifth parameter as an integer 546f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100.0f, 100.0f, 200.0f, 200); 547f6603c60Sopenharmony_ci // 7. Free memory by calling OH_Drawing_PathDestroy 548f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 549f6603c60Sopenharmony_ci} 550f6603c60Sopenharmony_ci 551f6603c60Sopenharmony_ci/* 552f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0703 553f6603c60Sopenharmony_ci * @tc.name: testPathQuadToMaximal 554f6603c60Sopenharmony_ci * @tc.desc: Test for adding a quadratic Bezier curve to a path with maximal values as parameters. 555f6603c60Sopenharmony_ci * @tc.size : SmallTest 556f6603c60Sopenharmony_ci * @tc.type : Function 557f6603c60Sopenharmony_ci * @tc.level : Level 3 558f6603c60Sopenharmony_ci */ 559f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathQuadToMaximal, TestSize.Level3) { 560f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 561f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 562f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 563f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 564f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathQuadTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 565f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, FLT_MAX + 1, 100, 200, 200); 566f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathQuadTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 567f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, FLT_MAX + 1, 200, 200); 568f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathQuadTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 569f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100, FLT_MAX + 1, 200); 570f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathQuadTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 571f6603c60Sopenharmony_ci OH_Drawing_PathQuadTo(path, 100, 100, 200, FLT_MAX + 1); 572f6603c60Sopenharmony_ci // 7. Free memory by calling OH_Drawing_PathDestroy 573f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 574f6603c60Sopenharmony_ci} 575f6603c60Sopenharmony_ci 576f6603c60Sopenharmony_ci/* 577f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0800 578f6603c60Sopenharmony_ci * @tc.name: testPathConicToNormal 579f6603c60Sopenharmony_ci * @tc.desc: Test for adding a conic curve to a path with normal parameters. 580f6603c60Sopenharmony_ci * @tc.size : SmallTest 581f6603c60Sopenharmony_ci * @tc.type : Function 582f6603c60Sopenharmony_ci * @tc.level : Level 0 583f6603c60Sopenharmony_ci */ 584f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathConicToNormal, TestSize.Level0) { 585f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 586f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 587f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 588f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 589f6603c60Sopenharmony_ci // 3. Add a line segment from the last point of the path to the target point by calling OH_Drawing_PathLineTo 590f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 591f6603c60Sopenharmony_ci // 4. Add a quadratic Bezier curve to the path by calling OH_Drawing_PathConicTo 592f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 100, 100, 0.5); 593f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 594f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 595f6603c60Sopenharmony_ci} 596f6603c60Sopenharmony_ci 597f6603c60Sopenharmony_ci/* 598f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0801 599f6603c60Sopenharmony_ci * @tc.name: testPathConicToNull 600f6603c60Sopenharmony_ci * @tc.desc: Test for adding a conic curve to a path with NULL or invalid parameters. 601f6603c60Sopenharmony_ci * @tc.size : SmallTest 602f6603c60Sopenharmony_ci * @tc.type : Function 603f6603c60Sopenharmony_ci * @tc.level : Level 3 604f6603c60Sopenharmony_ci */ 605f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathConicToNull, TestSize.Level3) { 606f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 607f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 608f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathConicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 609f6603c60Sopenharmony_ci // error code 610f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(nullptr, 50, 50, 100, 100, 0.5); 611f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 612f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathConicTo with 0.00 as the second parameter, no crash 613f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 0.00, 50, 100, 100, 0.5); 614f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathConicTo with 0.00 as the third parameter, no crash 615f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 0.00, 100, 100, 0.5); 616f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathConicTo with 0.00 as the fourth parameter, no crash 617f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 0.00, 100, 0.5); 618f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathConicTo with 0.00 as the fifth parameter, no crash 619f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 100, 0.00, 0.5); 620f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathConicTo with 0.00 as the sixth parameter, no crash 621f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 100, 100, 0.00); 622f6603c60Sopenharmony_ci // 8. Free memory by calling OH_Drawing_PathDestroy 623f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 624f6603c60Sopenharmony_ci} 625f6603c60Sopenharmony_ci 626f6603c60Sopenharmony_ci/* 627f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0802 628f6603c60Sopenharmony_ci * @tc.name: testPathConicToAbnormal 629f6603c60Sopenharmony_ci * @tc.desc: Test for adding a conic curve to a path with abnormal data types as parameters. 630f6603c60Sopenharmony_ci * @tc.size : SmallTest 631f6603c60Sopenharmony_ci * @tc.type : Function 632f6603c60Sopenharmony_ci * @tc.level : Level 3 633f6603c60Sopenharmony_ci */ 634f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathConicToAbnormal, TestSize.Level3) { 635f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 636f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 637f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 638f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 639f6603c60Sopenharmony_ci // 3. Add a line segment from the last point of the path to the target point by calling OH_Drawing_PathLineTo 640f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 641f6603c60Sopenharmony_ci // 4. Add a conic curve to the path with the second parameter as an integer or character type 642f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50.0f, 100.0f, 100.0f, 0.5f); 643f6603c60Sopenharmony_ci // 5. Add a conic curve to the path with the third parameter as an integer or character type 644f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50.0f, 50, 100.0f, 100.0f, 0.5f); 645f6603c60Sopenharmony_ci // 6. Add a conic curve to the path with the fourth parameter as an integer or character type 646f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100, 100.0f, 0.5f); 647f6603c60Sopenharmony_ci // 7. Add a conic curve to the path with the fifth parameter as an integer or character type 648f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100.0f, 100, 0.5f); 649f6603c60Sopenharmony_ci // 8. Add a conic curve to the path with the sixth parameter as an integer or character type 650f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50.0f, 50.0f, 100.0f, 100.0f, 1); 651f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 652f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 653f6603c60Sopenharmony_ci} 654f6603c60Sopenharmony_ci 655f6603c60Sopenharmony_ci/* 656f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0803 657f6603c60Sopenharmony_ci * @tc.name: testPathConicToMaximal 658f6603c60Sopenharmony_ci * @tc.desc: Test for adding a conic curve to a path with maximal values as parameters. 659f6603c60Sopenharmony_ci * @tc.size : SmallTest 660f6603c60Sopenharmony_ci * @tc.type : Function 661f6603c60Sopenharmony_ci * @tc.level : Level 3 662f6603c60Sopenharmony_ci */ 663f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathConicToMaximal, TestSize.Level3) { 664f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 665f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 666f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 667f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 668f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 669f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 670f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathConicTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 671f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, FLT_MAX + 1, 50, 100, 100, 0.5); 672f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathConicTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 673f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, FLT_MAX + 1, 100, 100, 0.5); 674f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathConicTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 675f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, FLT_MAX + 1, 100, 0.5); 676f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathConicTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 677f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 100, FLT_MAX + 1, 0.5); 678f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathConicTo with the sixth parameter as the maximum value of FLT_MAX + 1, no crash 679f6603c60Sopenharmony_ci OH_Drawing_PathConicTo(path, 50, 50, 100, 100, FLT_MAX + 1); 680f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 681f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 682f6603c60Sopenharmony_ci} 683f6603c60Sopenharmony_ci 684f6603c60Sopenharmony_ci/* 685f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0900 686f6603c60Sopenharmony_ci * @tc.name: testPathCubicToNormal 687f6603c60Sopenharmony_ci * @tc.desc: Test for adding a cubic Bezier curve to a path with normal parameters. 688f6603c60Sopenharmony_ci * @tc.size : SmallTest 689f6603c60Sopenharmony_ci * @tc.type : Function 690f6603c60Sopenharmony_ci * @tc.level : Level 0 691f6603c60Sopenharmony_ci */ 692f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCubicToNormal, TestSize.Level0) { 693f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 694f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 695f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 696f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 697f6603c60Sopenharmony_ci // 3. Add a cubic Bezier curve from the last point of the path to the target point by calling OH_Drawing_PathCubicTo 698f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, 300); 699f6603c60Sopenharmony_ci // 4. Free memory by calling OH_Drawing_PathDestroy 700f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 701f6603c60Sopenharmony_ci} 702f6603c60Sopenharmony_ci 703f6603c60Sopenharmony_ci/* 704f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0901 705f6603c60Sopenharmony_ci * @tc.name: testPathCubicToNull 706f6603c60Sopenharmony_ci * @tc.desc: Test for adding a cubic Bezier curve to a path with NULL or invalid parameters. 707f6603c60Sopenharmony_ci * @tc.size : SmallTest 708f6603c60Sopenharmony_ci * @tc.type : Function 709f6603c60Sopenharmony_ci * @tc.level : Level 3 710f6603c60Sopenharmony_ci */ 711f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCubicToNull, TestSize.Level3) { 712f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 713f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 714f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathCubicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 715f6603c60Sopenharmony_ci // error code 716f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(nullptr, 100, 100, 200, 200, 300, 300); 717f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 718f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathCubicTo with 0.00 as the second parameter, no crash 719f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 0.00, 100, 200, 200, 300, 300); 720f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathCubicTo with 0.00 as the third parameter, no crash 721f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 0.00, 200, 200, 300, 300); 722f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathCubicTo with 0.00 as the fourth parameter, no crash 723f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 0.00, 200, 300, 300); 724f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathCubicTo with 0.00 as the fifth parameter, no crash 725f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 0.00, 300, 300); 726f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathCubicTo with 0.00 as the sixth parameter, no crash 727f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 0.00, 300); 728f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathCubicTo with 0.00 as the seventh parameter, no crash 729f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, 0.00); 730f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 731f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 732f6603c60Sopenharmony_ci} 733f6603c60Sopenharmony_ci 734f6603c60Sopenharmony_ci/* 735f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0902 736f6603c60Sopenharmony_ci * @tc.name: testPathCubicToAbnormal 737f6603c60Sopenharmony_ci * @tc.desc: Test for adding a cubic Bezier curve to a path with abnormal data types as parameters. 738f6603c60Sopenharmony_ci * @tc.size : SmallTest 739f6603c60Sopenharmony_ci * @tc.type : Function 740f6603c60Sopenharmony_ci * @tc.level : Level 3 741f6603c60Sopenharmony_ci */ 742f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCubicToAbnormal, TestSize.Level3) { 743f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 744f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 745f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 746f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 747f6603c60Sopenharmony_ci // 3. Add a cubic Bezier curve to the path with the second parameter as an integer 748f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100.0f, 200.0f, 200.0f, 300.0f, 300.0f); 749f6603c60Sopenharmony_ci // 4. Add a cubic Bezier curve to the path with the third parameter as an integer 750f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100.0f, 100, 200.0f, 200.0f, 300.0f, 300.0f); 751f6603c60Sopenharmony_ci // 5. Add a cubic Bezier curve to the path with the fourth parameter as an integer 752f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200, 200.0f, 300.0f, 300.0f); 753f6603c60Sopenharmony_ci // 6. Add a cubic Bezier curve to the path with the fifth parameter as an integer 754f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200, 300.0f, 300.0f); 755f6603c60Sopenharmony_ci // 7. Add a cubic Bezier curve to the path with the sixth parameter as an integer 756f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300, 300.0f); 757f6603c60Sopenharmony_ci // 8. Add a cubic Bezier curve to the path with the seventh parameter as an integer 758f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300.0f, 300); 759f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 760f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 761f6603c60Sopenharmony_ci} 762f6603c60Sopenharmony_ci 763f6603c60Sopenharmony_ci/* 764f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_0903 765f6603c60Sopenharmony_ci * @tc.name: testPathCubicToMaximal 766f6603c60Sopenharmony_ci * @tc.desc: Test for adding a cubic Bezier curve to a path with maximal values as parameters. 767f6603c60Sopenharmony_ci * @tc.size : SmallTest 768f6603c60Sopenharmony_ci * @tc.type : Function 769f6603c60Sopenharmony_ci * @tc.level : Level 3 770f6603c60Sopenharmony_ci */ 771f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathCubicToMaximal, TestSize.Level3) { 772f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 773f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 774f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 775f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 776f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathCubicTo with the second parameter as the maximum value of FLT_MAX + 1, no crash 777f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, FLT_MAX + 1, 100, 200, 200, 300, 300); 778f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathCubicTo with the third parameter as the maximum value of FLT_MAX + 1, no crash 779f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, FLT_MAX + 1, 200, 200, 300, 300); 780f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathCubicTo with the fourth parameter as the maximum value of FLT_MAX + 1, no crash 781f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, FLT_MAX + 1, 200, 300, 300); 782f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathCubicTo with the fifth parameter as the maximum value of FLT_MAX + 1, no crash 783f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, FLT_MAX + 1, 300, 300); 784f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathCubicTo with the sixth parameter as the maximum value of FLT_MAX + 1, no crash 785f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, FLT_MAX + 1, 300); 786f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathCubicTo with the seventh parameter as the maximum value of FLT_MAX + 1, no crash 787f6603c60Sopenharmony_ci OH_Drawing_PathCubicTo(path, 100, 100, 200, 200, 300, FLT_MAX + 1); 788f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 789f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 790f6603c60Sopenharmony_ci} 791f6603c60Sopenharmony_ci 792f6603c60Sopenharmony_ci/* 793f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1000 794f6603c60Sopenharmony_ci * @tc.name: testPathRMoveToNormal 795f6603c60Sopenharmony_ci * @tc.desc: Test for setting a relative move to a path with normal parameters. 796f6603c60Sopenharmony_ci * @tc.size : SmallTest 797f6603c60Sopenharmony_ci * @tc.type : Function 798f6603c60Sopenharmony_ci * @tc.level : Level 0 799f6603c60Sopenharmony_ci */ 800f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRMoveToNormal, TestSize.Level0) { 801f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 802f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 803f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 804f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 805f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 806f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 807f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 808f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 809f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 810f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 811f6603c60Sopenharmony_ci} 812f6603c60Sopenharmony_ci 813f6603c60Sopenharmony_ci/* 814f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1001 815f6603c60Sopenharmony_ci * @tc.name: testPathRMoveToNull 816f6603c60Sopenharmony_ci * @tc.desc: Test for setting a relative move to a path with NULL or invalid parameters. 817f6603c60Sopenharmony_ci * @tc.size : SmallTest 818f6603c60Sopenharmony_ci * @tc.type : Function 819f6603c60Sopenharmony_ci * @tc.level : Level 3 820f6603c60Sopenharmony_ci */ 821f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRMoveToNull, TestSize.Level3) { 822f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 823f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 824f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathRMoveTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 825f6603c60Sopenharmony_ci // error code 826f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(nullptr, 100, 100); 827f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathRMoveTo with 0.00 as the second parameter, no crash 828f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 0.00, 100); 829f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathRMoveTo with 0.00 as the third parameter, no crash 830f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 0.00); 831f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 832f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 833f6603c60Sopenharmony_ci} 834f6603c60Sopenharmony_ci 835f6603c60Sopenharmony_ci/* 836f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1002 837f6603c60Sopenharmony_ci * @tc.name: testPathRMoveToAbnormal 838f6603c60Sopenharmony_ci * @tc.desc: Test for setting a relative move to a path with abnormal data types as parameters. 839f6603c60Sopenharmony_ci * @tc.size : SmallTest 840f6603c60Sopenharmony_ci * @tc.type : Function 841f6603c60Sopenharmony_ci * @tc.level : Level 3 842f6603c60Sopenharmony_ci */ 843f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRMoveToAbnormal, TestSize.Level3) { 844f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 845f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 846f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 847f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 848f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 849f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 850f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 851f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100.0f); 852f6603c60Sopenharmony_ci // 5. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 853f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100.0f, 100); 854f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 855f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 856f6603c60Sopenharmony_ci} 857f6603c60Sopenharmony_ci 858f6603c60Sopenharmony_ci/* 859f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1003 860f6603c60Sopenharmony_ci * @tc.name: testPathRMoveToMaximal 861f6603c60Sopenharmony_ci * @tc.desc: Test for setting a relative move to a path with maximal values as parameters. 862f6603c60Sopenharmony_ci * @tc.size : SmallTest 863f6603c60Sopenharmony_ci * @tc.type : Function 864f6603c60Sopenharmony_ci * @tc.level : Level 3 865f6603c60Sopenharmony_ci */ 866f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRMoveToMaximal, TestSize.Level3) { 867f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 868f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 869f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 870f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 871f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 872f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 873f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 874f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, FLT_MAX + 1, 100); 875f6603c60Sopenharmony_ci // 5. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 876f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, FLT_MAX + 1); 877f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 878f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 879f6603c60Sopenharmony_ci} 880f6603c60Sopenharmony_ci 881f6603c60Sopenharmony_ci/* 882f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1100 883f6603c60Sopenharmony_ci * @tc.name: testPathRLineToNormal 884f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative line to a path with normal parameters. 885f6603c60Sopenharmony_ci * @tc.size : SmallTest 886f6603c60Sopenharmony_ci * @tc.type : Function 887f6603c60Sopenharmony_ci * @tc.level : Level 0 888f6603c60Sopenharmony_ci */ 889f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRLineToNormal, TestSize.Level0) { 890f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 891f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 892f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 893f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 894f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 895f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 896f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 897f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 898f6603c60Sopenharmony_ci // 5. Add a relative line to the path from the current endpoint to the target point by calling 899f6603c60Sopenharmony_ci // OH_Drawing_PathRLineTo 900f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 100, 100); 901f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 902f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 903f6603c60Sopenharmony_ci} 904f6603c60Sopenharmony_ci 905f6603c60Sopenharmony_ci/* 906f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1101 907f6603c60Sopenharmony_ci * @tc.name: testPathRLineToNull 908f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative line to a path with NULL or invalid parameters. 909f6603c60Sopenharmony_ci * @tc.size : SmallTest 910f6603c60Sopenharmony_ci * @tc.type : Function 911f6603c60Sopenharmony_ci * @tc.level : Level 3 912f6603c60Sopenharmony_ci */ 913f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRLineToNull, TestSize.Level3) { 914f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 915f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 916f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathRLineTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 917f6603c60Sopenharmony_ci // error code 918f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(nullptr, 100, 100); 919f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 920f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathRLineTo with 0.00 as the second parameter, no crash 921f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 0.00, 100); 922f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathRLineTo with 0.00 as the third parameter, no crash 923f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 100, 0.00); 924f6603c60Sopenharmony_ci // 5. Free memory by calling OH_Drawing_PathDestroy 925f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 926f6603c60Sopenharmony_ci} 927f6603c60Sopenharmony_ci 928f6603c60Sopenharmony_ci/* 929f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1102 930f6603c60Sopenharmony_ci * @tc.name: testPathRLineToAbnormal 931f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative line to a path with abnormal data types as parameters. 932f6603c60Sopenharmony_ci * @tc.size : SmallTest 933f6603c60Sopenharmony_ci * @tc.type : Function 934f6603c60Sopenharmony_ci * @tc.level : Level 3 935f6603c60Sopenharmony_ci */ 936f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRLineToAbnormal, TestSize.Level3) { 937f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 938f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 939f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 940f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 941f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 942f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 943f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 944f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 945f6603c60Sopenharmony_ci // 5. Add a relative line to the path from the current endpoint to the target point by calling 946f6603c60Sopenharmony_ci // OH_Drawing_PathRLineTo 947f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 100.0f, 100); 948f6603c60Sopenharmony_ci // 6. Add a relative line to the path from the current endpoint to the target point by calling 949f6603c60Sopenharmony_ci // OH_Drawing_PathRLineTo 950f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 100, 100.0f); 951f6603c60Sopenharmony_ci // 7. Free memory by calling OH_Drawing_PathDestroy 952f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 953f6603c60Sopenharmony_ci} 954f6603c60Sopenharmony_ci 955f6603c60Sopenharmony_ci/* 956f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1103 957f6603c60Sopenharmony_ci * @tc.name: testPathRLineToMaximal 958f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative line to a path with maximal values as parameters. 959f6603c60Sopenharmony_ci * @tc.size : SmallTest 960f6603c60Sopenharmony_ci * @tc.type : Function 961f6603c60Sopenharmony_ci * @tc.level : Level 3 962f6603c60Sopenharmony_ci */ 963f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRLineToMaximal, TestSize.Level3) { 964f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 965f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 966f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 967f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 968f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 969f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 970f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 971f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 972f6603c60Sopenharmony_ci // 5. Add a relative line to the path from the current endpoint to the target point by calling 973f6603c60Sopenharmony_ci // OH_Drawing_PathRLineTo 974f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, FLT_MAX + 1, 100); 975f6603c60Sopenharmony_ci // 6. Add a relative line to the path from the current endpoint to the target point by calling 976f6603c60Sopenharmony_ci // OH_Drawing_PathRLineTo 977f6603c60Sopenharmony_ci OH_Drawing_PathRLineTo(path, 100, FLT_MAX + 1); 978f6603c60Sopenharmony_ci // 7. Free memory by calling OH_Drawing_PathDestroy 979f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 980f6603c60Sopenharmony_ci} 981f6603c60Sopenharmony_ci 982f6603c60Sopenharmony_ci/* 983f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1200 984f6603c60Sopenharmony_ci * @tc.name: testPathRQuadToNormal 985f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with normal parameters. 986f6603c60Sopenharmony_ci * @tc.size : SmallTest 987f6603c60Sopenharmony_ci * @tc.type : Function 988f6603c60Sopenharmony_ci * @tc.level : Level 0 989f6603c60Sopenharmony_ci */ 990f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRQuadToNormal, TestSize.Level0) { 991f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 992f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 993f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 994f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 995f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 996f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 997f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 998f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 999f6603c60Sopenharmony_ci // 5. Add a relative quadratic Bezier curve to the path from the current endpoint to the target point by calling 1000f6603c60Sopenharmony_ci // OH_Drawing_PathRQuadTo 1001f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100, 200, 200); 1002f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 1003f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1004f6603c60Sopenharmony_ci} 1005f6603c60Sopenharmony_ci 1006f6603c60Sopenharmony_ci/* 1007f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1201 1008f6603c60Sopenharmony_ci * @tc.name: testPathRQuadToNull 1009f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with NULL or invalid parameters. 1010f6603c60Sopenharmony_ci * @tc.size : SmallTest 1011f6603c60Sopenharmony_ci * @tc.type : Function 1012f6603c60Sopenharmony_ci * @tc.level : Level 3 1013f6603c60Sopenharmony_ci */ 1014f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRQuadToNull, TestSize.Level3) { 1015f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1016f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1017f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathRQuadTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1018f6603c60Sopenharmony_ci // error code 1019f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(nullptr, 0, 0, 0, 0); 1020f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1021f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathRQuadTo with 0.00 as the second parameter, no crash 1022f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 0.00, 100, 100, 300); 1023f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathRQuadTo with 0.00 as the third parameter, no crash 1024f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 0.00, 100, 300); 1025f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRQuadTo with 0.00 as the fourth parameter, no crash 1026f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100, 0.00, 300); 1027f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRQuadTo with 0.00 as the fifth parameter, no crash 1028f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100, 100, 0.00); 1029f6603c60Sopenharmony_ci // 7. Free memory by calling OH_Drawing_PathDestroy 1030f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1031f6603c60Sopenharmony_ci} 1032f6603c60Sopenharmony_ci 1033f6603c60Sopenharmony_ci/* 1034f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1202 1035f6603c60Sopenharmony_ci * @tc.name: testPathRQuadToAbnormal 1036f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with abnormal data types as parameters. 1037f6603c60Sopenharmony_ci * @tc.size : SmallTest 1038f6603c60Sopenharmony_ci * @tc.type : Function 1039f6603c60Sopenharmony_ci * @tc.level : Level 3 1040f6603c60Sopenharmony_ci */ 1041f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRQuadToAbnormal, TestSize.Level3) { 1042f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1043f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1044f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1045f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1046f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1047f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1048f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1049f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1050f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRQuadTo with an integer or character type as the second parameter 1051f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100.0f, 100.0f, 300.0f); 1052f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRQuadTo with an integer or character type as the third parameter 1053f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100.0f, 100, 100.0f, 300.0f); 1054f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRQuadTo with an integer or character type as the fourth parameter 1055f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100.0f, 100.0f, 100, 300.0f); 1056f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRQuadTo with an integer or character type as the fifth parameter 1057f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100.0f, 100.0f, 100.0f, 300); 1058f6603c60Sopenharmony_ci // 9. Free memory 1059f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1060f6603c60Sopenharmony_ci} 1061f6603c60Sopenharmony_ci 1062f6603c60Sopenharmony_ci/* 1063f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1203 1064f6603c60Sopenharmony_ci * @tc.name: testPathRQuadToMaximal 1065f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative quadratic Bezier curve to a path with maximal values as parameters. 1066f6603c60Sopenharmony_ci * @tc.size : SmallTest 1067f6603c60Sopenharmony_ci * @tc.type : Function 1068f6603c60Sopenharmony_ci * @tc.level : Level 3 1069f6603c60Sopenharmony_ci */ 1070f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRQuadToMaximal, TestSize.Level3) { 1071f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1072f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1073f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1074f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1075f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1076f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1077f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1078f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1079f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRQuadTo with a second parameter of FLT_MAX + 1 1080f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, FLT_MAX + 1, 100, 100, 300); 1081f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRQuadTo with a third parameter of FLT_MAX + 1 1082f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, FLT_MAX + 1, 100, 300); 1083f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRQuadTo with a fourth parameter of FLT_MAX + 1 1084f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100, FLT_MAX + 1, 300); 1085f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRQuadTo with a fifth parameter of FLT_MAX + 1 1086f6603c60Sopenharmony_ci OH_Drawing_PathRQuadTo(path, 100, 100, 100, FLT_MAX + 1); 1087f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 1088f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1089f6603c60Sopenharmony_ci} 1090f6603c60Sopenharmony_ci 1091f6603c60Sopenharmony_ci/* 1092f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1300 1093f6603c60Sopenharmony_ci * @tc.name: testPathRConicToNormal 1094f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative conic curve to a path with normal parameters. 1095f6603c60Sopenharmony_ci * @tc.size : SmallTest 1096f6603c60Sopenharmony_ci * @tc.type : Function 1097f6603c60Sopenharmony_ci * @tc.level : Level 0 1098f6603c60Sopenharmony_ci */ 1099f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRConicToNormal, TestSize.Level0) { 1100f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1101f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1102f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1103f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1104f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1105f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1106f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1107f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1108f6603c60Sopenharmony_ci // 5. Add a relative conic curve to the path from the current endpoint to the target point by calling 1109f6603c60Sopenharmony_ci // OH_Drawing_PathRConicTo 1110f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, 5); 1111f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 1112f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1113f6603c60Sopenharmony_ci} 1114f6603c60Sopenharmony_ci 1115f6603c60Sopenharmony_ci/* 1116f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1301 1117f6603c60Sopenharmony_ci * @tc.name: testPathRConicToNull 1118f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative conic curve to a path with NULL or invalid parameters. 1119f6603c60Sopenharmony_ci * @tc.size : SmallTest 1120f6603c60Sopenharmony_ci * @tc.type : Function 1121f6603c60Sopenharmony_ci * @tc.level : Level 3 1122f6603c60Sopenharmony_ci */ 1123f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRConicToNull, TestSize.Level3) { 1124f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1125f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1126f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathRConicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1127f6603c60Sopenharmony_ci // error code 1128f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(nullptr, 100, 100, 100, 300, 5); 1129f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1130f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathRConicTo with 0.00 as the second parameter, no crash 1131f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 0.00, 100, 100, 300, 5); 1132f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathRConicTo with 0.00 as the third parameter, no crash 1133f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 0.00, 100, 300, 5); 1134f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRConicTo with 0.00 as the fourth parameter, no crash 1135f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 0.00, 300, 5); 1136f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRConicTo with 0.00 as the fifth parameter, no crash 1137f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 100, 0.00, 5); 1138f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRConicTo with 0.00 as the sixth parameter, no crash 1139f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, 0.00); 1140f6603c60Sopenharmony_ci // 8. Free memory by calling OH_Drawing_PathDestroy 1141f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1142f6603c60Sopenharmony_ci} 1143f6603c60Sopenharmony_ci 1144f6603c60Sopenharmony_ci/* 1145f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1302 1146f6603c60Sopenharmony_ci * @tc.name: testPathRConicToAbnormal 1147f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative conic curve to a path with abnormal data types as parameters. 1148f6603c60Sopenharmony_ci * @tc.size : SmallTest 1149f6603c60Sopenharmony_ci * @tc.type : Function 1150f6603c60Sopenharmony_ci * @tc.level : Level 3 1151f6603c60Sopenharmony_ci */ 1152f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRConicToAbnormal, TestSize.Level3) { 1153f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1154f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1155f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1156f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1157f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1158f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1159f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1160f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1161f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRConicTo with an integer as the second parameter 1162f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100.0f, 100.0f, 300.0f, 5.0f); 1163f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRConicTo with an integer as the third parameter 1164f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100.0f, 100, 100.0f, 300.0f, 5.0f); 1165f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRConicTo with an integer as the fourth parameter 1166f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100, 300.0f, 5.0f); 1167f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRConicTo with an integer as the fifth parameter 1168f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100.0f, 300, 5.0f); 1169f6603c60Sopenharmony_ci // 9. Call OH_Drawing_PathRConicTo with an integer as the sixth parameter 1170f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100.0f, 100.0f, 100.0f, 300.0f, 5); 1171f6603c60Sopenharmony_ci // 10. Free memory by calling OH_Drawing_PathDestroy 1172f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1173f6603c60Sopenharmony_ci} 1174f6603c60Sopenharmony_ci 1175f6603c60Sopenharmony_ci/* 1176f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1303 1177f6603c60Sopenharmony_ci * @tc.name: testPathRConicToMaximal 1178f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative conic curve to a path with maximal values as parameters. 1179f6603c60Sopenharmony_ci * @tc.size : SmallTest 1180f6603c60Sopenharmony_ci * @tc.type : Function 1181f6603c60Sopenharmony_ci * @tc.level : Level 3 1182f6603c60Sopenharmony_ci */ 1183f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRConicToMaximal, TestSize.Level3) { 1184f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1185f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1186f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1187f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1188f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1189f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1190f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1191f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1192f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRConicTo with a second parameter of FLT_MAX + 1, no crash 1193f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, FLT_MAX + 1, 100, 100, 300, 5); 1194f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRConicTo with a third parameter of FLT_MAX + 1, no crash 1195f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, FLT_MAX + 1, 100, 300, 5); 1196f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRConicTo with a fourth parameter of FLT_MAX + 1, no crash 1197f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, FLT_MAX + 1, 300, 5); 1198f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRConicTo with a fifth parameter of FLT_MAX + 1, no crash 1199f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 100, FLT_MAX + 1, 5); 1200f6603c60Sopenharmony_ci // 9. Call OH_Drawing_PathRConicTo with a sixth parameter of FLT_MAX + 1, no crash 1201f6603c60Sopenharmony_ci OH_Drawing_PathRConicTo(path, 100, 100, 100, 300, FLT_MAX + 1); 1202f6603c60Sopenharmony_ci // 10. Free memory by calling OH_Drawing_PathDestroy 1203f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1204f6603c60Sopenharmony_ci} 1205f6603c60Sopenharmony_ci 1206f6603c60Sopenharmony_ci/* 1207f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1400 1208f6603c60Sopenharmony_ci * @tc.name: testPathRCubicToNormal 1209f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative cubic Bezier curve to a path with normal parameters. 1210f6603c60Sopenharmony_ci * @tc.size : SmallTest 1211f6603c60Sopenharmony_ci * @tc.type : Function 1212f6603c60Sopenharmony_ci * @tc.level : Level 0 1213f6603c60Sopenharmony_ci */ 1214f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRCubicToNormal, TestSize.Level0) { 1215f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1216f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1217f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1218f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1219f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1220f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1221f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1222f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1223f6603c60Sopenharmony_ci // 5. Add a relative cubic Bezier curve to the path from the current endpoint to the target point by calling 1224f6603c60Sopenharmony_ci // OH_Drawing_PathRCubicTo 1225f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, 300); 1226f6603c60Sopenharmony_ci // 6. Free memory by calling OH_Drawing_PathDestroy 1227f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1228f6603c60Sopenharmony_ci} 1229f6603c60Sopenharmony_ci 1230f6603c60Sopenharmony_ci/* 1231f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1401 1232f6603c60Sopenharmony_ci * @tc.name: testPathRCubicToNull 1233f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative cubic Bezier curve to a path with NULL or invalid parameters. 1234f6603c60Sopenharmony_ci * @tc.size : SmallTest 1235f6603c60Sopenharmony_ci * @tc.type : Function 1236f6603c60Sopenharmony_ci * @tc.level : Level 3 1237f6603c60Sopenharmony_ci */ 1238f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRCubicToNull, TestSize.Level3) { 1239f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1240f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1241f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathRCubicTo with nullptr as the first parameter, expecting OH_DRAWING_ERROR_INVALID_PARAMETER 1242f6603c60Sopenharmony_ci // error code 1243f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(nullptr, 100, 100, 200, 200, 300, 300); 1244f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathRCubicTo with 0.00 as the second parameter, no crash 1245f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 0.00, 100, 200, 200, 300, 300); 1246f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathRCubicTo with 0.00 as the third parameter, no crash 1247f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 0.00, 200, 200, 300, 300); 1248f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRCubicTo with 0.00 as the fourth parameter, no crash 1249f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 0.00, 200, 300, 300); 1250f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRCubicTo with 0.00 as the fifth parameter, no crash 1251f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 0.00, 300, 300); 1252f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRCubicTo with 0.00 as the sixth parameter, no crash 1253f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 0.00, 300); 1254f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRCubicTo with 0.00 as the seventh parameter, no crash 1255f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, 0.00); 1256f6603c60Sopenharmony_ci // 9. Free memory by calling OH_Drawing_PathDestroy 1257f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1258f6603c60Sopenharmony_ci} 1259f6603c60Sopenharmony_ci 1260f6603c60Sopenharmony_ci/* 1261f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1402 1262f6603c60Sopenharmony_ci * @tc.name: testPathRCubicToAbnormal 1263f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative cubic Bezier curve to a path with abnormal data types as parameters. 1264f6603c60Sopenharmony_ci * @tc.size : SmallTest 1265f6603c60Sopenharmony_ci * @tc.type : Function 1266f6603c60Sopenharmony_ci * @tc.level : Level 3 1267f6603c60Sopenharmony_ci */ 1268f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRCubicToAbnormal, TestSize.Level3) { 1269f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1270f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1271f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1272f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1273f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1274f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1275f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1276f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1277f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRCubicTo with an integer as the second parameter 1278f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100.0f, 200.0f, 200.0f, 300.0f, 300.0f); 1279f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRCubicTo with an integer as the third parameter 1280f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100.0f, 100, 200.0f, 200.0f, 300.0f, 300.0f); 1281f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRCubicTo with an integer as the fourth parameter 1282f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200, 200.0f, 300.0f, 300.0f); 1283f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRCubicTo with an integer as the fifth parameter 1284f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200, 300.0f, 300.0f); 1285f6603c60Sopenharmony_ci // 9. Call OH_Drawing_PathRCubicTo with an integer as the sixth parameter 1286f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300, 300.0f); 1287f6603c60Sopenharmony_ci // 10. Call OH_Drawing_PathRCubicTo with an integer as the seventh parameter 1288f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100.0f, 100.0f, 200.0f, 200.0f, 300.0f, 300); 1289f6603c60Sopenharmony_ci // 11. Free memory 1290f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1291f6603c60Sopenharmony_ci} 1292f6603c60Sopenharmony_ci 1293f6603c60Sopenharmony_ci/* 1294f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1403 1295f6603c60Sopenharmony_ci * @tc.name: testPathRCubicToMaximal 1296f6603c60Sopenharmony_ci * @tc.desc: Test for adding a relative cubic Bezier curve to a path with maximal values as parameters. 1297f6603c60Sopenharmony_ci * @tc.size : SmallTest 1298f6603c60Sopenharmony_ci * @tc.type : Function 1299f6603c60Sopenharmony_ci * @tc.level : Level 3 1300f6603c60Sopenharmony_ci */ 1301f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathRCubicToMaximal, TestSize.Level3) { 1302f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1303f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1304f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1305f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1306f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1307f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1308f6603c60Sopenharmony_ci // 4. Set a relative move to the path starting from the current endpoint by calling OH_Drawing_PathRMoveTo 1309f6603c60Sopenharmony_ci OH_Drawing_PathRMoveTo(path, 100, 100); 1310f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathRCubicTo with the second parameter as the maximum value FLT_MAX+1, no crash 1311f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, FLT_MAX + 1, 100, 200, 200, 300, 300); 1312f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathRCubicTo with the third parameter as the maximum value FLT_MAX+1, no crash 1313f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, FLT_MAX + 1, 200, 200, 300, 300); 1314f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathRCubicTo with the fourth parameter as the maximum value FLT_MAX+1, no crash 1315f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, FLT_MAX + 1, 200, 300, 300); 1316f6603c60Sopenharmony_ci // 8. Call OH_Drawing_PathRCubicTo with the fifth parameter as the maximum value FLT_MAX+1, no crash 1317f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, FLT_MAX + 1, 300, 300); 1318f6603c60Sopenharmony_ci // 9. Call OH_Drawing_PathRCubicTo with the sixth parameter as the maximum value FLT_MAX+1, no crash 1319f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, FLT_MAX + 1, 300); 1320f6603c60Sopenharmony_ci // 10. Call OH_Drawing_PathRCubicTo with the seventh parameter as the maximum value FLT_MAX+1, no crash 1321f6603c60Sopenharmony_ci OH_Drawing_PathRCubicTo(path, 100, 100, 200, 200, 300, FLT_MAX + 1); 1322f6603c60Sopenharmony_ci // 11. Free memory 1323f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1324f6603c60Sopenharmony_ci} 1325f6603c60Sopenharmony_ci 1326f6603c60Sopenharmony_ci/* 1327f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1500 1328f6603c60Sopenharmony_ci * @tc.name: testPathAddRectNormal 1329f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with normal parameters. 1330f6603c60Sopenharmony_ci * @tc.size : SmallTest 1331f6603c60Sopenharmony_ci * @tc.type : Function 1332f6603c60Sopenharmony_ci * @tc.level : Level 0 1333f6603c60Sopenharmony_ci */ 1334f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectNormal, TestSize.Level0) { 1335f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1336f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1337f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1338f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1339f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1340f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1341f6603c60Sopenharmony_ci // 4. Add a rectangle outline to the path with the specified direction by calling OH_Drawing_PathAddRect. Iterate 1342f6603c60Sopenharmony_ci // through the enum to call this interface. 1343f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1344f6603c60Sopenharmony_ci // 5. Free memory 1345f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1346f6603c60Sopenharmony_ci} 1347f6603c60Sopenharmony_ci 1348f6603c60Sopenharmony_ci/* 1349f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1501 1350f6603c60Sopenharmony_ci * @tc.name: testPathAddRectNull 1351f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with NULL or invalid parameters. 1352f6603c60Sopenharmony_ci * @tc.size : SmallTest 1353f6603c60Sopenharmony_ci * @tc.type : Function 1354f6603c60Sopenharmony_ci * @tc.level : Level 3 1355f6603c60Sopenharmony_ci */ 1356f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectNull, TestSize.Level3) { 1357f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1358f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1359f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PathAddRect with the first parameter as nullptr, expect OH_DRAWING_ERROR_INVALID_PARAMETER 1360f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(nullptr, 100, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1361f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1362f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddRect with 0.00 as the second parameter, no crash 1363f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 0.00, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1364f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddRect with 0.00 as the third parameter, no crash 1365f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 0.00, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1366f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRect with 0.00 as the fourth parameter, no crash 1367f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100, 0.00, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1368f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddRect with 0.00 as the fifth parameter, no crash 1369f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100, 200, 0.00, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1370f6603c60Sopenharmony_ci // 7. Free memory 1371f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1372f6603c60Sopenharmony_ci} 1373f6603c60Sopenharmony_ci 1374f6603c60Sopenharmony_ci/* 1375f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1502 1376f6603c60Sopenharmony_ci * @tc.name: testPathAddRectAbnormal 1377f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with abnormal data types as parameters. 1378f6603c60Sopenharmony_ci * @tc.size : SmallTest 1379f6603c60Sopenharmony_ci * @tc.type : Function 1380f6603c60Sopenharmony_ci * @tc.level : Level 3 1381f6603c60Sopenharmony_ci */ 1382f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectAbnormal, TestSize.Level3) { 1383f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1384f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1385f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1386f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1387f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1388f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1389f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddRect with an integer as the second parameter 1390f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100.0f, 200.0f, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1391f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRect with an integer as the third parameter 1392f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100.0f, 100, 200.0f, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1393f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddRect with an integer as the fourth parameter 1394f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100.0f, 100.0f, 200, 200.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1395f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathAddRect with an integer as the fifth parameter 1396f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100.0f, 100.0f, 200.0f, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1397f6603c60Sopenharmony_ci // 8. Free memory 1398f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1399f6603c60Sopenharmony_ci} 1400f6603c60Sopenharmony_ci 1401f6603c60Sopenharmony_ci/* 1402f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1503 1403f6603c60Sopenharmony_ci * @tc.name: testPathAddRectMaximal 1404f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with maximal values as parameters. 1405f6603c60Sopenharmony_ci * @tc.size : SmallTest 1406f6603c60Sopenharmony_ci * @tc.type : Function 1407f6603c60Sopenharmony_ci * @tc.level : Level 3 1408f6603c60Sopenharmony_ci */ 1409f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectMaximal, TestSize.Level3) { 1410f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1411f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1412f6603c60Sopenharmony_ci // 2. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1413f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1414f6603c60Sopenharmony_ci // 3. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1415f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1416f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddRect with the second parameter as the maximum value FLT_MAX+1, no crash 1417f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, FLT_MAX + 1, 100, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1418f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRect with the third parameter as the maximum value FLT_MAX+1, no crash 1419f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, FLT_MAX + 1, 200, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1420f6603c60Sopenharmony_ci // 6. Call OH_Drawing_PathAddRect with the fourth parameter as the maximum value FLT_MAX+1, no crash 1421f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100, FLT_MAX + 1, 200, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1422f6603c60Sopenharmony_ci // 7. Call OH_Drawing_PathAddRect with the fifth parameter as the maximum value FLT_MAX+1, no crash 1423f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 100, 100, 200, FLT_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1424f6603c60Sopenharmony_ci // 8. Free memory 1425f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1426f6603c60Sopenharmony_ci} 1427f6603c60Sopenharmony_ci 1428f6603c60Sopenharmony_ci/* 1429f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1600 1430f6603c60Sopenharmony_ci * @tc.name: testPathAddRectWithInitialCornerNormal 1431f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with initial corner and normal parameters. 1432f6603c60Sopenharmony_ci * @tc.size : SmallTest 1433f6603c60Sopenharmony_ci * @tc.type : Function 1434f6603c60Sopenharmony_ci * @tc.level : Level 0 1435f6603c60Sopenharmony_ci */ 1436f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerNormal, TestSize.Level0) { 1437f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1438f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1439f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1440f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1441f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1442f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1443f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1444f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1445f6603c60Sopenharmony_ci // 5. Add a rectangle outline to the path with the specified direction by calling 1446f6603c60Sopenharmony_ci // OH_Drawing_PathAddRectWithInitialCorner. Iterate through the enum to call this interface. 1447f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1448f6603c60Sopenharmony_ci // 6. Free memory 1449f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1450f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1451f6603c60Sopenharmony_ci} 1452f6603c60Sopenharmony_ci 1453f6603c60Sopenharmony_ci/* 1454f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1601 1455f6603c60Sopenharmony_ci * @tc.name: testPathAddRectWithInitialCornerNull 1456f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with initial corner and NULL or invalid parameters. 1457f6603c60Sopenharmony_ci * @tc.size : SmallTest 1458f6603c60Sopenharmony_ci * @tc.type : Function 1459f6603c60Sopenharmony_ci * @tc.level : Level 3 1460f6603c60Sopenharmony_ci */ 1461f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerNull, TestSize.Level3) { 1462f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1463f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1464f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1465f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1466f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddRectWithInitialCorner with the first parameter as nullptr, expect 1467f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1468f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(nullptr, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1469f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1470f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddRectWithInitialCorner with the second parameter as nullptr, expect 1471f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1472f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1473f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1474f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as 0 1475f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 0); 1476f6603c60Sopenharmony_ci // 6. Free memory 1477f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1478f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1479f6603c60Sopenharmony_ci} 1480f6603c60Sopenharmony_ci 1481f6603c60Sopenharmony_ci/* 1482f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1602 1483f6603c60Sopenharmony_ci * @tc.name: testPathAddRectWithInitialCornerAbnormal 1484f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with initial corner and abnormal data types as parameters. 1485f6603c60Sopenharmony_ci * @tc.size : SmallTest 1486f6603c60Sopenharmony_ci * @tc.type : Function 1487f6603c60Sopenharmony_ci * @tc.level : Level 3 1488f6603c60Sopenharmony_ci */ 1489f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerAbnormal, TestSize.Level3) { 1490f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1491f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1492f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1493f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1494f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1495f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1496f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1497f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1498f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as a float or a character 1499f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, 5.0f); 1500f6603c60Sopenharmony_ci // 6. Free memory 1501f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1502f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1503f6603c60Sopenharmony_ci} 1504f6603c60Sopenharmony_ci 1505f6603c60Sopenharmony_ci/* 1506f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1603 1507f6603c60Sopenharmony_ci * @tc.name: testPathAddRectWithInitialCornerMaximal 1508f6603c60Sopenharmony_ci * @tc.desc: Test for adding a rectangle to a path with initial corner and maximal values as parameters. 1509f6603c60Sopenharmony_ci * @tc.size : SmallTest 1510f6603c60Sopenharmony_ci * @tc.type : Function 1511f6603c60Sopenharmony_ci * @tc.level : Level 3 1512f6603c60Sopenharmony_ci */ 1513f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRectWithInitialCornerMaximal, TestSize.Level3) { 1514f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1515f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1516f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1517f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1518f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1519f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1520f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1521f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1522f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddRectWithInitialCorner with the fourth parameter as the maximum value INT32_MAX, no 1523f6603c60Sopenharmony_ci // crash 1524f6603c60Sopenharmony_ci OH_Drawing_PathAddRectWithInitialCorner(path, rect, OH_Drawing_PathDirection::PATH_DIRECTION_CW, INT32_MAX); 1525f6603c60Sopenharmony_ci // 6. Free memory 1526f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1527f6603c60Sopenharmony_ci} 1528f6603c60Sopenharmony_ci 1529f6603c60Sopenharmony_ci/* 1530f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1700 1531f6603c60Sopenharmony_ci * @tc.name: testPathAddRoundRectNormal 1532f6603c60Sopenharmony_ci * @tc.desc: Test for adding a round rectangle to a path with normal parameters. 1533f6603c60Sopenharmony_ci * @tc.size : SmallTest 1534f6603c60Sopenharmony_ci * @tc.type : Function 1535f6603c60Sopenharmony_ci * @tc.level : Level 0 1536f6603c60Sopenharmony_ci */ 1537f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRoundRectNormal, TestSize.Level0) { 1538f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1539f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1540f6603c60Sopenharmony_ci // 2. Create a rounded rectangle object by calling OH_Drawing_RoundRectCreate 1541f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1542f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20); 1543f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1544f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1545f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1546f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1547f6603c60Sopenharmony_ci // 5. Add the rounded rectangle outline to the path with the specified direction by calling 1548f6603c60Sopenharmony_ci // OH_Drawing_PathAddRoundRect. Iterate through the enum to call this interface. 1549f6603c60Sopenharmony_ci OH_Drawing_PathDirection directions[] = { 1550f6603c60Sopenharmony_ci PATH_DIRECTION_CW, 1551f6603c60Sopenharmony_ci PATH_DIRECTION_CCW, 1552f6603c60Sopenharmony_ci }; 1553f6603c60Sopenharmony_ci for (int i = 0; i < sizeof(directions) / sizeof(directions[0]); i++) { 1554f6603c60Sopenharmony_ci OH_Drawing_PathAddRoundRect(path, roundRect, directions[i]); 1555f6603c60Sopenharmony_ci } 1556f6603c60Sopenharmony_ci // 6. Free memory 1557f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1558f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 1559f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1560f6603c60Sopenharmony_ci} 1561f6603c60Sopenharmony_ci 1562f6603c60Sopenharmony_ci/* 1563f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1701 1564f6603c60Sopenharmony_ci * @tc.name: testPathAddRoundRectNull 1565f6603c60Sopenharmony_ci * @tc.desc: Test for adding a round rectangle to a path with NULL or invalid parameters. 1566f6603c60Sopenharmony_ci * @tc.size : SmallTest 1567f6603c60Sopenharmony_ci * @tc.type : Function 1568f6603c60Sopenharmony_ci * @tc.level : Level 3 1569f6603c60Sopenharmony_ci */ 1570f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddRoundRectNull, TestSize.Level3) { 1571f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1572f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1573f6603c60Sopenharmony_ci // 2. Create a rounded rectangle object by calling OH_Drawing_RoundRectCreate 1574f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1575f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20); 1576f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddRoundRect with the first parameter as nullptr, expect 1577f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1578f6603c60Sopenharmony_ci OH_Drawing_PathAddRoundRect(nullptr, roundRect, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1579f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1580f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddRoundRect with the second parameter as nullptr, expect 1581f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1582f6603c60Sopenharmony_ci OH_Drawing_PathAddRoundRect(path, nullptr, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1583f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1584f6603c60Sopenharmony_ci // 5. Free memory 1585f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1586f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 1587f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1588f6603c60Sopenharmony_ci} 1589f6603c60Sopenharmony_ci 1590f6603c60Sopenharmony_ci/* 1591f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1800 1592f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalWithInitialPointNormal 1593f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path with initial point and normal parameters. 1594f6603c60Sopenharmony_ci * @tc.size : SmallTest 1595f6603c60Sopenharmony_ci * @tc.type : Function 1596f6603c60Sopenharmony_ci * @tc.level : Level 0 1597f6603c60Sopenharmony_ci */ 1598f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointNormal, TestSize.Level0) { 1599f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1600f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1601f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1602f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1603f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1604f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1605f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1606f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1607f6603c60Sopenharmony_ci // 5. Add an oval to the path, where the rectangle object is the bounding rectangle of the oval. Iterate through the 1608f6603c60Sopenharmony_ci // enum to call this interface. 1609f6603c60Sopenharmony_ci OH_Drawing_PathDirection directions[] = { 1610f6603c60Sopenharmony_ci PATH_DIRECTION_CW, 1611f6603c60Sopenharmony_ci PATH_DIRECTION_CCW, 1612f6603c60Sopenharmony_ci }; 1613f6603c60Sopenharmony_ci for (int i = 0; i < sizeof(directions) / sizeof(directions[0]); i++) { 1614f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 10, directions[i]); 1615f6603c60Sopenharmony_ci } 1616f6603c60Sopenharmony_ci // 6. Free memory 1617f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1618f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1619f6603c60Sopenharmony_ci} 1620f6603c60Sopenharmony_ci 1621f6603c60Sopenharmony_ci/* 1622f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1801 1623f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalWithInitialPointNull 1624f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path with initial point and NULL or invalid parameters. 1625f6603c60Sopenharmony_ci * @tc.size : SmallTest 1626f6603c60Sopenharmony_ci * @tc.type : Function 1627f6603c60Sopenharmony_ci * @tc.level : Level 3 1628f6603c60Sopenharmony_ci */ 1629f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointNull, TestSize.Level3) { 1630f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1631f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1632f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1633f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1634f6603c60Sopenharmony_ci // 3. Call OH_Drawing_PathAddOvalWithInitialPoint with the first parameter as nullptr, expect 1635f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1636f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(nullptr, rect, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1637f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1638f6603c60Sopenharmony_ci // 4. Call OH_Drawing_PathAddOvalWithInitialPoint with the second parameter as nullptr, expect 1639f6603c60Sopenharmony_ci // OH_DRAWING_ERROR_INVALID_PARAMETER 1640f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(path, nullptr, 10, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1641f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER); 1642f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as 0, no crash 1643f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 0, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1644f6603c60Sopenharmony_ci // 6. Free memory 1645f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1646f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1647f6603c60Sopenharmony_ci} 1648f6603c60Sopenharmony_ci 1649f6603c60Sopenharmony_ci/* 1650f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1802 1651f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalWithInitialPointAbnormal 1652f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path with initial point and abnormal data types as parameters. 1653f6603c60Sopenharmony_ci * @tc.size : SmallTest 1654f6603c60Sopenharmony_ci * @tc.type : Function 1655f6603c60Sopenharmony_ci * @tc.level : Level 3 1656f6603c60Sopenharmony_ci */ 1657f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointAbnormal, TestSize.Level3) { 1658f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1659f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1660f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1661f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1662f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1663f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1664f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1665f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100.0f, 100.0f); 1666f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as a float or a character 1667f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(path, rect, 5.0f, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1668f6603c60Sopenharmony_ci // 6. Free memory 1669f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1670f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1671f6603c60Sopenharmony_ci} 1672f6603c60Sopenharmony_ci 1673f6603c60Sopenharmony_ci/* 1674f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PATH_1803 1675f6603c60Sopenharmony_ci * @tc.name: testPathAddOvalWithInitialPointMaximal 1676f6603c60Sopenharmony_ci * @tc.desc: Test for adding an oval to a path with initial point and maximal values as parameters. 1677f6603c60Sopenharmony_ci * @tc.size : SmallTest 1678f6603c60Sopenharmony_ci * @tc.type : Function 1679f6603c60Sopenharmony_ci * @tc.level : Level 3 1680f6603c60Sopenharmony_ci */ 1681f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePathTest, testPathAddOvalWithInitialPointMaximal, TestSize.Level3) { 1682f6603c60Sopenharmony_ci // 1. Create a path object by calling OH_Drawing_PathCreate 1683f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1684f6603c60Sopenharmony_ci // 2. Create a rectangle object by calling OH_Drawing_RectCreate 1685f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); 1686f6603c60Sopenharmony_ci // 3. Set the starting point of the path by calling OH_Drawing_PathMoveTo 1687f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1688f6603c60Sopenharmony_ci // 4. Add a line segment from the starting point of the path to the target point by calling OH_Drawing_PathLineTo 1689f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1690f6603c60Sopenharmony_ci // 5. Call OH_Drawing_PathAddOvalWithInitialPoint with the third parameter as the maximum value UINT32_MAX + 1, no 1691f6603c60Sopenharmony_ci // crash 1692f6603c60Sopenharmony_ci OH_Drawing_PathAddOvalWithInitialPoint(path, rect, UINT32_MAX + 1, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1693f6603c60Sopenharmony_ci // 6. Free memory 1694f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1695f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1696f6603c60Sopenharmony_ci} 1697f6603c60Sopenharmony_ci 1698f6603c60Sopenharmony_ci} // namespace Drawing 1699f6603c60Sopenharmony_ci} // namespace Rosen 1700f6603c60Sopenharmony_ci} // namespace OHOS