1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, Hardware
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "gtest/gtest.h"
17
18 #include "drawing_color.h"
19 #include "drawing_error_code.h"
20 #include "drawing_filter.h"
21 #include "drawing_mask_filter.h"
22 #include "drawing_rect.h"
23 #include "utils/scalar.h"
24
25 using namespace testing;
26 using namespace testing::ext;
27
28 namespace OHOS {
29 namespace Rosen {
30 namespace Drawing {
31 class NativeDrawingRectTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37 };
38
SetUpTestCase()39 void NativeDrawingRectTest::SetUpTestCase() {}
TearDownTestCase()40 void NativeDrawingRectTest::TearDownTestCase() {}
SetUp()41 void NativeDrawingRectTest::SetUp() {}
TearDown()42 void NativeDrawingRectTest::TearDown() {}
43
44 /*
45 * @tc.name: NativeDrawingRectTest_CreateAndDestroy001
46 * @tc.desc: test for create Rect and destroy Rect.
47 * @tc.type: FUNC
48 * @tc.require: AR000GTO5R
49 */
50 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_CreateAndDestroy001, TestSize.Level1)
51 {
52 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300);
53 EXPECT_NE(nullptr, rect);
54 OH_Drawing_RectDestroy(rect);
55 }
56
57 /*
58 * @tc.name: NativeDrawingRectTest_Intersect002
59 * @tc.desc: test for the Intersect methods of Rect.
60 * @tc.type: FUNC
61 * @tc.require: AR000GTO5R
62 */
63 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Intersect002, TestSize.Level1)
64 {
65 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300);
66 EXPECT_NE(nullptr, rect);
67
68 OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400);
69 EXPECT_NE(nullptr, otherOne);
70
71 OH_Drawing_Rect *otherTwo = OH_Drawing_RectCreate(600, 400, 700, 500);
72 EXPECT_NE(nullptr, otherTwo);
73
74 bool ret = OH_Drawing_RectIntersect(rect, otherOne);
75 EXPECT_EQ(ret, true);
76
77 ret = OH_Drawing_RectIntersect(rect, otherTwo);
78 EXPECT_EQ(ret, false);
79
80 OH_Drawing_RectDestroy(rect);
81 OH_Drawing_RectDestroy(otherOne);
82 OH_Drawing_RectDestroy(otherTwo);
83 }
84 /*
85 * @tc.name: NativeDrawingRectTest_GetHeight003
86 * @tc.desc: test for get height of rect.
87 * @tc.type: FUNC
88 * @tc.require: AR000GTO5R
89 */
90 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetHeight003, TestSize.Level1)
91 {
92 OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
93 OH_Drawing_RectGetHeight(nullptr);
94 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
95 float height = OH_Drawing_RectGetHeight(rect);
96 EXPECT_TRUE(IsScalarAlmostEqual(height, 800)); // 800 means height
97 OH_Drawing_RectDestroy(rect);
98 }
99
100 /*
101 * @tc.name: NativeDrawingRectTest_GetWidth004
102 * @tc.desc: test for get width of rect.
103 * @tc.type: FUNC
104 * @tc.require: AR000GTO5R
105 */
106 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetWidth004, TestSize.Level1)
107 {
108 OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
109 OH_Drawing_RectGetWidth(nullptr);
110 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
111 float width = OH_Drawing_RectGetWidth(rect);
112 EXPECT_TRUE(IsScalarAlmostEqual(width, 400)); // 400 means height
113 OH_Drawing_RectDestroy(rect);
114 }
115
116 /*
117 * @tc.name: NativeDrawingRectTest_SetAndGet005
118 * @tc.desc: test for set and get of rect.
119 * @tc.type: FUNC
120 * @tc.require: AR000GTO5R
121 */
122 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_SetAndGet005, TestSize.Level1)
123 {
124 OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
125 OH_Drawing_RectSetLeft(nullptr, 10);
126 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
127 OH_Drawing_RectSetLeft(rect, 10);
128 OH_Drawing_RectSetTop(nullptr, 10);
129 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
130 OH_Drawing_RectSetTop(rect, 10);
131 OH_Drawing_RectSetRight(nullptr, 300);
132 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
133 OH_Drawing_RectSetRight(rect, 300);
134 OH_Drawing_RectSetBottom(nullptr, 400);
135 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
136 OH_Drawing_RectSetBottom(rect, 400);
137
138 OH_Drawing_RectGetLeft(nullptr);
139 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
140 float left = OH_Drawing_RectGetLeft(rect);
141 OH_Drawing_RectGetTop(nullptr);
142 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
143 float top = OH_Drawing_RectGetTop(rect);
144 OH_Drawing_RectGetRight(nullptr);
145 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
146 float right = OH_Drawing_RectGetRight(rect);
147 OH_Drawing_RectGetBottom(nullptr);
148 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
149 float bottom = OH_Drawing_RectGetBottom(rect);
150 EXPECT_TRUE(IsScalarAlmostEqual(left, 10)); // 10 means left
151 EXPECT_TRUE(IsScalarAlmostEqual(top, 10)); // 10 means top
152 EXPECT_TRUE(IsScalarAlmostEqual(right, 300)); // 300 means right
153 EXPECT_TRUE(IsScalarAlmostEqual(bottom, 400)); // 400 means bottom
154 OH_Drawing_RectDestroy(rect);
155 }
156
157 /*
158 * @tc.name: NativeDrawingRectTest_Copy006
159 * @tc.desc: test for Copy of rect.
160 * @tc.type: FUNC
161 * @tc.require: AR000GTO5R
162 */
163 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Copy006, TestSize.Level1)
164 {
165 OH_Drawing_Rect* rectSrc = OH_Drawing_RectCreate(0, 0, 400, 800);
166 OH_Drawing_Rect* rectDst = OH_Drawing_RectCreate(11, 22, 333, 444);
167 OH_Drawing_RectCopy(nullptr, rectSrc);
168 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
169 OH_Drawing_RectCopy(rectDst, nullptr);
170 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
171 OH_Drawing_RectCopy(rectDst, rectSrc);
172 float left = OH_Drawing_RectGetLeft(rectSrc);
173 float top = OH_Drawing_RectGetTop(rectSrc);
174 float right = OH_Drawing_RectGetRight(rectSrc);
175 float bottom = OH_Drawing_RectGetBottom(rectSrc);
176 EXPECT_TRUE(IsScalarAlmostEqual(left, 11)); // 11 means left
177 EXPECT_TRUE(IsScalarAlmostEqual(top, 22)); // 22 means top
178 EXPECT_TRUE(IsScalarAlmostEqual(right, 333)); // 333 means right
179 EXPECT_TRUE(IsScalarAlmostEqual(bottom, 444)); // 444 means bottom
180 OH_Drawing_RectDestroy(rectSrc);
181 OH_Drawing_RectDestroy(rectDst);
182 }
183
184 /*
185 * @tc.name: NativeDrawingRectTest_RectJoin007
186 * @tc.desc: test for sets rect to the union of rect and other.
187 * @tc.type: FUNC
188 * @tc.require: AR000GTO5R
189 */
190 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin007, TestSize.Level1)
191 {
192 // rect left[10], top[20], right[40], bottom[30]
193 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 20, 40, 30);
194 // rect left[20], top[20], right[100], bottom[100]
195 OH_Drawing_Rect *other = OH_Drawing_RectCreate(20, 20, 100, 100);
196 EXPECT_EQ(OH_Drawing_RectJoin(rect, nullptr), false);
197 EXPECT_NE(OH_Drawing_RectJoin(rect, other), false);
198 OH_Drawing_RectDestroy(rect);
199 OH_Drawing_RectDestroy(other);
200 }
201
202 /*
203 * @tc.name: NativeDrawingRectTest_Intersect003
204 * @tc.desc: test for the Intersect methods of Rect.
205 * @tc.type: FUNC
206 * @tc.require: AR000GTO5R
207 */
208 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Intersect003, TestSize.Level1)
209 {
210 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
211 EXPECT_NE(nullptr, rect);
212
213 OH_Drawing_Rect *rectt = nullptr;
214 ASSERT_TRUE(rectt == nullptr);
215
216 OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400); // 250 300 400 600 rect param
217 EXPECT_NE(nullptr, otherOne);
218
219 OH_Drawing_Rect *otherTwo = nullptr;
220 ASSERT_TRUE(otherTwo == nullptr);
221
222 bool ret = OH_Drawing_RectIntersect(rectt, otherOne);
223 EXPECT_EQ(ret, false);
224 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
225
226 ret = OH_Drawing_RectIntersect(rect, otherTwo);
227 EXPECT_EQ(ret, false);
228 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
229
230 ret = OH_Drawing_RectIntersect(rectt, otherTwo);
231 EXPECT_EQ(ret, false);
232 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
233
234 OH_Drawing_RectDestroy(rect);
235 OH_Drawing_RectDestroy(rectt);
236 OH_Drawing_RectDestroy(otherOne);
237 OH_Drawing_RectDestroy(otherTwo);
238 }
239
240 /*
241 * @tc.name: NativeDrawingRectTest_RectJoin001
242 * @tc.desc: test for the RectJoin methods of Rect.
243 * @tc.type: FUNC
244 * @tc.require: AR000GTO5R
245 */
246 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin001, TestSize.Level1)
247 {
248 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
249 EXPECT_NE(nullptr, rect);
250
251 OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400); // 250 300 400 600 rect param
252 EXPECT_NE(nullptr, otherOne);
253
254 OH_Drawing_RectJoin(nullptr, otherOne);
255 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
256 OH_Drawing_RectJoin(rect, nullptr);
257 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
258 bool ret = OH_Drawing_RectJoin(rect, otherOne);
259 EXPECT_EQ(ret, true);
260
261 OH_Drawing_RectDestroy(rect);
262 OH_Drawing_RectDestroy(otherOne);
263 }
264
265 /*
266 * @tc.name: NativeDrawingRectTest_RectJoin002
267 * @tc.desc: test for the RectJoin methods of Rect.
268 * @tc.type: FUNC
269 * @tc.require: AR000GTO5R
270 */
271 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin002, TestSize.Level1)
272 {
273 OH_Drawing_Rect *rect = nullptr;
274 ASSERT_TRUE(rect == nullptr);
275 OH_Drawing_Rect *otherOne = nullptr;
276 ASSERT_TRUE(otherOne == nullptr);
277
278 bool ret = OH_Drawing_RectJoin(rect, otherOne);
279 EXPECT_EQ(ret, false);
280 }
281
282 /*
283 * @tc.name: NativeDrawingRectTest_RectSetTop001
284 * @tc.desc: test for the RectSetTop methods of Rect.
285 * @tc.type: FUNC
286 * @tc.require: AR000GTO5R
287 */
288 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetTop001, TestSize.Level1)
289 {
290 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
291 OH_Drawing_RectSetTop(rect, 10); // 10 means top
292
293 ASSERT_FLOAT_EQ(OH_Drawing_RectGetTop(rect), 10); // 10 equal to number
294 ASSERT_NE(OH_Drawing_RectGetTop(rect), 0.f);
295 OH_Drawing_RectDestroy(rect);
296 }
297
298 /*
299 * @tc.name: NativeDrawingRectTest_RectSetTop002
300 * @tc.desc: test for the RectSetTop methods of Rect.
301 * @tc.type: FUNC
302 * @tc.require: AR000GTO5R
303 */
304 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetTop002, TestSize.Level1)
305 {
306 OH_Drawing_Rect *rect = nullptr;
307 OH_Drawing_RectSetTop(rect, 10); // 10 means top
308
309 ASSERT_TRUE(rect == nullptr);
310 }
311
312 /*
313 * @tc.name: NativeDrawingRectTest_RectSetBottom001
314 * @tc.desc: test for the RectSetBottom methods of Rect.
315 * @tc.type: FUNC
316 * @tc.require: AR000GTO5R
317 */
318 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetBottom001, TestSize.Level1)
319 {
320 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
321 OH_Drawing_RectSetBottom(rect, 10); // 10 means Bottom
322
323 ASSERT_FLOAT_EQ(OH_Drawing_RectGetBottom(rect), 10); // 10 equal to number
324 ASSERT_NE(OH_Drawing_RectGetBottom(rect), 0.f);
325 OH_Drawing_RectDestroy(rect);
326 }
327
328 /*
329 * @tc.name: NativeDrawingRectTest_RectSetBottom002
330 * @tc.desc: test for the RectSetBottom methods of Rect.
331 * @tc.type: FUNC
332 * @tc.require: AR000GTO5R
333 */
334 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetBottom002, TestSize.Level1)
335 {
336 OH_Drawing_Rect *rect = nullptr;
337 OH_Drawing_RectSetBottom(rect, 10); // 10 means Bottom
338 ASSERT_TRUE(rect == nullptr);
339 OH_Drawing_RectDestroy(rect);
340 }
341
342 /*
343 * @tc.name: NativeDrawingRectTest_RectSetLeft001
344 * @tc.desc: test for the RectSetLeft methods of Rect.
345 * @tc.type: FUNC
346 * @tc.require: AR000GTO5R
347 */
348 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetLeft001, TestSize.Level1)
349 {
350 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
351 OH_Drawing_RectSetLeft(rect, 10); // 10 means Left
352
353 ASSERT_FLOAT_EQ(OH_Drawing_RectGetLeft(rect), 10); // 10 equal to number
354 OH_Drawing_RectDestroy(rect);
355 }
356
357 /*
358 * @tc.name: NativeDrawingRectTest_RectSetLeft002
359 * @tc.desc: test for the RectSetLeft methods of Rect.
360 * @tc.type: FUNC
361 * @tc.require: AR000GTO5R
362 */
363 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetLeft002, TestSize.Level1)
364 {
365 OH_Drawing_Rect *rect = nullptr;
366 OH_Drawing_RectSetLeft(rect, 10); // 10 means Left
367
368 ASSERT_TRUE(rect == nullptr);
369 OH_Drawing_RectDestroy(rect);
370 }
371
372 /*
373 * @tc.name: NativeDrawingRectTest_RectSetRight001
374 * @tc.desc: test for the RectSetRight methods of Rect.
375 * @tc.type: FUNC
376 * @tc.require: AR000GTO5R
377 */
378 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetRight001, TestSize.Level1)
379 {
380 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
381 OH_Drawing_RectSetRight(rect, 10); // 10 means Right
382
383 ASSERT_FLOAT_EQ(OH_Drawing_RectGetRight(rect), 10);
384 OH_Drawing_RectDestroy(rect);
385 }
386
387 /*
388 * @tc.name: NativeDrawingRectTest_RectSetRight002
389 * @tc.desc: test for the RectSetRight methods of Rect.
390 * @tc.type: FUNC
391 * @tc.require: AR000GTO5R
392 */
393 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetRight002, TestSize.Level1)
394 {
395 OH_Drawing_Rect *rect = nullptr;
396 OH_Drawing_RectSetRight(rect, 10); // 10 means Right
397
398 ASSERT_TRUE(rect == nullptr);
399 OH_Drawing_RectDestroy(rect);
400 }
401
402 /*
403 * @tc.name: NativeDrawingRectTest_RectGetTop001
404 * @tc.desc: test for the RectGetTop methods of Rect.
405 * @tc.type: FUNC
406 * @tc.require: AR000GTO5R
407 */
408 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetTop001, TestSize.Level1)
409 {
410 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50, 50, 250, 250 rect param
411 float top = OH_Drawing_RectGetTop(rect);
412 EXPECT_TRUE(IsScalarAlmostEqual(top, 50)); // 50 means top
413 OH_Drawing_RectDestroy(rect);
414 }
415
416 /*
417 * @tc.name: NativeDrawingRectTest_RectGetTop002
418 * @tc.desc: test for the RectGetTop methods of Rect.
419 * @tc.type: FUNC
420 * @tc.require: AR000GTO5R
421 */
422 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetTop002, TestSize.Level1)
423 {
424 OH_Drawing_Rect *rect = nullptr;
425 OH_Drawing_RectGetTop(rect);
426 ASSERT_TRUE(rect == nullptr);
427 OH_Drawing_RectDestroy(rect);
428 }
429
430 /*
431 * @tc.name: NativeDrawingRectTest_RectGetBottom001
432 * @tc.desc: test for the RectGetBottom methods of Rect.
433 * @tc.type: FUNC
434 * @tc.require: AR000GTO5R
435 */
436 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetBottom001, TestSize.Level1)
437 {
438 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50, 50, 250, 250 rect param
439 float bottom = OH_Drawing_RectGetBottom(rect);
440 EXPECT_TRUE(IsScalarAlmostEqual(bottom, 250)); // 250 means bottom
441 OH_Drawing_RectDestroy(rect);
442 }
443
444 /*
445 * @tc.name: NativeDrawingRectTest_RectGetBottom002
446 * @tc.desc: test for the RectGetBottom methods of Rect.
447 * @tc.type: FUNC
448 * @tc.require: AR000GTO5R
449 */
450 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetBottom002, TestSize.Level1)
451 {
452 OH_Drawing_Rect *rect = nullptr;
453 OH_Drawing_RectGetBottom(rect);
454 ASSERT_TRUE(rect == nullptr);
455 OH_Drawing_RectDestroy(rect);
456 }
457
458 /*
459 * @tc.name: NativeDrawingRectTest_RectGetLeft001
460 * @tc.desc: test for the RectGetLeft methods of Rect.
461 * @tc.type: FUNC
462 * @tc.require: AR000GTO5R
463 */
464 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetLeft001, TestSize.Level1)
465 {
466 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50 250 rect param
467 float left = OH_Drawing_RectGetLeft(rect);
468 EXPECT_TRUE(IsScalarAlmostEqual(left, 50)); // 50 means left
469 OH_Drawing_RectDestroy(rect);
470 }
471
472 /*
473 * @tc.name: NativeDrawingRectTest_RectGetLeft002
474 * @tc.desc: test for the RectGetLeft methods of Rect.
475 * @tc.type: FUNC
476 * @tc.require: AR000GTO5R
477 */
478 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetLeft002, TestSize.Level1)
479 {
480 OH_Drawing_Rect *rect = nullptr;
481 OH_Drawing_RectGetLeft(rect);
482 ASSERT_TRUE(rect == nullptr);
483 OH_Drawing_RectDestroy(rect);
484 }
485
486 /*
487 * @tc.name: NativeDrawingRectTest_RectGetRight001
488 * @tc.desc: test for the RectGetRight methods of Rect.
489 * @tc.type: FUNC
490 * @tc.require: AR000GTO5R
491 */
492 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetRight001, TestSize.Level1)
493 {
494 OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50 250 rect param
495 float right = OH_Drawing_RectGetRight(rect);
496 EXPECT_TRUE(IsScalarAlmostEqual(right, 250)); // 250 means right
497 OH_Drawing_RectDestroy(rect);
498 }
499
500 /*
501 * @tc.name: NativeDrawingRectTest_RectGetRight002
502 * @tc.desc: test for the RectGetRight methods of Rect.
503 * @tc.type: FUNC
504 * @tc.require: AR000GTO5R
505 */
506 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetRight002, TestSize.Level1)
507 {
508 ASSERT_TRUE(OH_Drawing_RectGetRight(nullptr) == 0);
509 }
510
511 /*
512 * @tc.name: NativeDrawingRectTest_GetHeight002
513 * @tc.desc: test for get height of rect.
514 * @tc.type: FUNC
515 * @tc.require: AR000GTO5R
516 */
517 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetHeight002, TestSize.Level1)
518 {
519 OH_Drawing_Rect *rect = nullptr;
520 OH_Drawing_RectGetHeight(rect);
521 ASSERT_TRUE(rect == nullptr);
522 OH_Drawing_RectDestroy(rect);
523 }
524
525 /*
526 * @tc.name: NativeDrawingRectTest_GetWidth002
527 * @tc.desc: test for get width of rect.
528 * @tc.type: FUNC
529 * @tc.require: AR000GTO5R
530 */
531 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetWidth002, TestSize.Level1)
532 {
533 OH_Drawing_Rect *rect = nullptr;
534 OH_Drawing_RectGetWidth(rect);
535 ASSERT_TRUE(rect == nullptr);
536 OH_Drawing_RectDestroy(rect);
537 }
538
539 /*
540 * @tc.name: NativeDrawingRectTest_RectCopy001
541 * @tc.desc: test for Copy of rect.
542 * @tc.type: FUNC
543 * @tc.require: AR000GTO5R
544 */
545 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectCopy001, TestSize.Level1)
546 {
547 OH_Drawing_Rect *rectDst = nullptr;
548 OH_Drawing_Rect *rectSrc = OH_Drawing_RectCreate(11, 22, 333, 444); // 11,22,333,444 rect param
549 OH_Drawing_RectCopy(rectSrc, rectDst);
550 ASSERT_TRUE(rectDst == nullptr);
551
552 OH_Drawing_Rect *rectDst1 = OH_Drawing_RectCreate(0, 0, 400, 800); // 400 800 v
553 OH_Drawing_Rect *rectSrc1 = nullptr;
554 OH_Drawing_RectCopy(rectSrc1, rectDst1);
555 ASSERT_TRUE(rectDst1 != nullptr);
556
557 OH_Drawing_RectDestroy(rectSrc);
558 OH_Drawing_RectDestroy(rectDst);
559 OH_Drawing_RectDestroy(rectSrc1);
560 OH_Drawing_RectDestroy(rectDst1);
561 }
562 } // namespace Drawing
563 } // namespace Rosen
564 } // namespace OHOS