• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef RS_ENABLE_VK
26 #include "platform/ohos/backend/rs_vulkan_context.h"
27 #endif
28 
29 using namespace testing;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace Drawing {
35 class NativeDrawingRectTest : public testing::Test {
36 public:
37     static void SetUpTestCase();
38     static void TearDownTestCase();
39     void SetUp() override;
40     void TearDown() override;
41 };
42 
SetUpTestCase()43 void NativeDrawingRectTest::SetUpTestCase()
44 {
45 #ifdef RS_ENABLE_VK
46     RsVulkanContext::SetRecyclable(false);
47 #endif
48 }
TearDownTestCase()49 void NativeDrawingRectTest::TearDownTestCase() {}
SetUp()50 void NativeDrawingRectTest::SetUp() {}
TearDown()51 void NativeDrawingRectTest::TearDown() {}
52 
53 /*
54  * @tc.name: NativeDrawingRectTest_CreateAndDestroy001
55  * @tc.desc: test for create Rect and destroy Rect.
56  * @tc.type: FUNC
57  * @tc.require: AR000GTO5R
58  */
59 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_CreateAndDestroy001, TestSize.Level1)
60 {
61     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300);
62     EXPECT_NE(nullptr, rect);
63     OH_Drawing_RectDestroy(rect);
64 }
65 
66 /*
67  * @tc.name: NativeDrawingRectTest_Intersect002
68  * @tc.desc: test for the Intersect methods of Rect.
69  * @tc.type: FUNC
70  * @tc.require: AR000GTO5R
71  */
72 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Intersect002, TestSize.Level1)
73 {
74     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300);
75     EXPECT_NE(nullptr, rect);
76 
77     OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400);
78     EXPECT_NE(nullptr, otherOne);
79 
80     OH_Drawing_Rect *otherTwo = OH_Drawing_RectCreate(600, 400, 700, 500);
81     EXPECT_NE(nullptr, otherTwo);
82 
83     bool ret = OH_Drawing_RectIntersect(rect, otherOne);
84     EXPECT_EQ(ret, true);
85 
86     ret = OH_Drawing_RectIntersect(rect, otherTwo);
87     EXPECT_EQ(ret, false);
88 
89     OH_Drawing_RectDestroy(rect);
90     OH_Drawing_RectDestroy(otherOne);
91     OH_Drawing_RectDestroy(otherTwo);
92 }
93 /*
94  * @tc.name: NativeDrawingRectTest_GetHeight003
95  * @tc.desc: test for get height of rect.
96  * @tc.type: FUNC
97  * @tc.require: AR000GTO5R
98  */
99 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetHeight003, TestSize.Level1)
100 {
101     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
102     OH_Drawing_RectGetHeight(nullptr);
103     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
104     float height = OH_Drawing_RectGetHeight(rect);
105     EXPECT_TRUE(IsScalarAlmostEqual(height, 800)); // 800 means height
106     OH_Drawing_RectDestroy(rect);
107 }
108 
109 /*
110  * @tc.name: NativeDrawingRectTest_GetWidth004
111  * @tc.desc: test for get width of rect.
112  * @tc.type: FUNC
113  * @tc.require: AR000GTO5R
114  */
115 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetWidth004, TestSize.Level1)
116 {
117     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
118     OH_Drawing_RectGetWidth(nullptr);
119     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
120     float width = OH_Drawing_RectGetWidth(rect);
121     EXPECT_TRUE(IsScalarAlmostEqual(width, 400)); // 400 means height
122     OH_Drawing_RectDestroy(rect);
123 }
124 
125 /*
126  * @tc.name: NativeDrawingRectTest_SetAndGet005
127  * @tc.desc: test for set and get of rect.
128  * @tc.type: FUNC
129  * @tc.require: AR000GTO5R
130  */
131 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_SetAndGet005, TestSize.Level1)
132 {
133     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
134     OH_Drawing_RectSetLeft(nullptr, 10);
135     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
136     OH_Drawing_RectSetLeft(rect, 10);
137     OH_Drawing_RectSetTop(nullptr, 10);
138     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
139     OH_Drawing_RectSetTop(rect, 10);
140     OH_Drawing_RectSetRight(nullptr, 300);
141     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
142     OH_Drawing_RectSetRight(rect, 300);
143     OH_Drawing_RectSetBottom(nullptr, 400);
144     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
145     OH_Drawing_RectSetBottom(rect, 400);
146 
147     OH_Drawing_RectGetLeft(nullptr);
148     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
149     float left = OH_Drawing_RectGetLeft(rect);
150     OH_Drawing_RectGetTop(nullptr);
151     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
152     float top = OH_Drawing_RectGetTop(rect);
153     OH_Drawing_RectGetRight(nullptr);
154     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
155     float right = OH_Drawing_RectGetRight(rect);
156     OH_Drawing_RectGetBottom(nullptr);
157     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
158     float bottom = OH_Drawing_RectGetBottom(rect);
159     EXPECT_TRUE(IsScalarAlmostEqual(left, 10)); // 10 means left
160     EXPECT_TRUE(IsScalarAlmostEqual(top, 10)); // 10 means top
161     EXPECT_TRUE(IsScalarAlmostEqual(right, 300)); // 300 means right
162     EXPECT_TRUE(IsScalarAlmostEqual(bottom, 400)); // 400 means bottom
163     OH_Drawing_RectDestroy(rect);
164 }
165 
166 /*
167  * @tc.name: NativeDrawingRectTest_Copy006
168  * @tc.desc: test for Copy of rect.
169  * @tc.type: FUNC
170  * @tc.require: AR000GTO5R
171  */
172 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Copy006, TestSize.Level1)
173 {
174     OH_Drawing_Rect* rectSrc = OH_Drawing_RectCreate(0, 0, 400, 800);
175     OH_Drawing_Rect* rectDst = OH_Drawing_RectCreate(11, 22, 333, 444);
176     OH_Drawing_RectCopy(nullptr, rectSrc);
177     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
178     OH_Drawing_RectCopy(rectDst, nullptr);
179     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
180     OH_Drawing_RectCopy(rectDst, rectSrc);
181     float left = OH_Drawing_RectGetLeft(rectSrc);
182     float top = OH_Drawing_RectGetTop(rectSrc);
183     float right = OH_Drawing_RectGetRight(rectSrc);
184     float bottom = OH_Drawing_RectGetBottom(rectSrc);
185     EXPECT_TRUE(IsScalarAlmostEqual(left, 11)); // 11 means left
186     EXPECT_TRUE(IsScalarAlmostEqual(top, 22)); // 22 means top
187     EXPECT_TRUE(IsScalarAlmostEqual(right, 333)); // 333 means right
188     EXPECT_TRUE(IsScalarAlmostEqual(bottom, 444)); // 444 means bottom
189     OH_Drawing_RectDestroy(rectSrc);
190     OH_Drawing_RectDestroy(rectDst);
191 }
192 
193 /*
194  * @tc.name: NativeDrawingRectTest_RectJoin007
195  * @tc.desc: test for sets rect to the union of rect and other.
196  * @tc.type: FUNC
197  * @tc.require: AR000GTO5R
198  */
199 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin007, TestSize.Level1)
200 {
201     // rect left[10], top[20], right[40], bottom[30]
202     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 20, 40, 30);
203     // rect left[20], top[20], right[100], bottom[100]
204     OH_Drawing_Rect *other = OH_Drawing_RectCreate(20, 20, 100, 100);
205     EXPECT_EQ(OH_Drawing_RectJoin(rect, nullptr), false);
206     EXPECT_NE(OH_Drawing_RectJoin(rect, other), false);
207     OH_Drawing_RectDestroy(rect);
208     OH_Drawing_RectDestroy(other);
209 }
210 
211 /*
212  * @tc.name: NativeDrawingRectTest_Intersect003
213  * @tc.desc: test for the Intersect methods of Rect.
214  * @tc.type: FUNC
215  * @tc.require: AR000GTO5R
216  */
217 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_Intersect003, TestSize.Level1)
218 {
219     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
220     EXPECT_NE(nullptr, rect);
221 
222     OH_Drawing_Rect *rectt = nullptr;
223     ASSERT_TRUE(rectt == nullptr);
224 
225     OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400); // 250 300 400 600  rect param
226     EXPECT_NE(nullptr, otherOne);
227 
228     OH_Drawing_Rect *otherTwo = nullptr;
229     ASSERT_TRUE(otherTwo == nullptr);
230 
231     bool ret = OH_Drawing_RectIntersect(rectt, otherOne);
232     EXPECT_EQ(ret, false);
233     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
234 
235     ret = OH_Drawing_RectIntersect(rect, otherTwo);
236     EXPECT_EQ(ret, false);
237     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
238 
239     ret = OH_Drawing_RectIntersect(rectt, otherTwo);
240     EXPECT_EQ(ret, false);
241     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
242 
243     OH_Drawing_RectDestroy(rect);
244     OH_Drawing_RectDestroy(rectt);
245     OH_Drawing_RectDestroy(otherOne);
246     OH_Drawing_RectDestroy(otherTwo);
247 }
248 
249 /*
250  * @tc.name: NativeDrawingRectTest_RectJoin001
251  * @tc.desc: test for the RectJoin methods of Rect.
252  * @tc.type: FUNC
253  * @tc.require: AR000GTO5R
254  */
255 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin001, TestSize.Level1)
256 {
257     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500  rect param
258     EXPECT_NE(nullptr, rect);
259 
260     OH_Drawing_Rect *otherOne = OH_Drawing_RectCreate(300, 250, 600, 400); // 250 300 400 600  rect param
261     EXPECT_NE(nullptr, otherOne);
262 
263     OH_Drawing_RectJoin(nullptr, otherOne);
264     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
265     OH_Drawing_RectJoin(rect, nullptr);
266     EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_ERROR_INVALID_PARAMETER);
267     bool ret = OH_Drawing_RectJoin(rect, otherOne);
268     EXPECT_EQ(ret, true);
269 
270     OH_Drawing_RectDestroy(rect);
271     OH_Drawing_RectDestroy(otherOne);
272 }
273 
274 /*
275  * @tc.name: NativeDrawingRectTest_RectJoin002
276  * @tc.desc: test for the RectJoin methods of Rect.
277  * @tc.type: FUNC
278  * @tc.require: AR000GTO5R
279  */
280 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectJoin002, TestSize.Level1)
281 {
282     OH_Drawing_Rect *rect = nullptr;
283     ASSERT_TRUE(rect == nullptr);
284     OH_Drawing_Rect *otherOne = nullptr;
285     ASSERT_TRUE(otherOne == nullptr);
286 
287     bool ret = OH_Drawing_RectJoin(rect, otherOne);
288     EXPECT_EQ(ret, false);
289 }
290 
291 /*
292  * @tc.name: NativeDrawingRectTest_RectSetTop001
293  * @tc.desc: test for the RectSetTop methods of Rect.
294  * @tc.type: FUNC
295  * @tc.require: AR000GTO5R
296  */
297 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetTop001, TestSize.Level1)
298 {
299     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
300     OH_Drawing_RectSetTop(rect, 10);                                   // 10 means top
301 
302     ASSERT_FLOAT_EQ(OH_Drawing_RectGetTop(rect), 10); // 10 equal to number
303     ASSERT_NE(OH_Drawing_RectGetTop(rect), 0.f);
304     OH_Drawing_RectDestroy(rect);
305 }
306 
307 /*
308  * @tc.name: NativeDrawingRectTest_RectSetTop002
309  * @tc.desc: test for the RectSetTop methods of Rect.
310  * @tc.type: FUNC
311  * @tc.require: AR000GTO5R
312  */
313 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetTop002, TestSize.Level1)
314 {
315     OH_Drawing_Rect *rect = nullptr;
316     OH_Drawing_RectSetTop(rect, 10); // 10 means top
317 
318     ASSERT_TRUE(rect == nullptr);
319 }
320 
321 /*
322  * @tc.name: NativeDrawingRectTest_RectSetBottom001
323  * @tc.desc: test for the RectSetBottom methods of Rect.
324  * @tc.type: FUNC
325  * @tc.require: AR000GTO5R
326  */
327 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetBottom001, TestSize.Level1)
328 {
329     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
330     OH_Drawing_RectSetBottom(rect, 10);                                // 10 means Bottom
331 
332     ASSERT_FLOAT_EQ(OH_Drawing_RectGetBottom(rect), 10); // 10 equal to number
333     ASSERT_NE(OH_Drawing_RectGetBottom(rect), 0.f);
334     OH_Drawing_RectDestroy(rect);
335 }
336 
337 /*
338  * @tc.name: NativeDrawingRectTest_RectSetBottom002
339  * @tc.desc: test for the RectSetBottom methods of Rect.
340  * @tc.type: FUNC
341  * @tc.require: AR000GTO5R
342  */
343 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetBottom002, TestSize.Level1)
344 {
345     OH_Drawing_Rect *rect = nullptr;
346     OH_Drawing_RectSetBottom(rect, 10); // 10 means Bottom
347     ASSERT_TRUE(rect == nullptr);
348     OH_Drawing_RectDestroy(rect);
349 }
350 
351 /*
352  * @tc.name: NativeDrawingRectTest_RectSetLeft001
353  * @tc.desc: test for the RectSetLeft methods of Rect.
354  * @tc.type: FUNC
355  * @tc.require: AR000GTO5R
356  */
357 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetLeft001, TestSize.Level1)
358 {
359     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
360     OH_Drawing_RectSetLeft(rect, 10);                                  // 10 means Left
361 
362     ASSERT_FLOAT_EQ(OH_Drawing_RectGetLeft(rect), 10); // 10 equal to number
363     OH_Drawing_RectDestroy(rect);
364 }
365 
366 /*
367  * @tc.name: NativeDrawingRectTest_RectSetLeft002
368  * @tc.desc: test for the RectSetLeft methods of Rect.
369  * @tc.type: FUNC
370  * @tc.require: AR000GTO5R
371  */
372 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetLeft002, TestSize.Level1)
373 {
374     OH_Drawing_Rect *rect = nullptr;
375     OH_Drawing_RectSetLeft(rect, 10); // 10 means Left
376 
377     ASSERT_TRUE(rect == nullptr);
378     OH_Drawing_RectDestroy(rect);
379 }
380 
381 /*
382  * @tc.name: NativeDrawingRectTest_RectSetRight001
383  * @tc.desc: test for the RectSetRight methods of Rect.
384  * @tc.type: FUNC
385  * @tc.require: AR000GTO5R
386  */
387 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetRight001, TestSize.Level1)
388 {
389     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 200, 500, 300); // 100 200 300 500 rect param
390     OH_Drawing_RectSetRight(rect, 10);                                 // 10 means Right
391 
392     ASSERT_FLOAT_EQ(OH_Drawing_RectGetRight(rect), 10);
393     OH_Drawing_RectDestroy(rect);
394 }
395 
396 /*
397  * @tc.name: NativeDrawingRectTest_RectSetRight002
398  * @tc.desc: test for the RectSetRight methods of Rect.
399  * @tc.type: FUNC
400  * @tc.require: AR000GTO5R
401  */
402 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectSetRight002, TestSize.Level1)
403 {
404     OH_Drawing_Rect *rect = nullptr;
405     OH_Drawing_RectSetRight(rect, 10); // 10 means Right
406 
407     ASSERT_TRUE(rect == nullptr);
408     OH_Drawing_RectDestroy(rect);
409 }
410 
411 /*
412  * @tc.name: NativeDrawingRectTest_RectGetTop001
413  * @tc.desc: test for the RectGetTop methods of Rect.
414  * @tc.type: FUNC
415  * @tc.require: AR000GTO5R
416  */
417 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetTop001, TestSize.Level1)
418 {
419     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50, 50, 250, 250 rect param
420     float top = OH_Drawing_RectGetTop(rect);
421     EXPECT_TRUE(IsScalarAlmostEqual(top, 50)); // 50 means top
422     OH_Drawing_RectDestroy(rect);
423 }
424 
425 /*
426  * @tc.name: NativeDrawingRectTest_RectGetTop002
427  * @tc.desc: test for the RectGetTop methods of Rect.
428  * @tc.type: FUNC
429  * @tc.require: AR000GTO5R
430  */
431 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetTop002, TestSize.Level1)
432 {
433     OH_Drawing_Rect *rect = nullptr;
434     OH_Drawing_RectGetTop(rect);
435     ASSERT_TRUE(rect == nullptr);
436     OH_Drawing_RectDestroy(rect);
437 }
438 
439 /*
440  * @tc.name: NativeDrawingRectTest_RectGetBottom001
441  * @tc.desc: test for the RectGetBottom methods of Rect.
442  * @tc.type: FUNC
443  * @tc.require: AR000GTO5R
444  */
445 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetBottom001, TestSize.Level1)
446 {
447     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50, 50, 250, 250 rect param
448     float bottom = OH_Drawing_RectGetBottom(rect);
449     EXPECT_TRUE(IsScalarAlmostEqual(bottom, 250)); // 250 means bottom
450     OH_Drawing_RectDestroy(rect);
451 }
452 
453 /*
454  * @tc.name: NativeDrawingRectTest_RectGetBottom002
455  * @tc.desc: test for the RectGetBottom methods of Rect.
456  * @tc.type: FUNC
457  * @tc.require: AR000GTO5R
458  */
459 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetBottom002, TestSize.Level1)
460 {
461     OH_Drawing_Rect *rect = nullptr;
462     OH_Drawing_RectGetBottom(rect);
463     ASSERT_TRUE(rect == nullptr);
464     OH_Drawing_RectDestroy(rect);
465 }
466 
467 /*
468  * @tc.name: NativeDrawingRectTest_RectGetLeft001
469  * @tc.desc: test for the RectGetLeft methods of Rect.
470  * @tc.type: FUNC
471  * @tc.require: AR000GTO5R
472  */
473 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetLeft001, TestSize.Level1)
474 {
475     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50 250 rect param
476     float left = OH_Drawing_RectGetLeft(rect);
477     EXPECT_TRUE(IsScalarAlmostEqual(left, 50)); // 50 means left
478     OH_Drawing_RectDestroy(rect);
479 }
480 
481 /*
482  * @tc.name: NativeDrawingRectTest_RectGetLeft002
483  * @tc.desc: test for the RectGetLeft methods of Rect.
484  * @tc.type: FUNC
485  * @tc.require: AR000GTO5R
486  */
487 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetLeft002, TestSize.Level1)
488 {
489     OH_Drawing_Rect *rect = nullptr;
490     OH_Drawing_RectGetLeft(rect);
491     ASSERT_TRUE(rect == nullptr);
492     OH_Drawing_RectDestroy(rect);
493 }
494 
495 /*
496  * @tc.name: NativeDrawingRectTest_RectGetRight001
497  * @tc.desc: test for the RectGetRight methods of Rect.
498  * @tc.type: FUNC
499  * @tc.require: AR000GTO5R
500  */
501 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetRight001, TestSize.Level1)
502 {
503     OH_Drawing_Rect *rect = OH_Drawing_RectCreate(50, 50, 250, 250); // 50 250 rect param
504     float right = OH_Drawing_RectGetRight(rect);
505     EXPECT_TRUE(IsScalarAlmostEqual(right, 250)); // 250 means right
506     OH_Drawing_RectDestroy(rect);
507 }
508 
509 /*
510  * @tc.name: NativeDrawingRectTest_RectGetRight002
511  * @tc.desc: test for the RectGetRight methods of Rect.
512  * @tc.type: FUNC
513  * @tc.require: AR000GTO5R
514  */
515 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectGetRight002, TestSize.Level1)
516 {
517     ASSERT_TRUE(OH_Drawing_RectGetRight(nullptr) == 0);
518 }
519 
520 /*
521  * @tc.name: NativeDrawingRectTest_GetHeight002
522  * @tc.desc: test for get height of rect.
523  * @tc.type: FUNC
524  * @tc.require: AR000GTO5R
525  */
526 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetHeight002, TestSize.Level1)
527 {
528     OH_Drawing_Rect *rect = nullptr;
529     OH_Drawing_RectGetHeight(rect);
530     ASSERT_TRUE(rect == nullptr);
531     OH_Drawing_RectDestroy(rect);
532 }
533 
534 /*
535  * @tc.name: NativeDrawingRectTest_GetWidth002
536  * @tc.desc: test for get width of rect.
537  * @tc.type: FUNC
538  * @tc.require: AR000GTO5R
539  */
540 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetWidth002, TestSize.Level1)
541 {
542     OH_Drawing_Rect *rect = nullptr;
543     OH_Drawing_RectGetWidth(rect);
544     ASSERT_TRUE(rect == nullptr);
545     OH_Drawing_RectDestroy(rect);
546 }
547 
548 /*
549  * @tc.name: NativeDrawingRectTest_RectCopy001
550  * @tc.desc: test for Copy of rect.
551  * @tc.type: FUNC
552  * @tc.require: AR000GTO5R
553  */
554 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_RectCopy001, TestSize.Level1)
555 {
556     OH_Drawing_Rect *rectDst = nullptr;
557     OH_Drawing_Rect *rectSrc = OH_Drawing_RectCreate(11, 22, 333, 444); // 11,22,333,444 rect param
558     OH_Drawing_RectCopy(rectSrc, rectDst);
559     ASSERT_TRUE(rectDst == nullptr);
560 
561     OH_Drawing_Rect *rectDst1 = OH_Drawing_RectCreate(0, 0, 400, 800); // 400 800 v
562     OH_Drawing_Rect *rectSrc1 = nullptr;
563     OH_Drawing_RectCopy(rectSrc1, rectDst1);
564     ASSERT_TRUE(rectDst1 != nullptr);
565 
566     OH_Drawing_RectDestroy(rectSrc);
567     OH_Drawing_RectDestroy(rectDst);
568     OH_Drawing_RectDestroy(rectSrc1);
569     OH_Drawing_RectDestroy(rectDst1);
570 }
571 
572 /*
573  * @tc.name: NativeDrawingRectTest_CreateArray001
574  * @tc.desc: test for nomral use of OH_Drawing_RectCreateArray
575  * @tc.type: FUNC
576  * @tc.require:
577  */
578 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_CreateArray001, TestSize.Level1)
579 {
580     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(50);
581     ASSERT_FALSE(rectArray == nullptr);
582     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
583 }
584 
585 /*
586  * @tc.name: NativeDrawingRectTest_CreateArray002
587  * @tc.desc: test for abnomral parameter of OH_Drawing_RectCreateArray
588  * @tc.type: FUNC
589  * @tc.require:
590  */
591 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_CreateArray002, TestSize.Level1)
592 {
593     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(0);
594     EXPECT_EQ(rectArray, nullptr);
595 }
596 
597 /*
598  * @tc.name: NativeDrawingRectTest_GetArraySize001
599  * @tc.desc: test for normal use of OH_Drawing_RectGetArraySize
600  * @tc.type: FUNC
601  * @tc.require:
602  */
603 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetArraySize001, TestSize.Level1)
604 {
605     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(10);
606     ASSERT_FALSE(rectArray == nullptr);
607     size_t size = 0;
608     EXPECT_EQ(OH_Drawing_RectGetArraySize(rectArray, &size), OH_DRAWING_SUCCESS);
609     EXPECT_EQ(size, 10);
610     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
611 }
612 
613 /*
614  * @tc.name: NativeDrawingRectTest_GetArraySize002
615  * @tc.desc: test for abnomral parameter of OH_Drawing_RectGetArraySize
616  * @tc.type: FUNC
617  * @tc.require:
618  */
619 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetArraySize002, TestSize.Level1)
620 {
621     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(50);
622     ASSERT_FALSE(rectArray == nullptr);
623     size_t size = 0;
624     EXPECT_EQ(OH_Drawing_RectGetArraySize(nullptr, &size), OH_DRAWING_ERROR_INVALID_PARAMETER);
625     EXPECT_EQ(OH_Drawing_RectGetArraySize(rectArray, nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
626     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
627 }
628 
629 /*
630  * @tc.name: NativeDrawingRectTest_GetArrayElement001
631  * @tc.desc: test for normal use of OH_Drawing_RectGetArrayElement
632  * @tc.type: FUNC
633  * @tc.require:
634  */
635 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetArrayElement001, TestSize.Level1)
636 {
637     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(10);
638     ASSERT_FALSE(rectArray == nullptr);
639     OH_Drawing_Rect *rect = nullptr;
640     EXPECT_EQ(OH_Drawing_RectGetArrayElement(rectArray, 0, &rect), OH_DRAWING_SUCCESS);
641     EXPECT_NE(rect, nullptr);
642     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
643 }
644 
645 /*
646  * @tc.name: NativeDrawingRectTest_GetArrayElement002
647  * @tc.desc: test for abnormal parameter of OH_Drawing_RectGetArrayElement
648  * @tc.type: FUNC
649  * @tc.require:
650  */
651 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_GetArrayElement002, TestSize.Level1)
652 {
653     size_t size = 50;
654     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(size);
655     ASSERT_FALSE(rectArray == nullptr);
656     OH_Drawing_Rect *rect = nullptr;
657     EXPECT_EQ(OH_Drawing_RectGetArrayElement(rectArray, size, &rect), OH_DRAWING_ERROR_INVALID_PARAMETER);
658     EXPECT_EQ(rect, nullptr);
659     EXPECT_EQ(OH_Drawing_RectGetArrayElement(rectArray, size - 1, nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
660     EXPECT_EQ(OH_Drawing_RectGetArrayElement(rectArray, size - 1, &rect), OH_DRAWING_SUCCESS);
661     EXPECT_NE(rect, nullptr);
662     rect = nullptr;
663     EXPECT_EQ(OH_Drawing_RectGetArrayElement(nullptr, size - 1, &rect), OH_DRAWING_ERROR_INVALID_PARAMETER);
664     EXPECT_EQ(rect, nullptr);
665     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
666 }
667 
668 /*
669  * @tc.name: NativeDrawingRectTest_DestroyArray001
670  * @tc.desc: test for normal use of OH_Drawing_RectDestroyArray
671  * @tc.type: FUNC
672  * @tc.require:
673  */
674 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_DestroyArray001, TestSize.Level1)
675 {
676     OH_Drawing_Array *rectArray = OH_Drawing_RectCreateArray(10);
677     ASSERT_FALSE(rectArray == nullptr);
678     EXPECT_EQ(OH_Drawing_RectDestroyArray(rectArray), OH_DRAWING_SUCCESS);
679 }
680 
681 /*
682  * @tc.name: NativeDrawingRectTest_DestroyArray002
683  * @tc.desc: test for abnormal parameter of OH_Drawing_RectDestroyArray
684  * @tc.type: FUNC
685  * @tc.require:
686  */
687 HWTEST_F(NativeDrawingRectTest, NativeDrawingRectTest_DestroyArray002, TestSize.Level1)
688 {
689     EXPECT_EQ(OH_Drawing_RectDestroyArray(nullptr), OH_DRAWING_ERROR_INVALID_PARAMETER);
690 }
691 } // namespace Drawing
692 } // namespace Rosen
693 } // namespace OHOS