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 "drawing_color.h"
17f6603c60Sopenharmony_ci#include "drawing_error_code.h"
18f6603c60Sopenharmony_ci#include "drawing_filter.h"
19f6603c60Sopenharmony_ci#include "drawing_mask_filter.h"
20f6603c60Sopenharmony_ci#include "drawing_rect.h"
21f6603c60Sopenharmony_ci#include "drawing_round_rect.h"
22f6603c60Sopenharmony_ci#include "utils/scalar.h"
23f6603c60Sopenharmony_ci#include "gtest/gtest.h"
24f6603c60Sopenharmony_ci
25f6603c60Sopenharmony_ciusing namespace testing;
26f6603c60Sopenharmony_ciusing namespace testing::ext;
27f6603c60Sopenharmony_ci
28f6603c60Sopenharmony_cinamespace OHOS {
29f6603c60Sopenharmony_cinamespace Rosen {
30f6603c60Sopenharmony_cinamespace Drawing {
31f6603c60Sopenharmony_ciclass DrawingNativeRectTest : public testing::Test {};
32f6603c60Sopenharmony_ci
33f6603c60Sopenharmony_ci/*
34f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0100
35f6603c60Sopenharmony_ci * @tc.name: testRectCreateNormal
36f6603c60Sopenharmony_ci * @tc.desc: Test for creating and destroying a rectangle object with normal parameters.
37f6603c60Sopenharmony_ci * @tc.size  : SmallTest
38f6603c60Sopenharmony_ci * @tc.type  : Function
39f6603c60Sopenharmony_ci * @tc.level : Level 0
40f6603c60Sopenharmony_ci */
41f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectCreateNormal, TestSize.Level0) {
42f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object
43f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 600);
44f6603c60Sopenharmony_ci    // 2. Free memory
45f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
46f6603c60Sopenharmony_ci}
47f6603c60Sopenharmony_ci
48f6603c60Sopenharmony_ci/*
49f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0200
50f6603c60Sopenharmony_ci * @tc.name: testRectIntersectNormal
51f6603c60Sopenharmony_ci * @tc.desc: Test for intersecting two rectangles with normal parameters.
52f6603c60Sopenharmony_ci * @tc.size  : SmallTest
53f6603c60Sopenharmony_ci * @tc.type  : Function
54f6603c60Sopenharmony_ci * @tc.level : Level 0
55f6603c60Sopenharmony_ci */
56f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectIntersectNormal, TestSize.Level0) {
57f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
58f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 600);
59f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create another rectangle object other
60f6603c60Sopenharmony_ci    OH_Drawing_Rect *other = OH_Drawing_RectCreate(300, 400, 700, 800);
61f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of rect
62f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0);
63f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect
64f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0);
65f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect
66f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 200);
67f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of rect
68f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 200);
69f6603c60Sopenharmony_ci    // 7. Repeat steps 3-6 to set the coordinates of the other rectangle object
70f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(other, 100);
71f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(other, 100);
72f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(other, 300);
73f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(other, 300);
74f6603c60Sopenharmony_ci    // 8. Call OH_Drawing_RectIntersect to check if the two rectangles intersect, Returns true if they intersect,
75f6603c60Sopenharmony_ci    // false otherwise
76f6603c60Sopenharmony_ci    bool ret = OH_Drawing_RectIntersect(rect, other);
77f6603c60Sopenharmony_ci    EXPECT_EQ(ret, true);
78f6603c60Sopenharmony_ci    // 9. Free memory
79f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
80f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(other);
81f6603c60Sopenharmony_ci}
82f6603c60Sopenharmony_ci
83f6603c60Sopenharmony_ci/*
84f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0201
85f6603c60Sopenharmony_ci * @tc.name: testRectIntersectNull
86f6603c60Sopenharmony_ci * @tc.desc: Test for intersecting rectangles with NULL parameters.
87f6603c60Sopenharmony_ci * @tc.size  : SmallTest
88f6603c60Sopenharmony_ci * @tc.type  : Function
89f6603c60Sopenharmony_ci * @tc.level : Level 3
90f6603c60Sopenharmony_ci */
91f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectIntersectNull, TestSize.Level3) {
92f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
93f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 600);
94f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create another rectangle object other
95f6603c60Sopenharmony_ci    OH_Drawing_Rect *other = OH_Drawing_RectCreate(300, 400, 700, 800);
96f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectIntersect with the first parameter as nullptr, Returns error code
97f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
98f6603c60Sopenharmony_ci    OH_Drawing_RectIntersect(nullptr, other);
99f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
100f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectIntersect with the second parameter as nullptr, Returns error code
101f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
102f6603c60Sopenharmony_ci    OH_Drawing_RectIntersect(rect, nullptr);
103f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
104f6603c60Sopenharmony_ci    // 5. Free memory
105f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
106f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(other);
107f6603c60Sopenharmony_ci}
108f6603c60Sopenharmony_ci
109f6603c60Sopenharmony_ci/*
110f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0300
111f6603c60Sopenharmony_ci * @tc.name: testRectJoinNormal
112f6603c60Sopenharmony_ci * @tc.desc: Test for joining two rectangles with normal parameters.
113f6603c60Sopenharmony_ci * @tc.size  : SmallTest
114f6603c60Sopenharmony_ci * @tc.type  : Function
115f6603c60Sopenharmony_ci * @tc.level : Level 0
116f6603c60Sopenharmony_ci */
117f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectJoinNormal, TestSize.Level0) {
118f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
119f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
120f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create another rectangle object other
121f6603c60Sopenharmony_ci    OH_Drawing_Rect *other = OH_Drawing_RectCreate(100, 100, 300, 300);
122f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of rect
123f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0);
124f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect
125f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0);
126f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect
127f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 200);
128f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of rect
129f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 200);
130f6603c60Sopenharmony_ci    // 7. Repeat steps 3-6 to set the coordinates of the other rectangle object
131f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(other, 100);
132f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(other, 100);
133f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(other, 300);
134f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(other, 300);
135f6603c60Sopenharmony_ci    // 8. Call OH_Drawing_RectJoin to take the union of the two rectangles
136f6603c60Sopenharmony_ci    bool ret = OH_Drawing_RectJoin(rect, other);
137f6603c60Sopenharmony_ci    EXPECT_TRUE(ret);
138f6603c60Sopenharmony_ci    // 9. Free memory
139f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
140f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(other);
141f6603c60Sopenharmony_ci}
142f6603c60Sopenharmony_ci
143f6603c60Sopenharmony_ci/*
144f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0301
145f6603c60Sopenharmony_ci * @tc.name: testRectJoinNull
146f6603c60Sopenharmony_ci * @tc.desc: Test for joining rectangles with NULL parameters.
147f6603c60Sopenharmony_ci * @tc.size  : SmallTest
148f6603c60Sopenharmony_ci * @tc.type  : Function
149f6603c60Sopenharmony_ci * @tc.level : Level 3
150f6603c60Sopenharmony_ci */
151f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectJoinNull, TestSize.Level3) {
152f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
153f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
154f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create another rectangle object other
155f6603c60Sopenharmony_ci    OH_Drawing_Rect *other = OH_Drawing_RectCreate(100, 100, 300, 300);
156f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectJoin with the first parameter as nullptr, Returns error code
157f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
158f6603c60Sopenharmony_ci    OH_Drawing_RectJoin(nullptr, other);
159f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
160f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectJoin with the second parameter as nullptr, Returns error code
161f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
162f6603c60Sopenharmony_ci    OH_Drawing_RectJoin(rect, nullptr);
163f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
164f6603c60Sopenharmony_ci    // 5. Free memory
165f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
166f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(other);
167f6603c60Sopenharmony_ci}
168f6603c60Sopenharmony_ci
169f6603c60Sopenharmony_ci/*
170f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0400
171f6603c60Sopenharmony_ci * @tc.name: testRectSetLeftNormal
172f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the left coordinate of a rectangle with normal parameters.
173f6603c60Sopenharmony_ci * @tc.size  : SmallTest
174f6603c60Sopenharmony_ci * @tc.type  : Function
175f6603c60Sopenharmony_ci * @tc.level : Level 0
176f6603c60Sopenharmony_ci */
177f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetLeftNormal, TestSize.Level0) {
178f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
179f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
180f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of rect
181f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 100);
182f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetLeft to get the x-coordinate of the top-left corner of rect, Returns the value set
183f6603c60Sopenharmony_ci    // in step 2
184f6603c60Sopenharmony_ci    float left = OH_Drawing_RectGetLeft(rect);
185f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(left, 100));
186f6603c60Sopenharmony_ci    // 4. Free memory
187f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
188f6603c60Sopenharmony_ci}
189f6603c60Sopenharmony_ci
190f6603c60Sopenharmony_ci/*
191f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0401
192f6603c60Sopenharmony_ci * @tc.name: testRectSetLeftNull
193f6603c60Sopenharmony_ci * @tc.desc: Test for setting the left coordinate of a rectangle with NULL parameters.
194f6603c60Sopenharmony_ci * @tc.size  : SmallTest
195f6603c60Sopenharmony_ci * @tc.type  : Function
196f6603c60Sopenharmony_ci * @tc.level : Level 3
197f6603c60Sopenharmony_ci */
198f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetLeftNull, TestSize.Level3) {
199f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
200f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
201f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft with the first parameter as nullptr, Returns error code
202f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
203f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(nullptr, 0.00);
204f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
205f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetLeft with the second parameter as 0.00, Call fails without crashing
206f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0.00);
207f6603c60Sopenharmony_ci    // 4. Free memory
208f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
209f6603c60Sopenharmony_ci}
210f6603c60Sopenharmony_ci
211f6603c60Sopenharmony_ci/*
212f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0402
213f6603c60Sopenharmony_ci * @tc.name: testRectSetLeftAbnormal
214f6603c60Sopenharmony_ci * @tc.desc: Test for setting the left coordinate of a rectangle with abnormal parameters.
215f6603c60Sopenharmony_ci * @tc.size  : SmallTest
216f6603c60Sopenharmony_ci * @tc.type  : Function
217f6603c60Sopenharmony_ci * @tc.level : Level 3
218f6603c60Sopenharmony_ci */
219f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetLeftAbnormal, TestSize.Level3) {
220f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
221f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
222f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft with the second parameter as an integer or character data
223f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 100);
224f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetLeft to get the x-coordinate of the top-left corner of rect, Returns the value set
225f6603c60Sopenharmony_ci    // in step 2 (the passed parameter is forcibly converted)
226f6603c60Sopenharmony_ci    float left = OH_Drawing_RectGetLeft(rect);
227f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(left, 100));
228f6603c60Sopenharmony_ci    // 4. Free memory
229f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
230f6603c60Sopenharmony_ci}
231f6603c60Sopenharmony_ci
232f6603c60Sopenharmony_ci/*
233f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0403
234f6603c60Sopenharmony_ci * @tc.name: testRectSetLeftMultipleCalls
235f6603c60Sopenharmony_ci * @tc.desc: Test for repeatedly setting and getting the left coordinate of a rectangle.
236f6603c60Sopenharmony_ci * @tc.size  : SmallTest
237f6603c60Sopenharmony_ci * @tc.type  : Function
238f6603c60Sopenharmony_ci * @tc.level : Level 3
239f6603c60Sopenharmony_ci */
240f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetLeftMultipleCalls, TestSize.Level3) {
241f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
242f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
243f6603c60Sopenharmony_ci        OH_Drawing_RectSetLeft(rect, i * 10);
244f6603c60Sopenharmony_ci        float left = OH_Drawing_RectGetLeft(rect);
245f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(left, i * 10));
246f6603c60Sopenharmony_ci    }
247f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
248f6603c60Sopenharmony_ci}
249f6603c60Sopenharmony_ci
250f6603c60Sopenharmony_ci/*
251f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0500
252f6603c60Sopenharmony_ci * @tc.name: testRectSetTopNormal
253f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the top coordinate of a rectangle with normal parameters.
254f6603c60Sopenharmony_ci * @tc.size  : SmallTest
255f6603c60Sopenharmony_ci * @tc.type  : Function
256f6603c60Sopenharmony_ci * @tc.level : Level 0
257f6603c60Sopenharmony_ci */
258f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetTopNormal, TestSize.Level0) {
259f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
260f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
261f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect
262f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 100);
263f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect, Returns the value set in
264f6603c60Sopenharmony_ci    // step 2
265f6603c60Sopenharmony_ci    float top = OH_Drawing_RectGetTop(rect);
266f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(top, 100));
267f6603c60Sopenharmony_ci    // 4. Free memory
268f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
269f6603c60Sopenharmony_ci}
270f6603c60Sopenharmony_ci
271f6603c60Sopenharmony_ci/*
272f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0501
273f6603c60Sopenharmony_ci * @tc.name: testRectSetTopNull
274f6603c60Sopenharmony_ci * @tc.desc: Test for setting the top coordinate of a rectangle with NULL parameters.
275f6603c60Sopenharmony_ci * @tc.size  : SmallTest
276f6603c60Sopenharmony_ci * @tc.type  : Function
277f6603c60Sopenharmony_ci * @tc.level : Level 3
278f6603c60Sopenharmony_ci */
279f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetTopNull, TestSize.Level3) {
280f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
281f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
282f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetTop with the first parameter as nullptr, Returns error code
283f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
284f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(nullptr, 0.00);
285f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
286f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetTop with the second parameter as 0.00, Call fails without crashing
287f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0.00);
288f6603c60Sopenharmony_ci    // 4. Free memory
289f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
290f6603c60Sopenharmony_ci}
291f6603c60Sopenharmony_ci
292f6603c60Sopenharmony_ci/*
293f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0502
294f6603c60Sopenharmony_ci * @tc.name: testRectSetTopAbnormal
295f6603c60Sopenharmony_ci * @tc.desc: Test for setting the top coordinate of a rectangle with abnormal parameters.
296f6603c60Sopenharmony_ci * @tc.size  : SmallTest
297f6603c60Sopenharmony_ci * @tc.type  : Function
298f6603c60Sopenharmony_ci * @tc.level : Level 3
299f6603c60Sopenharmony_ci */
300f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetTopAbnormal, TestSize.Level3) {
301f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
302f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
303f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetTop with the second parameter as an integer or character data
304f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 100);
305f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect, Returns the value set in
306f6603c60Sopenharmony_ci    // step 2 (the passed parameter is forcibly converted)
307f6603c60Sopenharmony_ci    float top = OH_Drawing_RectGetTop(rect);
308f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(top, 100));
309f6603c60Sopenharmony_ci    // 4. Free memory
310f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
311f6603c60Sopenharmony_ci}
312f6603c60Sopenharmony_ci
313f6603c60Sopenharmony_ci/*
314f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0503
315f6603c60Sopenharmony_ci * @tc.name: testRectSetTopMultipleCalls
316f6603c60Sopenharmony_ci * @tc.desc: Test for repeatedly setting and getting the top coordinate of a rectangle.
317f6603c60Sopenharmony_ci * @tc.size  : SmallTest
318f6603c60Sopenharmony_ci * @tc.type  : Function
319f6603c60Sopenharmony_ci * @tc.level : Level 3
320f6603c60Sopenharmony_ci */
321f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetTopMultipleCalls, TestSize.Level3) {
322f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
323f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
324f6603c60Sopenharmony_ci    // 2. Loop to call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect 10 times (each time
325f6603c60Sopenharmony_ci    // with a different value)
326f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
327f6603c60Sopenharmony_ci        OH_Drawing_RectSetTop(rect, i * 10);
328f6603c60Sopenharmony_ci        // 3. Loop to call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect 10 times, Each
329f6603c60Sopenharmony_ci        // time the returned value is consistent with the set value
330f6603c60Sopenharmony_ci        float top = OH_Drawing_RectGetTop(rect);
331f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(top, i * 10));
332f6603c60Sopenharmony_ci    }
333f6603c60Sopenharmony_ci    // 3. Loop to call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect 10 times, Each time
334f6603c60Sopenharmony_ci    // the returned value is consistent with the set value
335f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
336f6603c60Sopenharmony_ci        OH_Drawing_RectSetTop(rect, 10);
337f6603c60Sopenharmony_ci        // 3. Loop to call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect 10 times, Each
338f6603c60Sopenharmony_ci        // time the returned value is consistent with the set value
339f6603c60Sopenharmony_ci        float top = OH_Drawing_RectGetTop(rect);
340f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(top, 10));
341f6603c60Sopenharmony_ci    }
342f6603c60Sopenharmony_ci    // 4. Free memory
343f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
344f6603c60Sopenharmony_ci}
345f6603c60Sopenharmony_ci
346f6603c60Sopenharmony_ci/*
347f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0600
348f6603c60Sopenharmony_ci * @tc.name: testRectSetRightNormal
349f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the right coordinate of a rectangle with normal parameters.
350f6603c60Sopenharmony_ci * @tc.size  : SmallTest
351f6603c60Sopenharmony_ci * @tc.type  : Function
352f6603c60Sopenharmony_ci * @tc.level : Level 0
353f6603c60Sopenharmony_ci */
354f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetRightNormal, TestSize.Level0) {
355f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
356f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
357f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect
358f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 300);
359f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect, Returns the value set
360f6603c60Sopenharmony_ci    // in step 2
361f6603c60Sopenharmony_ci    float right = OH_Drawing_RectGetRight(rect);
362f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(right, 300));
363f6603c60Sopenharmony_ci    // 4. Free memory
364f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
365f6603c60Sopenharmony_ci}
366f6603c60Sopenharmony_ci
367f6603c60Sopenharmony_ci/*
368f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0601
369f6603c60Sopenharmony_ci * @tc.name: testRectSetRightNull
370f6603c60Sopenharmony_ci * @tc.desc: Test for setting the right coordinate of a rectangle with NULL parameters.
371f6603c60Sopenharmony_ci * @tc.size  : SmallTest
372f6603c60Sopenharmony_ci * @tc.type  : Function
373f6603c60Sopenharmony_ci * @tc.level : Level 3
374f6603c60Sopenharmony_ci */
375f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetRightNull, TestSize.Level3) {
376f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
377f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
378f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetRight with the first parameter as nullptr, Returns error code
379f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
380f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(nullptr, 0.00);
381f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
382f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetRight with the second parameter as 0.00, 3. Call fails without crashing
383f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 0.00);
384f6603c60Sopenharmony_ci    // 4. Free memory
385f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
386f6603c60Sopenharmony_ci}
387f6603c60Sopenharmony_ci
388f6603c60Sopenharmony_ci/*
389f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0602
390f6603c60Sopenharmony_ci * @tc.name: testRectSetRightAbnormal
391f6603c60Sopenharmony_ci * @tc.desc: Test for setting the right coordinate of a rectangle with abnormal parameters.
392f6603c60Sopenharmony_ci * @tc.size  : SmallTest
393f6603c60Sopenharmony_ci * @tc.type  : Function
394f6603c60Sopenharmony_ci * @tc.level : Level 3
395f6603c60Sopenharmony_ci */
396f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetRightAbnormal, TestSize.Level3) {
397f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
398f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
399f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetRight with the second parameter as an integer or character data
400f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 100);
401f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect, Returns the value set
402f6603c60Sopenharmony_ci    // in step 2 (the passed parameter is forcibly converted)
403f6603c60Sopenharmony_ci    float right = OH_Drawing_RectGetRight(rect);
404f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(right, 100));
405f6603c60Sopenharmony_ci    // 4. Free memory
406f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
407f6603c60Sopenharmony_ci}
408f6603c60Sopenharmony_ci
409f6603c60Sopenharmony_ci/*
410f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0603
411f6603c60Sopenharmony_ci * @tc.name: testRectSetRightMultipleCalls
412f6603c60Sopenharmony_ci * @tc.desc: Test for repeatedly setting and getting the right coordinate of a rectangle.
413f6603c60Sopenharmony_ci * @tc.size  : SmallTest
414f6603c60Sopenharmony_ci * @tc.type  : Function
415f6603c60Sopenharmony_ci * @tc.level : Level 3
416f6603c60Sopenharmony_ci */
417f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetRightMultipleCalls, TestSize.Level3) {
418f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
419f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
420f6603c60Sopenharmony_ci    // 2. Loop to call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect 10 times (each
421f6603c60Sopenharmony_ci    // time with a different value)
422f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
423f6603c60Sopenharmony_ci        OH_Drawing_RectSetRight(rect, i * 10);
424f6603c60Sopenharmony_ci        // 3. Loop to call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect 10 times,
425f6603c60Sopenharmony_ci        // Each time the returned value is consistent with the set value
426f6603c60Sopenharmony_ci        float right = OH_Drawing_RectGetRight(rect);
427f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(right, i * 10));
428f6603c60Sopenharmony_ci    }
429f6603c60Sopenharmony_ci    // 3. Loop to call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect 10 times, Each
430f6603c60Sopenharmony_ci    // time the returned value is consistent with the set value
431f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
432f6603c60Sopenharmony_ci        OH_Drawing_RectSetRight(rect, 10);
433f6603c60Sopenharmony_ci        // 3. Loop to call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect 10 times,
434f6603c60Sopenharmony_ci        // Each time the returned value is consistent with the set value
435f6603c60Sopenharmony_ci        float right = OH_Drawing_RectGetRight(rect);
436f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(right, 10));
437f6603c60Sopenharmony_ci    }
438f6603c60Sopenharmony_ci    // 4. Free memory
439f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
440f6603c60Sopenharmony_ci}
441f6603c60Sopenharmony_ci
442f6603c60Sopenharmony_ci/*
443f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0700
444f6603c60Sopenharmony_ci * @tc.name: testRectSetBottomNormal
445f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the bottom coordinate of a rectangle with normal parameters.
446f6603c60Sopenharmony_ci * @tc.size  : SmallTest
447f6603c60Sopenharmony_ci * @tc.type  : Function
448f6603c60Sopenharmony_ci * @tc.level : Level 0
449f6603c60Sopenharmony_ci */
450f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetBottomNormal, TestSize.Level0) {
451f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
452f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
453f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of rect
454f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 300);
455f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetBottom to get the y-coordinate of the bottom-right corner of rect, 3. Returns the value
456f6603c60Sopenharmony_ci    // set in step 2
457f6603c60Sopenharmony_ci    float bottom = OH_Drawing_RectGetBottom(rect);
458f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(bottom, 300));
459f6603c60Sopenharmony_ci    // 4. Free memory
460f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
461f6603c60Sopenharmony_ci}
462f6603c60Sopenharmony_ci
463f6603c60Sopenharmony_ci/*
464f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0701
465f6603c60Sopenharmony_ci * @tc.name: testRectSetBottomNull
466f6603c60Sopenharmony_ci * @tc.desc: Test for setting the bottom coordinate of a rectangle with NULL parameters.
467f6603c60Sopenharmony_ci * @tc.size  : SmallTest
468f6603c60Sopenharmony_ci * @tc.type  : Function
469f6603c60Sopenharmony_ci * @tc.level : Level 3
470f6603c60Sopenharmony_ci */
471f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetBottomNull, TestSize.Level3) {
472f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
473f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
474f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetBottom with the first parameter as nullptr, returns error code
475f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
476f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(nullptr, 0.00);
477f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
478f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetBottom with the second parameter as 0.00, the call fails without crashing
479f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 0.00);
480f6603c60Sopenharmony_ci    // 4. Free memory
481f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
482f6603c60Sopenharmony_ci}
483f6603c60Sopenharmony_ci
484f6603c60Sopenharmony_ci/*
485f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0702
486f6603c60Sopenharmony_ci * @tc.name: testRectSetBottomAbnormal
487f6603c60Sopenharmony_ci * @tc.desc: Test for setting the bottom coordinate of a rectangle with abnormal parameters.
488f6603c60Sopenharmony_ci * @tc.size  : SmallTest
489f6603c60Sopenharmony_ci * @tc.type  : Function
490f6603c60Sopenharmony_ci * @tc.level : Level 3
491f6603c60Sopenharmony_ci */
492f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetBottomAbnormal, TestSize.Level3) {
493f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
494f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
495f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetBottom with the second parameter as an integer or character data
496f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 100);
497f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetBottom to get the y-coordinate of the bottom-right corner of rect
498f6603c60Sopenharmony_ci    float bottom = OH_Drawing_RectGetBottom(rect);
499f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(bottom, 100));
500f6603c60Sopenharmony_ci    // 4. Free memory
501f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
502f6603c60Sopenharmony_ci}
503f6603c60Sopenharmony_ci
504f6603c60Sopenharmony_ci/*
505f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0703
506f6603c60Sopenharmony_ci * @tc.name: testRectSetBottomMultipleCalls
507f6603c60Sopenharmony_ci * @tc.desc: Test for repeatedly setting and getting the bottom coordinate of a rectangle.
508f6603c60Sopenharmony_ci * @tc.size  : SmallTest
509f6603c60Sopenharmony_ci * @tc.type  : Function
510f6603c60Sopenharmony_ci * @tc.level : Level 3
511f6603c60Sopenharmony_ci */
512f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectSetBottomMultipleCalls, TestSize.Level3) {
513f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
514f6603c60Sopenharmony_ci
515f6603c60Sopenharmony_ci    for (int i = 0; i < 10; i++) {
516f6603c60Sopenharmony_ci        OH_Drawing_RectSetBottom(rect, i * 10);
517f6603c60Sopenharmony_ci        float bottom = OH_Drawing_RectGetBottom(rect);
518f6603c60Sopenharmony_ci        EXPECT_TRUE(IsScalarAlmostEqual(bottom, i * 10));
519f6603c60Sopenharmony_ci    }
520f6603c60Sopenharmony_ci
521f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
522f6603c60Sopenharmony_ci}
523f6603c60Sopenharmony_ci
524f6603c60Sopenharmony_ci/*
525f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0800
526f6603c60Sopenharmony_ci * @tc.name: testRectGetLeftNormal
527f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the left coordinate of a rectangle with normal parameters.
528f6603c60Sopenharmony_ci * @tc.size  : SmallTest
529f6603c60Sopenharmony_ci * @tc.type  : Function
530f6603c60Sopenharmony_ci * @tc.level : Level 0
531f6603c60Sopenharmony_ci */
532f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetLeftNormal, TestSize.Level0) {
533f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
534f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
535f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of rect
536f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 100);
537f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetLeft to get the x-coordinate of the top-left corner of rect
538f6603c60Sopenharmony_ci    float left = OH_Drawing_RectGetLeft(rect);
539f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(left, 100));
540f6603c60Sopenharmony_ci    // 4. Free memory
541f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
542f6603c60Sopenharmony_ci}
543f6603c60Sopenharmony_ci
544f6603c60Sopenharmony_ci/*
545f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0801
546f6603c60Sopenharmony_ci * @tc.name: testRectGetLeftNull
547f6603c60Sopenharmony_ci * @tc.desc: Test for getting the left coordinate of a rectangle with NULL parameters.
548f6603c60Sopenharmony_ci * @tc.size  : SmallTest
549f6603c60Sopenharmony_ci * @tc.type  : Function
550f6603c60Sopenharmony_ci * @tc.level : Level 3
551f6603c60Sopenharmony_ci */
552f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetLeftNull, TestSize.Level3) {
553f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
554f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
555f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetLeft with nullptr as the parameter
556f6603c60Sopenharmony_ci    OH_Drawing_RectGetLeft(nullptr);
557f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
558f6603c60Sopenharmony_ci    // 3. Free memory
559f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
560f6603c60Sopenharmony_ci}
561f6603c60Sopenharmony_ci
562f6603c60Sopenharmony_ci/*
563f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0900
564f6603c60Sopenharmony_ci * @tc.name: testRectGetTopNormal
565f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the top coordinate of a rectangle with normal parameters.
566f6603c60Sopenharmony_ci * @tc.size  : SmallTest
567f6603c60Sopenharmony_ci * @tc.type  : Function
568f6603c60Sopenharmony_ci * @tc.level : Level 0
569f6603c60Sopenharmony_ci */
570f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetTopNormal, TestSize.Level0) {
571f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
572f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
573f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect
574f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 100);
575f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of rect
576f6603c60Sopenharmony_ci    float top = OH_Drawing_RectGetTop(rect);
577f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(top, 100));
578f6603c60Sopenharmony_ci    // 4. Free memory
579f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
580f6603c60Sopenharmony_ci}
581f6603c60Sopenharmony_ci
582f6603c60Sopenharmony_ci/*
583f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_0901
584f6603c60Sopenharmony_ci * @tc.name: testRectGetTopNull
585f6603c60Sopenharmony_ci * @tc.desc: Test for getting the top coordinate of a rectangle with NULL parameters.
586f6603c60Sopenharmony_ci * @tc.size  : SmallTest
587f6603c60Sopenharmony_ci * @tc.type  : Function
588f6603c60Sopenharmony_ci * @tc.level : Level 3
589f6603c60Sopenharmony_ci */
590f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetTopNull, TestSize.Level3) {
591f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
592f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
593f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetTop with nullptr as the parameter
594f6603c60Sopenharmony_ci    OH_Drawing_RectGetTop(nullptr);
595f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
596f6603c60Sopenharmony_ci    // 3. Free memory
597f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
598f6603c60Sopenharmony_ci}
599f6603c60Sopenharmony_ci
600f6603c60Sopenharmony_ci/*
601f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1000
602f6603c60Sopenharmony_ci * @tc.name: testRectGetRightNormal
603f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the right coordinate of a rectangle with normal parameters.
604f6603c60Sopenharmony_ci * @tc.size  : SmallTest
605f6603c60Sopenharmony_ci * @tc.type  : Function
606f6603c60Sopenharmony_ci * @tc.level : Level 0
607f6603c60Sopenharmony_ci */
608f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetRightNormal, TestSize.Level0) {
609f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
610f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
611f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect
612f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 300);
613f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of rect
614f6603c60Sopenharmony_ci    float right = OH_Drawing_RectGetRight(rect);
615f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(right, 300));
616f6603c60Sopenharmony_ci    // 4. Free memory
617f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
618f6603c60Sopenharmony_ci}
619f6603c60Sopenharmony_ci
620f6603c60Sopenharmony_ci/*
621f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1001
622f6603c60Sopenharmony_ci * @tc.name: testRectGetRightNull
623f6603c60Sopenharmony_ci * @tc.desc: Test for getting the right coordinate of a rectangle with NULL parameters.
624f6603c60Sopenharmony_ci * @tc.size  : SmallTest
625f6603c60Sopenharmony_ci * @tc.type  : Function
626f6603c60Sopenharmony_ci * @tc.level : Level 3
627f6603c60Sopenharmony_ci */
628f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetRightNull, TestSize.Level3) {
629f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
630f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
631f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetRight with nullptr as the parameter, returns error code
632f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
633f6603c60Sopenharmony_ci    OH_Drawing_RectGetRight(nullptr);
634f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
635f6603c60Sopenharmony_ci    // 3. Free memory
636f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
637f6603c60Sopenharmony_ci}
638f6603c60Sopenharmony_ci
639f6603c60Sopenharmony_ci/*
640f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1100
641f6603c60Sopenharmony_ci * @tc.name: testRectGetBottomNormal
642f6603c60Sopenharmony_ci * @tc.desc: Test for setting and getting the bottom coordinate of a rectangle with normal parameters.
643f6603c60Sopenharmony_ci * @tc.size  : SmallTest
644f6603c60Sopenharmony_ci * @tc.type  : Function
645f6603c60Sopenharmony_ci * @tc.level : Level 0
646f6603c60Sopenharmony_ci */
647f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetBottomNormal, TestSize.Level0) {
648f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
649f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
650f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of rect
651f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 300);
652f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectGetBottom to get the y-coordinate of the bottom-right corner of rect, the return value
653f6603c60Sopenharmony_ci    // should be the same as the set value
654f6603c60Sopenharmony_ci    float bottom = OH_Drawing_RectGetBottom(rect);
655f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(bottom, 300));
656f6603c60Sopenharmony_ci    // 4. Free memory
657f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
658f6603c60Sopenharmony_ci}
659f6603c60Sopenharmony_ci
660f6603c60Sopenharmony_ci/*
661f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1101
662f6603c60Sopenharmony_ci * @tc.name: testRectGetBottomNull
663f6603c60Sopenharmony_ci * @tc.desc: Test for getting the bottom coordinate of a rectangle with NULL parameters.
664f6603c60Sopenharmony_ci * @tc.size  : SmallTest
665f6603c60Sopenharmony_ci * @tc.type  : Function
666f6603c60Sopenharmony_ci * @tc.level : Level 3
667f6603c60Sopenharmony_ci */
668f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetBottomNull, TestSize.Level3) {
669f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
670f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
671f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetBottom with nullptr as the parameter, returns error code
672f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
673f6603c60Sopenharmony_ci    OH_Drawing_RectGetBottom(nullptr);
674f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
675f6603c60Sopenharmony_ci    // 3. Free memory
676f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
677f6603c60Sopenharmony_ci}
678f6603c60Sopenharmony_ci
679f6603c60Sopenharmony_ci/*
680f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1200
681f6603c60Sopenharmony_ci * @tc.name: testRectGetHeightNormal
682f6603c60Sopenharmony_ci * @tc.desc: Test for setting coordinates and getting the height of a rectangle with normal parameters.
683f6603c60Sopenharmony_ci * @tc.size  : SmallTest
684f6603c60Sopenharmony_ci * @tc.type  : Function
685f6603c60Sopenharmony_ci * @tc.level : Level 0
686f6603c60Sopenharmony_ci */
687f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetHeightNormal, TestSize.Level0) {
688f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
689f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
690f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of rect
691f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0);
692f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of rect
693f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0);
694f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of rect
695f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 200);
696f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of rect
697f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 200);
698f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectGetHeight to get the height of the rectangle, which is the difference between the
699f6603c60Sopenharmony_ci    // y-coordinate of the bottom-right corner and the y-coordinate of the top-left corner
700f6603c60Sopenharmony_ci    float height = OH_Drawing_RectGetHeight(rect);
701f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(height, 200 - 0));
702f6603c60Sopenharmony_ci    // 7. Free memory
703f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
704f6603c60Sopenharmony_ci}
705f6603c60Sopenharmony_ci
706f6603c60Sopenharmony_ci/*
707f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1201
708f6603c60Sopenharmony_ci * @tc.name: testRectGetHeightNull
709f6603c60Sopenharmony_ci * @tc.desc: Test for getting the height of a rectangle with NULL parameters.
710f6603c60Sopenharmony_ci * @tc.size  : SmallTest
711f6603c60Sopenharmony_ci * @tc.type  : Function
712f6603c60Sopenharmony_ci * @tc.level : Level 3
713f6603c60Sopenharmony_ci */
714f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetHeightNull, TestSize.Level3) {
715f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
716f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
717f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetHeight with nullptr as the parameter, returns error code
718f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
719f6603c60Sopenharmony_ci    OH_Drawing_RectGetHeight(nullptr);
720f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
721f6603c60Sopenharmony_ci    // 3. Free memory
722f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
723f6603c60Sopenharmony_ci}
724f6603c60Sopenharmony_ci
725f6603c60Sopenharmony_ci/*
726f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1300
727f6603c60Sopenharmony_ci * @tc.name: testRectGetWidthNormal
728f6603c60Sopenharmony_ci * @tc.desc: Test for setting coordinates and getting the width of a rectangle with normal parameters.
729f6603c60Sopenharmony_ci * @tc.size  : SmallTest
730f6603c60Sopenharmony_ci * @tc.type  : Function
731f6603c60Sopenharmony_ci * @tc.level : Level 0
732f6603c60Sopenharmony_ci */
733f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetWidthNormal, TestSize.Level0) {
734f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
735f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
736f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner
737f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0);
738f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner
739f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0);
740f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner
741f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, 200);
742f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner
743f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, 200);
744f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectGetWidth to get the width of the rectangle, which is the difference between the
745f6603c60Sopenharmony_ci    // x-coordinate of the bottom-right corner and the x-coordinate of the top-left corner
746f6603c60Sopenharmony_ci    float width = OH_Drawing_RectGetWidth(rect);
747f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(width, 200 - 0));
748f6603c60Sopenharmony_ci    // 7. Free memory
749f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
750f6603c60Sopenharmony_ci}
751f6603c60Sopenharmony_ci
752f6603c60Sopenharmony_ci/*
753f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1301
754f6603c60Sopenharmony_ci * @tc.name: testRectGetWidthNull
755f6603c60Sopenharmony_ci * @tc.desc: Test for getting the width of a rectangle with NULL parameters.
756f6603c60Sopenharmony_ci * @tc.size  : SmallTest
757f6603c60Sopenharmony_ci * @tc.type  : Function
758f6603c60Sopenharmony_ci * @tc.level : Level 3
759f6603c60Sopenharmony_ci */
760f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetWidthNull, TestSize.Level3) {
761f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
762f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
763f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectGetWidth with nullptr as the parameter, returns error code
764f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
765f6603c60Sopenharmony_ci    OH_Drawing_RectGetWidth(nullptr);
766f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
767f6603c60Sopenharmony_ci    // 3. Free memory
768f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
769f6603c60Sopenharmony_ci}
770f6603c60Sopenharmony_ci
771f6603c60Sopenharmony_ci/*
772f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1302
773f6603c60Sopenharmony_ci * @tc.name: testRectGetWidthBoundary
774f6603c60Sopenharmony_ci * @tc.desc: Test for setting coordinates and getting the width of a rectangle with normal parameters.
775f6603c60Sopenharmony_ci * @tc.size  : SmallTest
776f6603c60Sopenharmony_ci * @tc.type  : Function
777f6603c60Sopenharmony_ci * @tc.level : Level 0
778f6603c60Sopenharmony_ci */
779f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectGetWidthBoundary, TestSize.Level0) {
780f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object rect
781f6603c60Sopenharmony_ci    uint32_t width = 4096;
782f6603c60Sopenharmony_ci    uint32_t height = 2160;
783f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, width, height);
784f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner
785f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(rect, 0);
786f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner
787f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(rect, 0);
788f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner
789f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(rect, width);
790f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner
791f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(rect, height);
792f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectGetWidth to get the width of the rectangle, which is the difference between the
793f6603c60Sopenharmony_ci    // x-coordinate of the bottom-right corner and the x-coordinate of the top-left corner
794f6603c60Sopenharmony_ci    float getWidth = OH_Drawing_RectGetWidth(rect);
795f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(getWidth, width - 0));
796f6603c60Sopenharmony_ci    // 7. Free memory
797f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
798f6603c60Sopenharmony_ci}
799f6603c60Sopenharmony_ci
800f6603c60Sopenharmony_ci/*
801f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1400
802f6603c60Sopenharmony_ci * @tc.name: testRectCopyNormal
803f6603c60Sopenharmony_ci * @tc.desc: Test for copying a rectangle with normal parameters and checking the copied values.
804f6603c60Sopenharmony_ci * @tc.size  : SmallTest
805f6603c60Sopenharmony_ci * @tc.type  : Function
806f6603c60Sopenharmony_ci * @tc.level : Level 0
807f6603c60Sopenharmony_ci */
808f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectCopyNormal, TestSize.Level0) {
809f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object src
810f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 200, 200);
811f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create a rectangle object dst
812f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 0, 0);
813f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectSetLeft to set the x-coordinate of the top-left corner of src
814f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(src, 100);
815f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectSetTop to set the y-coordinate of the top-left corner of src
816f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(src, 100);
817f6603c60Sopenharmony_ci    // 5. Call OH_Drawing_RectSetRight to set the x-coordinate of the bottom-right corner of src
818f6603c60Sopenharmony_ci    OH_Drawing_RectSetRight(src, 300);
819f6603c60Sopenharmony_ci    // 6. Call OH_Drawing_RectSetBottom to set the y-coordinate of the bottom-right corner of src
820f6603c60Sopenharmony_ci    OH_Drawing_RectSetBottom(src, 300);
821f6603c60Sopenharmony_ci    // 7. Call OH_Drawing_RectCopy to copy the source rectangle object src to the destination rectangle object dst
822f6603c60Sopenharmony_ci    OH_Drawing_RectCopy(src, dst);
823f6603c60Sopenharmony_ci    // 8. Call OH_Drawing_RectGetLeft to get the x-coordinate of the top-left corner of dst, which should be the same as
824f6603c60Sopenharmony_ci    // the value set in src
825f6603c60Sopenharmony_ci    float left = OH_Drawing_RectGetLeft(dst);
826f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(left, 100));
827f6603c60Sopenharmony_ci    // 9. Call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of dst, which should be the same as
828f6603c60Sopenharmony_ci    // the value set in src
829f6603c60Sopenharmony_ci    float top = OH_Drawing_RectGetTop(dst);
830f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(top, 100));
831f6603c60Sopenharmony_ci    // 10. Call OH_Drawing_RectGetRight to get the x-coordinate of the bottom-right corner of dst, which should be the
832f6603c60Sopenharmony_ci    // same as the value set in src
833f6603c60Sopenharmony_ci    float right = OH_Drawing_RectGetRight(dst);
834f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(right, 300));
835f6603c60Sopenharmony_ci    // 11. Call OH_Drawing_RectGetBottom to get the y-coordinate of the bottom-right corner of dst, which should be the
836f6603c60Sopenharmony_ci    // same as the value set in src
837f6603c60Sopenharmony_ci    float bottom = OH_Drawing_RectGetBottom(dst);
838f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(bottom, 300));
839f6603c60Sopenharmony_ci    // 12. Call OH_Drawing_RectSetLeft to modify the x-coordinate of the top-left corner of src
840f6603c60Sopenharmony_ci    OH_Drawing_RectSetLeft(src, 200);
841f6603c60Sopenharmony_ci    // 13. Call OH_Drawing_RectSetTop to modify the y-coordinate of the top-left corner of src
842f6603c60Sopenharmony_ci    OH_Drawing_RectSetTop(src, 200);
843f6603c60Sopenharmony_ci    // 14. Call OH_Drawing_RectGetLeft to get the x-coordinate of the top-left corner of dst, which should be the same
844f6603c60Sopenharmony_ci    // as the previous value (indicating that the modification in src does not affect the result in dst)
845f6603c60Sopenharmony_ci    left = OH_Drawing_RectGetLeft(dst);
846f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(left, 100));
847f6603c60Sopenharmony_ci    // 15. Call OH_Drawing_RectGetTop to get the y-coordinate of the top-left corner of dst, which should be the same as
848f6603c60Sopenharmony_ci    // the previous value (indicating that the modification in src does not affect the result in dst)
849f6603c60Sopenharmony_ci    top = OH_Drawing_RectGetTop(dst);
850f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(top, 100));
851f6603c60Sopenharmony_ci    // 16. Free memory
852f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
853f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
854f6603c60Sopenharmony_ci}
855f6603c60Sopenharmony_ci
856f6603c60Sopenharmony_ci/*
857f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1401
858f6603c60Sopenharmony_ci * @tc.name: testRectCopyNull
859f6603c60Sopenharmony_ci * @tc.desc: Test for copying a rectangle with NULL parameters.
860f6603c60Sopenharmony_ci * @tc.size  : SmallTest
861f6603c60Sopenharmony_ci * @tc.type  : Function
862f6603c60Sopenharmony_ci * @tc.level : Level 3
863f6603c60Sopenharmony_ci */
864f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectCopyNull, TestSize.Level3) {
865f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object src
866f6603c60Sopenharmony_ci    OH_Drawing_Rect *src = OH_Drawing_RectCreate(0, 0, 200, 200);
867f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectCreate to create a rectangle object dst
868f6603c60Sopenharmony_ci    OH_Drawing_Rect *dst = OH_Drawing_RectCreate(0, 0, 0, 0);
869f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectCopy with nullptr as the first parameter, returns error code
870f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
871f6603c60Sopenharmony_ci    OH_Drawing_RectCopy(nullptr, dst);
872f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
873f6603c60Sopenharmony_ci    // 4. Call OH_Drawing_RectCopy with nullptr as the second parameter, returns error code
874f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
875f6603c60Sopenharmony_ci    OH_Drawing_RectCopy(src, nullptr);
876f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
877f6603c60Sopenharmony_ci    // 5. Free memory
878f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(src);
879f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(dst);
880f6603c60Sopenharmony_ci}
881f6603c60Sopenharmony_ci
882f6603c60Sopenharmony_ci/*
883f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1500
884f6603c60Sopenharmony_ci * @tc.name: testRectDestroyNormal
885f6603c60Sopenharmony_ci * @tc.desc: Test for creating and destroying a rectangle object with normal parameters.
886f6603c60Sopenharmony_ci * @tc.size  : SmallTest
887f6603c60Sopenharmony_ci * @tc.type  : Function
888f6603c60Sopenharmony_ci * @tc.level : Level 0
889f6603c60Sopenharmony_ci */
890f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectDestroyNormal, TestSize.Level0) {
891f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object
892f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
893f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectDestroy to destroy the rectangle object
894f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
895f6603c60Sopenharmony_ci}
896f6603c60Sopenharmony_ci
897f6603c60Sopenharmony_ci/*
898f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_RECT_1501
899f6603c60Sopenharmony_ci * @tc.name: testRectDestroyNull
900f6603c60Sopenharmony_ci * @tc.desc: Test for destroying a rectangle object with NULL parameters.
901f6603c60Sopenharmony_ci * @tc.size  : SmallTest
902f6603c60Sopenharmony_ci * @tc.type  : Function
903f6603c60Sopenharmony_ci * @tc.level : Level 3
904f6603c60Sopenharmony_ci */
905f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeRectTest, testRectDestroyNull, TestSize.Level3) {
906f6603c60Sopenharmony_ci    // 1. Call OH_Drawing_RectCreate to create a rectangle object
907f6603c60Sopenharmony_ci    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200);
908f6603c60Sopenharmony_ci    // 2. Call OH_Drawing_RectDestroy with nullptr as the parameter, returns error code
909f6603c60Sopenharmony_ci    // OH_DRAWING_ERROR_INVALID_PARAMETER
910f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(nullptr);
911f6603c60Sopenharmony_ci    // 3. Call OH_Drawing_RectDestroy to destroy the rectangle object
912f6603c60Sopenharmony_ci    OH_Drawing_RectDestroy(rect);
913f6603c60Sopenharmony_ci}
914f6603c60Sopenharmony_ci
915f6603c60Sopenharmony_ci} // namespace Drawing
916f6603c60Sopenharmony_ci} // namespace Rosen
917f6603c60Sopenharmony_ci} // namespace OHOS