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 "gtest/gtest.h" 17f6603c60Sopenharmony_ci 18f6603c60Sopenharmony_ci#include "drawing_point.h" 19f6603c60Sopenharmony_ci#include <random> 20f6603c60Sopenharmony_ci 21f6603c60Sopenharmony_ciusing namespace testing; 22f6603c60Sopenharmony_ciusing namespace testing::ext; 23f6603c60Sopenharmony_ci 24f6603c60Sopenharmony_cinamespace OHOS { 25f6603c60Sopenharmony_cinamespace Rosen { 26f6603c60Sopenharmony_cinamespace Drawing { 27f6603c60Sopenharmony_ciclass DrawingNativePointTest : public testing::Test {}; 28f6603c60Sopenharmony_ci 29f6603c60Sopenharmony_ci/* 30f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0100 31f6603c60Sopenharmony_ci * @tc.name: testPointCreateNormal 32f6603c60Sopenharmony_ci * @tc.desc: test for testPointCreateNormal. 33f6603c60Sopenharmony_ci * @tc.size : SmallTest 34f6603c60Sopenharmony_ci * @tc.type : Function 35f6603c60Sopenharmony_ci * @tc.level : Level 0 36f6603c60Sopenharmony_ci */ 37f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointCreateNormal, TestSize.Level0) { 38f6603c60Sopenharmony_ci // 1. Pass integer values for X and Y coordinates to OH_Drawing_PointCreate interface 39f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 40f6603c60Sopenharmony_ci // 2. Pass floating-point values for X and Y coordinates to OH_Drawing_PointCreate interface 41f6603c60Sopenharmony_ci OH_Drawing_Point *point2 = OH_Drawing_PointCreate(100.5f, 60.0f); 42f6603c60Sopenharmony_ci // 3. Free memory 43f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 44f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point2); 45f6603c60Sopenharmony_ci} 46f6603c60Sopenharmony_ci 47f6603c60Sopenharmony_ci/* 48f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0101 49f6603c60Sopenharmony_ci * @tc.name: testPointCreateNull 50f6603c60Sopenharmony_ci * @tc.desc: test for testPointCreateNull. 51f6603c60Sopenharmony_ci * @tc.size : SmallTest 52f6603c60Sopenharmony_ci * @tc.type : Function 53f6603c60Sopenharmony_ci * @tc.level : Level 3 54f6603c60Sopenharmony_ci */ 55f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointCreateNull, TestSize.Level3) { 56f6603c60Sopenharmony_ci // 1. The first parameter of OH_Drawing_PointCreate is empty 57f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(0, 60); 58f6603c60Sopenharmony_ci // 2. The second parameter of OH_Drawing_PointCreate is empty 59f6603c60Sopenharmony_ci OH_Drawing_Point *point2 = OH_Drawing_PointCreate(100, 0); 60f6603c60Sopenharmony_ci // 3. Free memory 61f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 62f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point2); 63f6603c60Sopenharmony_ci} 64f6603c60Sopenharmony_ci 65f6603c60Sopenharmony_ci/* 66f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0102 67f6603c60Sopenharmony_ci * @tc.name: testPointCreateAbnormal 68f6603c60Sopenharmony_ci * @tc.desc: test for testPointCreateAbnormal. 69f6603c60Sopenharmony_ci * @tc.size : SmallTest 70f6603c60Sopenharmony_ci * @tc.type : Function 71f6603c60Sopenharmony_ci * @tc.level : Level 3 72f6603c60Sopenharmony_ci */ 73f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointCreateAbnormal, TestSize.Level3) { 74f6603c60Sopenharmony_ci // 1. The first parameter of OH_Drawing_PointCreate is negative 75f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(-100, 60); 76f6603c60Sopenharmony_ci // 2. The second parameter of OH_Drawing_PointCreate is negative 77f6603c60Sopenharmony_ci OH_Drawing_Point *point2 = OH_Drawing_PointCreate(100, -60); 78f6603c60Sopenharmony_ci // 3. Free memory 79f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 80f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point2); 81f6603c60Sopenharmony_ci} 82f6603c60Sopenharmony_ci 83f6603c60Sopenharmony_ci/* 84f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0103 85f6603c60Sopenharmony_ci * @tc.name: testPointCreateMaximum 86f6603c60Sopenharmony_ci * @tc.desc: test for testPointCreateMaximum. 87f6603c60Sopenharmony_ci * @tc.size : SmallTest 88f6603c60Sopenharmony_ci * @tc.type : Function 89f6603c60Sopenharmony_ci * @tc.level : Level 3 90f6603c60Sopenharmony_ci */ 91f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointCreateMaximum, TestSize.Level3) { 92f6603c60Sopenharmony_ci // 1. The first parameter of OH_Drawing_PointCreate is FLT_MAX 93f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(FLT_MAX, 60); 94f6603c60Sopenharmony_ci // 2. The second parameter of OH_Drawing_PointCreate is FLT_MAX 95f6603c60Sopenharmony_ci OH_Drawing_Point *point2 = OH_Drawing_PointCreate(100, FLT_MAX); 96f6603c60Sopenharmony_ci // 3. Free memory 97f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 98f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point2); 99f6603c60Sopenharmony_ci} 100f6603c60Sopenharmony_ci 101f6603c60Sopenharmony_ci/* 102f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0104 103f6603c60Sopenharmony_ci * @tc.name: testPointCreateMultipleCalls 104f6603c60Sopenharmony_ci * @tc.desc: test for testPointCreateMultipleCalls. 105f6603c60Sopenharmony_ci * @tc.size : SmallTest 106f6603c60Sopenharmony_ci * @tc.type : Function 107f6603c60Sopenharmony_ci * @tc.level : Level 3 108f6603c60Sopenharmony_ci */ 109f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointCreateMultipleCalls, TestSize.Level3) { 110f6603c60Sopenharmony_ci // 1. Call OH_Drawing_PointCreate 10 times with random values for X and Y coordinates 111f6603c60Sopenharmony_ci std::random_device rd; 112f6603c60Sopenharmony_ci std::mt19937 gen(rd()); 113f6603c60Sopenharmony_ci std::uniform_real_distribution<float> dis(0, 100); 114f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 115f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(dis(gen), dis(gen)); 116f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 117f6603c60Sopenharmony_ci } 118f6603c60Sopenharmony_ci} 119f6603c60Sopenharmony_ci 120f6603c60Sopenharmony_ci/* 121f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0200 122f6603c60Sopenharmony_ci * @tc.name: testPointDestroyNormal 123f6603c60Sopenharmony_ci * @tc.desc: test for testPointDestroyNormal. 124f6603c60Sopenharmony_ci * @tc.size : SmallTest 125f6603c60Sopenharmony_ci * @tc.type : Function 126f6603c60Sopenharmony_ci * @tc.level : Level 0 127f6603c60Sopenharmony_ci */ 128f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointDestroyNormal, TestSize.Level0) { 129f6603c60Sopenharmony_ci // 1. Call OH_Drawing_PointCreate 130f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 131f6603c60Sopenharmony_ci // 2. Call OH_Drawing_PointDestroy 132f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 133f6603c60Sopenharmony_ci} 134f6603c60Sopenharmony_ci 135f6603c60Sopenharmony_ci/* 136f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0201 137f6603c60Sopenharmony_ci * @tc.name: testPointDestroyNull 138f6603c60Sopenharmony_ci * @tc.desc: test for testPointDestroyNull. 139f6603c60Sopenharmony_ci * @tc.size : SmallTest 140f6603c60Sopenharmony_ci * @tc.type : Function 141f6603c60Sopenharmony_ci * @tc.level : Level 3 142f6603c60Sopenharmony_ci */ 143f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointDestroyNull, TestSize.Level3) { 144f6603c60Sopenharmony_ci // 1. The parameter of OH_Drawing_PointDestroy is nullptr 145f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(nullptr); 146f6603c60Sopenharmony_ci} 147f6603c60Sopenharmony_ci 148f6603c60Sopenharmony_ci/* 149f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0300 150f6603c60Sopenharmony_ci * @tc.name: testPointGetXNormal 151f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetXNormal. 152f6603c60Sopenharmony_ci * @tc.size : SmallTest 153f6603c60Sopenharmony_ci * @tc.type : Function 154f6603c60Sopenharmony_ci * @tc.level : Level 0 155f6603c60Sopenharmony_ci */ 156f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetXNormal, TestSize.Level0) { 157f6603c60Sopenharmony_ci //1. Pass integer values to OH_Drawing_PointGetX interface 158f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 159f6603c60Sopenharmony_ci float x; 160f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point, &x); 161f6603c60Sopenharmony_ci //2. Pass floating-point values to OH_Drawing_PointGetX interface 162f6603c60Sopenharmony_ci OH_Drawing_Point *point1 = OH_Drawing_PointCreate(100.0f, 60.0f); 163f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point1, &x); 164f6603c60Sopenharmony_ci //3. free memory 165f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 166f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point1); 167f6603c60Sopenharmony_ci} 168f6603c60Sopenharmony_ci 169f6603c60Sopenharmony_ci/* 170f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0301 171f6603c60Sopenharmony_ci * @tc.name: testPointGetXNull 172f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetXNull. 173f6603c60Sopenharmony_ci * @tc.size : SmallTest 174f6603c60Sopenharmony_ci * @tc.type : Function 175f6603c60Sopenharmony_ci * @tc.level : Level 3 176f6603c60Sopenharmony_ci */ 177f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetXNull, TestSize.Level3) { 178f6603c60Sopenharmony_ci //1. OH_Drawing_PointGetX with the first parameter as null 179f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 180f6603c60Sopenharmony_ci float x; 181f6603c60Sopenharmony_ci OH_Drawing_PointGetX(nullptr, &x); 182f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 183f6603c60Sopenharmony_ci //2. OH_Drawing_PointGetX with the second parameter as null 184f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point, nullptr); 185f6603c60Sopenharmony_ci //3. free memory 186f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 187f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 188f6603c60Sopenharmony_ci} 189f6603c60Sopenharmony_ci 190f6603c60Sopenharmony_ci/* 191f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0302 192f6603c60Sopenharmony_ci * @tc.name: testPointGetXMultipleCalls 193f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetXMultipleCalls. 194f6603c60Sopenharmony_ci * @tc.size : SmallTest 195f6603c60Sopenharmony_ci * @tc.type : Function 196f6603c60Sopenharmony_ci * @tc.level : Level 3 197f6603c60Sopenharmony_ci */ 198f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetXMultipleCalls, TestSize.Level3) { 199f6603c60Sopenharmony_ci //1. Call OH_Drawing_PointGetX 10 times with random values 200f6603c60Sopenharmony_ci std::random_device rd; 201f6603c60Sopenharmony_ci std::mt19937 gen(rd()); 202f6603c60Sopenharmony_ci std::uniform_real_distribution<float> dis(0, 100); 203f6603c60Sopenharmony_ci float x; 204f6603c60Sopenharmony_ci OH_Drawing_Point *point = nullptr; 205f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 206f6603c60Sopenharmony_ci point = OH_Drawing_PointCreate(dis(gen), dis(gen)); 207f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point, &x); 208f6603c60Sopenharmony_ci } 209f6603c60Sopenharmony_ci //2. free memory 210f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 211f6603c60Sopenharmony_ci} 212f6603c60Sopenharmony_ci 213f6603c60Sopenharmony_ci/* 214f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0400 215f6603c60Sopenharmony_ci * @tc.name: testPointGetYNormal 216f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetYNormal. 217f6603c60Sopenharmony_ci * @tc.size : SmallTest 218f6603c60Sopenharmony_ci * @tc.type : Function 219f6603c60Sopenharmony_ci * @tc.level : Level 0 220f6603c60Sopenharmony_ci */ 221f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetYNormal, TestSize.Level0) { 222f6603c60Sopenharmony_ci //1. Pass integer values to OH_Drawing_PointGetY interface 223f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 224f6603c60Sopenharmony_ci float y; 225f6603c60Sopenharmony_ci OH_Drawing_PointGetX(nullptr, &y); 226f6603c60Sopenharmony_ci //2. Pass floating-point values to OH_Drawing_PointGetX interface 227f6603c60Sopenharmony_ci OH_Drawing_Point *point1 = OH_Drawing_PointCreate(100.0f, 60.0f); 228f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point1, &y); 229f6603c60Sopenharmony_ci //3. free memory 230f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 231f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point1); 232f6603c60Sopenharmony_ci} 233f6603c60Sopenharmony_ci 234f6603c60Sopenharmony_ci/* 235f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0401 236f6603c60Sopenharmony_ci * @tc.name: testPointGetYNull 237f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetYNull. 238f6603c60Sopenharmony_ci * @tc.size : SmallTest 239f6603c60Sopenharmony_ci * @tc.type : Function 240f6603c60Sopenharmony_ci * @tc.level : Level 3 241f6603c60Sopenharmony_ci */ 242f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetYNull, TestSize.Level3) { 243f6603c60Sopenharmony_ci //1. OH_Drawing_PointGetY with the first parameter as null 244f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 245f6603c60Sopenharmony_ci float y; 246f6603c60Sopenharmony_ci OH_Drawing_PointGetX(nullptr, &y); 247f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 248f6603c60Sopenharmony_ci //2. OH_Drawing_PointGetY with the second parameter as null 249f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point, nullptr); 250f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 251f6603c60Sopenharmony_ci //3. free memory 252f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 253f6603c60Sopenharmony_ci} 254f6603c60Sopenharmony_ci 255f6603c60Sopenharmony_ci/* 256f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0402 257f6603c60Sopenharmony_ci * @tc.name: testPointGetYMultipleCalls 258f6603c60Sopenharmony_ci * @tc.desc: test for testPointGetYMultipleCalls. 259f6603c60Sopenharmony_ci * @tc.size : SmallTest 260f6603c60Sopenharmony_ci * @tc.type : Function 261f6603c60Sopenharmony_ci * @tc.level : Level 3 262f6603c60Sopenharmony_ci */ 263f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointGetYMultipleCalls, TestSize.Level3) { 264f6603c60Sopenharmony_ci //1. Call OH_Drawing_PointGetX 10 times with random values 265f6603c60Sopenharmony_ci std::random_device rd; 266f6603c60Sopenharmony_ci std::mt19937 gen(rd()); 267f6603c60Sopenharmony_ci std::uniform_real_distribution<float> dis(0, 100); 268f6603c60Sopenharmony_ci float y; 269f6603c60Sopenharmony_ci OH_Drawing_Point *point = nullptr; 270f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 271f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(dis(gen), dis(gen)); 272f6603c60Sopenharmony_ci OH_Drawing_PointGetX(point, &y); 273f6603c60Sopenharmony_ci } 274f6603c60Sopenharmony_ci //2. free memory 275f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 276f6603c60Sopenharmony_ci} 277f6603c60Sopenharmony_ci 278f6603c60Sopenharmony_ci/* 279f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0400 280f6603c60Sopenharmony_ci * @tc.name: testPointSetNormal 281f6603c60Sopenharmony_ci * @tc.desc: test for testPointSetNormal. 282f6603c60Sopenharmony_ci * @tc.size : SmallTest 283f6603c60Sopenharmony_ci * @tc.type : Function 284f6603c60Sopenharmony_ci * @tc.level : Level 0 285f6603c60Sopenharmony_ci */ 286f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointSetNormal, TestSize.Level0) { 287f6603c60Sopenharmony_ci //1. Pass integar point values to OH_Drawing_PointSet interface 288f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 289f6603c60Sopenharmony_ci OH_Drawing_PointSet(point, 10, 10); 290f6603c60Sopenharmony_ci //2. Pass floating-point values to OH_Drawing_PointSet interface 291f6603c60Sopenharmony_ci OH_Drawing_PointSet(point, 20.f, 20.f); 292f6603c60Sopenharmony_ci //3. free memory 293f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 294f6603c60Sopenharmony_ci} 295f6603c60Sopenharmony_ci 296f6603c60Sopenharmony_ci/* 297f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0401 298f6603c60Sopenharmony_ci * @tc.name: testPointSetNull 299f6603c60Sopenharmony_ci * @tc.desc: test for testPointSetNull. 300f6603c60Sopenharmony_ci * @tc.size : SmallTest 301f6603c60Sopenharmony_ci * @tc.type : Function 302f6603c60Sopenharmony_ci * @tc.level : Level 3 303f6603c60Sopenharmony_ci */ 304f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointSetNull, TestSize.Level3) { 305f6603c60Sopenharmony_ci //1. OH_Drawing_PointSet with the first parameter as null 306f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 307f6603c60Sopenharmony_ci OH_Drawing_PointSet(nullptr, 10, 10); 308f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 309f6603c60Sopenharmony_ci //2. OH_Drawing_PointSet with the second parameter as 0 310f6603c60Sopenharmony_ci OH_Drawing_PointSet(point, 0, 10); 311f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 312f6603c60Sopenharmony_ci //3. OH_Drawing_PointSet with the third parameter as 0 313f6603c60Sopenharmony_ci OH_Drawing_PointSet(point, 10, 0); 314f6603c60Sopenharmony_ci EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER); 315f6603c60Sopenharmony_ci //4. free memory 316f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 317f6603c60Sopenharmony_ci} 318f6603c60Sopenharmony_ci 319f6603c60Sopenharmony_ci/* 320f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_POINT_0402 321f6603c60Sopenharmony_ci * @tc.name: testPointSetMultipleCalls 322f6603c60Sopenharmony_ci * @tc.desc: test for testPointSetMultipleCalls. 323f6603c60Sopenharmony_ci * @tc.size : SmallTest 324f6603c60Sopenharmony_ci * @tc.type : Function 325f6603c60Sopenharmony_ci * @tc.level : Level 3 326f6603c60Sopenharmony_ci */ 327f6603c60Sopenharmony_ciHWTEST_F(DrawingNativePointTest, testPointSetMultipleCalls, TestSize.Level3) { 328f6603c60Sopenharmony_ci //1. Call OH_Drawing_PointSet 10 times with random values 329f6603c60Sopenharmony_ci OH_Drawing_Point *point = OH_Drawing_PointCreate(100, 60); 330f6603c60Sopenharmony_ci std::random_device rd; 331f6603c60Sopenharmony_ci std::mt19937 gen(rd()); 332f6603c60Sopenharmony_ci std::uniform_real_distribution<float> dis(0, 100); 333f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 334f6603c60Sopenharmony_ci OH_Drawing_PointSet(point, dis(gen), dis(gen)); 335f6603c60Sopenharmony_ci } 336f6603c60Sopenharmony_ci //2. free memory 337f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(point); 338f6603c60Sopenharmony_ci} 339f6603c60Sopenharmony_ci 340f6603c60Sopenharmony_ci} // namespace Drawing 341f6603c60Sopenharmony_ci} // namespace Rosen 342f6603c60Sopenharmony_ci} // namespace OHOS